commit a2b99df9e7008ae9c31caa0c6b9eebc6e41ecd55 Author: John Denker Date: Wed Jan 21 13:17:22 2015 -0700 add some automatic dependency checking diff --git a/src/Makefile b/src/Makefile index 8c6da46..ebcd37e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -38,6 +38,15 @@ APPS = test1 test2 test3 test4 test5 test6 test-dipole \ test14 test16 ivis sectors otree wb1 test17 chargedist test18 test19 wb2 test20 \ test21 test22 test23 test24 test25 wb3 #polywell_double tt tt3 #tt2 #tt # tt +## dependency-finding scheme (with local mods) based on: +## http://www.gnu.org/manual/make-3.77/html_mono/make.html#SEC42 +## (requires an include statement at end of the makefile) + +%.d: %.cpp + @$(SHELL) -ec '$(CXX) -MM $(CXXFLAGS) $< \ + | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ + [ -s $@ ] || rm -f $@' + ifeq ($(PNG),yes) LDFLAGS += -lpng CXXFLAGS += -DENABLE_PNG @@ -292,3 +301,6 @@ ephi_wrap.o: ephi.swig libephi.a $(CXX) -I/usr/include/python -c $(CXXFLAGS) ephi_wrap.cxx -include .depend + +include $(APPS:%=%.d) +include $(OBJS:%.o=%.d)