Hristo Venev
Hristo Venev

Reputation: 992

make - Why are some pattern rules marked implicit?

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

Answers (1)

MadScientist
MadScientist

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

Related Questions