Why GNU Make always says `target’ is up to date
In Category GNU Make
The GNU make expects the rule target to be files by default. That’s why it first checks the presense of a file/directory with the name specified in the rule. For example GNU make attempts to find if a file with name “target1″ with the following Makefile.
target1: prog prog: one.o two.o gcc $^ -o prog
If by chance you have a file or directory with name “target1” in the same directory, GNU Make interprets its last modified date. Because of that some times Make doesn’t compile anything saying target is up to date even if some of the dependencies are changed.
It is always recommended that if the rule names are not that of the target files, it should be defined so using a special .PHONY rule. So the above example will become as below.
.PHONY: target1 target1: prog prog: one.o two.o gcc $^ -o prog
Recent Comments