summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-03-29 12:06:24 +0200
committerRoland Reichwein <mail@reichwein.it>2020-03-29 12:06:24 +0200
commit3e9e87e720a4f643c783843687337c72c082cbaf (patch)
tree3d5b4753d43d15355b2eb3a817205fb3fc93631a
parentee18ec019ef6f0ef9d7cd3b4cf0314291814cab0 (diff)
Add dependency handling
-rw-r--r--.gitignore1
-rw-r--r--Makefile11
2 files changed, 10 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index f1b0458..299c540 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*.o
+*.d
default.profraw
test-minicc
diff --git a/Makefile b/Makefile
index d11ffe6..4a693c8 100644
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,12 @@ all: test-$(PROJECTNAME)
test-$(PROJECTNAME): $(SRC:.cpp=.o)
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
-%.o: %.cpp
+dep: $(SRC:.cpp=.d)
+
+%.d: %.cpp
+ $(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -MM -MP -MF $@ -c $<
+
+%.o: %.cpp %.d
$(CXX) $(CXXFLAGS) $(CXXTESTFLAGS) -c $< -o $@
googletest/src/%.o: googletest/src/%.cc
@@ -80,7 +85,7 @@ ADD_DEP=Makefile
# misc ---------------------------------------------------
clean:
-rm -f test-$(PROJECTNAME)
- -find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm
+ -find . -name '*.o' -o -name '*.d' -o -name '*.gcno' -o -name '*.gcda' | xargs rm -f
zip: clean
-rm -f ../$(PROJECTNAME).zip
@@ -88,3 +93,5 @@ zip: clean
ls -l ../$(PROJECTNAME).zip
.PHONY: clean all zip
+
+-include $(wildcard $(SRC:.cpp=.d))