I get this Makefile:
LIST = foo bar
$(LIST):
echo $@
When I run make targets the outputs works as desired:
$ make foo
echo foo
foo
$ make bar
echo bar
bar
But if I concatenate a string another-, only another-foo works:
LIST = foo bar
another-$(LIST):
echo $@
$ make another-foo
echo another-foo
another-foo
$ make another-bar
make: *** No rule to make target 'another-bar'. Stop.
How can I concatenate a target to expand to all values in my variable?
>Solution :
The behavior you observe is standard: when writing
another-$(LIST)
make just replaces $(LIST) with its content, yielding another-foo bar.
That is, this has nothing to do with, e.g., a bash brace expression such as another-{foo,bar}.
Yet, you can achieve what you want by doing something like:
LIST = foo bar
$(addprefix another-,$(LIST)):
echo "$@"