Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 30402ce

Browse files
committed
Automatic dependency tracking for C++ (GCC only)
1 parent 86f0812 commit 30402ce

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

src/Makefile.global.in

+30-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.106 2000/10/27 23:59:39 petere Exp $
2+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.107 2000/10/29 16:13:28 petere Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -332,28 +332,48 @@ $(top_builddir)/config.status: $(top_srcdir)/configure
332332
# that make will update all files that depended on the now removed
333333
# file.)
334334

335-
COMPILE.c = $(CC) -c $(CPPFLAGS) $(CFLAGS)
336-
337335
autodepend = @autodepend@
338336

339337
ifeq ($(autodepend), yes)
340338

339+
ifndef COMPILE.c
340+
COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
341+
endif
342+
343+
ifndef COMPILE.cc
344+
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
345+
endif
346+
341347
DEPDIR = .deps
342348
df = $(DEPDIR)/$(*F)
343349

350+
# This converts a .d file in the current directory to a .P file in the .deps
351+
# subdirectory, with the dummy targets as explained above.
352+
define postprocess-depend
353+
@if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi
354+
@cp $*.d $(df).P
355+
@sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
356+
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P
357+
@rm -f $*.d
358+
endef
359+
344360
ifeq ($(GCC), yes)
345361

346362
# GCC allows us to create object and dependency file in one invocation.
347363
%.o : %.c
348-
$(COMPILE.c) -MMD $< -o $@
349-
@if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi; \
350-
cp $*.d $(df).P; \
351-
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
352-
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P; \
353-
rm -f $*.d
364+
$(COMPILE.c) -o $@ $< -MMD
365+
$(postprocess-depend)
354366

355367
endif # GCC
356368

369+
ifeq ($(GXX), yes)
370+
371+
%.o : %.cc
372+
$(COMPILE.cc) -o $@ $< -MMD
373+
$(postprocess-depend)
374+
375+
endif # GXX
376+
357377
# Include all the dependency files generated for the current
358378
# directory. List /dev/null as dummy because if the wildcard expands
359379
# to nothing then make would complain.
@@ -364,6 +384,6 @@ clean distclean maintainer-clean: clean-deps
364384

365385
.PHONY: clean-deps
366386
clean-deps:
367-
@rm -rf $(DEPDIR)
387+
@rm -rf $(DEPDIR) *.d
368388

369389
endif # autodepend

0 commit comments

Comments
 (0)