Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 
like image 979
wickedchicken Avatar asked Nov 11 '10 16:11

wickedchicken


People also ask

Is the .phony target mandatory in makefile what is it for?

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!

What is $( make in makefile?

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.

What are targets in makefile?

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.

What does .phony do in makefile?

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 .


1 Answers

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

like image 95
Beta Avatar answered Sep 24 '22 02:09

Beta