From b150906b8959ffb42a7322e1c9806798367d2e45 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 1 Jul 2000 21:16:44 +0000 Subject: We don't need config.status substituting anything into Gen_fmgrtab.sh, we just pass in CPP and AWK via the environment from the Makefile. --- src/GNUmakefile.in | 3 +- src/Makefile.global.in | 3 +- src/backend/utils/Gen_fmgrtab.sh | 267 ++++++++++++++++++++++++++++++++++ src/backend/utils/Gen_fmgrtab.sh.in | 280 ------------------------------------ src/backend/utils/Makefile | 4 +- 5 files changed, 272 insertions(+), 285 deletions(-) create mode 100644 src/backend/utils/Gen_fmgrtab.sh delete mode 100644 src/backend/utils/Gen_fmgrtab.sh.in (limited to 'src') diff --git a/src/GNUmakefile.in b/src/GNUmakefile.in index e3055bac2a..cb3c1b4449 100644 --- a/src/GNUmakefile.in +++ b/src/GNUmakefile.in @@ -7,7 +7,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.54 2000/06/28 18:29:13 petere Exp $ +# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.55 2000/07/01 21:16:42 petere Exp $ # #------------------------------------------------------------------------- @@ -54,7 +54,6 @@ distclean maintainer-clean: -$(MAKE) -C utils clean -$(MAKE) -C backend clean rm -f backend/port/Makefile backend/catalog/genbki.sh \ - backend/utils/Gen_fmgrtab.sh \ backend/port/tas.s backend/port/dynloader.c -$(MAKE) -C interfaces $@ -$(MAKE) -C bin $@ diff --git a/src/Makefile.global.in b/src/Makefile.global.in index fcd85289c8..653102a3ea 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -7,7 +7,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.83 2000/07/01 15:02:16 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.84 2000/07/01 21:16:42 petere Exp $ # # NOTES # Essentially all Postgres make files include this file and use the @@ -183,6 +183,7 @@ LN_S= @LN_S@ TAR= @tar@ GZCAT= @GZCAT@ PERL = @PERL@ +AWK = @AWK@ CXX=@CXX@ CXXFLAGS=@CXXFLAGS@ @INCLUDES@ diff --git a/src/backend/utils/Gen_fmgrtab.sh b/src/backend/utils/Gen_fmgrtab.sh new file mode 100644 index 0000000000..12b3626426 --- /dev/null +++ b/src/backend/utils/Gen_fmgrtab.sh @@ -0,0 +1,267 @@ +#! /bin/sh +#------------------------------------------------------------------------- +# +# Gen_fmgrtab.sh +# shell script to generate fmgroids.h and fmgrtab.c from pg_proc.h +# +# 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,v 1.15 2000/07/01 21:16:44 petere Exp $ +# +#------------------------------------------------------------------------- + +CMDNAME=`basename $0` + +: ${AWK='awk'} +: ${CPP='cc -E'} + +cleanup(){ + [ x"$noclean" != x"t" ] && rm -f "$CPPTMPFILE" "$RAWFILE" +} + +BKIOPTS= +noclean= + +# +# Process command line switches. +# +while [ $# -gt 0 ] +do + 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 "The environment variables CPP and AWK determine which C" + echo "preprocessor and Awk program to use. The defaults are" + echo "\`cc -E' and \`awk'." + echo + echo "Report bugs to ." + exit 0 + ;; + --) shift; break;; + -*) + echo "$CMDNAME: invalid option: $1" + exit 1 + ;; + *) + INFILE=$1 + esac + shift +done + + +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...). +# +# Unlike genbki.sh, which can run through cpp last, we have to +# deal with preprocessor statements first (before we sort the +# function table by oid). +# +$AWK ' +BEGIN { raw = 0; } +/^DATA/ { print; next; } +/^BKI_BEGIN/ { raw = 1; next; } +/^BKI_END/ { raw = 0; next; } +raw == 1 { print; next; }' $INFILE | \ +sed -e 's/^.*OID[^=]*=[^0-9]*//' \ + -e 's/(//g' \ + -e 's/[ ]*).*$//' | \ +$AWK ' +/^#/ { print; next; } +$4 == "11" { print; next; } +$4 == "12" { print; next; }' > $CPPTMPFILE + +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + +$CPP $BKIOPTS $CPPTMPFILE | \ +egrep '^[0-9]' | \ +sort -n > $RAWFILE + +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" <> "$OIDSFILE" + +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + +cat >> "$OIDSFILE" < "$TABLEFILE" <> "$TABLEFILE" + +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + + +cat >> "$TABLEFILE" <> "$TABLEFILE" + +if [ $? -ne 0 ]; then + cleanup + echo "$CMDNAME failed" + exit 1 +fi + +cat >> "$TABLEFILE" <." - exit 0 - ;; - --) shift; break;; - -*) - echo "$CMDNAME: invalid option: $1" - exit 1 - ;; - *) - INFILE=$1 - esac - shift -done - - -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...). -# -# Unlike genbki.sh, which can run through cpp last, we have to -# deal with preprocessor statements first (before we sort the -# function table by oid). -# -$AWK ' -BEGIN { raw = 0; } -/^DATA/ { print; next; } -/^BKI_BEGIN/ { raw = 1; next; } -/^BKI_END/ { raw = 0; next; } -raw == 1 { print; next; }' $INFILE | \ -sed -e 's/^.*OID[^=]*=[^0-9]*//' \ - -e 's/(//g' \ - -e 's/[ ]*).*$//' | \ -$AWK ' -/^#/ { print; next; } -$4 == "11" { print; next; } -$4 == "12" { print; next; }' > $CPPTMPFILE - -if [ $? -ne 0 ]; then - cleanup - echo "$CMDNAME failed" - exit 1 -fi - -$CPP $BKIOPTS $CPPTMPFILE | \ -egrep '^[0-9]' | \ -sort -n > $RAWFILE - -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}.tmp" <> "${OIDSFILE}.tmp" - -if [ $? -ne 0 ]; then - cleanup - echo "$CMDNAME failed" - exit 1 -fi - -cat >> "${OIDSFILE}.tmp" < "${TABLEFILE}.tmp" <> "${TABLEFILE}.tmp" - -if [ $? -ne 0 ]; then - cleanup - echo "$CMDNAME failed" - exit 1 -fi - - -cat >> "${TABLEFILE}.tmp" <> "${TABLEFILE}.tmp" - -if [ $? -ne 0 ]; then - cleanup - echo "$CMDNAME failed" - exit 1 -fi - -cat >> "${TABLEFILE}.tmp" <