makefile (.PHONY)
I saw alot of makefile which contain a target .PHONY. what it do?
|
Re: makefile (.PHONY)
Quote:
Code:
FileToBuild : Other target this one depends on Often rules are used that do not really builds/generates some file. E.g. when you do "make clean" you don't expect "make" to build a file called "clean". Still, "make" cannot guess that, so with a make-rule like this: Code:
clean: Normally this will do what we want it to do. But imagine a person creates some file called "clean" by accident or for some reason. Then "make" will not do the cleaning up command (rm *.o) when "make clean" is run, because the file "clean" is "up to date". Labeling the target "clean" as "phony" will prevent that. It tells "make" that "clean" is a phony target, i.e. not a real file that needs to be kept up to date. While it may sound like a unlikely thing to happen, it could introduce hard to find errors when it does happen. When makefile's are used with a lot of (phony) targets changes these accindents will actually happen increase. And makefile generated by configure-scripts contain quite a lot of phony targets. Also. listing target as "phony" helps documenting/explaining the makefile itself. |
All times are GMT -5. The time now is 11:04 PM. |