From 8a3cbc84efdf3ba205b5aece838ffbe1d548e851 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <peter_e@gmx.net> Date: Thu, 13 Jul 2000 16:07:14 +0000 Subject: [PATCH] Repair parallel make in backend tree (and make it really parallel). Make Gen_fmgrtab.sh reasonably robust against concurrent invocation. --- src/backend/Makefile | 25 ++++++-------- src/backend/access/Makefile | 56 +++++++++----------------------- src/backend/optimizer/Makefile | 34 +++++++++---------- src/backend/storage/Makefile | 36 +++++++++----------- src/backend/storage/ipc/Makefile | 19 ++++------- src/backend/utils/Gen_fmgrtab.sh | 31 ++++++++++-------- src/backend/utils/Makefile | 47 ++++++++++++--------------- src/backend/utils/adt/Makefile | 16 +++------ 8 files changed, 107 insertions(+), 157 deletions(-) diff --git a/src/backend/Makefile b/src/backend/Makefile index b84af541c86..0b541a6b46d 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.59 2000/07/08 02:40:27 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.60 2000/07/13 16:06:42 petere Exp $ # #------------------------------------------------------------------------- @@ -34,22 +34,16 @@ endif all: postgres $(POSTGRES_IMP) -# Note that this is bogus. The desired effect is to build these -# commonly used headers before doing much else. However, nothing says -# that make is required to update these dependencies in any particular -# order, it just happens to do that. Parallel make is broken though. - ifneq ($(PORTNAME), win) -postgres: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h $(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS) +postgres: $(OBJS) + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) else # win # No points for style here. How about encapsulating some of these # commands into variables? -postgres: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h \ - $(DLLOBJS) $(top_builddir)/src/utils/dllinit.o postgres.def libpostgres.a +postgres: $(DLLOBJS) $(top_builddir)/src/utils/dllinit.o postgres.def libpostgres.a dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def gcc -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(DLLOBJS) $(DLLLIBS) dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def @@ -60,11 +54,12 @@ endif # win # Parallel make trickery -$(OBJS): $(DIRS:%=%.dir) +$(OBJS): $(DIRS:%=%-recursive) -.PHONY: $(DIRS:%=%.dir) -$(DIRS:%=%.dir): - $(MAKE) -C $(subst .dir,,$@) all +.PHONY: $(DIRS:%=%-recursive) +# Update the commonly used headers before building the subdirectories +$(DIRS:%=%-recursive): $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h + $(MAKE) -C $(subst -recursive,,$@) all ifeq ($(MAKE_DLL), true) @@ -166,7 +161,7 @@ ifeq ($(MAKE_DLL), true) rm -f postgres.dll postgres.def libpostgres.a endif endif - for i in $(DIRS); do $(MAKE) -C $$i clean; done + for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done distclean: clean rm -f port/Makefile port/tas.s port/dynloader.c diff --git a/src/backend/access/Makefile b/src/backend/access/Makefile index bee3c48d244..fb1a19f0008 100644 --- a/src/backend/access/Makefile +++ b/src/backend/access/Makefile @@ -1,54 +1,30 @@ -#------------------------------------------------------------------------- # -# Makefile-- -# Makefile for the access methods module +# Makefile for the access methods module # -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/access/Makefile,v 1.5 1999/12/13 22:32:17 momjian Exp $ +# $Header: /cvsroot/pgsql/src/backend/access/Makefile,v 1.6 2000/07/13 16:06:42 petere Exp $ # -#------------------------------------------------------------------------- -SRCDIR = ../.. +subdir = src/backend/access +top_builddir = ../../.. include ../../Makefile.global -OBJS = common/SUBSYS.o gist/SUBSYS.o hash/SUBSYS.o heap/SUBSYS.o \ - index/SUBSYS.o rtree/SUBSYS.o nbtree/SUBSYS.o transam/SUBSYS.o +SUBDIRS := common gist hash heap index nbtree rtree transam +SUBDIROBJS := $(SUBDIRS:%=%/SUBSYS.o) +all: SUBSYS.o -all: submake SUBSYS.o +SUBSYS.o: $(SUBDIROBJS) + $(LD) $(LDREL) $(LDOUT) $@ $^ -SUBSYS.o: $(OBJS) - $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) +$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) -.PHONY: submake -submake: - $(MAKE) -C common SUBSYS.o - $(MAKE) -C gist SUBSYS.o - $(MAKE) -C hash SUBSYS.o - $(MAKE) -C heap SUBSYS.o - $(MAKE) -C index SUBSYS.o - $(MAKE) -C rtree SUBSYS.o - $(MAKE) -C nbtree SUBSYS.o - $(MAKE) -C transam SUBSYS.o +.PHONY: $(SUBDIRS:%=%-recursive) +$(SUBDIRS:%=%-recursive): + $(MAKE) -C $(subst -recursive,,$@) SUBSYS.o clean: + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done rm -f SUBSYS.o - $(MAKE) -C common clean - $(MAKE) -C gist clean - $(MAKE) -C hash clean - $(MAKE) -C heap clean - $(MAKE) -C index clean - $(MAKE) -C rtree clean - $(MAKE) -C nbtree clean - $(MAKE) -C transam clean - -.DEFAULT: - $(MAKE) -C common $@ - $(MAKE) -C gist $@ - $(MAKE) -C hash $@ - $(MAKE) -C heap $@ - $(MAKE) -C index $@ - $(MAKE) -C rtree $@ - $(MAKE) -C nbtree $@ - $(MAKE) -C transam $@ +dep depend: + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done diff --git a/src/backend/optimizer/Makefile b/src/backend/optimizer/Makefile index d99ea9c4f62..accb3c033d5 100644 --- a/src/backend/optimizer/Makefile +++ b/src/backend/optimizer/Makefile @@ -1,32 +1,30 @@ -#------------------------------------------------------------------------- # -# Makefile-- -# Makefile for optimizer +# Makefile for optimizer # -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/optimizer/Makefile,v 1.7 1999/12/13 22:32:48 momjian Exp $ +# $Header: /cvsroot/pgsql/src/backend/optimizer/Makefile,v 1.8 2000/07/13 16:06:44 petere Exp $ # -#------------------------------------------------------------------------- -SRCDIR= ../.. +subdir = src/backend/optimizer +top_builddir = ../../.. include ../../Makefile.global -all: submake SUBSYS.o +SUBDIRS := geqo path plan prep util +SUBDIROBJS := $(SUBDIRS:%=%/SUBSYS.o) -OBJS = path/SUBSYS.o plan/SUBSYS.o prep/SUBSYS.o util/SUBSYS.o geqo/SUBSYS.o +all: SUBSYS.o -DIRS = path plan prep util geqo +SUBSYS.o: $(SUBDIROBJS) + $(LD) $(LDREL) $(LDOUT) $@ $^ -SUBSYS.o: $(OBJS) - $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) +$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) -.PHONY: submake clean dep depend -submake: - for i in $(DIRS); do $(MAKE) -C $$i SUBSYS.o; done +.PHONY: $(SUBDIRS:%=%-recursive) +$(SUBDIRS:%=%-recursive): + $(MAKE) -C $(subst -recursive,,$@) SUBSYS.o clean: + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done rm -f SUBSYS.o - for i in $(DIRS); do $(MAKE) -C $$i clean; done -.DEFAULT: - for i in $(DIRS); do $(MAKE) -C $$i $@; done +dep depend: + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done diff --git a/src/backend/storage/Makefile b/src/backend/storage/Makefile index 73dcf0cf1b2..812fd53e801 100644 --- a/src/backend/storage/Makefile +++ b/src/backend/storage/Makefile @@ -1,34 +1,30 @@ -#------------------------------------------------------------------------- # -# Makefile-- -# Makefile for the storage manager subsystem +# Makefile for the storage manager subsystem # -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/storage/Makefile,v 1.6 1999/12/13 22:33:33 momjian Exp $ +# $Header: /cvsroot/pgsql/src/backend/storage/Makefile,v 1.7 2000/07/13 16:06:48 petere Exp $ # -#------------------------------------------------------------------------- -SRCDIR= ../.. +subdir = src/backend/storage +top_builddir = ../../.. include ../../Makefile.global -all: submake SUBSYS.o +SUBDIRS := buffer file ipc large_object lmgr page smgr +SUBDIROBJS := $(SUBDIRS:%=%/SUBSYS.o) -OBJS = buffer/SUBSYS.o file/SUBSYS.o ipc/SUBSYS.o large_object/SUBSYS.o \ - lmgr/SUBSYS.o page/SUBSYS.o smgr/SUBSYS.o +all: SUBSYS.o -DIRS = buffer file ipc large_object lmgr page smgr +SUBSYS.o: $(SUBDIROBJS) + $(LD) $(LDREL) $(LDOUT) $@ $^ -SUBSYS.o: $(OBJS) - $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) +$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) -.PHONY: submake clean dep - -submake: - for i in $(DIRS); do $(MAKE) -C $$i SUBSYS.o; done +.PHONY: $(SUBDIRS:%=%-recursive) +$(SUBDIRS:%=%-recursive): + $(MAKE) -C $(subst -recursive,,$@) SUBSYS.o clean: + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done rm -f SUBSYS.o - for i in $(DIRS); do $(MAKE) -C $$i clean; done -.DEFAULT: - for i in $(DIRS); do $(MAKE) -C $$i $@; done +dep depend: + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done diff --git a/src/backend/storage/ipc/Makefile b/src/backend/storage/ipc/Makefile index 7d9a662055d..dc6989bbcd8 100644 --- a/src/backend/storage/ipc/Makefile +++ b/src/backend/storage/ipc/Makefile @@ -1,22 +1,16 @@ -#------------------------------------------------------------------------- # -# Makefile-- -# Makefile for storage/ipc +# Makefile for storage/ipc # -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/storage/ipc/Makefile,v 1.11 2000/05/29 05:45:06 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/storage/ipc/Makefile,v 1.12 2000/07/13 16:06:54 petere Exp $ # -#------------------------------------------------------------------------- -SRCDIR = ../../.. +subdir = src/backend/storage/ipc +top_builddir = ../../../.. include ../../../Makefile.global # seems to be required 1999/07/22 bjm -ifeq ($(CPU),alpha) -ifeq ($(CC), gcc) -CFLAGS+= -fno-inline -endif -ifeq ($(CC), egcs) +ifeq ($(CPU), alpha) +ifeq ($(GCC), yes) CFLAGS+= -fno-inline endif endif @@ -38,4 +32,3 @@ clean: ifeq (depend,$(wildcard depend)) include depend endif - diff --git a/src/backend/utils/Gen_fmgrtab.sh b/src/backend/utils/Gen_fmgrtab.sh index b532e0f3383..41a0bc3d712 100644 --- a/src/backend/utils/Gen_fmgrtab.sh +++ b/src/backend/utils/Gen_fmgrtab.sh @@ -9,7 +9,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh,v 1.16 2000/07/06 21:33:30 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh,v 1.17 2000/07/13 16:07:06 petere Exp $ # #------------------------------------------------------------------------- @@ -19,7 +19,7 @@ CMDNAME=`basename $0` : ${CPP='cc -E'} cleanup(){ - [ x"$noclean" != x"t" ] && rm -f "$CPPTMPFILE" "$RAWFILE" + [ x"$noclean" != x"t" ] && rm -f "$CPPTMPFILE" "$RAWFILE" "$$-$OIDSFILE" "$$-$TABLEFILE" } BKIOPTS= @@ -71,13 +71,13 @@ if [ x"$INFILE" = x ] ; then exit 1 fi -CPPTMPFILE=fmgrtmp.c -RAWFILE=fmgr.raw +CPPTMPFILE="$$-fmgrtmp.c" +RAWFILE="$$-fmgr.raw" OIDSFILE=fmgroids.h TABLEFILE=fmgrtab.c -trap 'echo "Caught signal." ; cleanup ; exit 1' 1 2 3 15 +trap 'echo "Caught signal." ; cleanup ; exit 1' 1 2 15 # @@ -124,7 +124,7 @@ cpp_define=`echo $OIDSFILE | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTU # # Generate fmgroids.h # -cat > "$OIDSFILE" <<FuNkYfMgRsTuFf +cat > "$$-$OIDSFILE" <<FuNkYfMgRsTuFf /*------------------------------------------------------------------------- * * $OIDSFILE @@ -165,7 +165,7 @@ FuNkYfMgRsTuFf tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $RAWFILE | \ $AWK ' BEGIN { OFS = ""; } - { if (seenit[$(NF-1)]++ == 0) print "#define F_", $(NF-1), " ", $1; }' >> "$OIDSFILE" + { if (seenit[$(NF-1)]++ == 0) print "#define F_", $(NF-1), " ", $1; }' >> "$$-$OIDSFILE" if [ $? -ne 0 ]; then cleanup @@ -173,7 +173,7 @@ if [ $? -ne 0 ]; then exit 1 fi -cat >> "$OIDSFILE" <<FuNkYfMgRsTuFf +cat >> "$$-$OIDSFILE" <<FuNkYfMgRsTuFf #endif /* $cpp_define */ FuNkYfMgRsTuFf @@ -187,7 +187,7 @@ FuNkYfMgRsTuFf # this table definition as a separate C file that won't need to include any # "real" declarations for those functions! # -cat > "$TABLEFILE" <<FuNkYfMgRtAbStUfF +cat > "$$-$TABLEFILE" <<FuNkYfMgRtAbStUfF /*------------------------------------------------------------------------- * * $TABLEFILE @@ -218,7 +218,7 @@ cat > "$TABLEFILE" <<FuNkYfMgRtAbStUfF FuNkYfMgRtAbStUfF -$AWK '{ print "extern Datum", $(NF-1), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> "$TABLEFILE" +$AWK '{ print "extern Datum", $(NF-1), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> "$$-$TABLEFILE" if [ $? -ne 0 ]; then cleanup @@ -227,7 +227,7 @@ if [ $? -ne 0 ]; then fi -cat >> "$TABLEFILE" <<FuNkYfMgRtAbStUfF +cat >> "$$-$TABLEFILE" <<FuNkYfMgRtAbStUfF const FmgrBuiltin fmgr_builtins[] = { FuNkYfMgRtAbStUfF @@ -244,7 +244,7 @@ $AWK 'BEGIN { } { printf (" { %d, \"%s\", %d, %s, %s, %s },\n"), \ $1, $(NF-1), $9, Strict[$8], OldStyle[$4], $(NF-1) -}' $RAWFILE >> "$TABLEFILE" +}' $RAWFILE >> "$$-$TABLEFILE" if [ $? -ne 0 ]; then cleanup @@ -252,7 +252,7 @@ if [ $? -ne 0 ]; then exit 1 fi -cat >> "$TABLEFILE" <<FuNkYfMgRtAbStUfF +cat >> "$$-$TABLEFILE" <<FuNkYfMgRtAbStUfF /* dummy entry is easier than getting rid of comma after last real one */ /* (not that there has ever been anything wrong with *having* a comma after the last field in an array initializer) */ @@ -264,5 +264,10 @@ const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin)) - 1; FuNkYfMgRtAbStUfF +# We use the temporary files to avoid problems with concurrent runs +# (which can happen during parallel make). +mv "$$-$OIDSFILE" $OIDSFILE +mv "$$-$TABLEFILE" $TABLEFILE + cleanup exit 0 diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile index bddf2179656..b57232209f9 100644 --- a/src/backend/utils/Makefile +++ b/src/backend/utils/Makefile @@ -1,48 +1,41 @@ -#------------------------------------------------------------------------- # -# Makefile-- -# Makefile for utils +# Makefile for utils # -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/Makefile,v 1.16 2000/07/01 21:16:44 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/Makefile,v 1.17 2000/07/13 16:07:06 petere Exp $ # -#------------------------------------------------------------------------- -SRCDIR = ../.. -include $(SRCDIR)/Makefile.global - -all: submake SUBSYS.o - -OBJS = fmgrtab.o adt/SUBSYS.o cache/SUBSYS.o error/SUBSYS.o \ - fmgr/SUBSYS.o hash/SUBSYS.o init/SUBSYS.o misc/SUBSYS.o mmgr/SUBSYS.o \ - sort/SUBSYS.o time/SUBSYS.o - -DIRS = adt cache error fmgr hash init misc mmgr sort time +subdir = src/backend/utils/ +top_builddir = ../../.. +include ../../Makefile.global +SUBDIRS := adt cache error fmgr hash init misc mmgr sort time ifdef MULTIBYTE -OBJS += mb/SUBSYS.o -DIRS += mb +SUBDIRS += mb endif +SUBDIROBJS := $(SUBDIRS:%=%/SUBSYS.o) + -SUBSYS.o: $(OBJS) - $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) +all: SUBSYS.o fmgroids.h -.PHONY: submake clean dep depend +SUBSYS.o: fmgrtab.o $(SUBDIROBJS) + $(LD) $(LDREL) $(LDOUT) $@ $^ -submake: - for i in $(DIRS); do $(MAKE) -C $$i SUBSYS.o; done +$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) +.PHONY: $(SUBDIRS:%=%-recursive) +$(SUBDIRS:%=%-recursive): fmgroids.h + $(MAKE) -C $(subst -recursive,,$@) SUBSYS.o -fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h - CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $< $(SRCDIR)/include/catalog/pg_proc.h +fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h + CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $< $(top_srcdir)/src/include/catalog/pg_proc.h clean: + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done rm -f SUBSYS.o fmgrtab.o fmgroids.h fmgrtab.c - for i in $(DIRS); do $(MAKE) -C $$i clean; done dep depend: fmgroids.h fmgrtab.c - for i in $(DIRS); do $(MAKE) -C $$i depend; done + for dir in $(SUBDIRS); do $(MAKE) -C $$dir $@ || exit; done ifeq (depend,$(wildcard depend)) include depend diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile index 3bdce0998b4..ba39ab03003 100644 --- a/src/backend/utils/adt/Makefile +++ b/src/backend/utils/adt/Makefile @@ -1,22 +1,16 @@ -#------------------------------------------------------------------------- # -# Makefile-- -# Makefile for utils/adt +# Makefile for utils/adt # -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.38 2000/07/07 19:24:37 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.39 2000/07/13 16:07:14 petere Exp $ # -#------------------------------------------------------------------------- -SRCDIR = ../../.. +subdir = src/backend/utils/adt +top_builddir = ../../../.. include ../../../Makefile.global # seems to be required for some date/time stuff 1999/07/22 bjm ifeq ($(CPU),alpha) -ifeq ($(CC), gcc) -CFLAGS+= -mieee -endif -ifeq ($(CC), egcs) +ifeq ($(GCC), yes) CFLAGS+= -mieee endif endif -- GitLab