From aff53b27f0942cf9a0dcc5b10dca528e88b0cabf Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 16 Nov 2001 16:32:33 +0000 Subject: [PATCH] Make the yacc rules safe for parallel make. See discussion on pgsql-patches and comment in src/backend/parser/Makefile for the technical details. --- contrib/cube/Makefile | 6 ++++-- contrib/seg/Makefile | 6 ++++-- src/backend/bootstrap/Makefile | 8 +++++--- src/backend/parser/Makefile | 19 +++++++++++++++---- src/interfaces/ecpg/preproc/Makefile | 10 ++++++---- src/pl/plpgsql/src/Makefile | 6 ++++-- 6 files changed, 38 insertions(+), 17 deletions(-) diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile index 1622843702..1bf47b90e9 100644 --- a/contrib/cube/Makefile +++ b/contrib/cube/Makefile @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/contrib/cube/Makefile,v 1.5 2001/09/06 10:49:29 petere Exp $ +# $Header: /cvsroot/pgsql/contrib/cube/Makefile,v 1.6 2001/11/16 16:32:33 petere Exp $ subdir = contrib/cube top_builddir = ../.. @@ -12,7 +12,9 @@ DOCS = README.cube REGRESS = cube -cubeparse.c cubeparse.h: cubeparse.y +cubeparse.c: cubeparse.h ; + +cubeparse.h: cubeparse.y ifdef YACC $(YACC) -d $(YFLAGS) -p cube_yy $< mv -f y.tab.c cubeparse.c diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile index d784a582fd..ac9b543d83 100644 --- a/contrib/seg/Makefile +++ b/contrib/seg/Makefile @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.5 2001/09/06 10:49:30 petere Exp $ +# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.6 2001/11/16 16:32:33 petere Exp $ subdir = contrib/seg top_builddir = ../.. @@ -11,7 +11,9 @@ DOCS = README.seg REGRESS = seg -segparse.c segparse.h: segparse.y +segparse.c: segparse.h ; + +segparse.h: segparse.y ifdef YACC $(YACC) -d $(YFLAGS) -p seg_yy $< mv -f y.tab.c segparse.c diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile index 5e3ad7b12b..0e21dc57a5 100644 --- a/src/backend/bootstrap/Makefile +++ b/src/backend/bootstrap/Makefile @@ -2,7 +2,7 @@ # # Makefile for the bootstrap module # -# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.28 2001/08/22 20:02:56 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.29 2001/11/16 16:32:33 petere Exp $ # #------------------------------------------------------------------------- @@ -25,7 +25,7 @@ SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) $@ $^ -bootstrap.o bootscanner.c: $(srcdir)/bootstrap_tokens.h +bootstrap.o bootscanner.o: $(srcdir)/bootstrap_tokens.h # `sed' rules to remove conflicts between bootstrap scanner and parser @@ -37,7 +37,9 @@ sed -e 's/^yy/Int_yy/g' \ endef -$(srcdir)/bootparse.c $(srcdir)/bootstrap_tokens.h: bootparse.y Makefile +$(srcdir)/bootparse.c: $(srcdir)/bootstrap_tokens.h ; + +$(srcdir)/bootstrap_tokens.h: bootparse.y Makefile ifdef YACC $(YACC) -d $(YFLAGS) $< $(sed-magic) < y.tab.c > $(srcdir)/bootparse.c diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile index 62ff3098ed..ed910f09a4 100644 --- a/src/backend/parser/Makefile +++ b/src/backend/parser/Makefile @@ -2,7 +2,7 @@ # # Makefile for parser # -# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.34 2001/08/09 18:13:23 petere Exp $ +# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.35 2001/11/16 16:32:33 petere Exp $ # #------------------------------------------------------------------------- @@ -20,15 +20,26 @@ all: SUBSYS.o SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) $@ $^ -$(srcdir)/gram.c $(srcdir)/parse.h: gram.y + +# There is no correct way to write a rule that generates two files. +# Rules with two targets don't have that meaning, they are merely +# shorthand for two otherwise separate rules. To be safe for parallel +# make, we must chain the dependencies like this. The semicolon is +# important, otherwise make will choose the built-in rule for +# gram.y=>gram.c. + +$(srcdir)/gram.c: $(srcdir)/parse.h ; + +$(srcdir)/parse.h: gram.y ifdef YACC $(YACC) -d $(YFLAGS) $< - mv y.tab.c $(srcdir)/gram.c - mv y.tab.h $(srcdir)/parse.h + mv -f y.tab.c $(srcdir)/gram.c + mv -f y.tab.h $(srcdir)/parse.h else @$(missing) bison $< $@ endif + $(srcdir)/scan.c: scan.l ifdef FLEX $(FLEX) $(FLEXFLAGS) -Pbase_yy -o'$@' $< diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile index 7841a8d501..2c280f7ab7 100644 --- a/src/interfaces/ecpg/preproc/Makefile +++ b/src/interfaces/ecpg/preproc/Makefile @@ -1,4 +1,4 @@ -# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.77 2001/09/19 14:09:32 meskes Exp $ +# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.78 2001/11/16 16:32:33 petere Exp $ subdir = src/interfaces/ecpg/preproc top_builddir = ../../../.. @@ -35,11 +35,13 @@ endif ecpg: $(OBJS) $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@ -$(srcdir)/preproc.c $(srcdir)/preproc.h: preproc.y +$(srcdir)/preproc.c: $(srcdir)/preproc.h ; + +$(srcdir)/preproc.h: preproc.y ifdef YACC $(YACC) -d $(YFLAGS) $< - mv y.tab.c $(srcdir)/preproc.c - mv y.tab.h $(srcdir)/preproc.h + mv -f y.tab.c $(srcdir)/preproc.c + mv -f y.tab.h $(srcdir)/preproc.h else @$(missing) bison $< $@ endif diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile index 914b57d115..88bd611402 100644 --- a/src/pl/plpgsql/src/Makefile +++ b/src/pl/plpgsql/src/Makefile @@ -2,7 +2,7 @@ # # Makefile for the plpgsql shared object # -# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.19 2001/10/09 04:15:38 tgl Exp $ +# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.20 2001/11/16 16:32:33 petere Exp $ # #------------------------------------------------------------------------- @@ -64,7 +64,9 @@ pl_gram.o pl_scan.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o: plpgsql.h $(src # Note: Since the yacc and lex files are shipped in the distribution, # they must be generated in the srcdir (as opposed to builddir). -$(srcdir)/pl_gram.c $(srcdir)/pl.tab.h: gram.y +$(srcdir)/pl_gram.c: $(srcdir)/pl.tab.h ; + +$(srcdir)/pl.tab.h: gram.y ifdef YACC $(YACC) -d $(YFLAGS) $< sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' < y.tab.c > $(srcdir)/pl_gram.c