#1522: Improve determining make dependencies -------------------------+-------------------------------------------------- Reporter: eschnett | Owner: Type: enhancement | Status: new Priority: major | Milestone: Component: Cactus | Version: development version Keywords: | -------------------------+-------------------------------------------------- Cactus automatically determines the dependencies between source files and their include files. This mechanism doesn't quite work in all cases; e.g. when a source file (or header file?) is removed, the build aborts, and the auto-generated dependencies have to be deleted automatically.
I have recently come across a mechanism that works reliably. Here is the relevant Makefile fragment, applied to building C++ files:
{{{ # Taken from http://mad-scientist.net/make/autodep.html as written # by Paul D. Smith psmith@gnu.org, originally developed by Tom # Tromey tromey@cygnus.com PROCESS_DEPENDENCIES = \ sed -e 's/$@.tmp/$@/g' < $*.o.d > $*.d && \ sed -e 's/#.*//' \ -e 's/^[^:]*: *//' \ -e 's/ *\$$//' \ -e '/^$$/ d' \ -e 's/$$/ :/' < $*.o.d >> $*.d && \ rm -f $*.o.d
%.o: %.cc ${CXX} -MD ${CPPFLAGS} ${CXXFLAGS} -o $@.tmp -c $*.cc @${PROCESS_DEPENDENCIES} @mv $@.tmp $@
-include ${DEPS} }}}