Contents
What kind of targets should have a phony directive in the Makefile?
Generally all targets in your Makefile which do not produce an output file with the same name as the target name should be PHONY. This typically includes all , install , clean , distclean , and so on.
What are Makefile targets?
A make target is basically a file that you want rebuilt. Make can’t divine what you want built, so you have to tell it, implicitly or explicitly, what it should build.
What is .phony target?
A phony target is one that is not really the name of a file; rather it is just a name for a recipe to be executed when you make an explicit request. There are two reasons to use a phony target: to avoid a conflict with a file of the same name, and to improve performance.
How do I run a Makefile with a different name?
If you want to use a nonstandard name for your makefile, you can specify the makefile name with the ‘ -f ‘ or ‘ –file ‘ option. The arguments ‘ -f name ‘ or ‘ –file= name ‘ tell make to read the file name as the makefile. If you use more than one ‘ -f ‘ or ‘ –file ‘ option, you can specify several makefiles.
What does FONY mean?
adjective, pho·ni·er, pho·ni·est. not real or genuine; fake; counterfeit: a phony diamond. false or deceiving; not truthful; concocted: a phony explanation. something that is phony; a counterfeit or fake. an insincere, pretentious, or deceitful person: He thought my friends were a bunch of phonies.
Why is phony Madefile?
How to make a phony target in makefile?
When one directory contains multiple programs, it is most convenient to describe all of the programs in one makefile ./Makefile. Since the target remade by default will be the first one in the makefile, it is common to make this a phony target named ‘ all ’ and give it, as prerequisites, all the individual programs.
Is it good to declare a phony target in make?
This is why declaring a target as .PHONY is good for performance, even if you are not worried about the actual file existing. A phony target should not be a prerequisite of a real target file; if it is, its recipe will be run every time make goes to update that file.
Which is the first target in the Makefile?
Since the target remade by default will be the first one in the makefile, it is common to make this a phony target named ‘ all ’ and give it, as prerequisites, all the individual programs. For example:
Who are the phony targets in GNU make?
The best explanation is the GNU make manual itself: 4.6 Phony Targets section. .PHONY is one of make’s Special Built-in Target Names. There are other targets that you may be interested in, so it’s worth skimming through these references.