gnu make - Argh, makefile won't pick up dependencies correctly -
my simple little makefile exhibiting behavior i'm not able understand. if touch source file except dictionary.cpp no targets built, , if touch dictionary.cpp compiles doesn't link. source files in src/ object (.o) , dependencies (.d) in obj/ , binary goes bin/
if rm obj/* builds ok timestamps don't seem being picked up. can tell me i'm going wrong?
the .d files seem being created correctly, here's dictionary.d:
obj/dictionary.o: src/dictionary.cpp src/pch.h src/types.h src/util.h \ src/refcount.h src/dictionary.h src/dictionary.cpp: src/pch.h: src/types.h: src/util.h: src/refcount.h: src/dictionary.h:
which looks correct me. here's makefile:
sources = dictionary.cpp \ util.cpp \ tile.cpp \ board.cpp \ vec2.cpp \ letter.cpp \ random.cpp \ server.cpp \ main.cpp objects = $(patsubst %.cpp,obj/%.o,$(sources)) depends = $(patsubst %.cpp,obj/%.d,$(sources)) cxx = g++ cppflags = -isrc -std=c++0x cxxflags = -c -include $(depends) bin/dictionary: $(objects) @echo link... $(cxx) $(cppflags) $(objects) -o bin/dictionary -lrt obj/%.o: src/%.cpp @echo [$*] @$(cxx) $(cppflags) $(cxxflags) src/$*.cpp -o obj/$*.o @$(cxx) $(cppflags) -mm src/$*.cpp -mf obj/$*.d @mv -f obj/$*.d obj/$*.d.tmp @sed -e 's|.*:|obj/$*.o:|' < obj/$*.d.tmp > obj/$*.d @sed -e 's/.*://' -e 's/\\$$//' < obj/$*.d.tmp | fmt -1 | sed -e 's/^ *//' -e ' s/$$/:/' >> obj/$*.d @rm -f obj/$*.d.tmp
you have move include
end, or put bin/dictionary
rule before it, or add all: bin/dictionary
rule before include, or something.
or, resign running make bin/dictionary
, work well.
remember make, default, tries build first target in makefile. because have include
line before other target, first target defined include
d file considered default goal, , happens obj/dictionary.o
.
Comments
Post a Comment