Is it possible to have multiple .PHONY targets in a GNU makefile?

MakefileGnu Make

Makefile Problem Overview


For various reasons, it would be convenient for me to specify .PHONY in multiple parts of a makefile. I feel like I'm not correctly understanding how this works, but is this possible?

Instead of .PHONY: clean cleanall do:

.PHONY: clean
<some text>
.PHONY: cleanall

Makefile Solutions


Solution 1 - Makefile

Yes, that's allowed. (If you don't believe me, just try it!)

Solution 2 - Makefile

PHONY= 
PHONY+= clean

...

PHONY+= cleanall
.PHONY : $(PHONY)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionwickedchickenView Question on Stackoverflow
Solution 1 - MakefileBetaView Answer on Stackoverflow
Solution 2 - MakefileSTyxView Answer on Stackoverflow