Automatic dependency tracking for C++ (GCC only)
authorPeter Eisentraut <peter_e@gmx.net>
Sun, 29 Oct 2000 16:13:28 +0000 (16:13 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Sun, 29 Oct 2000 16:13:28 +0000 (16:13 +0000)
src/Makefile.global.in

index a1367cf641b0f6c2a09dc808f8537dc1a6912f64..64c48dd0833ffabc136f318688c4aa6a123df669 100644 (file)
@@ -332,28 +332,48 @@ $(top_builddir)/config.status: $(top_srcdir)/configure
 # that make will update all files that depended on the now removed
 # file.)
 
-COMPILE.c = $(CC) -c $(CPPFLAGS) $(CFLAGS)
-
 autodepend = @autodepend@
 
 ifeq ($(autodepend), yes)
 
+ifndef COMPILE.c
+COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
+endif
+
+ifndef COMPILE.cc
+COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
+endif
+
 DEPDIR = .deps
 df = $(DEPDIR)/$(*F)
 
+# This converts a .d file in the current directory to a .P file in the .deps
+# subdirectory, with the dummy targets as explained above.
+define postprocess-depend
+@if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi
+@cp $*.d $(df).P
+@sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+     -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P
+@rm -f $*.d
+endef
+
 ifeq ($(GCC), yes)
 
 # GCC allows us to create object and dependency file in one invocation.
 %.o : %.c
-       $(COMPILE.c) -MMD $< -o $@
-       @if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi; \
-        cp $*.d $(df).P; \
-        sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-            -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P; \
-        rm -f $*.d
+       $(COMPILE.c) -o $@ $< -MMD
+       $(postprocess-depend)
 
 endif # GCC
 
+ifeq ($(GXX), yes)
+
+%.o : %.cc
+       $(COMPILE.cc) -o $@ $< -MMD
+       $(postprocess-depend)
+
+endif # GXX
+
 # Include all the dependency files generated for the current
 # directory. List /dev/null as dummy because if the wildcard expands
 # to nothing then make would complain.
@@ -364,6 +384,6 @@ clean distclean maintainer-clean: clean-deps
 
 .PHONY: clean-deps
 clean-deps:
-       @rm -rf $(DEPDIR)
+       @rm -rf $(DEPDIR) *.d
 
 endif # autodepend