Reputation: 31186
Using GNU-Make,
Suppose I write the following:
.PHONY: foo bar
foo:
$(eval foo:=1)
@echo foo
bar:
ifneq (${foo},)
@echo bar
endif
Then I make the following commands:
$: make foo
foo
$: make bar
bar
$: make bar foo
bar
foo
$: make foo bar
foo
bar
However, I am trying to make the following result occur for the last two commands, preferably without dropping into shell code:
$: make foo bar
foo
$: make bar foo
bar
foo
How do I cause the if guard to dynamically inhibit the bar
rule?
Upvotes: 0
Views: 34
Reputation: 15081
First, you misuse ifneq
--- it's always processed on the first pass, i.e. before any recipe-related stuff. So it's not an option.
Second, it's a bad design to behave differently on make foo bar
and make bar foo
, as it breaks parallel processing with -jN
option. You should revise your logic: either foo must depend on bar, or bar on foo, or they must be fully independent on each other.
Upvotes: 2