I have a command foo
that accepts a list of parameters. I want to alter the parameters I pass to foo
depending on the target I am building. I have tried appending to target-specific variables, but that doesn't quite do what I want...
So, for example take this Makefile (which doesn't work since foo is built by target1):
all: target1 target2
foo:
echo foo $(foo_args)
target1: foo_args += abc
target1: foo
echo Target1
target2: foo_args += def
target2: foo
echo Target2
.PHONY: foo target1 target2
What happens:
> make all
foo abc
target1
target2
> make target1
foo abc
target1
> make target2
foo def
target2
What I want:
> make all
foo abc def
target1
target2
> make target1
foo abc
target1
> make target2
foo def
target2
Makefile syntax can be specific to GNU make. I'd also like to keep the parallelism so that target1 and target2 can be built in parallel.