Reputation: 992
I'm working on a header file dependency Makefile. This is a very reduced version of the code:
cdeps/%.mk:: %
mkdir -p $(@D)
./cdeps.sh cdeps $* .
%.cpp.o: %.cpp cdeps/%.cpp.mk
g++ -c $< -o $@ -I.
include $(shell find cdeps -type f 2>/dev/null)
a.cpp includes b.cpp; cdeps.sh adds dependencies to other cdeps/%.mk for included files.
So when I 'make a.cpp.o', first cdeps/a.cpp.mk is created, then a.cpp.o (exactly as expected). Then cdeps/a.cpp.mk is deleted. Why?
Upvotes: 0
Views: 50
Reputation: 101081
You can read about implicit rules and when the targets are deleted, and how to prevent that, here: http://www.gnu.org/software/make/manual/html_node/Chained-Rules.html
Upvotes: 1