From fdf434e8ebdd31725cea7c0569371aad652d324f Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Tue, 16 Jan 2018 00:12:24 +0100 Subject: [PATCH] Makefile: fix dependency generation Let's generalize the depends.mk target so we can easily move files around later. While doing it, let's also fix the "gcc -M" call to use explicit target names and not clobber it with preprocessor output. Signed-off-by: Kai Krakow --- lib/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index e466ada..227dc6d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -25,8 +25,8 @@ libcrucible.so: $(CRUCIBLE_OBJS) include ../makeflags depends.mk: *.cc - for x in *.cc; do $(CXX) $(CXXFLAGS) -M "$$x"; done > depends.mk.new - mv -fv depends.mk.new depends.mk + for x in $^; do $(CXX) $(CXXFLAGS) -M -MG -MT "$${x/%.cc/.o}" "$$x"; done > $@.new + mv -fv $@.new $@ .version.cc: Makefile ../makeflags *.cc ../include/crucible/*.h echo "namespace crucible { const char *VERSION = \"$(TAG)\"; }" > .version.new.cc