]> git.itanic.dy.fi Git - sdl-planets/commitdiff
Makefile: More advanced dependency tracking
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 3 Feb 2011 20:10:15 +0000 (22:10 +0200)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Thu, 3 Feb 2011 20:10:15 +0000 (22:10 +0200)
Inspired by: http://mad-scientist.net/make/autodep.html#norule

Ensure that dependency tracking does not get confused even if some
dependencies (header files for example) are renamed or deleted.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
Makefile

index a27a3e34871eb7c61805b2da7a90c934807552c8..01bcb604e540b4286bf4248ddb5d6f297ae7f16d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,11 @@ debug-planet: $(PLANET_DEBUG_OBJS)
 .c.o:
        @echo -e "\tCC\t" $@
        @$(CC) -MMD -MF .$@.d $(CFLAGS) -c $< -o $@
+       @cp .$@.d .$@.P; \
+            sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+                -e '/^$$/ d' -e 's/$$/ :/' < .$@.d >> .$@.P; \
+            mv .$@.P .$@.d
+
 ifeq ($(C),1)
        sparse $(CFLAGS) $<
 endif
@@ -32,6 +37,10 @@ endif
 %-debug.o: %.c
        @echo -e "\tCC\t" $@
        @$(CC) -MMD -MF .$@.d $(CFLAGS) -DDEBUG -O0 -c $< -o $@
+       @cp .$@.d .$@.P; \
+            sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+                -e '/^$$/ d' -e 's/$$/ :/' < .$@.d >> .$@.P; \
+            mv .$@.P .$@.d
 
 TAGS:
        @echo -e "\tTAGS\t"