Repair parallel make in backend tree (and make it really parallel).

Make Gen_fmgrtab.sh reasonably robust against concurrent invocation.
This commit is contained in:
Peter Eisentraut 2000-07-13 16:07:14 +00:00
parent 9191d684a7
commit 8a3cbc84ef
8 changed files with 110 additions and 160 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
.PHONY: submake clean dep depend
submake:
for i in $(DIRS); do $(MAKE) -C $$i SUBSYS.o; done
SUBDIROBJS := $(SUBDIRS:%=%/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
all: SUBSYS.o fmgroids.h
SUBSYS.o: fmgrtab.o $(SUBDIROBJS)
$(LD) $(LDREL) $(LDOUT) $@ $^
$(SUBDIROBJS): $(SUBDIRS:%=%-recursive)
.PHONY: $(SUBDIRS:%=%-recursive)
$(SUBDIRS:%=%-recursive): fmgroids.h
$(MAKE) -C $(subst -recursive,,$@) SUBSYS.o
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

View File

@ -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