From b150906b8959ffb42a7322e1c9806798367d2e45 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 1 Jul 2000 21:16:44 +0000
Subject: [PATCH] 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.

---
 configure                                     |  2 -
 configure.in                                  |  1 -
 src/GNUmakefile.in                            |  3 +-
 src/Makefile.global.in                        |  3 +-
 .../{Gen_fmgrtab.sh.in => Gen_fmgrtab.sh}     | 45 +++++++------------
 src/backend/utils/Makefile                    |  4 +-
 6 files changed, 21 insertions(+), 37 deletions(-)
 rename src/backend/utils/{Gen_fmgrtab.sh.in => Gen_fmgrtab.sh} (86%)

diff --git a/configure b/configure
index 2d92b0be117..c4232a845ba 100755
--- a/configure
+++ b/configure
@@ -8902,7 +8902,6 @@ trap 'rm -fr `echo "GNUmakefile
 	src/Makefile.global
 	src/backend/port/Makefile
 	src/backend/catalog/genbki.sh
-	src/backend/utils/Gen_fmgrtab.sh
 	src/include/version.h
 	src/test/regress/GNUmakefile
  src/include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
@@ -9073,7 +9072,6 @@ CONFIG_FILES=\${CONFIG_FILES-"GNUmakefile
 	src/Makefile.global
 	src/backend/port/Makefile
 	src/backend/catalog/genbki.sh
-	src/backend/utils/Gen_fmgrtab.sh
 	src/include/version.h
 	src/test/regress/GNUmakefile
 "}
diff --git a/configure.in b/configure.in
index 3d7a60815e9..2e12f1cb334 100644
--- a/configure.in
+++ b/configure.in
@@ -1198,7 +1198,6 @@ AC_OUTPUT(
 	src/Makefile.global
 	src/backend/port/Makefile
 	src/backend/catalog/genbki.sh
-	src/backend/utils/Gen_fmgrtab.sh
 	src/include/version.h
 	src/test/regress/GNUmakefile
 )
diff --git a/src/GNUmakefile.in b/src/GNUmakefile.in
index e3055bac2a8..cb3c1b4449e 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 fcd85289c8a..653102a3ea8 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.in b/src/backend/utils/Gen_fmgrtab.sh
similarity index 86%
rename from src/backend/utils/Gen_fmgrtab.sh.in
rename to src/backend/utils/Gen_fmgrtab.sh
index 0ed5e0253b2..12b36264262 100644
--- a/src/backend/utils/Gen_fmgrtab.sh.in
+++ b/src/backend/utils/Gen_fmgrtab.sh
@@ -9,17 +9,17 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.25 2000/06/07 16:26:48 petere Exp $
+#    $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="@CPP@"
+: ${AWK='awk'}
+: ${CPP='cc -E'}
 
 cleanup(){
-    [ x"$noclean" != x"t" ] && rm -f "$CPPTMPFILE" "$RAWFILE" "$OIDSFILE.tmp" "$TABLEFILE.tmp"
+    [ x"$noclean" != x"t" ] && rm -f "$CPPTMPFILE" "$RAWFILE"
 }
 
 BKIOPTS=
@@ -46,6 +46,10 @@ do
             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 <pgsql-bugs@postgresql.org>."
             exit 0
             ;;
@@ -119,7 +123,7 @@ cpp_define=`echo $OIDSFILE | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTU
 #
 # Generate fmgroids.h
 #
-cat > "${OIDSFILE}.tmp" <<FuNkYfMgRsTuFf
+cat > "$OIDSFILE" <<FuNkYfMgRsTuFf
 /*-------------------------------------------------------------------------
  *
  * $OIDSFILE
@@ -160,7 +164,7 @@ FuNkYfMgRsTuFf
 tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' < $RAWFILE | \
 $AWK '
 BEGIN	{ OFS = ""; }
-	{ if (seenit[$(NF-1)]++ == 0) print "#define F_", $(NF-1), " ", $1; }' >> "${OIDSFILE}.tmp"
+	{ if (seenit[$(NF-1)]++ == 0) print "#define F_", $(NF-1), " ", $1; }' >> "$OIDSFILE"
 
 if [ $? -ne 0 ]; then
     cleanup
@@ -168,7 +172,7 @@ if [ $? -ne 0 ]; then
     exit 1
 fi
 
-cat >> "${OIDSFILE}.tmp" <<FuNkYfMgRsTuFf
+cat >> "$OIDSFILE" <<FuNkYfMgRsTuFf
 
 #endif	/* $cpp_define */
 FuNkYfMgRsTuFf
@@ -182,7 +186,7 @@ FuNkYfMgRsTuFf
 # this table definition as a separate C file that won't need to include any
 # "real" declarations for those functions!
 #
-cat > "${TABLEFILE}.tmp" <<FuNkYfMgRtAbStUfF
+cat > "$TABLEFILE" <<FuNkYfMgRtAbStUfF
 /*-------------------------------------------------------------------------
  *
  * $TABLEFILE
@@ -213,7 +217,7 @@ cat > "${TABLEFILE}.tmp" <<FuNkYfMgRtAbStUfF
 
 FuNkYfMgRtAbStUfF
 
-$AWK '{ print "extern Datum", $(NF-1), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> "${TABLEFILE}.tmp"
+$AWK '{ print "extern Datum", $(NF-1), "(PG_FUNCTION_ARGS);"; }' $RAWFILE >> "$TABLEFILE"
 
 if [ $? -ne 0 ]; then
     cleanup
@@ -222,7 +226,7 @@ if [ $? -ne 0 ]; then
 fi
 
 
-cat >> "${TABLEFILE}.tmp" <<FuNkYfMgRtAbStUfF
+cat >> "$TABLEFILE" <<FuNkYfMgRtAbStUfF
 
 const FmgrBuiltin fmgr_builtins[] = {
 FuNkYfMgRtAbStUfF
@@ -239,7 +243,7 @@ $AWK 'BEGIN {
 }
 { printf ("  { %d, \"%s\", %d, %s, %s, %s },\n"), \
 	$1, $(NF-1), $9, Strict[$8], OldStyle[$4], $(NF-1)
-}' $RAWFILE >> "${TABLEFILE}.tmp"
+}' $RAWFILE >> "$TABLEFILE"
 
 if [ $? -ne 0 ]; then
     cleanup
@@ -247,7 +251,7 @@ if [ $? -ne 0 ]; then
     exit 1
 fi
 
-cat >> "${TABLEFILE}.tmp" <<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) */
@@ -259,22 +263,5 @@ const int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrBuiltin)) - 1;
 
 FuNkYfMgRtAbStUfF
 
-
-
-# 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 5d230f94e28..bddf2179656 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.15 2000/06/17 00:09:43 petere Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/Makefile,v 1.16 2000/07/01 21:16:44 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -34,7 +34,7 @@ submake:
 
 
 fmgroids.h fmgrtab.c: Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h
-	$(SHELL) $(SHOPTS) Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h
+	CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $< $(SRCDIR)/include/catalog/pg_proc.h
 
 
 clean:
-- 
GitLab