While searching for the usage of .PHONY
in makefile, i came accross this which says something like
.PHONY also allows you to have targets that do not have an associated rule
I put the example metioned in that post in a makefile and I ran that but it is not showing me any error as mentioned in the OP. Can someone please detail it?
target1: dostuff
.PHONY: target2
target2: dostuff
dostuff:
@echo "Stuff gets done!!!!"
[sourav@titan temp]$ make target1
Stuff gets done!!!!
[sourav@titan temp]$ make target2
Stuff gets done!!!!
[sourav@titan temp]$ make
Stuff gets done!!!!
[sourav@titan temp]$
As per the OP, make target1 should throw an error. Please enlight.
Some Info
[sourav@titan temp]$ uname -r
2.6.18-194.el5PAE
[sourav@titan temp]$ make --version
GNU Make 3.81
[sourav@titan temp]$
True. A .PHONY
target can have only dependencies, without any rule. In this case, make will not execute any rule, but will check if the dependencies are satisfied (and, if not, will execute their rules).
Therefore, in your example, it is correct that both target1
and target2
call dostuff
because it is a dependency.
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