diff options
| author | Peter Eisentraut | 2000-06-07 16:27:00 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2000-06-07 16:27:00 +0000 |
| commit | e3059fc0f53ede1ae6f95076034b678f394d2e7a (patch) | |
| tree | 173e8b5e3767928d823f8b45f4ebe2737f3f550d /src/backend | |
| parent | 7d301947e595eda323a441af499b432eb2886293 (diff) | |
Gen_fmgrtab.sh is strange: it is a platform dependent way (because it uses
CPP) to create platform independent files. Unfortunately, that means that
every config.status (or configure) run invariably causes a relink of the
postmaster and also that we can't put these files in the distribution
(usefully). So we make it a little smarter: when the output files already
exist and it notices that it would recreate them in identical form, it
doesn't touch them. In order to avoid re-running the make rule all the time
we update a timestamp file instead.
Update release_prep accordingly. Also make Gen_fmgrtab.sh use the awk that
is detected at configure time, not necessarily named `awk' and have it check
for exit statuses a little better.
In other news... Remove USE_LOCALE from the templates, it was set to `no'
everywhere anyway. Also remove YACC and YFLAGS from the templates, configure
is smart enough to find bison or yacc itself. Use AC_PROG_YACC for that
instead of the hand-crafted code. Do not set YFLAGS to `-d'. The make rules
that need this flag should explicitly invoke it. YFLAGS should be a user
variable. Update the makefiles to that effect.
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/bootstrap/Makefile | 6 | ||||
| -rw-r--r-- | src/backend/parser/Makefile | 6 | ||||
| -rw-r--r-- | src/backend/utils/Gen_fmgrtab.sh.in | 168 | ||||
| -rw-r--r-- | src/backend/utils/Makefile | 15 |
4 files changed, 141 insertions, 54 deletions
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile index 9cffe422f01..deda81105d7 100644 --- a/src/backend/bootstrap/Makefile +++ b/src/backend/bootstrap/Makefile @@ -4,7 +4,7 @@ # Makefile for the bootstrap module # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.22 2000/05/29 05:44:42 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.23 2000/06/07 16:26:37 petere Exp $ # # # We must build bootparse.c and bootscanner.c with yacc and lex and sed, @@ -48,14 +48,14 @@ SUBSYS.o: $(OBJS) bootstrap.o: bootstrap_tokens.h bootstrap_tokens.h bootparse.c: bootparse.y - $(YACC) $(YFLAGS) $< + $(YACC) -d $(YFLAGS) $< grep -v "^#" boot.sed > sedfile sed -f sedfile < y.tab.c > bootparse.c mv y.tab.h bootstrap_tokens.h rm -f y.tab.c sedfile bootscanner.c: bootscanner.l - $(LEX) $< + $(LEX) $(LFLAGS) $< grep -v "^#" boot.sed > sedfile sed -f sedfile < lex.yy.c > bootscanner.c rm -f lex.yy.c sedfile diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile index 1fdbd55a382..22310f8e282 100644 --- a/src/backend/parser/Makefile +++ b/src/backend/parser/Makefile @@ -4,7 +4,7 @@ # Makefile for parser # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.25 2000/05/29 05:44:53 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.26 2000/06/07 16:26:41 petere Exp $ # #------------------------------------------------------------------------- @@ -25,12 +25,12 @@ SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) gram.c parse.h: gram.y - $(YACC) $(YFLAGS) $< + $(YACC) -d $(YFLAGS) $< mv y.tab.c gram.c mv y.tab.h parse.h scan.c: scan.l - $(LEX) $< + $(LEX) $(LFLAGS) $< mv lex.yy.c scan.c # The following dependencies on parse.h are computed by diff --git a/src/backend/utils/Gen_fmgrtab.sh.in b/src/backend/utils/Gen_fmgrtab.sh.in index bc6edf9019a..0ed5e0253b2 100644 --- a/src/backend/utils/Gen_fmgrtab.sh.in +++ b/src/backend/utils/Gen_fmgrtab.sh.in @@ -1,4 +1,4 @@ -#!/bin/sh +#! /bin/sh #------------------------------------------------------------------------- # # Gen_fmgrtab.sh @@ -9,36 +9,72 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.24 2000/06/02 02:00:28 tgl Exp $ -# -# NOTES -# Passes any -D options on to cpp prior to generating the list -# of internal functions. These come from BKIOPTS. +# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.25 2000/06/07 16:26:48 petere Exp $ # #------------------------------------------------------------------------- -BKIOPTS='' +CMDNAME=`basename $0` + +AWK="@AWK@" +CPP="@CPP@" + +cleanup(){ + [ x"$noclean" != x"t" ] && rm -f "$CPPTMPFILE" "$RAWFILE" "$OIDSFILE.tmp" "$TABLEFILE.tmp" +} + +BKIOPTS= +noclean= # -# Pass on any -D declarations, throwing away any other command -# line switches. +# Process command line switches. # -for opt in $* +while [ $# -gt 0 ] do - case $opt in - -D) BKIOPTS="$BKIOPTS -D$2"; shift; shift;; - -D*) BKIOPTS="$BKIOPTS $1"; shift;; + case $1 in + -D) + BKIOPTS="$BKIOPTS -D$2" + ;; + -D*) + BKIOPTS="$BKIOPTS $1" + shift;; + --noclean) + noclean=t + ;; + --help) + echo "$CMDNAME generates fmgroids.h and fmgrtab.c from pg_proc.h." + echo + echo "Usage:" + echo " $CMDNAME [ -D define [...] ]" + echo + echo "Report bugs to <pgsql-bugs@postgresql.org>." + exit 0 + ;; --) shift; break;; - -*) shift;; - esac + -*) + echo "$CMDNAME: invalid option: $1" + exit 1 + ;; + *) + INFILE=$1 + esac + shift done -INFILE=$1 -RAWFILE=fmgr.raw + +if [ x"$INFILE" = x ] ; then + echo "$CMDNAME: no input file" + exit 1 +fi + CPPTMPFILE=fmgrtmp.c +RAWFILE=fmgr.raw OIDSFILE=fmgroids.h TABLEFILE=fmgrtab.c + +trap 'echo "Caught signal." ; cleanup ; exit 1' 1 2 3 15 + + # # Generate the file containing raw pg_proc tuple data # (but only for "internal" and "newinternal" language procedures...). @@ -47,7 +83,7 @@ TABLEFILE=fmgrtab.c # deal with preprocessor statements first (before we sort the # function table by oid). # -awk ' +$AWK ' BEGIN { raw = 0; } /^DATA/ { print; next; } /^BKI_BEGIN/ { raw = 1; next; } @@ -56,21 +92,34 @@ raw == 1 { print; next; }' $INFILE | \ sed -e 's/^.*OID[^=]*=[^0-9]*//' \ -e 's/(//g' \ -e 's/[ ]*).*$//' | \ -awk ' +$AWK ' /^#/ { print; next; } $4 == "11" { print; next; } $4 == "12" { print; next; }' > $CPPTMPFILE -@CPP@ $BKIOPTS $CPPTMPFILE | \ +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + +$CPP $BKIOPTS $CPPTMPFILE | \ egrep '^[0-9]' | \ sort -n > $RAWFILE -rm -f $CPPTMPFILE +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + + +cpp_define=`echo $OIDSFILE | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | sed -e 's/[^A-Z]/_/g'` # # Generate fmgroids.h # -cat > $OIDSFILE <<FuNkYfMgRsTuFf +cat > "${OIDSFILE}.tmp" <<FuNkYfMgRsTuFf /*------------------------------------------------------------------------- * * $OIDSFILE @@ -82,20 +131,18 @@ cat > $OIDSFILE <<FuNkYfMgRsTuFf * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: Gen_fmgrtab.sh.in,v 1.24 2000/06/02 02:00:28 tgl Exp $ - * * NOTES * ****************************** * *** DO NOT EDIT THIS FILE! *** * ****************************** * - * It has been GENERATED by $0 + * It has been GENERATED by $CMDNAME * from $INFILE * *------------------------------------------------------------------------- */ -#ifndef FMGROIDS_H -#define FMGROIDS_H +#ifndef $cpp_define +#define $cpp_define /* * Constant macros for the OIDs of entries in pg_proc. @@ -111,13 +158,19 @@ cat > $OIDSFILE <<FuNkYfMgRsTuFf FuNkYfMgRsTuFf tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $RAWFILE | \ -awk ' +$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}.tmp" + +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi -cat >> $OIDSFILE <<FuNkYfMgRsTuFf +cat >> "${OIDSFILE}.tmp" <<FuNkYfMgRsTuFf -#endif /* FMGROIDS_H */ +#endif /* $cpp_define */ FuNkYfMgRsTuFf # @@ -129,7 +182,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}.tmp" <<FuNkYfMgRtAbStUfF /*------------------------------------------------------------------------- * * $TABLEFILE @@ -138,16 +191,13 @@ cat > $TABLEFILE <<FuNkYfMgRtAbStUfF * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.24 2000/06/02 02:00:28 tgl Exp $ - * * NOTES * * ****************************** * *** DO NOT EDIT THIS FILE! *** * ****************************** * - * It has been GENERATED by $0 + * It has been GENERATED by $CMDNAME * from $INFILE * * We lie here to cc about the return type and arguments of old-style @@ -163,9 +213,16 @@ 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}.tmp" + +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + -cat >> $TABLEFILE <<FuNkYfMgRtAbStUfF +cat >> "${TABLEFILE}.tmp" <<FuNkYfMgRtAbStUfF const FmgrBuiltin fmgr_builtins[] = { FuNkYfMgRtAbStUfF @@ -174,7 +231,7 @@ FuNkYfMgRtAbStUfF # may seem tedious, but avoid the temptation to write a quick x?y:z # conditional expression instead. Not all awks have conditional expressions. -awk 'BEGIN { +$AWK 'BEGIN { Strict["t"] = "true" Strict["f"] = "false" OldStyle["11"] = "true" @@ -182,10 +239,18 @@ awk 'BEGIN { } { printf (" { %d, \"%s\", %d, %s, %s, %s },\n"), \ $1, $(NF-1), $9, Strict[$8], OldStyle[$4], $(NF-1) -}' $RAWFILE >> $TABLEFILE +}' $RAWFILE >> "${TABLEFILE}.tmp" -cat >> $TABLEFILE <<FuNkYfMgRtAbStUfF +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + +cat >> "${TABLEFILE}.tmp" <<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) */ { 0, NULL, 0, false, false, (PGFunction) NULL } }; @@ -194,9 +259,22 @@ const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin)) - 1; FuNkYfMgRtAbStUfF -rm -f $RAWFILE -# ---------------- -# all done -# ---------------- + +# Now we check if the files fmgroids.h and fmgrtab.c already exist and +# are identical to what we would make them. In that case we avoid +# writing our new version, so as to not cause unnecessary recompilation +# because of changed timestamps. + +for file in "$OIDSFILE" "$TABLEFILE" ; do + if test -f "$file" && cmp -s "$file" "${file}.tmp" ; then + echo "$file unchanged" + rm -f "${file}.tmp" + else + mv "${file}.tmp" "$file" + fi +done + + +cleanup exit 0 diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile index deafee16d33..ed636429518 100644 --- a/src/backend/utils/Makefile +++ b/src/backend/utils/Makefile @@ -4,7 +4,7 @@ # Makefile for utils # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/Makefile,v 1.12 2000/05/29 05:45:18 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/Makefile,v 1.13 2000/06/07 16:26:48 petere Exp $ # #------------------------------------------------------------------------- @@ -31,11 +31,20 @@ SUBSYS.o: $(OBJS) submake: for i in $(DIRS); do $(MAKE) -C $$i SUBSYS.o; done -fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h +# Gen_fmgrtab.sh will not change the timestamp of its output files +# if they already exist and would not be changed. This is to avoid +# unnecessary recompilations. In order to avoid re-running it all +# the time we update a stamp file instead. (Idea stolen from +# autoconf and autoheader.) + +fmgroids.h fmgrtab.c: fmgrstamp-h +fmgrstamp-h: Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h $(SHELL) $(SHOPTS) Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h + echo timestamp > fmgrstamp-h +# don't clean fmgroids.h and fmgrtab.c clean: - rm -f SUBSYS.o fmgroids.h fmgrtab.o fmgrtab.c + rm -f SUBSYS.o fmgrtab.o for i in $(DIRS); do $(MAKE) -C $$i clean; done dep depend: fmgroids.h fmgrtab.c |
