added dependency tracking to the GNU makefile
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Mon, 3 Oct 2016 06:40:03 +0000 (09:40 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Mon, 3 Oct 2016 06:40:03 +0000 (09:40 +0300)
.gitignore
GNUmakefile

index 4b4c87a..f957445 100644 (file)
@@ -1,5 +1,6 @@
 *.swp
 *.o
+*.d
 *.obj
 *.OBJ
 *.exe
index e81d771..5e3fdeb 100644 (file)
@@ -1,5 +1,6 @@
 src = $(wildcard src/*.c) $(wildcard src/sdl/*.c)
 obj = $(src:.c=.o)
+dep = $(obj:.o=.d)
 bin = demo
 
 inc = -Isrc -Isrc/sdl -Ilibs/imago/src -Ilibs/mikmod/include
@@ -10,6 +11,11 @@ LDFLAGS = -Llibs/imago -Llibs/mikmod -limago -lmikmod `sdl-config --libs` -lm
 $(bin): $(obj) imago mikmod
        $(CC) -o $@ $(obj) $(LDFLAGS)
 
+-include $(dep)
+
+%.d: %.c
+       @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
+
 .PHONY: imago
 imago:
        $(MAKE) -C libs/imago
@@ -21,3 +27,7 @@ mikmod:
 .PHONY: clean
 clean:
        rm -f $(obj) $(bin)
+
+.PHONY: cleandep
+cleandep:
+       rm -f $(dep)