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
PHONY as long as you don't have a file with the same name as the task. The task will always be executed anyway, and the Makefile will be more readable. "a phony target is simply a target that is always out-of-date" - great explanation!
And in your scenario, $MAKE is used in commands part (recipe) of makefile. It means whenever there is a change in dependency, make executes the command make --no-print-directory post-build in whichever directory you are on.
A simple makefile consists of "rules" with the following shape: target ... : dependencies ... command ... ... A target is usually the name of a file that is generated by a program; examples of targets are executable or object files.
The special rule . PHONY is used to specify that the target is not a file. Common uses are clean and all . This way it won't conflict if you have files named clean or all .
Yes, that's allowed. (If you don't believe me, just try it!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With