Makefile always thinks project is up to date - but files don't even exist
I have the following makefile:
CCC = g++ CCFLAGS = -ansi driver: driver.o graph.o $(CCC) -o driver driver.o graph.o graph.o: graph.h driver.o: graph.h adjl: rm -f graph.h graph.cc ln -s adjl/graph.cc . ln -s adjl/graph.h . touch graph.cc graph.h adjm: rm -f graph.h graph.cc ln -s adjm/graph.cc . ln -s adjm/graph.h . touch graph.cc graph.h clean: rm -f *.o real_clean: clean rm -f graph.cc graph.h rm -f driver
The idea is that I am trying to link two different .cc/.h files depending on which implementation I want to use. If I make real_clean, none of the .cc/.h files exist, I merely have a driver.cc file and the makefile in开发者_如何学Go the folder. If I call make, it says they are up to date. This happens even if I edit the files in adjl/adjm to make them "newer" versions.
[95]% ls adjl/ adjm/ driver.cc makefile [96]% make adjl make: `adjl' is up to date. [97]% make adjm make: `adjm' is up to date.
I took the template makefile from another project I had done, and they are written the same way but I can repeatedly make the same commands with no "up to date" issues.
I have googled but have not found a problem similar to mine (they generally seem to involve users who aren't cleaning before making).
Thanks to anyone for reading.
The problem is that you have directory named the same as your targets in Makefile.
When you issue make adjl
make checks for file adjl
which it finds and does nothing.
Rename targets to something else and try again.
The adjl
and adjm
targets are real targets. Since they have no dependencies, and the files are present (the 2 directories in your listing), make doesn't do anything (because they are around).
However, what you want is to specify adjl
and adjm
as phony targets (so that the commands are executed when you specify them). To do so,
.PHONY: adjl adjm
Read http://www.gnu.org/software/automake/manual/make/Phony-Targets.html for more information.
EDIT
In fact, the real_clean
and clean
rules should probably also be made phony.
Your have directories with the same name as your targets.
Since your targets don't depend on anything, they'll always be considered up to date.
When specifying a target that isn't linked to a file on disk, you need to use the special target .PHONY
:
.PHONY: adjl adjm
You should also do the same for your clean and real_clean targets as well - otherwise they'll break if someone creates a file called "clean".
精彩评论