Reputation: 286
Say I have a set of Makefile modules:
# foo.mk
rule1: prereq1
recipe1
and
# bar.mk
rule2: prereq2
recipe2
and a primary Makefile:
# Makefile
include foo.mk
include bar.mk
Should .PHONY:
be included in each individual .mk file for the phony targets just in that file, or should there be some acculmulated list that is included only in the primary Makefile?
# foo.mk
TARGETS += rule1
...
# bar.mk
TARGETS += rule2
...
# Makefile
.PHONY: $(TARGETS)
I didn't find anything relevant in the GNU Make docs or similar questions.
Upvotes: 3
Views: 2165
Reputation: 667
As with other targets, you can add to .PHONY
multiple times cumulatively. So giving each file its own .PHONY
is can be a nice way of keeping things compartmentalized.
Upvotes: 0
Reputation: 99124
The statement
.PHONY: rule1
tells Make that it should not consider "rule1" the name of a file to be built. Suppose you put it in the Makefile
. What happens when you run another makefile, either foo.mk
or a makefile that includes it?
When you run the rule1
rule, do you want Make to treat it as a PHONY target? If your answer isn't "that depends on which makefile I'm using", then you should have the statement in the makefile that defines the rule.
Upvotes: 1