From: John Tsiombikas Date: Mon, 3 Oct 2016 06:40:03 +0000 (+0300) Subject: added dependency tracking to the GNU makefile X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=dosdemo;a=commitdiff_plain;h=b2dd6c9916fc3ed24545eaae52e0138b558e6543 added dependency tracking to the GNU makefile --- diff --git a/.gitignore b/.gitignore index 4b4c87a..f957445 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.swp *.o +*.d *.obj *.OBJ *.exe diff --git a/GNUmakefile b/GNUmakefile index e81d771..5e3fdeb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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)