diff --git a/GNUmakefile.in b/GNUmakefile.in
index 01323aa746379e8efc781b3c8ec9f075f1f93b16..8f544455e9c3d3b7eaeae2240461af04ab36fe08 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -1,7 +1,7 @@
 #
 # PostgreSQL top level makefile
 #
-# $Header: /cvsroot/pgsql/GNUmakefile.in,v 1.8 2000/07/17 22:31:56 petere Exp $
+# $Header: /cvsroot/pgsql/GNUmakefile.in,v 1.9 2000/07/19 16:29:41 petere Exp $
 #
 
 subdir =
@@ -18,7 +18,7 @@ install:
 	$(MAKE) -C src install
 	@cat $(srcdir)/register.txt
 
-installdirs uninstall clean:
+installdirs uninstall clean distprep:
 	$(MAKE) -C doc $@
 	$(MAKE) -C src $@
 
@@ -51,3 +51,73 @@ endif
 # aclocal.m4' or `make configure'.
 $(top_srcdir)/aclocal.m4: $(wildcard $(top_srcdir)/config/*.m4)
 	cat $^ > $@
+
+
+##########################################################################
+
+distdir	:= postgresql-$(VERSION)
+dummy	:= =install=
+garbage := =*  "#"*  ."#"*  *~*  *.orig  *.rej  core  postgresql-*
+
+
+dist: $(distdir).tar.gz
+ifeq ($(split-dist), yes)
+dist: $(distdir).base.tar.gz $(distdir).docs.tar.gz $(distdir).support.tar.gz $(distdir).test.tar.gz
+endif
+dist:
+	-rm -rf $(distdir)
+
+$(distdir).tar: distdir
+	$(TAR) chf $@ $(distdir)
+
+$(distdir).base.tar: distdir
+	$(TAR) -c $(addprefix --exclude $(distdir)/, doc src/test src/interfaces src/bin) \
+	  -f $@ $(distdir)
+
+$(distdir).docs.tar: distdir
+	$(TAR) cf $@ $(distdir)/doc
+
+$(distdir).support.tar: distdir
+	$(TAR) cf $@ $(distdir)/src/interfaces $(distdir)/src/bin
+
+$(distdir).test.tar: distdir
+	$(TAR) cf $@ $(distdir)/src/test
+
+%.gz: %
+	gzip -f --best $<
+	@text="$@ is ready for distribution." ; \
+	 frame=`echo "$$text" | sed -e 's/./=/g'` ; \
+	 echo "$$frame" ; echo "$$text" ; echo "$$frame"
+
+distdir: distprep
+	-rm -rf $(distdir)* $(install)
+	for x in `cd $(top_srcdir) && find . -name CVS -prune -o -print`; do \
+	  file=`expr $$x : '\./\(.*\)'`; \
+	  if test -d "$(top_srcdir)/$$file" ; then \
+	    mkdir "$(distdir)/$$file" && chmod 777 "$(distdir)/$$file";	\
+	  else \
+	    ln "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
+	  fi || exit; \
+	done
+	$(MAKE) -C $(distdir) distclean
+
+distcheck: dist
+	-rm -rf $(dummy)
+	mkdir $(dummy)
+	gunzip -c $(distdir).tar.gz | $(TAR) xf -
+	install_prefix=`cd $(dummy) && pwd`; \
+	cd $(distdir) \
+	&& ./configure --prefix="$$install_prefix"
+	$(MAKE) -C $(distdir) -q distprep
+	$(MAKE) -C $(distdir)
+	$(MAKE) -C $(distdir) install
+	$(MAKE) -C $(distdir) uninstall
+	@echo "checking whether \`$(MAKE) uninstall' works"
+	test `find $(dummy) -not -type d | wc -l` -eq 0
+	$(MAKE) -C $(distdir) dist
+# Room for improvement: Check here whether this distribution tarball
+# is sufficiently similar to the original one.
+	-rm -rf $(distdir) $(dummy)
+	@echo "Distribution integrity checks out."
+
+.PHONY: dist distdir distcheck
diff --git a/configure b/configure
index 0584c433f36fbda677bfe8b5c654be72167b70a8..55e85474877df1b3d264be32ace533d7f5199f75 100755
--- a/configure
+++ b/configure
@@ -7850,11 +7850,12 @@ done
 ac_given_srcdir=$srcdir
 ac_given_INSTALL="$INSTALL"
 
-trap 'rm -fr `echo "GNUmakefile
-	src/GNUmakefile
-	src/Makefile.global
-	src/backend/port/Makefile
-	src/test/regress/GNUmakefile
+trap 'rm -fr `echo "
+  GNUmakefile
+  src/GNUmakefile
+  src/Makefile.global
+  src/backend/port/Makefile
+  src/test/regress/GNUmakefile
  src/include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
@@ -8011,10 +8012,10 @@ EOF
 cat >> $CONFIG_STATUS <<EOF
 
 CONFIG_FILES=\${CONFIG_FILES-"GNUmakefile
-	src/GNUmakefile
-	src/Makefile.global
-	src/backend/port/Makefile
-	src/test/regress/GNUmakefile
+  src/GNUmakefile
+  src/Makefile.global
+  src/backend/port/Makefile
+  src/test/regress/GNUmakefile
 "}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
@@ -8231,6 +8232,7 @@ cat >> $CONFIG_STATUS <<EOF
 
 EOF
 cat >> $CONFIG_STATUS <<\EOF
+echo timestamp > src/include/stamp-h
 
 exit 0
 EOF
diff --git a/configure.in b/configure.in
index 62fdbecc8a051dc31bb504a56e49a5e323650465..c035dc14aea1f55baf4f65851183396f47ddeca6 100644
--- a/configure.in
+++ b/configure.in
@@ -1277,9 +1277,12 @@ fi
 dnl Finally ready to produce output files ...
 
 AC_OUTPUT(
-	GNUmakefile
-	src/GNUmakefile
-	src/Makefile.global
-	src/backend/port/Makefile
-	src/test/regress/GNUmakefile
+[
+  GNUmakefile
+  src/GNUmakefile
+  src/Makefile.global
+  src/backend/port/Makefile
+  src/test/regress/GNUmakefile
+],
+[echo timestamp > src/include/stamp-h]
 )
diff --git a/src/GNUmakefile.in b/src/GNUmakefile.in
index 83d69dd406ce7269931ffbeecb1934f8f5b13500..236400f8e075927009db1d43729a6121b0acf6be 100644
--- a/src/GNUmakefile.in
+++ b/src/GNUmakefile.in
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.57 2000/07/06 21:33:12 petere Exp $
+# $Header: /cvsroot/pgsql/src/Attic/GNUmakefile.in,v 1.58 2000/07/19 16:29:42 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -13,7 +13,7 @@ top_builddir = ..
 include Makefile.global
 
 
-all install installdirs uninstall dep depend:
+all install installdirs uninstall dep depend distprep:
 	$(MAKE) -C backend $@
 	$(MAKE) -C include $@
 	$(MAKE) -C interfaces $@
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 5a8b2e07474d83220f67778ea8f8a1fa219d1bef..b3572ecabf18558d222f6f85c2b6c8c70f3ba486 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.88 2000/07/17 22:31:59 petere Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.89 2000/07/19 16:29:42 petere Exp $
 #
 # NOTES
 #    Essentially all Postgres make files include this file and use the
@@ -281,15 +281,34 @@ STRERROR2 = @STRERROR2@
 SNPRINTF = @SNPRINTF@
 STRDUP = @STRDUP@
 
-.PHONY: all install installdirs uninstall dep depend clean distclean maintainer-clean
+.PHONY: all install installdirs uninstall dep depend clean distclean maintainer-clean distprep
 .SILENT: installdirs
 
 # make `all' the default target
 all:
 
+
+# Remake Makefile.global from Makefile.global.in if the latter
+# changed. In order to trigger this rule, the including file must
+# write `include $(top_builddir)/src/Makefile.global', not some
+# shortcut thereof.
 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
 	cd $(top_builddir) && CONFIG_FILES=src/Makefile.global CONFIG_HEADERS= ./config.status
 
+# Remake config.h from config.h.in if the latter changed.
+# config.status will not change the timestamp on config.h if it
+# doesn't change, so as to avoid recompiling the entire tree
+# unnecessarily. Therefore config.status will update a timestamp file
+# everytime it runs so that we don't trigger this rule everytime.
+#
+# Of course you need to turn on dependency tracking to get any
+# dependencies on config.h
+$(top_builddir)/src/include/config.h: $(top_builddir)/src/include/stamp-h
+$(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/config.h.in $(top_builddir)/config.status
+	cd $(top_builddir) && CONFIG_FILES= CONFIG_HEADERS=src/include/config.h ./config.status
+
+# When configure changes, rerun configure with the same options as
+# last time. To change configure, you need to run autoconf manually.
 $(top_builddir)/config.status: $(top_srcdir)/configure
 	cd $(top_builddir) && ./config.status --recheck
 
diff --git a/src/backend/Makefile b/src/backend/Makefile
index f9d64711d93c7546544e2c88288b963ba6bcb17b..f2848c4a7ac68f0fbf4069ebcba3ef6248dc1a99 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.62 2000/07/16 14:50:44 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.63 2000/07/19 16:29:44 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -106,6 +106,14 @@ $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
 	    $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
 
 
+##########################################################################
+
+distprep:
+	$(MAKE) -C parser	gram.c parse.h scan.c
+	$(MAKE) -C bootstrap	bootparse.c bootstrap_tokens.h bootscanner.c
+	$(MAKE) -C utils/misc	guc-file.c
+
+
 ##########################################################################
 
 install: all installdirs install-bin
@@ -122,7 +130,7 @@ endif
 installdirs:
 	$(mkinstalldirs) $(bindir) $(libdir) $(datadir)
 
-install-bin:
+install-bin: postgres $(POSTGRES_IMP) installdirs
 	$(INSTALL_PROGRAM) postgres$(X) $(bindir)/postgres$(X)
 	@rm -f $(bindir)/postmaster
 	ln -s postgres$(X) $(bindir)/postmaster
@@ -130,7 +138,7 @@ ifeq ($(MAKE_EXPORTS), true)
 	$(INSTALL_DATA) $(POSTGRES_IMP) $(libdir)/$(POSTGRES_IMP)
 endif
 
-.PHONY: install installdirs install-bin
+.PHONY: install-bin
 
 ##########################################################################
 
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile
index deda81105d78fbe8794e34b29c3ba21b1f876fb7..d1b40e99830a0dd6959a79e9272bb65b6df2caad 100644
--- a/src/backend/bootstrap/Makefile
+++ b/src/backend/bootstrap/Makefile
@@ -1,69 +1,62 @@
 #-------------------------------------------------------------------------
 #
-# Makefile--
-#    Makefile for the bootstrap module
+# Makefile for the bootstrap module
 #
-# IDENTIFICATION
-#    $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,
-# but bootstrap.c is part of the distribution.
-#
-# Another kinda weird Makefile cause we need two
-#  scanner/parsers in the backend and most yaccs and lexs
-#  don't have the prefix option.
-#
-#	sed files are HACK CITY! - redo...
+# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.24 2000/07/19 16:29:47 petere Exp $
 #
 #-------------------------------------------------------------------------
 
-SRCDIR= ../..
-include $(SRCDIR)/Makefile.global
+subdir = src/backend/bootstrap
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
 
-ifeq ($(CC), gcc)
+ifeq ($(GCC), yes)
 CFLAGS+= -Wno-error
 endif
 
-BOOTYACCS= bootstrap_tokens.h bootparse.c
-
+# qnx4's wlink currently crashes with bootstrap.o
 ifneq ($(PORTNAME), qnx4)
 OBJS= bootparse.o bootscanner.o bootstrap.o 
 else
-# qnx4's wlink currently crashes with bootstrap.o
 OBJS= bootparse.o bootscanner.o
 endif
 
+
 # make sure bootstrap.o is built even on qnx4
 all: SUBSYS.o bootstrap.o
 
 SUBSYS.o: $(OBJS)
-	$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
+	$(LD) $(LDREL) $(LDOUT) $@ $^
+
 
-# bootstrap.o's dependency on bootstrap_tokens.h is computed by the
-# make depend, but we state it here explicitly anyway because 
-# bootstrap_tokens.h doesn't even exist at first and if user fails to 
-# do make depend, we still want the build to succeed.
+bootstrap.o bootscanner.c: $(srcdir)/bootstrap_tokens.h
 
-bootstrap.o: bootstrap_tokens.h
 
-bootstrap_tokens.h bootparse.c: bootparse.y
+# `sed' rules to remove conflicts between bootstrap scanner and parser
+# and the SQL scanner and parser. For correctness' sake the rules that
+# use this must depend on this Makefile.
+define sed-magic
+sed -e 's/^yy/Int_yy/g' \
+    -e 's/\([^a-zA-Z0-9_]\)yy/\1Int_yy/g'
+endef
+
+
+$(srcdir)/bootparse.c $(srcdir)/bootstrap_tokens.h: bootparse.y Makefile
 	$(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
+	$(sed-magic) < y.tab.c > $(srcdir)/bootparse.c
+	$(sed-magic) < y.tab.h > $(srcdir)/bootstrap_tokens.h
+	rm -f y.tab.c y.tab.h
 
-bootscanner.c: bootscanner.l
+$(srcdir)/bootscanner.c: bootscanner.l Makefile
 	$(LEX) $(LFLAGS) $<
-	grep -v "^#" boot.sed > sedfile
-	sed -f sedfile < lex.yy.c > bootscanner.c
-	rm -f lex.yy.c sedfile
+	$(sed-magic) < lex.yy.c > $@
+	rm -f lex.yy.c
 
 clean:
 	rm -f SUBSYS.o $(OBJS) bootstrap.o
 # And the garbage that might have been left behind by partial build:
-	rm -f y.tab.h y.tab.c y.output lex.yy.c
+	@rm -f y.tab.h y.tab.c y.output lex.yy.c
+
 
 # This is unusual:  We actually have to build some of the parts before
 # we know what the header file dependencies are.  
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 4ef557271f31f9b0f1eea61b35d1bbd81e369fd1..169575e082d33c506ee707ba57349b6a95cfc23b 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -1,17 +1,16 @@
 #-------------------------------------------------------------------------
 #
-# Makefile--
-#    Makefile for parser
+# Makefile for parser
 #
-# IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.27 2000/07/14 15:32:04 thomas Exp $
+# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.28 2000/07/19 16:29:50 petere Exp $
 #
 #-------------------------------------------------------------------------
 
-SRCDIR= ../..
-include $(SRCDIR)/Makefile.global
+subdir = src/backend/parser
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
 
-ifeq ($(CC), gcc)
+ifeq ($(GCC), yes)
 CFLAGS+= -Wno-error
 endif
 
@@ -19,46 +18,38 @@ OBJS= analyze.o gram.o keywords.o parser.o parse_agg.o parse_clause.o \
       parse_expr.o parse_func.o parse_node.o parse_oper.o parse_relation.o \
       parse_type.o parse_coerce.o parse_target.o scan.o scansup.o
 
-all: $(SRCDIR)/include/parser/parse.h SUBSYS.o
 
-SUBSYS.o: $(OBJS)
-	$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
+all: SUBSYS.o
 
-$(SRCDIR)/include/parser/parse.h: parse.h
-	cp $< $@
+SUBSYS.o: $(OBJS)
+	$(LD) $(LDREL) $(LDOUT) $@ $^
 
-gram.c parse.h: gram.y
+$(srcdir)/gram.c $(srcdir)/parse.h: gram.y
 	$(YACC) -d $(YFLAGS) $<
-	mv y.tab.c gram.c
-	mv y.tab.h parse.h
+	mv y.tab.c $(srcdir)/gram.c
+	mv y.tab.h $(srcdir)/parse.h
 
-scan.c:	scan.l
+$(srcdir)/scan.c: scan.l
 	$(LEX) $(LFLAGS) $<
-	mv lex.yy.c scan.c
+	mv lex.yy.c $@
+
 
-# The following dependencies on parse.h are computed by
-# make depend, but we state them here explicitly anyway because 
-# parse.h doesn't even exist at first and if user fails to 
-# do make depend, we still want the build to succeed.
+analyze.o keywords.o parse_clause.o parse_expr.o scan.o: $(srcdir)/parse.h
+
+
+# gram.c, parse.h, and scan.c are in the distribution tarball, so they
+# are not cleaned here.
+clean: 
+	rm -f SUBSYS.o $(OBJS)
+# And the garbage that might have been left behind by partial build:
+	@rm -f y.tab.c y.tab.h lex.yy.c
 
-analyze.o keywords.o scan.o: parse.h
 
 # This is unusual:  We actually have to build some of the parts before
 # we know what the header file dependencies are.  
 dep depend: gram.c scan.c
 	$(CC) -MM $(CFLAGS) *.c >depend
 
-# Remove scan.c from the clean since we want to avoid rebuilding when using
-# the original source distribution. This should help Solaris machines whose
-# lex has trouble with exclusive states.
-# Remove gram.c, parse.h from the clean since we have now started to exceed
-# internal limits for some non-bison yaccs. - thomas 1998-02-17
-clean: 
-	rm -f SUBSYS.o $(OBJS) # gram.c parse.h # scan.c
-# And the garbage that might have been left behind by partial build:
-	rm -f y.tab.c y.tab.h lex.yy.c
-
 ifeq (depend,$(wildcard depend))
 include depend
 endif
-
diff --git a/src/bin/Makefile b/src/bin/Makefile
index d3e1556b5db1995b301ac3ca1f5a1178334538bd..0029f6f99ec9bf8910448064f08e2c3110d92747 100644
--- a/src/bin/Makefile
+++ b/src/bin/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.28 2000/07/02 15:20:56 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.29 2000/07/19 16:29:53 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -27,8 +27,8 @@ endif
 	DIRS += pgtclsh
 endif
 
-all install installdirs uninstall depend:
-	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit 1; done
+all install installdirs uninstall depend distprep:
+	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
 
 clean distclean maintainer-clean:
 	-@for dir in $(DIRS); do $(MAKE) -C $$dir $@; done
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index be45136b847b449b7d6e338fb434c480e12d5945..f605ad809ea89c9ff170e180177fec11a99994d0 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.22 2000/06/28 18:29:31 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.23 2000/07/19 16:29:56 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -65,6 +65,8 @@ endif
 submake:
 	$(MAKE) -C $(LIBPQDIR) all
 
+distprep: $(srcdir)/sql_help.h
+
 install: all installdirs
 	$(INSTALL_PROGRAM) psql$(X) $(bindir)/psql$(X)
 
diff --git a/src/include/Makefile b/src/include/Makefile
index d36e8bc7f9ab9b15bb3f1073a0b6f4dc7a87a221..81afc850d37e07a901beae978a24ae5adbd07dc5 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -5,7 +5,7 @@
 # Install exported headers to the include directory (these headers are
 # the minimal ones needed to build loadable backend extensions).
 #
-# $Header: /cvsroot/pgsql/src/include/Makefile,v 1.1 2000/07/06 21:33:44 petere Exp $
+# $Header: /cvsroot/pgsql/src/include/Makefile,v 1.2 2000/07/19 16:29:58 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -52,4 +52,4 @@ clean:
 	rm -f utils/fmgroids.h parser/parse.h
 
 distclean maintainer-clean: clean
-	rm -f config.h dynloader.h os.h
+	rm -f config.h dynloader.h os.h stamp-h
diff --git a/src/interfaces/Makefile b/src/interfaces/Makefile
index d9fbf0abec1cf85de45ef6207ff91eec2bf5a502..146fbf93e89374aedd1b8fa5d03950e4ea3332e8 100644
--- a/src/interfaces/Makefile
+++ b/src/interfaces/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/interfaces/Makefile,v 1.40 2000/06/28 18:29:35 petere Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/Makefile,v 1.41 2000/07/19 16:30:06 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -37,8 +37,8 @@ DIRS += python
 endif
 
 
-all install installdirs uninstall dep depend:
-	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit 1; done
+all install installdirs uninstall dep depend distprep:
+	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
 
 clean:
 	@for dir in $(DIRS); do $(MAKE) -C $$dir $@; done
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index fb537e671bb2d339e23bd30ec6059a7de78ef4e2..d3f9df7c9a4d608d35720463df0f0681f081e962 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -2,7 +2,7 @@ subdir = src/interfaces/ecpg
 top_builddir = ../../..
 include ../../Makefile.global
 
-all install installdirs uninstall dep depend:
+all install installdirs uninstall dep depend distprep:
 	$(MAKE) -C include $@
 	$(MAKE) -C lib $@
 	$(MAKE) -C preproc $@
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 9c23780ab4b608d261b6d578c2a53d2bb2bc8431..48ab51d53531576b778480223d3a9c4f4af6142e 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -35,6 +35,8 @@ $(srcdir)/pgc.c: pgc.l
 	$(LEX) $(LFLAGS) $<
 	mv lex.yy.c $@
 
+distprep: $(srcdir)/preproc.c $(srcdir)/preproc.h $(srcdir)/pgc.c
+
 install: all installdirs
 	$(INSTALL_PROGRAM) ecpg$(X) $(bindir)
 
diff --git a/src/pl/Makefile b/src/pl/Makefile
index e64bf02dab28de60b6433d09211b79c5a7c6942f..ccc8b57c1e7475dfff2d8ea95dbb0985e0b7a068 100644
--- a/src/pl/Makefile
+++ b/src/pl/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/pl/Makefile,v 1.10 2000/07/01 15:02:27 petere Exp $
+# $Header: /cvsroot/pgsql/src/pl/Makefile,v 1.11 2000/07/19 16:30:16 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -23,8 +23,8 @@ endif
 #DIRS += plperl
 #endif
 
-all install installdirs uninstall depend:
-	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit 1; done
+all install installdirs uninstall depend distprep:
+	@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
 
 clean distclean maintainer-clean:
 	@for dir in $(DIRS); do $(MAKE) -C $$dir $@; done
diff --git a/src/pl/plpgsql/Makefile b/src/pl/plpgsql/Makefile
index 2c6848622563d76a6cc5d41c041fc206f90330cf..d2d1911f5e047720e4a53f19f6be0db2a175a16b 100644
--- a/src/pl/plpgsql/Makefile
+++ b/src/pl/plpgsql/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/pl/plpgsql/Makefile,v 1.3 2000/06/27 00:31:56 petere Exp $
+# $Header: /cvsroot/pgsql/src/pl/plpgsql/Makefile,v 1.4 2000/07/19 16:30:21 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -12,7 +12,7 @@ subdir = src/pl/plpgsql
 top_builddir = ../../..
 include ../../Makefile.global
 
-all install installdirs uninstall:
+all install installdirs uninstall distprep:
 	$(MAKE) -C src $@
 
 clean distclean maintainer-clean:
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index 5cf37052f0d8c6f10d5cc21bfddacf2147ef5490..66013c62a75b7eb96166810a362735d6e83e617d 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.4 2000/06/28 18:30:16 petere Exp $
+# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.5 2000/07/19 16:30:24 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -66,6 +66,9 @@ $(srcdir)/pl_scan.c: scan.l
 	sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' < lex.yy.c > $@
 	rm -f lex.yy.c
 
+
+distprep: $(srcdir)/pl_scan.c $(srcdir)/pl.tab.h $(srcdir)/pl_gram.c
+
 mklang.sql: mklang.sql.in
 	sed -e 's%__libdir__%$(libdir)%g' -e 's%__DLSUFFIX__%$(DLSUFFIX)%g' < $< > $@
 
diff --git a/src/tools/release_prep b/src/tools/release_prep
index 85d12b13151459b9f2d11b998db2494df73bb699..2503b7bcdd7b478866f42f9970c3cd652a5d8353 100755
--- a/src/tools/release_prep
+++ b/src/tools/release_prep
@@ -1,4 +1,4 @@
-#!/bin/sh
+#! /bin/sh
 #
 # release_prep: prepare the Postgres source tree for distribution
 #
@@ -9,70 +9,18 @@
 # Run the script from the toplevel Postgres directory, ie, do
 #	cd pgsql
 #	src/tools/release_prep
-# (Right now, the cleanup tasks are all in the src subdirectory, but we
-# might want to add housekeeping in doc too?)
 #
 # The script's tasks are:
 # 1. Run configure to prepare usable Makefiles on the local system.
 # 2. Generate distribution copies of some derived files such as gram.c.
 #    (We do this so that recipients of the distribution don't have to have
 #    tools that can create these files.)
-#    Note we force these files to be recreated, to ensure they will have
-#    newer timestamps than their master files.
 # 3. "make distclean" to get rid of the configure outputs, as well as any
 #    other cruft that might be laying about.
 
 # Select make to use --- default gmake, can be overridden by env var
-MAKE=${MAKE:-gmake}
-
-# Configure ... should we run autoconf here???
-
-./configure
-
-# Generate parser's yacc and lex files
-
-cd src/backend/parser
-rm -f gram.c parse.h scan.c
-$MAKE gram.c parse.h scan.c
-cd ../../..
-
-# Generate bootstrap parser's yacc and lex files
-
-cd src/backend/bootstrap
-rm -f bootstrap_tokens.h bootparse.c bootscanner.c
-$MAKE bootstrap_tokens.h bootparse.c bootscanner.c
-cd ../../..
-
-# Generate configuration file scanner
-
-cd src/backend/utils/misc
-rm -f guc-file.c lex.yy.c
-$MAKE guc-file.c
-cd ../../../..
-
-# Generate ecpg preprocessor's yacc and lex files
-
-cd src/interfaces/ecpg/preproc
-rm -f preproc.c preproc.h pgc.c
-$MAKE preproc.c preproc.h pgc.c
-cd ../../../..
-
-# Generate plpgsql's yacc and lex files
-
-cd src/pl/plpgsql/src
-rm -f pl_scan.c pl.tab.h pl_gram.c
-$MAKE pl_scan.c pl.tab.h pl_gram.c
-cd ../../../..
-
-# Generate psql's help on SQL command from the SGML docs
-
-cd src/bin/psql
-rm -f sql_help.h
-$MAKE sql_help.h
-cd ../../..
-
-# Clean up
+: ${MAKE=gmake}
 
+./configure && \
+$MAKE distprep && \
 $MAKE distclean
-
-exit 0