diff options
| author | Peter Eisentraut <peter_e@gmx.net> | 2000-07-06 21:33:45 +0000 |
|---|---|---|
| committer | Peter Eisentraut <peter_e@gmx.net> | 2000-07-06 21:33:45 +0000 |
| commit | f0b4ae697fcbaf5844e83f4cec43c33480d6f814 (patch) | |
| tree | 777a48071daf041e6bdb13375c9c98f0a4a98845 /src/backend/catalog | |
| parent | b027ad9a7a95fb14b62b73b507d1a8c7d6f5e940 (diff) | |
| download | postgresql-f0b4ae697fcbaf5844e83f4cec43c33480d6f814.tar.gz | |
Backend makefile cleanup. make maintainer-clean is now completely
functional.
Handle include file installation in src/include/Makefile
genbki.sh improvements: Don't substitute anything by config.status,
instead pass in AWK and CPP through environment. Change calling
convention to support named output files, so we get to see error
messages on stderr.
Rename bootstrap template files and install them into PREFIX/share.
Update initdb to that effect and other readability improvements
in initdb.
Diffstat (limited to 'src/backend/catalog')
| -rw-r--r-- | src/backend/catalog/Makefile | 90 | ||||
| -rw-r--r-- | src/backend/catalog/genbki.sh (renamed from src/backend/catalog/genbki.sh.in) | 135 |
2 files changed, 137 insertions, 88 deletions
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile index 4cf81c91da..2368851c97 100644 --- a/src/backend/catalog/Makefile +++ b/src/backend/catalog/Makefile @@ -1,74 +1,68 @@ #------------------------------------------------------------------------- # -# Makefile-- -# Makefile for catalog +# Makefile for catalog # -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.22 2000/06/05 07:16:13 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.23 2000/07/06 21:33:22 petere Exp $ # #------------------------------------------------------------------------- -SRCDIR = ../.. -include $(SRCDIR)/Makefile.global +subdir = src/backend/catalog +top_builddir = ../../.. +include ../../Makefile.global OBJS = catalog.o heap.o index.o indexing.o aclchk.o \ pg_aggregate.o pg_operator.o pg_proc.o pg_type.o -BKIFILES = global1.bki.source local1_template1.bki.source \ - global1.description local1_template1.description +BKIFILES = global.bki template1.bki global.description template1.description all: SUBSYS.o $(BKIFILES) SUBSYS.o: $(OBJS) $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS) -GENBKI= ./genbki.sh - -GLOBALBKI_SRCS= $(addprefix $(SRCDIR)/include/catalog/, \ - pg_database.h pg_variable.h pg_shadow.h \ - pg_group.h pg_log.h \ - ) - -LOCALBKI_SRCS= $(addprefix $(SRCDIR)/include/catalog/, \ - pg_proc.h pg_type.h pg_attribute.h pg_class.h \ - pg_inherits.h pg_index.h pg_statistic.h \ - pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \ - pg_language.h \ - pg_aggregate.h pg_ipl.h pg_inheritproc.h \ - pg_rewrite.h pg_listener.h pg_description.h indexing.h \ - ) - -global1.bki.source: $(GENBKI) $(GLOBALBKI_SRCS) \ - $(addprefix $(SRCDIR)/include/catalog/, indexing.h) -ifneq ($(PORTNAME), win) - sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description -else - $(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description -endif -local1_template1.bki.source: $(GENBKI) $(LOCALBKI_SRCS) -ifneq ($(PORTNAME), win) - sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(LOCALBKI_SRCS) > $@ 2>local1_template1.description -else - $(GENBKI) $(BKIOPTS) $(LOCALBKI_SRCS) > $@ 2>local1_template1.description -endif +GLOBAL_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\ + pg_database.h pg_variable.h pg_shadow.h pg_group.h pg_log.h \ + ) -install-bki-templates: $(BKIFILES) - $(INSTALL) $(INSTLOPTS) global1.bki.source \ - $(TEMPLATEDIR)/global1.bki.source - $(INSTALL) $(INSTLOPTS) global1.description \ - $(TEMPLATEDIR)/global1.description - $(INSTALL) $(INSTLOPTS) local1_template1.bki.source \ - $(TEMPLATEDIR)/local1_template1.bki.source - $(INSTALL) $(INSTLOPTS) local1_template1.description \ - $(TEMPLATEDIR)/local1_template1.description +TEMPLATE1_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\ + pg_proc.h pg_type.h pg_attribute.h pg_class.h \ + pg_inherits.h pg_index.h pg_statistic.h \ + pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \ + pg_language.h \ + pg_aggregate.h pg_ipl.h pg_inheritproc.h \ + pg_rewrite.h pg_listener.h pg_description.h indexing.h \ + ) + + +global.bki global.description: genbki.sh $(GLOBAL_BKI_SRCS) $(top_srcdir)/src/include/catalog/indexing.h + CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $< $(BKIOPTS) -o global -I$(top_srcdir)/src/include $(GLOBAL_BKI_SRCS) + +template1.bki template1.description: genbki.sh $(TEMPLATE1_BKI_SRCS) + CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $< $(BKIOPTS) -o template1 -I$(top_srcdir)/src/include $(TEMPLATE1_BKI_SRCS) + +.PHONY: install-bki +install-bki: $(BKIFILES) installdirs + $(INSTALL_DATA) global.bki $(datadir)/global.bki + $(INSTALL_DATA) global.description $(datadir)/global.description + $(INSTALL_DATA) template1.bki $(datadir)/template1.bki + $(INSTALL_DATA) template1.description $(datadir)/template1.description + +installdirs: + $(mkinstalldirs) $(datadir) + +.PHONY: uninstall-bki +uninstall-bki: + rm -f $(addprefix $(datadir)/, $(BKIFILES)) -depend dep: - $(CC) -MM $(CFLAGS) *.c >depend clean: rm -f SUBSYS.o $(OBJS) $(BKIFILES) + +depend dep: + $(CC) -MM $(CFLAGS) *.c >depend + ifeq (depend,$(wildcard depend)) include depend endif diff --git a/src/backend/catalog/genbki.sh.in b/src/backend/catalog/genbki.sh index 58ddcd54a0..188521524f 100644 --- a/src/backend/catalog/genbki.sh.in +++ b/src/backend/catalog/genbki.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#! /bin/sh #------------------------------------------------------------------------- # # genbki.sh-- @@ -10,7 +10,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh.in,v 1.5 2000/01/11 04:02:28 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.15 2000/07/06 21:33:22 petere Exp $ # # NOTES # non-essential whitespace is removed from the generated file. @@ -18,45 +18,105 @@ # end can be changed into another awk script or something smarter.. # #------------------------------------------------------------------------- -trap "rm -f /tmp/genbki.tmp /tmp/genbkitmp.c" 0 1 2 3 15 -# make sure it is empty ->/tmp/genbki.tmp +: ${AWK='awk'} +: ${CPP='cc -E'} -if [ $? != 0 ] -then - echo `basename $0`: Bad option - exit 1 -fi +CMDNAME=`basename $0` -BKIOPTS='' +BKIOPTS= +INCLUDE_DIR= +OUTPUT_PREFIX= +INFILES= -for opt in $* +# +# Process command line switches. +# +while [ $# -gt 0 ] do - case $opt in - -D) BKIOPTS="$BKIOPTS -D$2"; shift; shift;; - -D*) BKIOPTS="$BKIOPTS $1";shift;; - --) shift; break;; + case $1 in + -D) + BKIOPTS="$BKIOPTS -D$2" + shift;; + -D*) + BKIOPTS="$BKIOPTS $1" + ;; + -I) + INCLUDE_DIR="$2" + shift;; + -I*) + INCLUDE_DIR=`echo $1 | sed s/^-I//` + ;; + -o) + OUTPUT_PREFIX="$2" + shift;; + -o*) + OUTPUT_PREFIX=`echo $1 | sed s/^-o//` + ;; + --help) + echo "$CMDNAME generates system catalog bootstrapping files." + echo + echo "Usage:" + echo " $CMDNAME [ -D define [...] ] [ -I dir ] [ -o prefix ]" + echo + echo "Options:" + echo " -I path to postgres_ext.h and config.h files" + echo " -o prefix of output files" + 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 + ;; + -*) + echo "$CMDNAME: invalid option: $1" + exit 1 + ;; + *) + INFILES="$INFILES $1" + ;; esac -done - -# ---------------- -# collect nodefiles -# ---------------- -SYSFILES='' -x=1 -numargs=$# -while test $x -le $numargs ; do - SYSFILES="$SYSFILES $1" - x=`expr $x + 1` shift done +if [ x"$INFILES" = x"" ] ; then + echo "$CMDNAME: no input files" 1>&2 + exit 1 +fi + +if [ x"$OUTPUT_PREFIX" = x"" ] ; then + echo "$CMDNAME: no output prefix specified" 1>&2 + exit 1 +fi + +if [ x"$INCLUDE_DIR" = x"" ] ; then + echo "$CMDNAME: path to include directory unknown" 1>&2 + exit 1 +fi + + +if [ x"$TMPDIR" = x"" ] ; then + TMPDIR=/tmp +fi + + +TMPFILE="$TMPDIR/genbkitmp.c" + +trap "rm -f $TMPFILE" 0 1 2 3 15 + + +# clear output files +> ${OUTPUT_PREFIX}.bki +> ${OUTPUT_PREFIX}.description + + # Get NAMEDATALEN from postgres_ext.h -NAMEDATALEN=`grep '#define[ ]*NAMEDATALEN' ../../include/postgres_ext.h | awk '{ print $3 }'` +NAMEDATALEN=`grep '#define[ ]*NAMEDATALEN' $INCLUDE_DIR/postgres_ext.h | awk '{ print $3 }'` # Get INDEX_MAX_KEYS from config.h (who needs consistency?) -INDEXMAXKEYS=`grep '#define[ ]*INDEX_MAX_KEYS' ../../include/config.h | awk '{ print $3 }'` +INDEXMAXKEYS=`grep '#define[ ]*INDEX_MAX_KEYS' $INCLUDE_DIR/config.h | awk '{ print $3 }'` # NOTE: we assume here that FUNC_MAX_ARGS has the same value as INDEX_MAX_KEYS, # and don't read it separately from config.h. This is OK because both of them @@ -73,7 +133,7 @@ INDEXMAXKEYS4=`expr $INDEXMAXKEYS '*' 4` # also, change NameData to name. -- jolly 8/21/95. # put multi-line start/end comments on a separate line # -cat $SYSFILES | \ +cat $INFILES | \ sed -e 's;/\*.*\*/;;g' \ -e 's;/\*;\ /*\ @@ -96,7 +156,7 @@ sed -e "s/;[ ]*$//g" \ -e "s/FUNC_MAX_ARGS\*2/$INDEXMAXKEYS2/g" \ -e "s/FUNC_MAX_ARGS\*4/$INDEXMAXKEYS4/g" \ -e "s/FUNC_MAX_ARGS/$INDEXMAXKEYS/g" \ -| awk ' +| $AWK ' # ---------------- # now use awk to process remaining .h file.. # @@ -161,7 +221,7 @@ raw == 1 { print; next; } { data = substr($0, 8, length($0) - 9); if (data != "") - printf "%d %s\n", oid, data >> "/tmp/genbki.tmp"; + printf "%d %s\n", oid, data >>descriptionfile; } next; } @@ -289,16 +349,11 @@ END { reln_open = 0; } } -' >/tmp/genbkitmp.c +' "descriptionfile=${OUTPUT_PREFIX}.description" > $TMPFILE || exit -@CPP@ $BKIOPTS /tmp/genbkitmp.c | \ +$CPP $BKIOPTS $TMPFILE | \ sed -e '/^[ ]*$/d' \ - -e 's/[ ][ ]*/ /g' || exit 1 + -e 's/[ ][ ]*/ /g' > ${OUTPUT_PREFIX}.bki || exit -# send pg_description file contents to standard error -cat /tmp/genbki.tmp 1>&2 -# ---------------- -# all done -# ---------------- exit 0 |
