Remove distprep

Started by Peter Eisentrautover 2 years ago38 messages
#1Peter Eisentraut
peter@eisentraut.org
1 attachment(s)

Per discussion at the unconference[0]https://wiki.postgresql.org/wiki/PgCon_2023_Developer_Unconference#Build_System, I started to write a patch that
removes the make distprep target. A more detailed explanation of the
rationale is also in the patch.

It needs some polishing around the edges, but I wanted to put it out
here to get things moving and avoid duplicate work.

One thing in particular that isn't clear right now is how "make world"
should behave if the documentation tools are not found. Maybe we should
make a build option, like "--with-docs", to mirror the meson behavior.

[0]: https://wiki.postgresql.org/wiki/PgCon_2023_Developer_Unconference#Build_System
https://wiki.postgresql.org/wiki/PgCon_2023_Developer_Unconference#Build_System

Attachments:

v1-0001-Remove-distprep.patchtext/plain; charset=UTF-8; name=v1-0001-Remove-distprep.patchDownload
From b187ce08fe140225f9ff24bf3ae4d2e97f57221d Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 9 Jun 2023 10:53:51 +0200
Subject: [PATCH v1] Remove distprep

A PostgreSQL release tarball contains a number of prebuilt files, in
particular files produced by bison, flex, perl, and well as html and
man documentation.  We have done this consistent with established
practice at the time to not require these tools for building from a
tarball.  Some of these tools were hard to get, or get the right
version of, from time to time, and shipping the prebuilt output was a
convenience to users.

Now this has at least two problems:

One, we have to make the build system(s) work in two modes: Building
from a git checkout and building from a tarball.  This is pretty
complicated, but it works so far for autoconf/make.  It does not
currently work for meson; you can currently only build with meson from
a git checkout.  Making meson builds work from a tarball seems very
difficult or impossible.  One particular problem is that since meson
requires a separate build directory, we cannot make the build update
files like gram.h in the source tree.  So if you were to build from a
tarball and update gram.y, you will have a gram.h in the source tree
and one in the build tree, but the way things work is that the
compiler will always use the one in the source tree.  So you cannot,
for example, make any gram.y changes when building from a tarball.
This seems impossible to fix in a non-horrible way.

Second, there is increased interest nowadays in precisely tracking the
origin of software.  We can reasonably track contributions into the
git tree, and users can reasonably track the path from a tarball to
packages and downloads and installs.  But what happens between the git
tree and the tarball is obscure and in some cases non-reproducible.

The solution for both of these issues is to get rid of the step that
adds prebuilt files to the tarball.  The tarball now only contains
what is in the git tree (*).  Getting the additional build
dependencies is no longer a problem nowadays, and the complications to
keep these dual build modes working are significant.  And of course we
want to get the meson build system working universally.

This commit removes the make distprep target altogether.  The make
dist target continues to do its job, it just doesn't call distprep
anymore.

(*) - The tarball also contains the INSTALL file that is built at make
dist time, but not by distprep.  This is unchanged for now.

The make maintainer-clean target, whose job it is to remove the
prebuilt files in addition to what make distclean does, is now just an
alias to make distprep.  (In practice, it is probably obsolete given
that git clean is available.)

The following programs are now hard build requirements in configure
(they were already required by meson.build):

- bison
- flex
- perl

FIXME: What should happen in configure if xmllint and xsltproc are not
found?
---
 GNUmakefile.in                                |  6 +-
 config/Makefile                               |  2 -
 config/meson.build                            |  2 +-
 config/missing                                | 54 ------------
 config/perl.m4                                |  9 +-
 config/programs.m4                            | 21 +----
 configure                                     | 62 ++------------
 contrib/cube/Makefile                         |  7 +-
 contrib/fuzzystrmatch/Makefile                |  9 +-
 contrib/seg/Makefile                          |  7 +-
 doc/Makefile                                  |  2 +-
 doc/src/Makefile                              |  2 +-
 doc/src/sgml/Makefile                         | 31 +------
 doc/src/sgml/installation.sgml                | 83 ++++++++-----------
 meson.build                                   | 56 +------------
 src/Makefile                                  |  5 +-
 src/Makefile.global.in                        | 32 +++----
 src/backend/Makefile                          | 52 ++----------
 src/backend/bootstrap/Makefile                |  6 +-
 src/backend/catalog/Makefile                  |  8 +-
 src/backend/jit/llvm/Makefile                 |  2 +-
 src/backend/nls.mk                            |  2 +-
 src/backend/nodes/Makefile                    |  6 +-
 src/backend/parser/Makefile                   |  8 +-
 src/backend/port/Makefile                     |  2 +-
 src/backend/replication/Makefile              | 10 ++-
 .../replication/libpqwalreceiver/Makefile     |  2 +-
 src/backend/replication/pgoutput/Makefile     |  2 +-
 src/backend/snowball/Makefile                 |  4 -
 src/backend/storage/lmgr/Makefile             |  4 +-
 src/backend/utils/Makefile                    |  8 +-
 src/backend/utils/adt/Makefile                |  5 +-
 src/backend/utils/mb/Makefile                 |  2 +-
 src/backend/utils/mb/Unicode/Makefile         |  2 -
 src/backend/utils/mb/conversion_procs/proc.mk |  2 +-
 src/backend/utils/misc/Makefile               |  3 +-
 src/bin/initdb/Makefile                       |  2 +-
 src/bin/pg_amcheck/Makefile                   |  2 +-
 src/bin/pg_archivecleanup/Makefile            |  2 +-
 src/bin/pg_basebackup/Makefile                |  2 +-
 src/bin/pg_checksums/Makefile                 |  2 +-
 src/bin/pg_config/Makefile                    |  2 +-
 src/bin/pg_controldata/Makefile               |  2 +-
 src/bin/pg_ctl/Makefile                       |  2 +-
 src/bin/pg_dump/Makefile                      |  2 +-
 src/bin/pg_resetwal/Makefile                  |  2 +-
 src/bin/pg_rewind/Makefile                    |  2 +-
 src/bin/pg_test_fsync/Makefile                |  2 +-
 src/bin/pg_test_timing/Makefile               |  2 +-
 src/bin/pg_upgrade/Makefile                   |  2 +-
 src/bin/pg_verifybackup/Makefile              |  2 +-
 src/bin/pg_waldump/Makefile                   |  2 +-
 src/bin/pgbench/Makefile                      |  4 -
 src/bin/psql/Makefile                         |  6 --
 src/bin/scripts/Makefile                      |  2 +-
 src/common/Makefile                           |  5 --
 src/common/unicode/Makefile                   |  2 -
 src/fe_utils/Makefile                         |  6 --
 src/include/Makefile                          |  2 +-
 src/interfaces/ecpg/Makefile                  |  2 +-
 src/interfaces/ecpg/compatlib/Makefile        |  2 -
 src/interfaces/ecpg/ecpglib/Makefile          |  2 -
 src/interfaces/ecpg/include/Makefile          |  2 +-
 src/interfaces/ecpg/pgtypeslib/Makefile       |  2 -
 src/interfaces/ecpg/preproc/Makefile          |  6 --
 src/interfaces/ecpg/test/Makefile             |  4 +-
 src/interfaces/libpq/Makefile                 |  3 -
 src/interfaces/libpq/test/Makefile            |  2 +-
 src/makefiles/pgxs.mk                         |  2 +-
 src/nls-global.mk                             |  2 +-
 src/pl/plperl/GNUmakefile                     |  2 +-
 src/pl/plpgsql/src/Makefile                   |  7 --
 src/pl/plpython/Makefile                      |  6 +-
 src/pl/tcl/Makefile                           |  5 --
 src/port/Makefile                             |  2 +-
 src/test/authentication/Makefile              |  2 +-
 src/test/examples/Makefile                    |  2 +-
 src/test/icu/Makefile                         |  2 +-
 src/test/isolation/Makefile                   |  4 -
 src/test/kerberos/Makefile                    |  2 +-
 src/test/ldap/Makefile                        |  2 +-
 src/test/locale/Makefile                      |  2 +-
 src/test/recovery/Makefile                    |  2 +-
 src/test/regress/GNUmakefile                  |  2 +-
 src/test/ssl/Makefile                         |  2 +-
 src/test/ssl/sslfiles.mk                      |  4 +-
 src/test/subscription/Makefile                |  2 +-
 src/timezone/Makefile                         |  2 +-
 src/tools/ifaddrs/Makefile                    |  2 +-
 src/tools/pg_bsd_indent/Makefile              |  2 +-
 src/tools/pginclude/cpluspluscheck            |  3 +
 src/tools/pginclude/headerscheck              |  3 +
 92 files changed, 162 insertions(+), 508 deletions(-)
 delete mode 100755 config/missing

diff --git a/GNUmakefile.in b/GNUmakefile.in
index 9c18c56233..80db4c73f8 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -41,7 +41,7 @@ install-world-bin-contrib-recurse: install-world-bin-src-recurse
 
 $(call recurse,installdirs uninstall init-po update-po,doc src config)
 
-$(call recurse,distprep coverage,doc src config contrib)
+$(call recurse,coverage,doc src config contrib)
 
 # clean, distclean, etc should apply to contrib too, even though
 # it's not built by default
@@ -53,7 +53,7 @@ clean:
 
 # Important: distclean `src' last, otherwise Makefile.global
 # will be gone too soon.
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C doc $@
 	$(MAKE) -C contrib $@
 	$(MAKE) -C config $@
@@ -109,7 +109,6 @@ distdir:
 	      || cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
 	  fi || exit; \
 	done
-	$(MAKE) -C $(distdir) distprep
 	$(MAKE) -C $(distdir)/doc/src/sgml/ INSTALL
 	cp $(distdir)/doc/src/sgml/INSTALL $(distdir)/
 	$(MAKE) -C $(distdir) distclean
@@ -122,7 +121,6 @@ distcheck: dist
 	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
diff --git a/config/Makefile b/config/Makefile
index 67e7998f55..da1283868e 100644
--- a/config/Makefile
+++ b/config/Makefile
@@ -7,11 +7,9 @@ include $(top_builddir)/src/Makefile.global
 
 install: all installdirs
 	$(INSTALL_SCRIPT) $(srcdir)/install-sh '$(DESTDIR)$(pgxsdir)/config/install-sh'
-	$(INSTALL_SCRIPT) $(srcdir)/missing '$(DESTDIR)$(pgxsdir)/config/missing'
 
 installdirs:
 	$(MKDIR_P) '$(DESTDIR)$(pgxsdir)/config'
 
 uninstall:
 	rm -f '$(DESTDIR)$(pgxsdir)/config/install-sh'
-	rm -f '$(DESTDIR)$(pgxsdir)/config/missing'
diff --git a/config/meson.build b/config/meson.build
index ab19c380bd..36ffbce93a 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -1,4 +1,4 @@
 install_data(
-  'install-sh', 'missing',
+  'install-sh',
   install_dir: dir_pgxs / 'config'
 )
diff --git a/config/missing b/config/missing
deleted file mode 100755
index 6df77e9473..0000000000
--- a/config/missing
+++ /dev/null
@@ -1,54 +0,0 @@
-#! /bin/sh
-
-# config/missing
-
-# This is *not* the GNU `missing' script, although it is similar in
-# concept. You can call it from the makefiles to get consistent
-# behavior when certain utility programs are missing.
-
-case $1 in
-    flex|bison)
-        # `missing flex|bison <input> <output>'
-        input=$2
-        output=$3
-        if test -f "$output"; then
-            echo "\
-***
-WARNING: \`$1' is missing on your system. You should only need it
-if you changed the file \`$input'; these changes will not take effect.
-You can get $1 from a GNU mirror site.
-***" >&2
-            echo "touch $output"
-            touch "$output"
-            exit 0
-        else # ! test -f $output
-            echo "\
-***
-ERROR: \`$1' is missing on your system. It is needed to create the
-file \`$output'. You can either get $1 from a GNU mirror site
-or download an official distribution of PostgreSQL, which contains
-pre-packaged $1 output.
-***" >&2
-            exit 1
-        fi
-        ;;
-
-    perl)
-        # `missing perl'
-        echo "\
-***
-ERROR: Perl is missing on your system. It is needed unless you are building
-from an unmodified official distribution of PostgreSQL.
-***" >&2
-        exit 1
-        ;;
-
-    *)
-        # `missing something-or-other'
-        echo "\
-***
-ERROR: \`$1' is missing on your system.
-***" >&2
-        exit 1
-        ;;
-esac
diff --git a/config/perl.m4 b/config/perl.m4
index 8126e79f67..1a3bb55649 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -13,19 +13,14 @@ if test "$PERL"; then
   if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
     $AWK '{ if ([$]1 == 5 && ([$]2 >= 14)) exit 1; else exit 0;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
 *** Perl version 5.14 or later is required, but this is $pgac_perl_version.])
-    PERL=""
   fi
 fi
 
 if test -z "$PERL"; then
-  AC_MSG_WARN([
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)])
+  AC_MSG_ERROR([Perl not found])
 fi
 ])# PGAC_PATH_PERL
 
diff --git a/config/programs.m4 b/config/programs.m4
index 8a118b4e03..490ec9fe9f 100644
--- a/config/programs.m4
+++ b/config/programs.m4
@@ -33,10 +33,9 @@ if test "$BISON"; then
   AC_MSG_NOTICE([using $pgac_bison_version])
   if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 2.3) exit 0; else exit 1;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
 *** Bison version 2.3 or later is required, but this is $pgac_bison_version.])
-    BISON=""
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -49,12 +48,7 @@ if test "$BISON"; then
 fi
 
 if test -z "$BISON"; then
-  AC_MSG_WARN([
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)])
+  AC_MSG_ERROR([bison not found])
 fi
 dnl We don't need AC_SUBST(BISON) because PGAC_PATH_PROGS did it
 AC_SUBST(BISONFLAGS)
@@ -95,7 +89,7 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            AC_MSG_WARN([
+            AC_MSG_ERROR([
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
 *** Flex version 2.5.35 or later is required, but this is $pgac_flex_version.])
           fi
@@ -109,14 +103,7 @@ fi
 ])[]dnl AC_CACHE_CHECK
 
 if test x"$pgac_cv_path_flex" = x"no"; then
-  AC_MSG_WARN([
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)])
-
-  FLEX=
+  AC_MSG_ERROR([flex not found])
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
diff --git a/configure b/configure
index 1b415142d1..7705ff1f92 100755
--- a/configure
+++ b/configure
@@ -10200,13 +10200,9 @@ if test "$BISON"; then
 $as_echo "$as_me: using $pgac_bison_version" >&6;}
   if echo "$pgac_bison_version" | $AWK '{ if ($4 < 2.3) exit 0; else exit 1;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&2;}
-    BISON=""
+*** Bison version 2.3 or later is required, but this is $pgac_bison_version." "$LINENO" 5
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -10219,18 +10215,7 @@ $as_echo "$as_me: WARNING:
 fi
 
 if test -z "$BISON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&2;}
+  as_fn_error $? "bison not found" "$LINENO" 5
 fi
 
 
@@ -10263,12 +10248,9 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&5
-$as_echo "$as_me: WARNING:
+            as_fn_error $? "
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&2;}
+*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." "$LINENO" 5
           fi
         fi
       fi
@@ -10282,20 +10264,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_path_flex" >&5
 $as_echo "$pgac_cv_path_flex" >&6; }
 if test x"$pgac_cv_path_flex" = x"no"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&2;}
-
-  FLEX=
+  as_fn_error $? "flex not found" "$LINENO" 5
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
@@ -10369,27 +10338,14 @@ $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
   if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
     $AWK '{ if ($1 == 5 && ($2 >= 14)) exit 1; else exit 0;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&2;}
-    PERL=""
+*** Perl version 5.14 or later is required, but this is $pgac_perl_version." "$LINENO" 5
   fi
 fi
 
 if test -z "$PERL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&2;}
+  as_fn_error $? "Perl not found" "$LINENO" 5
 fi
 
 if test "$with_perl" = yes; then
diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 4fd19aac35..dfb0d806e4 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -18,6 +18,8 @@ REGRESS = cube cube_sci
 
 SHLIB_LINK += $(filter -lm, $(LIBS))
 
+EXTRA_CLEAN = cubeparse.h cubeparse.c cubescan.c
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -37,8 +39,3 @@ cubeparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 cubeparse.o cubescan.o: cubeparse.h
-
-distprep: cubeparse.c cubescan.c
-
-maintainer-clean:
-	rm -f cubeparse.h cubeparse.c cubescan.c
diff --git a/contrib/fuzzystrmatch/Makefile b/contrib/fuzzystrmatch/Makefile
index e68bc0e33f..04c83a34a7 100644
--- a/contrib/fuzzystrmatch/Makefile
+++ b/contrib/fuzzystrmatch/Makefile
@@ -15,6 +15,8 @@ PGFILEDESC = "fuzzystrmatch - similarities and distance between strings"
 
 REGRESS = fuzzystrmatch fuzzystrmatch_utf8
 
+EXTRA_CLEAN = daitch_mokotoff.h
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -31,10 +33,3 @@ daitch_mokotoff.o: daitch_mokotoff.h
 
 daitch_mokotoff.h: daitch_mokotoff_header.pl
 	$(PERL) $< $@
-
-# daitch_mokotoff.h is included in tarballs, so it has to be made by
-# "distprep" and not cleaned except by "maintainer-clean".
-distprep: daitch_mokotoff.h
-
-maintainer-clean:
-	rm -f daitch_mokotoff.h
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index a1e49bf051..132ec8dbfe 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -16,7 +16,7 @@ HEADERS = segdata.h
 
 REGRESS = security seg
 
-EXTRA_CLEAN = y.tab.c y.tab.h
+EXTRA_CLEAN = segparse.h segparse.c segscan.c
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
@@ -38,8 +38,3 @@ segparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 segparse.o segscan.o: segparse.h
-
-distprep: segparse.c segscan.c
-
-maintainer-clean:
-	rm -f segparse.h segparse.c segscan.c
diff --git a/doc/Makefile b/doc/Makefile
index aee3cc0965..24370fc903 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -12,5 +12,5 @@ subdir = doc
 top_builddir = ..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C src $@
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 30d883815a..2ed02084ff 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -4,5 +4,5 @@ subdir = doc/src
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C sgml $@
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 71cbef230f..c0153f64c7 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -7,10 +7,9 @@
 #----------------------------------------------------------------------------
 
 # This makefile is for building and installing the documentation.
-# When a release tarball is created, the documentation files are
-# prepared using the distprep target.  In Git-based trees these files
+# In Git-based trees these files
 # don't exist, unless explicitly built, so we skip the installation in
-# that case.
+# that case. FIXME
 
 
 # Make "html" the default target, since that is what most people tend
@@ -28,31 +27,9 @@ include $(top_builddir)/src/Makefile.global
 
 all: html man
 
-distprep: html distprep-man
-
-
-ifndef DBTOEPUB
-DBTOEPUB = $(missing) dbtoepub
-endif
-
-ifndef FOP
-FOP = $(missing) fop
-endif
 
 XMLINCLUDE = --path . --path $(srcdir)
 
-ifdef XMLLINT
-XMLLINT := $(XMLLINT) --nonet
-else
-XMLLINT = $(missing) xmllint
-endif
-
-ifdef XSLTPROC
-XSLTPROC := $(XSLTPROC) --nonet
-else
-XSLTPROC = $(missing) xsltproc
-endif
-
 override XSLTPROCFLAGS += --stringparam pg.version '$(VERSION)'
 
 
@@ -77,7 +54,7 @@ postgres-full.xml: postgres.sgml $(ALLSGML)
 ## Man pages
 ##
 
-man distprep-man: man-stamp
+man: man-stamp
 
 man-stamp: stylesheet-man.xsl postgres-full.xml
 	$(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_MAN_FLAGS) $^
@@ -303,8 +280,6 @@ clean:
 	rm -f *.texixml *.texi *.info db2texi.refs
 
 distclean: clean
-
-maintainer-clean: distclean
 # HTML
 	rm -fr html/ html-stamp
 # man
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 75dc81a0a9..36675cac1c 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -72,8 +72,7 @@ <title>Requirements</title>
 
       Alternatively, <productname>PostgreSQL</productname> can be built using
       <ulink url="https://mesonbuild.com/">Meson</ulink>.  This is currently
-      experimental and only works when building from a Git checkout (not from
-      a distribution tarball).  If you choose to use
+      experimental.  If you choose to use
       <application>Meson</application>, then you don't need
       <acronym>GNU</acronym> <application>make</application>, but the other
       requirements below still apply.
@@ -102,6 +101,41 @@ <title>Requirements</title>
      </para>
     </listitem>
 
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>flex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>lex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>bison</primary>
+      </indexterm>
+      <indexterm>
+       <primary>yacc</primary>
+      </indexterm>
+
+      <application>Flex</application> 2.5.35 or later and
+      <application>Bison</application> 2.3 or later are required.  Other
+      <application>lex</application> and <application>yacc</application>
+      programs cannot be used.
+     </para>
+    </listitem>
+
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>perl</primary>
+      </indexterm>
+
+      <application>Perl</application> 5.14 or later is needed during the build
+      process and to run some test suites.  (This requirement is separate from
+      the requirements for building <application>PL/Perl</application>; see
+      below.)
+     </para>
+    </listitem>
+
     <listitem>
      <para>
       <indexterm>
@@ -315,51 +349,6 @@ <title>Requirements</title>
    </itemizedlist>
   </para>
 
-  <para>
-   If you are building from a <productname>Git</productname> tree instead of
-   using a released source package, or if you want to do server development,
-   you also need the following packages:
-
-   <itemizedlist>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>flex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>lex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>bison</primary>
-      </indexterm>
-      <indexterm>
-       <primary>yacc</primary>
-      </indexterm>
-
-      <application>Flex</application> and <application>Bison</application>
-      are needed to build from a Git checkout, or if you changed the actual
-      scanner and parser definition files. If you need them, be sure
-      to get <application>Flex</application> 2.5.35 or later and
-      <application>Bison</application> 2.3 or later. Other <application>lex</application>
-      and <application>yacc</application> programs cannot be used.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>perl</primary>
-      </indexterm>
-
-      <application>Perl</application> 5.14 or later is needed to build from a Git checkout,
-      or if you changed the input files for any of the build steps that
-      use Perl scripts.  If building on Windows you will need
-      <application>Perl</application> in any case.  <application>Perl</application> is
-      also required to run some test suites.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
-
   <para>
    If you need to get a <acronym>GNU</acronym> package, you can find
    it at your local <acronym>GNU</acronym> mirror site (see <ulink
diff --git a/meson.build b/meson.build
index 16b2e86646..cba1ccc280 100644
--- a/meson.build
+++ b/meson.build
@@ -72,7 +72,7 @@ configure. Alternatively use a separate check out for meson based builds.
 @0@
 ****'''
 if fs.exists(meson.current_source_dir() / 'src' / 'include' / 'pg_config.h')
-  errmsg_cleanup = 'To clean up, run make maintainer-clean in the source tree.'
+  errmsg_cleanup = 'To clean up, run make distclean in the source tree.'
   error(errmsg_nonclean_base.format(errmsg_cleanup))
 endif
 
@@ -339,7 +339,6 @@ program_lz4 = find_program(get_option('LZ4'), native: true, required: false)
 openssl = find_program(get_option('OPENSSL'), native: true, required: false)
 program_zstd = find_program(get_option('ZSTD'), native: true, required: false)
 dtrace = find_program(get_option('DTRACE'), native: true, required: get_option('dtrace'))
-missing = find_program('config/missing', native: true)
 cp = find_program('cp', required: false, native: true)
 xmllint_bin = find_program(get_option('XMLLINT'), native: true, required: false)
 xsltproc_bin = find_program(get_option('XSLTPROC'), native: true, required: false)
@@ -2895,59 +2894,6 @@ generated_sources_ac += {'': ['GNUmakefile']}
 testprep_targets += test_install_libs
 
 
-# If there are any files in the source directory that we also generate in the
-# build directory, they might get preferred over the newly generated files,
-# e.g. because of a #include "file", which always will search in the current
-# directory first.
-message('checking for file conflicts between source and build directory')
-conflicting_files = []
-potentially_conflicting_files_t = []
-potentially_conflicting_files_t += generated_headers
-potentially_conflicting_files_t += generated_backend_headers
-potentially_conflicting_files_t += generated_backend_sources
-potentially_conflicting_files_t += generated_sources
-
-potentially_conflicting_files = []
-
-# convert all sources of potentially conflicting files into uniform shape
-foreach t : potentially_conflicting_files_t
-  potentially_conflicting_files += t.full_path()
-endforeach
-foreach t : configure_files
-  t = '@0@'.format(t)
-  potentially_conflicting_files += meson.current_build_dir() / t
-endforeach
-foreach sub, fnames : generated_sources_ac
-  sub = meson.build_root() / sub
-  foreach fname : fnames
-    potentially_conflicting_files += sub / fname
-  endforeach
-endforeach
-
-# find and report conflicting files
-foreach build_path : potentially_conflicting_files
-  build_path = host_system == 'windows' ? fs.as_posix(build_path) : build_path
-  # str.replace is in 0.56
-  src_path = meson.current_source_dir() / build_path.split(meson.current_build_dir() / '')[1]
-  if fs.exists(src_path) or fs.is_symlink(src_path)
-    conflicting_files += src_path
-  endif
-endforeach
-# XXX: Perhaps we should generate a file that would clean these up? The list
-# can be long.
-if conflicting_files.length() > 0
-  errmsg_cleanup = '''
-Conflicting files in source directory:
-  @0@
-
-The conflicting files need to be removed, either by removing the files listed
-above, or by running configure and then make maintainer-clean.
-'''
-  errmsg_cleanup = errmsg_cleanup.format(' '.join(conflicting_files))
-  error(errmsg_nonclean_base.format(errmsg_cleanup))
-endif
-
-
 
 ###############################################################
 # Install targets
diff --git a/src/Makefile b/src/Makefile
index 94649c36c7..2f31a2f20a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -59,16 +59,13 @@ uninstall: uninstall-local
 uninstall-local:
 	rm -f $(addprefix '$(DESTDIR)$(pgxsdir)/$(subdir)'/, Makefile.global Makefile.port Makefile.shlib nls-global.mk)
 
-distprep:
-	$(MAKE) -C test/isolation $@
-
 clean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
 	$(MAKE) -C tools/pg_bsd_indent $@
 
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 974b1dfef9..7a2700899e 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -19,11 +19,11 @@
 #
 # Meta configuration
 
-standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check checkprep installcheck init-po update-po
+standard_targets = all install installdirs uninstall clean distclean coverage check checkprep installcheck init-po update-po
 # these targets should recurse even into subdirectories not being built:
-standard_always_targets = distprep clean distclean maintainer-clean
+standard_always_targets = clean distclean
 
-.PHONY: $(standard_targets) install-strip html man installcheck-parallel update-unicode
+.PHONY: $(standard_targets) maintainer-clean install-strip html man installcheck-parallel update-unicode
 
 # make `all' the default target
 all:
@@ -35,6 +35,8 @@ all:
 # Never delete any intermediate files automatically.
 .SECONDARY:
 
+maintainer-clean: distclean
+
 # PostgreSQL version number
 VERSION = @PACKAGE_VERSION@
 MAJORVERSION = @PG_MAJORVERSION@
@@ -320,12 +322,8 @@ X = @EXEEXT@
 
 # Perl
 
-ifneq (@PERL@,)
-    # quoted to protect pathname with spaces
-    PERL		= '@PERL@'
-else
-    PERL		= $(missing) perl
-endif
+# quoted to protect pathname with spaces
+PERL		= '@PERL@'
 perl_archlibexp		= @perl_archlibexp@
 perl_privlibexp		= @perl_privlibexp@
 perl_includespec	= @perl_includespec@
@@ -506,8 +504,6 @@ INSTALL_SHLIB_OPTS = -m 755
 
 MKDIR_P = @MKDIR_P@
 
-missing		= $(SHELL) $(top_srcdir)/config/missing
-
 STRIP		= @STRIP@
 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
@@ -766,21 +762,13 @@ TAS         = @TAS@
 # Global targets and rules
 
 %.c: %.l
-ifdef FLEX
 	$(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
 	@$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
 	$(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
-else
-	@$(missing) flex $< '$@'
-endif
 
 %.c: %.y
 	$(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
-ifdef BISON
 	$(BISON) $(BISONFLAGS) -o $@ $<
-else
-	@$(missing) bison $< $@
-endif
 
 %.i: %.c
 	$(CPP) $(CPPFLAGS) -o $@ $<
@@ -908,7 +896,7 @@ recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if
 # If a makefile's list of SUBDIRS varies depending on configuration, then
 # any subdirectories excluded from SUBDIRS should instead be added to
 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
-# This ensures that distprep, distclean, etc will apply to all subdirectories.
+# This ensures that distclean, etc will apply to all subdirectories.
 # In the normal case all arguments will be defaulted.
 # $1: targets to make recursive (defaults to standard_always_targets)
 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
@@ -963,7 +951,7 @@ include $(Po_files)
 endif
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-deps
+clean distclean: clean-deps
 
 .PHONY: clean-deps
 clean-deps:
@@ -1047,7 +1035,7 @@ lcov_test.info: $(all_gcda_files)
 
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-coverage
+clean distclean: clean-coverage
 
 .PHONY: clean-coverage
 clean-coverage:
diff --git a/src/backend/Makefile b/src/backend/Makefile
index e4bf0fe9c0..0625f80ed5 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -136,15 +136,15 @@ storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl storage/lmgr/lw
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-catalog-headers:
-	$(MAKE) -C catalog distprep generated-header-symlinks
+	$(MAKE) -C catalog generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-nodes-headers:
-	$(MAKE) -C nodes distprep generated-header-symlinks
+	$(MAKE) -C nodes generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-utils-headers:
-	$(MAKE) -C utils distprep generated-header-symlinks
+	$(MAKE) -C utils generated-header-symlinks
 
 .PHONY: submake-catalog-headers submake-nodes-headers submake-utils-headers
 
@@ -154,7 +154,7 @@ submake-utils-headers:
 #
 # The point of the prereqdir incantation in some of the rules below is to
 # force the symlink to use an absolute path rather than a relative path.
-# For headers which are generated by make distprep, the actual header within
+# For headers which are generated by make FIXME, the actual header within
 # src/backend will be in the source tree, while the symlink in src/include
 # will be in the build tree, so a simple ../.. reference won't work.
 # For headers generated during regular builds, we prefer a relative symlink.
@@ -164,29 +164,13 @@ submake-utils-headers:
 generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h submake-catalog-headers submake-nodes-headers submake-utils-headers
 
 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 utils/probes.o: utils/probes.d $(SUBDIROBJS)
 	$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
 
 
-##########################################################################
-
-# Be sure that these files get removed by the maintainer-clean target
-distprep:
-	$(MAKE) -C parser	gram.c gram.h scan.c
-	$(MAKE) -C bootstrap	bootparse.c bootparse.h bootscanner.c
-	$(MAKE) -C catalog	distprep
-	$(MAKE) -C nodes	distprep
-	$(MAKE) -C replication	repl_gram.c repl_gram.h repl_scanner.c syncrep_gram.c syncrep_gram.h syncrep_scanner.c
-	$(MAKE) -C storage/lmgr	lwlocknames.h lwlocknames.c
-	$(MAKE) -C utils	distprep
-	$(MAKE) -C utils/adt	jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
-	$(MAKE) -C utils/misc	guc-file.c
-
-
 ##########################################################################
 
 install: all installdirs install-bin
@@ -282,31 +266,9 @@ ifeq ($(PORTNAME), win32)
 endif
 
 distclean: clean
+# generated by configure
 	rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
 
-maintainer-clean: distclean
-	$(MAKE) -C catalog $@
-	$(MAKE) -C nodes $@
-	$(MAKE) -C utils $@
-	rm -f bootstrap/bootparse.c \
-	      bootstrap/bootparse.h \
-	      bootstrap/bootscanner.c \
-	      parser/gram.c \
-	      parser/gram.h \
-	      parser/scan.c \
-	      replication/repl_gram.c \
-	      replication/repl_gram.h \
-	      replication/repl_scanner.c \
-	      replication/syncrep_gram.c \
-	      replication/syncrep_gram.h \
-	      replication/syncrep_scanner.c \
-	      storage/lmgr/lwlocknames.c \
-	      storage/lmgr/lwlocknames.h \
-	      utils/adt/jsonpath_gram.c \
-	      utils/adt/jsonpath_gram.h \
-	      utils/adt/jsonpath_scan.c \
-	      utils/misc/guc-file.c
-
 
 ##########################################################################
 #
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile
index 606c8021e7..43dd2bc9aa 100644
--- a/src/backend/bootstrap/Makefile
+++ b/src/backend/bootstrap/Makefile
@@ -28,5 +28,7 @@ bootparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 bootparse.o bootscanner.o: bootparse.h
 
-# bootparse.c and bootscanner.c are in the distribution tarball, so
-# they are not cleaned here.
+clean:
+	rm -f bootstrap/bootparse.c \
+	      bootstrap/bootparse.h \
+	      bootstrap/bootscanner.c
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index a60107bf94..207d83e32b 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -89,9 +89,7 @@ POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
 	pg_ts_template.dat pg_type.dat \
 	)
 
-all: distprep generated-header-symlinks
-
-distprep: bki-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -138,9 +136,5 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
 
-# postgres.bki, system_constraints.sql, and the generated headers are
-# in the distribution tarball, so they are not cleaned here.
 clean:
-
-maintainer-clean: clean
 	rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
index 2da122a391..0036c4f552 100644
--- a/src/backend/jit/llvm/Makefile
+++ b/src/backend/jit/llvm/Makefile
@@ -71,6 +71,6 @@ uninstall-types:
 
 include $(top_srcdir)/src/Makefile.shlib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -f llvmjit_types.bc
diff --git a/src/backend/nls.mk b/src/backend/nls.mk
index 8263527c85..a2579d646b 100644
--- a/src/backend/nls.mk
+++ b/src/backend/nls.mk
@@ -22,7 +22,7 @@ GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS) \
     report_invalid_record:2:c-format \
     ereport_startup_progress:1:c-format
 
-gettext-files: distprep
+gettext-files:
 	find $(srcdir) $(srcdir)/../common $(srcdir)/../port -name '*.c' -print | LC_ALL=C sort >$@
 
 my-clean:
diff --git a/src/backend/nodes/Makefile b/src/backend/nodes/Makefile
index 0a95e683d0..c913bcd92b 100644
--- a/src/backend/nodes/Makefile
+++ b/src/backend/nodes/Makefile
@@ -65,9 +65,7 @@ node_headers = \
 
 # see also catalog/Makefile for an explanation of these make rules
 
-all: distprep generated-header-symlinks
-
-distprep: node-support-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -98,5 +96,5 @@ outfuncs.o: outfuncs.c outfuncs.funcs.c outfuncs.switch.c | node-support-stamp
 queryjumblefuncs.o: queryjumblefuncs.c queryjumblefuncs.funcs.c queryjumblefuncs.switch.c | node-support-stamp
 readfuncs.o:  readfuncs.c readfuncs.funcs.c readfuncs.switch.c | node-support-stamp
 
-maintainer-clean: clean
+clean:
 	rm -f node-support-stamp $(addsuffix funcs.funcs.c,copy equal out queryjumble read) $(addsuffix funcs.switch.c,copy equal out queryjumble read) nodetags.h
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 9f1c4022bb..3d33b082f2 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -64,8 +64,8 @@ scan.c: FLEX_FIX_WARNING=yes
 # Force these dependencies to be known even without dependency info built:
 gram.o scan.o parser.o: gram.h
 
-
-# gram.c, gram.h, and scan.c are in the distribution tarball, so they
-# are not cleaned here.
-clean distclean maintainer-clean:
+clean:
+	rm -f parser/gram.c \
+	      parser/gram.h \
+	      parser/scan.c
 	rm -f lex.backup
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 2d00b4f05a..47338d9922 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -43,6 +43,6 @@ else
 	$(CC) $(CFLAGS) -c $<
 endif
 
-distclean clean:
+clean:
 	rm -f tas_cpp.s
 	$(MAKE) -C win32 clean
diff --git a/src/backend/replication/Makefile b/src/backend/replication/Makefile
index 23f29ba545..9cc82680ab 100644
--- a/src/backend/replication/Makefile
+++ b/src/backend/replication/Makefile
@@ -48,6 +48,10 @@ syncrep_gram.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 syncrep_gram.o syncrep_scanner.o: syncrep_gram.h
 
-# repl_gram.c, repl_scanner.c, syncrep_gram.c and syncrep_scanner.c
-# are in the distribution tarball, so they are not cleaned here.
-# (Our parent Makefile takes care of them during maintainer-clean.)
+clean:
+	rm -f replication/repl_gram.c \
+	      replication/repl_gram.h \
+	      replication/repl_scanner.c \
+	      replication/syncrep_gram.c \
+	      replication/syncrep_gram.h \
+	      replication/syncrep_scanner.c
diff --git a/src/backend/replication/libpqwalreceiver/Makefile b/src/backend/replication/libpqwalreceiver/Makefile
index f26daa135f..e882907350 100644
--- a/src/backend/replication/libpqwalreceiver/Makefile
+++ b/src/backend/replication/libpqwalreceiver/Makefile
@@ -33,5 +33,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/replication/pgoutput/Makefile b/src/backend/replication/pgoutput/Makefile
index 3b41fbcfac..d89d317fe7 100644
--- a/src/backend/replication/pgoutput/Makefile
+++ b/src/backend/replication/pgoutput/Makefile
@@ -28,5 +28,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/snowball/Makefile b/src/backend/snowball/Makefile
index 4bebfa0250..efc4300eb9 100644
--- a/src/backend/snowball/Makefile
+++ b/src/backend/snowball/Makefile
@@ -104,8 +104,6 @@ include $(top_srcdir)/src/Makefile.shlib
 $(SQLSCRIPT): snowball_create.pl snowball_func.sql.in snowball.sql.in
 	$(PERL) $< --input ${srcdir} --outdir .
 
-distprep: $(SQLSCRIPT)
-
 install: all installdirs install-lib install-script
 	$(INSTALL_DATA) $(addprefix $(srcdir)/stopwords/,$(stop_files)) '$(DESTDIR)$(datadir)/$(DICTDIR)'
 
@@ -122,6 +120,4 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
 	rm -f $(SQLSCRIPT)
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index b25b7ee421..c48ba943c4 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -45,8 +45,6 @@ lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt generate-l
 check: s_lock_test
 	./s_lock_test
 
-clean distclean:
+clean:
 	rm -f s_lock_test
-
-maintainer-clean: clean
 	rm -f lwlocknames.h lwlocknames.c
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index deb901609f..abbf9b4355 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -34,9 +34,7 @@ catalogdir  = $(top_srcdir)/src/backend/catalog
 
 include $(top_srcdir)/src/backend/common.mk
 
-all: distprep probes.h generated-header-symlinks
-
-distprep: fmgr-stamp errcodes.h
+all: probes.h generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -104,10 +102,6 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, errcodes.txt)
 
-# fmgroids.h, fmgrprotos.h, fmgrtab.c, fmgr-stamp, and errcodes.h are in the
-# distribution tarball, so they are not cleaned here.
 clean:
 	rm -f probes.h probes.h.tmp
-
-maintainer-clean: clean
 	rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile
index 0de0bbb1b8..199eae525d 100644
--- a/src/backend/utils/adt/Makefile
+++ b/src/backend/utils/adt/Makefile
@@ -132,10 +132,9 @@ jsonpath_scan.c: FLEX_NO_BACKUP=yes
 # Force these dependencies to be known even without dependency info built:
 jsonpath_gram.o jsonpath_scan.o: jsonpath_gram.h
 
-# jsonpath_gram.c and jsonpath_scan.c are in the distribution tarball,
-# so they are not cleaned here.
-clean distclean maintainer-clean:
+clean:
 	rm -f lex.backup
+	rm -f jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
 
 like.o: like.c like_match.c
 
diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile
index b19a125fa2..bbde71b5aa 100644
--- a/src/backend/utils/mb/Makefile
+++ b/src/backend/utils/mb/Makefile
@@ -21,5 +21,5 @@ OBJS = \
 
 include $(top_srcdir)/src/backend/common.mk
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C conversion_procs $@
diff --git a/src/backend/utils/mb/Unicode/Makefile b/src/backend/utils/mb/Unicode/Makefile
index 728ccb99c2..6c0a8150f2 100644
--- a/src/backend/utils/mb/Unicode/Makefile
+++ b/src/backend/utils/mb/Unicode/Makefile
@@ -66,8 +66,6 @@ all: $(MAPS)
 
 distclean: clean
 	rm -f $(TEXTS)
-
-maintainer-clean: distclean
 	rm -f $(MAPS)
 
 
diff --git a/src/backend/utils/mb/conversion_procs/proc.mk b/src/backend/utils/mb/conversion_procs/proc.mk
index e0a3b74b25..2eeae28240 100644
--- a/src/backend/utils/mb/conversion_procs/proc.mk
+++ b/src/backend/utils/mb/conversion_procs/proc.mk
@@ -13,5 +13,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/utils/misc/Makefile b/src/backend/utils/misc/Makefile
index 2910032930..c2971c7678 100644
--- a/src/backend/utils/misc/Makefile
+++ b/src/backend/utils/misc/Makefile
@@ -40,6 +40,5 @@ endif
 
 include $(top_srcdir)/src/backend/common.mk
 
-# Note: guc-file.c is not deleted by 'make clean',
-# since we want to ship it in distribution tarballs.
 clean:
+	rm -f guc-file.c
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index d69bd89572..7043289239 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -55,7 +55,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/initdb$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f initdb$(X) $(OBJS) localtime.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_amcheck/Makefile b/src/bin/pg_amcheck/Makefile
index 947f2267ed..528c588e35 100644
--- a/src/bin/pg_amcheck/Makefile
+++ b/src/bin/pg_amcheck/Makefile
@@ -40,7 +40,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_amcheck$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_amcheck$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index 49935d6dce..93fd703f22 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -25,7 +25,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_archivecleanup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_archivecleanup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile
index 893a75c942..74dc1ddd6d 100644
--- a/src/bin/pg_basebackup/Makefile
+++ b/src/bin/pg_basebackup/Makefile
@@ -71,7 +71,7 @@ uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_receivewal$(X)'
 	rm -f '$(DESTDIR)$(bindir)/pg_recvlogical$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_basebackup$(X) pg_receivewal$(X) pg_recvlogical$(X) \
 		$(BBOBJS) pg_receivewal.o pg_recvlogical.o \
 		$(OBJS)
diff --git a/src/bin/pg_checksums/Makefile b/src/bin/pg_checksums/Makefile
index 4911f6bee2..ac736b2260 100644
--- a/src/bin/pg_checksums/Makefile
+++ b/src/bin/pg_checksums/Makefile
@@ -36,7 +36,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_checksums$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_checksums$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index 1a405f9c97..cb13aceafa 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_config$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_config$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index aa5bd58222..00ee1e25b3 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_controldata$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_controldata$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index 4b6d47a8f8..4d29ca72c1 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -42,7 +42,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_ctl$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_ctl$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 24de7593a6..604cddb997 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -69,6 +69,6 @@ installcheck:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o
 	rm -rf tmp_check
diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile
index a363b948b5..a06e493ba8 100644
--- a/src/bin/pg_resetwal/Makefile
+++ b/src/bin/pg_resetwal/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_resetwal$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_resetwal$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
index bed05f1609..8df1da80cb 100644
--- a/src/bin/pg_rewind/Makefile
+++ b/src/bin/pg_rewind/Makefile
@@ -49,7 +49,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_rewind$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_rewind$(X) $(OBJS) xlogreader.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index 631d0f38a8..4c5e518125 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_fsync$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index 84d84c38aa..7f677edadb 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_timing$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_timing$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 5834513add..f76aca1b1a 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -46,7 +46,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_upgrade$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_upgrade$(X) $(OBJS)
 	rm -rf delete_old_cluster.sh log/ tmp_check/ \
 	       reindex_hash.sql
diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile
index 596df15118..c96323faa9 100644
--- a/src/bin/pg_verifybackup/Makefile
+++ b/src/bin/pg_verifybackup/Makefile
@@ -38,7 +38,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_verifybackup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile
index 0ecf582039..4c1ee64950 100644
--- a/src/bin/pg_waldump/Makefile
+++ b/src/bin/pg_waldump/Makefile
@@ -45,7 +45,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_waldump$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_waldump$(X) $(OBJS) $(RMGRDESCSOURCES) xlogreader.c xlogstats.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index 68b6eb0376..987bf64df9 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -38,8 +38,6 @@ exprparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 exprparse.o exprscan.o: exprparse.h
 
-distprep: exprparse.c exprscan.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pgbench$(X) '$(DESTDIR)$(bindir)/pgbench$(X)'
 
@@ -52,8 +50,6 @@ uninstall:
 clean distclean:
 	rm -f pgbench$(X) $(OBJS)
 	rm -rf tmp_check
-
-maintainer-clean: distclean
 	rm -f exprparse.h exprparse.c exprscan.c
 
 check:
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 1f2bf0c6b0..8ad7c65446 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -62,8 +62,6 @@ psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
 psqlscanslash.c: FLEX_NO_BACKUP=yes
 psqlscanslash.c: FLEX_FIX_WARNING=yes
 
-distprep: sql_help.h sql_help.c psqlscanslash.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
 	$(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
@@ -77,10 +75,6 @@ uninstall:
 clean distclean:
 	rm -f psql$(X) $(OBJS) lex.backup
 	rm -rf tmp_check
-
-# files removed here are supposed to be in the distribution tarball,
-# so do not clean them in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f sql_help.h sql_help.c psqlscanslash.c
 
 check:
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index a7a9d0fea5..20db40b103 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -48,7 +48,7 @@ installdirs:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(addsuffix $(X), $(PROGRAMS)))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS))
 	rm -f common.o $(WIN32RES)
 	rm -rf tmp_check
diff --git a/src/common/Makefile b/src/common/Makefile
index 113029bf7b..ec063c6e18 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -121,8 +121,6 @@ GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
 
 all: libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 
-distprep: kwlist_d.h
-
 # libpgcommon is needed by some contrib
 install: all installdirs
 	$(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
@@ -188,10 +186,7 @@ RYU_OBJS = $(RYU_FILES) $(RYU_FILES:%.o=%_shlib.o) $(RYU_FILES:%.o=%_srv.o)
 
 $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
 
-# kwlist_d.h is in the distribution tarball, so it is not cleaned here.
 clean distclean:
 	rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 	rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)
-
-maintainer-clean: distclean
 	rm -f kwlist_d.h
diff --git a/src/common/unicode/Makefile b/src/common/unicode/Makefile
index 382da476cf..d6e427b582 100644
--- a/src/common/unicode/Makefile
+++ b/src/common/unicode/Makefile
@@ -68,5 +68,3 @@ clean:
 
 distclean: clean
 	rm -f UnicodeData.txt EastAsianWidth.txt CompositionExclusions.txt NormalizationTest.txt norm_test_table.h unicode_norm_table.h
-
-maintainer-clean: distclean
diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile
index 456d6dd390..8accd5906d 100644
--- a/src/fe_utils/Makefile
+++ b/src/fe_utils/Makefile
@@ -48,8 +48,6 @@ psqlscan.c: FLEXFLAGS = -Cfe -p -p
 psqlscan.c: FLEX_NO_BACKUP=yes
 psqlscan.c: FLEX_FIX_WARNING=yes
 
-distprep: psqlscan.c
-
 # libpgfeutils could be useful to contrib, so install it
 install: all installdirs
 	$(INSTALL_STLIB) libpgfeutils.a '$(DESTDIR)$(libdir)/libpgfeutils.a'
@@ -62,8 +60,4 @@ uninstall:
 
 clean distclean:
 	rm -f libpgfeutils.a $(OBJS) lex.backup
-
-# psqlscan.c is supposed to be in the distribution tarball,
-# so do not clean it in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f psqlscan.c
diff --git a/src/include/Makefile b/src/include/Makefile
index 56576dcf5c..0a8aa62ec5 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -77,5 +77,5 @@ clean:
 	rm -f catalog/pg_*_d.h catalog/header-stamp
 	rm -f nodes/nodetags.h nodes/header-stamp
 
-distclean maintainer-clean: clean
+distclean: clean
 	rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index e4bbf7b8a8..3002bc3c1b 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -23,7 +23,7 @@ install-pgtypeslib-recurse install-ecpglib-recurse install-compatlib-recurse ins
 install-compatlib-recurse: install-ecpglib-recurse
 install-ecpglib-recurse: install-pgtypeslib-recurse
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C test clean
 
 checktcp: | temp-install
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index b9483fba08..695fd1a080 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -55,5 +55,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 652e023405..103cce393a 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -66,5 +66,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/include/Makefile b/src/interfaces/ecpg/include/Makefile
index 9c68bf3c47..3476409cef 100644
--- a/src/interfaces/ecpg/include/Makefile
+++ b/src/interfaces/ecpg/include/Makefile
@@ -31,5 +31,5 @@ uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers))
 	rm -f '$(DESTDIR)$(includedir)'/$(notdir $(ecpg_config_h))
 
-distclean maintainer-clean:
+distclean:
 	rm -f ecpg_config.h stamp-h
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index b0e154eb15..e56700a12e 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -50,5 +50,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 77ae9ab722..afd46cd17c 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -81,8 +81,6 @@ ecpg_keywords.o: ecpg_kwlist_d.h
 c_keywords.o: c_kwlist_d.h
 keywords.o: $(top_srcdir)/src/include/parser/kwlist.h
 
-distprep: preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
-
 install: all installdirs
 	$(INSTALL_PROGRAM) ecpg$(X) '$(DESTDIR)$(bindir)'
 
@@ -92,11 +90,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/ecpg$(X)'
 
-# preproc.y, preproc.c, preproc.h, pgc.c, c_kwlist_d.h, and ecpg_kwlist_d.h
-# are in the distribution tarball, so they are not cleaned here.
 clean distclean:
 	rm -f *.o ecpg$(X)
 	rm -f typename.c
-
-maintainer-clean: distclean
 	rm -f preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index cf841a3a5b..3769488f16 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -20,7 +20,7 @@ else
 abs_builddir := $(shell sh -c "pwd -W")
 endif
 
-all install installdirs uninstall distprep:
+all install installdirs uninstall:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
@@ -29,7 +29,7 @@ all install installdirs uninstall distprep:
 	$(MAKE) -C compat_oracle $@
 	$(MAKE) -C thread $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 0919d8f32f..85dc10d31e 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -168,6 +168,3 @@ clean distclean: clean-lib
 	rm -f $(OBJS) pthread.h libpq-refs-stamp
 # Might be left over from a Win32 client-only build
 	rm -f pg_config_paths.h
-
-maintainer-clean: distclean
-	$(MAKE) -C test $@
diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile
index 75ac08f943..4e17ec1514 100644
--- a/src/interfaces/libpq/test/Makefile
+++ b/src/interfaces/libpq/test/Makefile
@@ -20,5 +20,5 @@ all: $(PROGS)
 
 $(PROGS): $(WIN32RES)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 7ba8d5bc98..0de3737e78 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -391,7 +391,7 @@ ifdef MODULE_big
 clean: clean-lib
 endif
 
-distclean maintainer-clean: clean
+distclean: clean
 
 
 ifdef REGRESS
diff --git a/src/nls-global.mk b/src/nls-global.mk
index f21bd5ed55..dfff472cb3 100644
--- a/src/nls-global.mk
+++ b/src/nls-global.mk
@@ -171,7 +171,7 @@ all: all-po
 install: install-po
 installdirs: installdirs-po
 uninstall: uninstall-po
-clean distclean maintainer-clean: clean-po
+clean distclean: clean-po
 
 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
         init-po update-po
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index 51f8890d15..975f540b3e 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -127,7 +127,7 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index f7eb42d54f..dfb815212f 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile
@@ -104,14 +104,7 @@ submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
 
-distprep: pl_gram.h pl_gram.c plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
-
-# pl_gram.c, pl_gram.h, plerrcodes.h, pl_reserved_kwlist_d.h, and
-# pl_unreserved_kwlist_d.h are in the distribution tarball, so they
-# are not cleaned here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f pl_gram.c pl_gram.h plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index 6b1865c240..ef0a5905ae 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -142,6 +142,7 @@ clean distclean: clean-lib
 ifeq ($(PORTNAME), win32)
 	rm -f python${pytverstr}.def
 endif
+	rm -f spiexceptions.h
 
 
 # Force this dependency to be known even without dependency info built:
@@ -149,8 +150,3 @@ plpy_plpymodule.o: spiexceptions.h
 
 spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
 	$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
-
-distprep: spiexceptions.h
-
-maintainer-clean: distclean
-	rm -f spiexceptions.h
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index 314f9b2eec..ea52a2efc2 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -63,8 +63,6 @@ pltcl.o: pltclerrcodes.h
 pltclerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-pltclerrcodes.pl
 	$(PERL) $(srcdir)/generate-pltclerrcodes.pl $< > $@
 
-distprep: pltclerrcodes.h
-
 install: all install-lib install-data
 
 installdirs: installdirs-lib
@@ -91,13 +89,10 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-# pltclerrcodes.h is in the distribution tarball, so don't clean it here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
 	rm -f $(tclwithver).def
 endif
-
-maintainer-clean: distclean
 	rm -f pltclerrcodes.h
diff --git a/src/port/Makefile b/src/port/Makefile
index 711f59e32b..8d7bbe8180 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -158,6 +158,6 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
 	echo "#define HTMLDIR \"$(htmldir)\"" >>$@
 	echo "#define MANDIR \"$(mandir)\"" >>$@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f libpgport.a libpgport_shlib.a libpgport_srv.a
 	rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h
diff --git a/src/test/authentication/Makefile b/src/test/authentication/Makefile
index 46fa72052d..a48ce39aaf 100644
--- a/src/test/authentication/Makefile
+++ b/src/test/authentication/Makefile
@@ -19,5 +19,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/examples/Makefile b/src/test/examples/Makefile
index a67f456904..e72d058e0c 100644
--- a/src/test/examples/Makefile
+++ b/src/test/examples/Makefile
@@ -18,5 +18,5 @@ PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo testlo64
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/test/icu/Makefile b/src/test/icu/Makefile
index 033b0d03cc..c4fc8cdb8c 100644
--- a/src/test/icu/Makefile
+++ b/src/test/icu/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index b8738b7c1b..8f5192fb37 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -43,8 +43,6 @@ pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
 isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
 	$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
-distprep: specparse.c specscanner.c
-
 # See notes in src/backend/parser/Makefile about the following two rules
 specparse.h: specparse.c
 	touch $@
@@ -60,8 +58,6 @@ clean distclean:
 	rm -f isolationtester$(X) pg_isolation_regress$(X) $(OBJS) isolation_main.o
 	rm -f pg_regress.o
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f specparse.h specparse.c specscanner.c
 
 installcheck: all
diff --git a/src/test/kerberos/Makefile b/src/test/kerberos/Makefile
index f460d2c0e7..44da65611e 100644
--- a/src/test/kerberos/Makefile
+++ b/src/test/kerberos/Makefile
@@ -24,5 +24,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/ldap/Makefile b/src/test/ldap/Makefile
index 73bc878ea8..d4305ed5eb 100644
--- a/src/test/ldap/Makefile
+++ b/src/test/ldap/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/locale/Makefile b/src/test/locale/Makefile
index 7ba096b542..a40c67af07 100644
--- a/src/test/locale/Makefile
+++ b/src/test/locale/Makefile
@@ -10,7 +10,7 @@ DIRS = de_DE.ISO8859-1 gr_GR.ISO8859-7 koi8-r koi8-to-win1251
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
 	rm -rf tmp_check
 	for d in $(DIRS); do \
diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile
index c60314d195..49f1d1c118 100644
--- a/src/test/recovery/Makefile
+++ b/src/test/recovery/Makefile
@@ -25,5 +25,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 38c3a1f85b..388f2700bd 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -146,7 +146,7 @@ bigcheck: all | temp-install
 ## Clean up
 ##
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 # things built by `all' target
 	rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
 	rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
diff --git a/src/test/ssl/Makefile b/src/test/ssl/Makefile
index af1e06e949..2d7c69068f 100644
--- a/src/test/ssl/Makefile
+++ b/src/test/ssl/Makefile
@@ -23,7 +23,7 @@ export OPENSSL with_ssl
 sslfiles sslfiles-clean:
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
diff --git a/src/test/ssl/sslfiles.mk b/src/test/ssl/sslfiles.mk
index f7ababe42c..62b2272183 100644
--- a/src/test/ssl/sslfiles.mk
+++ b/src/test/ssl/sslfiles.mk
@@ -269,6 +269,6 @@ sslfiles-clean:
 # clean targets will be run during a "standard" recursive clean run from the
 # main build tree. The sslfiles-clean target must be run explicitly from this
 # directory.
-.PHONY: clean distclean maintainer-clean
-clean distclean maintainer-clean:
+.PHONY: clean distclean
+clean distclean:
 	rm -rf ssl/*.old ssl/new_certs_dir ssl/client*_tmp.key
diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile
index 99d1fe012d..36475ffabc 100644
--- a/src/test/subscription/Makefile
+++ b/src/test/subscription/Makefile
@@ -23,5 +23,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/timezone/Makefile b/src/timezone/Makefile
index fbbaae4cc5..c85e831247 100644
--- a/src/timezone/Makefile
+++ b/src/timezone/Makefile
@@ -75,5 +75,5 @@ ifeq (,$(with_system_tzdata))
 endif
 	$(MAKE) -C tznames $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f zic$(X) $(ZICOBJS) abbrevs.txt
diff --git a/src/tools/ifaddrs/Makefile b/src/tools/ifaddrs/Makefile
index e74d754769..ef5e8f0e0e 100644
--- a/src/tools/ifaddrs/Makefile
+++ b/src/tools/ifaddrs/Makefile
@@ -24,5 +24,5 @@ all: test_ifaddrs
 test_ifaddrs: test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o
 	$(CC) $(CFLAGS) test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f test_ifaddrs$(X) $(OBJS)
diff --git a/src/tools/pg_bsd_indent/Makefile b/src/tools/pg_bsd_indent/Makefile
index d176ceb326..ce5d815f07 100644
--- a/src/tools/pg_bsd_indent/Makefile
+++ b/src/tools/pg_bsd_indent/Makefile
@@ -39,7 +39,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_bsd_indent$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_bsd_indent$(X) $(OBJS)
 	rm -rf log/ tmp_check/
 
diff --git a/src/tools/pginclude/cpluspluscheck b/src/tools/pginclude/cpluspluscheck
index 4e09c4686b..287395887c 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -134,6 +134,9 @@ do
 	test "$f" = src/interfaces/ecpg/preproc/preproc.h && continue
 	test "$f" = src/test/isolation/specparse.h && continue
 
+	# FIXME
+	test "$f" = src/backend/utils/adt/jsonpath_internal.h && continue
+
 	# ppport.h is not under our control, so we can't make it standalone.
 	test "$f" = src/pl/plperl/ppport.h && continue
 
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 8dee1b5670..d2ddfac476 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -129,6 +129,9 @@ do
 	test "$f" = src/interfaces/ecpg/preproc/preproc.h && continue
 	test "$f" = src/test/isolation/specparse.h && continue
 
+	# FIXME
+	test "$f" = src/backend/utils/adt/jsonpath_internal.h && continue
+
 	# This produces a "no previous prototype" warning.
 	test "$f" = src/include/storage/checksum_impl.h && continue
 

base-commit: 9aee26a491ba9b7ceff40e6192183ab7200b6bfb
-- 
2.40.1

#2Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#1)
Re: Remove distprep

Hi,

On 2023-06-09 11:10:14 +0200, Peter Eisentraut wrote:

Per discussion at the unconference[0], I started to write a patch that
removes the make distprep target. A more detailed explanation of the
rationale is also in the patch.

Thanks for tackling this!

It needs some polishing around the edges, but I wanted to put it out here to
get things moving and avoid duplicate work.

It'd be nice if we could get this in soon, so we could move ahead with the
src/tools/msvc removal.

One thing in particular that isn't clear right now is how "make world"
should behave if the documentation tools are not found. Maybe we should
make a build option, like "--with-docs", to mirror the meson behavior.

Isn't that somewhat unrelated to distprep? I see that you removed missing,
but I don't really understand why as part of this commit?

-# If there are any files in the source directory that we also generate in the
-# build directory, they might get preferred over the newly generated files,
-# e.g. because of a #include "file", which always will search in the current
-# directory first.
-message('checking for file conflicts between source and build directory')

You're thinking this can be removed because distclean is now reliable? There
were some pretty annoying to debug issues early on, where people switched from
an in-tree autoconf build to meson, with some files left over from the source
build, causing problems at a *later* time (when the files should have changed,
but the wrong ones were picked up). That's not really related distprep etc,
so I'd change this separately, if we want to change it.

diff --git a/src/tools/pginclude/cpluspluscheck b/src/tools/pginclude/cpluspluscheck
index 4e09c4686b..287395887c 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -134,6 +134,9 @@ do
test "$f" = src/interfaces/ecpg/preproc/preproc.h && continue
test "$f" = src/test/isolation/specparse.h && continue
+	# FIXME
+	test "$f" = src/backend/utils/adt/jsonpath_internal.h && continue
+
# ppport.h is not under our control, so we can't make it standalone.
test "$f" = src/pl/plperl/ppport.h && continue

Hm, what's that about?

We really ought to replace these scripts with something better, which
understands concurrency...

Greetings,

Andres Freund

#3Peter Eisentraut
peter@eisentraut.org
In reply to: Andres Freund (#2)
1 attachment(s)
Re: Remove distprep

On 13.07.23 01:19, Andres Freund wrote:

One thing in particular that isn't clear right now is how "make world"
should behave if the documentation tools are not found. Maybe we should
make a build option, like "--with-docs", to mirror the meson behavior.

Isn't that somewhat unrelated to distprep? I see that you removed missing,
but I don't really understand why as part of this commit?

Ok, I put the docs stuff back the way it was and put "missing" back in.

-# If there are any files in the source directory that we also generate in the
-# build directory, they might get preferred over the newly generated files,
-# e.g. because of a #include "file", which always will search in the current
-# directory first.
-message('checking for file conflicts between source and build directory')

You're thinking this can be removed because distclean is now reliable? There
were some pretty annoying to debug issues early on, where people switched from
an in-tree autoconf build to meson, with some files left over from the source
build, causing problems at a *later* time (when the files should have changed,
but the wrong ones were picked up). That's not really related distprep etc,
so I'd change this separately, if we want to change it.

Ok, I kept it in.

diff --git a/src/tools/pginclude/cpluspluscheck b/src/tools/pginclude/cpluspluscheck
index 4e09c4686b..287395887c 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -134,6 +134,9 @@ do
test "$f" = src/interfaces/ecpg/preproc/preproc.h && continue
test "$f" = src/test/isolation/specparse.h && continue
+	# FIXME
+	test "$f" = src/backend/utils/adt/jsonpath_internal.h && continue
+
# ppport.h is not under our control, so we can't make it standalone.
test "$f" = src/pl/plperl/ppport.h && continue

Hm, what's that about?

Don't remember ... ;-) I removed this.

Attached is a new version with the above changes, also updated for the
recently added generate-wait_event_types.pl, and I have adjusted all the
header file linking to use relative paths consistently. This addresses
all issues known to me.

Attachments:

v2-0001-Remove-distprep.patchtext/plain; charset=UTF-8; name=v2-0001-Remove-distprep.patchDownload
From 260d055b0428130d9db96bed2298495ce7e93505 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 14 Jul 2023 09:33:09 +0200
Subject: [PATCH v2] Remove distprep

A PostgreSQL release tarball contains a number of prebuilt files, in
particular files produced by bison, flex, perl, and well as html and
man documentation.  We have done this consistent with established
practice at the time to not require these tools for building from a
tarball.  Some of these tools were hard to get, or get the right
version of, from time to time, and shipping the prebuilt output was a
convenience to users.

Now this has at least two problems:

One, we have to make the build system(s) work in two modes: Building
from a git checkout and building from a tarball.  This is pretty
complicated, but it works so far for autoconf/make.  It does not
currently work for meson; you can currently only build with meson from
a git checkout.  Making meson builds work from a tarball seems very
difficult or impossible.  One particular problem is that since meson
requires a separate build directory, we cannot make the build update
files like gram.h in the source tree.  So if you were to build from a
tarball and update gram.y, you will have a gram.h in the source tree
and one in the build tree, but the way things work is that the
compiler will always use the one in the source tree.  So you cannot,
for example, make any gram.y changes when building from a tarball.
This seems impossible to fix in a non-horrible way.

Second, there is increased interest nowadays in precisely tracking the
origin of software.  We can reasonably track contributions into the
git tree, and users can reasonably track the path from a tarball to
packages and downloads and installs.  But what happens between the git
tree and the tarball is obscure and in some cases non-reproducible.

The solution for both of these issues is to get rid of the step that
adds prebuilt files to the tarball.  The tarball now only contains
what is in the git tree (*).  Getting the additional build
dependencies is no longer a problem nowadays, and the complications to
keep these dual build modes working are significant.  And of course we
want to get the meson build system working universally.

This commit removes the make distprep target altogether.  The make
dist target continues to do its job, it just doesn't call distprep
anymore.

(*) - The tarball also contains the INSTALL file that is built at make
dist time, but not by distprep.  This is unchanged for now.

The make maintainer-clean target, whose job it is to remove the
prebuilt files in addition to what make distclean does, is now just an
alias to make distprep.  (In practice, it is probably obsolete given
that git clean is available.)

The following programs are now hard build requirements in configure
(they were already required by meson.build):

- bison
- flex
- perl
---
 GNUmakefile.in                                |  6 +-
 config/perl.m4                                |  9 +-
 config/programs.m4                            | 21 +----
 configure                                     | 62 ++------------
 contrib/cube/Makefile                         |  7 +-
 contrib/fuzzystrmatch/Makefile                |  9 +-
 contrib/seg/Makefile                          |  7 +-
 doc/Makefile                                  |  2 +-
 doc/src/Makefile                              |  2 +-
 doc/src/sgml/Makefile                         |  9 +-
 doc/src/sgml/installation.sgml                | 83 ++++++++-----------
 meson.build                                   |  2 +-
 src/Makefile                                  |  5 +-
 src/Makefile.global.in                        | 30 +++----
 src/backend/Makefile                          | 65 ++-------------
 src/backend/bootstrap/Makefile                |  6 +-
 src/backend/catalog/Makefile                  | 14 +---
 src/backend/jit/llvm/Makefile                 |  2 +-
 src/backend/nls.mk                            |  2 +-
 src/backend/nodes/Makefile                    | 12 +--
 src/backend/parser/Makefile                   |  8 +-
 src/backend/port/Makefile                     |  2 +-
 src/backend/replication/Makefile              | 10 ++-
 .../replication/libpqwalreceiver/Makefile     |  2 +-
 src/backend/replication/pgoutput/Makefile     |  2 +-
 src/backend/snowball/Makefile                 |  4 -
 src/backend/storage/lmgr/Makefile             |  4 +-
 src/backend/utils/Makefile                    | 25 ++----
 src/backend/utils/activity/Makefile           |  2 +-
 src/backend/utils/adt/Makefile                |  5 +-
 src/backend/utils/mb/Makefile                 |  2 +-
 src/backend/utils/mb/Unicode/Makefile         |  2 -
 src/backend/utils/mb/conversion_procs/proc.mk |  2 +-
 src/backend/utils/misc/Makefile               |  3 +-
 src/bin/initdb/Makefile                       |  2 +-
 src/bin/pg_amcheck/Makefile                   |  2 +-
 src/bin/pg_archivecleanup/Makefile            |  2 +-
 src/bin/pg_basebackup/Makefile                |  2 +-
 src/bin/pg_checksums/Makefile                 |  2 +-
 src/bin/pg_config/Makefile                    |  2 +-
 src/bin/pg_controldata/Makefile               |  2 +-
 src/bin/pg_ctl/Makefile                       |  2 +-
 src/bin/pg_dump/Makefile                      |  2 +-
 src/bin/pg_resetwal/Makefile                  |  2 +-
 src/bin/pg_rewind/Makefile                    |  2 +-
 src/bin/pg_test_fsync/Makefile                |  2 +-
 src/bin/pg_test_timing/Makefile               |  2 +-
 src/bin/pg_upgrade/Makefile                   |  2 +-
 src/bin/pg_verifybackup/Makefile              |  2 +-
 src/bin/pg_waldump/Makefile                   |  2 +-
 src/bin/pgbench/Makefile                      |  4 -
 src/bin/psql/Makefile                         |  6 --
 src/bin/scripts/Makefile                      |  2 +-
 src/common/Makefile                           |  5 --
 src/common/unicode/Makefile                   |  2 -
 src/fe_utils/Makefile                         |  6 --
 src/include/Makefile                          |  2 +-
 src/interfaces/ecpg/Makefile                  |  2 +-
 src/interfaces/ecpg/compatlib/Makefile        |  2 -
 src/interfaces/ecpg/ecpglib/Makefile          |  2 -
 src/interfaces/ecpg/include/Makefile          |  2 +-
 src/interfaces/ecpg/pgtypeslib/Makefile       |  2 -
 src/interfaces/ecpg/preproc/Makefile          |  6 --
 src/interfaces/ecpg/test/Makefile             |  4 +-
 src/interfaces/libpq/Makefile                 |  3 -
 src/interfaces/libpq/test/Makefile            |  2 +-
 src/makefiles/pgxs.mk                         |  2 +-
 src/nls-global.mk                             |  2 +-
 src/pl/plperl/GNUmakefile                     |  2 +-
 src/pl/plpgsql/src/Makefile                   |  7 --
 src/pl/plpython/Makefile                      |  6 +-
 src/pl/tcl/Makefile                           |  5 --
 src/port/Makefile                             |  2 +-
 src/test/authentication/Makefile              |  2 +-
 src/test/examples/Makefile                    |  2 +-
 src/test/icu/Makefile                         |  2 +-
 src/test/isolation/Makefile                   |  4 -
 src/test/kerberos/Makefile                    |  2 +-
 src/test/ldap/Makefile                        |  2 +-
 src/test/locale/Makefile                      |  2 +-
 src/test/recovery/Makefile                    |  2 +-
 src/test/regress/GNUmakefile                  |  2 +-
 src/test/ssl/Makefile                         |  2 +-
 src/test/ssl/sslfiles.mk                      |  4 +-
 src/test/subscription/Makefile                |  2 +-
 src/timezone/Makefile                         |  2 +-
 src/tools/ifaddrs/Makefile                    |  2 +-
 src/tools/pg_bsd_indent/Makefile              |  2 +-
 88 files changed, 165 insertions(+), 407 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index 9c18c56233..80db4c73f8 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -41,7 +41,7 @@ install-world-bin-contrib-recurse: install-world-bin-src-recurse
 
 $(call recurse,installdirs uninstall init-po update-po,doc src config)
 
-$(call recurse,distprep coverage,doc src config contrib)
+$(call recurse,coverage,doc src config contrib)
 
 # clean, distclean, etc should apply to contrib too, even though
 # it's not built by default
@@ -53,7 +53,7 @@ clean:
 
 # Important: distclean `src' last, otherwise Makefile.global
 # will be gone too soon.
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C doc $@
 	$(MAKE) -C contrib $@
 	$(MAKE) -C config $@
@@ -109,7 +109,6 @@ distdir:
 	      || cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
 	  fi || exit; \
 	done
-	$(MAKE) -C $(distdir) distprep
 	$(MAKE) -C $(distdir)/doc/src/sgml/ INSTALL
 	cp $(distdir)/doc/src/sgml/INSTALL $(distdir)/
 	$(MAKE) -C $(distdir) distclean
@@ -122,7 +121,6 @@ distcheck: dist
 	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
diff --git a/config/perl.m4 b/config/perl.m4
index 8126e79f67..1a3bb55649 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -13,19 +13,14 @@ if test "$PERL"; then
   if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
     $AWK '{ if ([$]1 == 5 && ([$]2 >= 14)) exit 1; else exit 0;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
 *** Perl version 5.14 or later is required, but this is $pgac_perl_version.])
-    PERL=""
   fi
 fi
 
 if test -z "$PERL"; then
-  AC_MSG_WARN([
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)])
+  AC_MSG_ERROR([Perl not found])
 fi
 ])# PGAC_PATH_PERL
 
diff --git a/config/programs.m4 b/config/programs.m4
index 8a118b4e03..490ec9fe9f 100644
--- a/config/programs.m4
+++ b/config/programs.m4
@@ -33,10 +33,9 @@ if test "$BISON"; then
   AC_MSG_NOTICE([using $pgac_bison_version])
   if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 2.3) exit 0; else exit 1;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
 *** Bison version 2.3 or later is required, but this is $pgac_bison_version.])
-    BISON=""
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -49,12 +48,7 @@ if test "$BISON"; then
 fi
 
 if test -z "$BISON"; then
-  AC_MSG_WARN([
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)])
+  AC_MSG_ERROR([bison not found])
 fi
 dnl We don't need AC_SUBST(BISON) because PGAC_PATH_PROGS did it
 AC_SUBST(BISONFLAGS)
@@ -95,7 +89,7 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            AC_MSG_WARN([
+            AC_MSG_ERROR([
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
 *** Flex version 2.5.35 or later is required, but this is $pgac_flex_version.])
           fi
@@ -109,14 +103,7 @@ fi
 ])[]dnl AC_CACHE_CHECK
 
 if test x"$pgac_cv_path_flex" = x"no"; then
-  AC_MSG_WARN([
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)])
-
-  FLEX=
+  AC_MSG_ERROR([flex not found])
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
diff --git a/configure b/configure
index 2e518c8007..802fc9edc4 100755
--- a/configure
+++ b/configure
@@ -10160,13 +10160,9 @@ if test "$BISON"; then
 $as_echo "$as_me: using $pgac_bison_version" >&6;}
   if echo "$pgac_bison_version" | $AWK '{ if ($4 < 2.3) exit 0; else exit 1;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&2;}
-    BISON=""
+*** Bison version 2.3 or later is required, but this is $pgac_bison_version." "$LINENO" 5
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -10179,18 +10175,7 @@ $as_echo "$as_me: WARNING:
 fi
 
 if test -z "$BISON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&2;}
+  as_fn_error $? "bison not found" "$LINENO" 5
 fi
 
 
@@ -10223,12 +10208,9 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&5
-$as_echo "$as_me: WARNING:
+            as_fn_error $? "
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&2;}
+*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." "$LINENO" 5
           fi
         fi
       fi
@@ -10242,20 +10224,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_path_flex" >&5
 $as_echo "$pgac_cv_path_flex" >&6; }
 if test x"$pgac_cv_path_flex" = x"no"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&2;}
-
-  FLEX=
+  as_fn_error $? "flex not found" "$LINENO" 5
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
@@ -10329,27 +10298,14 @@ $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
   if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
     $AWK '{ if ($1 == 5 && ($2 >= 14)) exit 1; else exit 0;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&2;}
-    PERL=""
+*** Perl version 5.14 or later is required, but this is $pgac_perl_version." "$LINENO" 5
   fi
 fi
 
 if test -z "$PERL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&2;}
+  as_fn_error $? "Perl not found" "$LINENO" 5
 fi
 
 if test "$with_perl" = yes; then
diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 4fd19aac35..dfb0d806e4 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -18,6 +18,8 @@ REGRESS = cube cube_sci
 
 SHLIB_LINK += $(filter -lm, $(LIBS))
 
+EXTRA_CLEAN = cubeparse.h cubeparse.c cubescan.c
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -37,8 +39,3 @@ cubeparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 cubeparse.o cubescan.o: cubeparse.h
-
-distprep: cubeparse.c cubescan.c
-
-maintainer-clean:
-	rm -f cubeparse.h cubeparse.c cubescan.c
diff --git a/contrib/fuzzystrmatch/Makefile b/contrib/fuzzystrmatch/Makefile
index e68bc0e33f..04c83a34a7 100644
--- a/contrib/fuzzystrmatch/Makefile
+++ b/contrib/fuzzystrmatch/Makefile
@@ -15,6 +15,8 @@ PGFILEDESC = "fuzzystrmatch - similarities and distance between strings"
 
 REGRESS = fuzzystrmatch fuzzystrmatch_utf8
 
+EXTRA_CLEAN = daitch_mokotoff.h
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -31,10 +33,3 @@ daitch_mokotoff.o: daitch_mokotoff.h
 
 daitch_mokotoff.h: daitch_mokotoff_header.pl
 	$(PERL) $< $@
-
-# daitch_mokotoff.h is included in tarballs, so it has to be made by
-# "distprep" and not cleaned except by "maintainer-clean".
-distprep: daitch_mokotoff.h
-
-maintainer-clean:
-	rm -f daitch_mokotoff.h
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index a1e49bf051..132ec8dbfe 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -16,7 +16,7 @@ HEADERS = segdata.h
 
 REGRESS = security seg
 
-EXTRA_CLEAN = y.tab.c y.tab.h
+EXTRA_CLEAN = segparse.h segparse.c segscan.c
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
@@ -38,8 +38,3 @@ segparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 segparse.o segscan.o: segparse.h
-
-distprep: segparse.c segscan.c
-
-maintainer-clean:
-	rm -f segparse.h segparse.c segscan.c
diff --git a/doc/Makefile b/doc/Makefile
index aee3cc0965..24370fc903 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -12,5 +12,5 @@ subdir = doc
 top_builddir = ..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C src $@
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 30d883815a..2ed02084ff 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -4,5 +4,5 @@ subdir = doc/src
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C sgml $@
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 1e55e531db..82d57674a2 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -7,8 +7,7 @@
 #----------------------------------------------------------------------------
 
 # This makefile is for building and installing the documentation.
-# When a release tarball is created, the documentation files are
-# prepared using the distprep target.  In Git-based trees these files
+# In Git-based trees these files
 # don't exist, unless explicitly built, so we skip the installation in
 # that case.
 
@@ -28,8 +27,6 @@ include $(top_builddir)/src/Makefile.global
 
 all: html man
 
-distprep: html distprep-man
-
 
 ifndef DBTOEPUB
 DBTOEPUB = $(missing) dbtoepub
@@ -77,7 +74,7 @@ postgres-full.xml: postgres.sgml $(ALLSGML)
 ## Man pages
 ##
 
-man distprep-man: man-stamp
+man: man-stamp
 
 man-stamp: stylesheet-man.xsl postgres-full.xml
 	$(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_MAN_FLAGS) $^
@@ -305,8 +302,6 @@ clean:
 	rm -f *.texixml *.texi *.info db2texi.refs
 
 distclean: clean
-
-maintainer-clean: distclean
 # HTML
 	rm -fr html/ html-stamp
 # man
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index ac8eee47c6..8eb928903e 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -72,8 +72,7 @@ <title>Requirements</title>
 
       Alternatively, <productname>PostgreSQL</productname> can be built using
       <ulink url="https://mesonbuild.com/">Meson</ulink>.  This is currently
-      experimental and only works when building from a Git checkout (not from
-      a distribution tarball).  If you choose to use
+      experimental.  If you choose to use
       <application>Meson</application>, then you don't need
       <acronym>GNU</acronym> <application>make</application>, but the other
       requirements below still apply.
@@ -102,6 +101,41 @@ <title>Requirements</title>
      </para>
     </listitem>
 
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>flex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>lex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>bison</primary>
+      </indexterm>
+      <indexterm>
+       <primary>yacc</primary>
+      </indexterm>
+
+      <application>Flex</application> 2.5.35 or later and
+      <application>Bison</application> 2.3 or later are required.  Other
+      <application>lex</application> and <application>yacc</application>
+      programs cannot be used.
+     </para>
+    </listitem>
+
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>perl</primary>
+      </indexterm>
+
+      <application>Perl</application> 5.14 or later is needed during the build
+      process and to run some test suites.  (This requirement is separate from
+      the requirements for building <application>PL/Perl</application>; see
+      below.)
+     </para>
+    </listitem>
+
     <listitem>
      <para>
       <indexterm>
@@ -315,51 +349,6 @@ <title>Requirements</title>
    </itemizedlist>
   </para>
 
-  <para>
-   If you are building from a <productname>Git</productname> tree instead of
-   using a released source package, or if you want to do server development,
-   you also need the following packages:
-
-   <itemizedlist>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>flex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>lex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>bison</primary>
-      </indexterm>
-      <indexterm>
-       <primary>yacc</primary>
-      </indexterm>
-
-      <application>Flex</application> and <application>Bison</application>
-      are needed to build from a Git checkout, or if you changed the actual
-      scanner and parser definition files. If you need them, be sure
-      to get <application>Flex</application> 2.5.35 or later and
-      <application>Bison</application> 2.3 or later. Other <application>lex</application>
-      and <application>yacc</application> programs cannot be used.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>perl</primary>
-      </indexterm>
-
-      <application>Perl</application> 5.14 or later is needed to build from a Git checkout,
-      or if you changed the input files for any of the build steps that
-      use Perl scripts.  If building on Windows you will need
-      <application>Perl</application> in any case.  <application>Perl</application> is
-      also required to run some test suites.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
-
   <para>
    If you need to get a <acronym>GNU</acronym> package, you can find
    it at your local <acronym>GNU</acronym> mirror site (see <ulink
diff --git a/meson.build b/meson.build
index 04ea348852..0f426d68d6 100644
--- a/meson.build
+++ b/meson.build
@@ -72,7 +72,7 @@ configure. Alternatively use a separate check out for meson based builds.
 @0@
 ****'''
 if fs.exists(meson.current_source_dir() / 'src' / 'include' / 'pg_config.h')
-  errmsg_cleanup = 'To clean up, run make maintainer-clean in the source tree.'
+  errmsg_cleanup = 'To clean up, run make distclean in the source tree.'
   error(errmsg_nonclean_base.format(errmsg_cleanup))
 endif
 
diff --git a/src/Makefile b/src/Makefile
index 94649c36c7..2f31a2f20a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -59,16 +59,13 @@ uninstall: uninstall-local
 uninstall-local:
 	rm -f $(addprefix '$(DESTDIR)$(pgxsdir)/$(subdir)'/, Makefile.global Makefile.port Makefile.shlib nls-global.mk)
 
-distprep:
-	$(MAKE) -C test/isolation $@
-
 clean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
 	$(MAKE) -C tools/pg_bsd_indent $@
 
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index df9f721a41..2159692439 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -19,11 +19,11 @@
 #
 # Meta configuration
 
-standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check checkprep installcheck init-po update-po
+standard_targets = all install installdirs uninstall clean distclean coverage check checkprep installcheck init-po update-po
 # these targets should recurse even into subdirectories not being built:
-standard_always_targets = distprep clean distclean maintainer-clean
+standard_always_targets = clean distclean
 
-.PHONY: $(standard_targets) install-strip html man installcheck-parallel update-unicode
+.PHONY: $(standard_targets) maintainer-clean install-strip html man installcheck-parallel update-unicode
 
 # make `all' the default target
 all:
@@ -35,6 +35,8 @@ all:
 # Never delete any intermediate files automatically.
 .SECONDARY:
 
+maintainer-clean: distclean
+
 # PostgreSQL version number
 VERSION = @PACKAGE_VERSION@
 MAJORVERSION = @PG_MAJORVERSION@
@@ -319,12 +321,8 @@ X = @EXEEXT@
 
 # Perl
 
-ifneq (@PERL@,)
-    # quoted to protect pathname with spaces
-    PERL		= '@PERL@'
-else
-    PERL		= $(missing) perl
-endif
+# quoted to protect pathname with spaces
+PERL		= '@PERL@'
 perl_archlibexp		= @perl_archlibexp@
 perl_privlibexp		= @perl_privlibexp@
 perl_includespec	= @perl_includespec@
@@ -765,21 +763,13 @@ TAS         = @TAS@
 # Global targets and rules
 
 %.c: %.l
-ifdef FLEX
 	$(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
 	@$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
 	$(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
-else
-	@$(missing) flex $< '$@'
-endif
 
 %.c: %.y
 	$(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
-ifdef BISON
 	$(BISON) $(BISONFLAGS) -o $@ $<
-else
-	@$(missing) bison $< $@
-endif
 
 %.i: %.c
 	$(CPP) $(CPPFLAGS) -o $@ $<
@@ -907,7 +897,7 @@ recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if
 # If a makefile's list of SUBDIRS varies depending on configuration, then
 # any subdirectories excluded from SUBDIRS should instead be added to
 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
-# This ensures that distprep, distclean, etc will apply to all subdirectories.
+# This ensures that distclean, etc will apply to all subdirectories.
 # In the normal case all arguments will be defaulted.
 # $1: targets to make recursive (defaults to standard_always_targets)
 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
@@ -962,7 +952,7 @@ include $(Po_files)
 endif
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-deps
+clean distclean: clean-deps
 
 .PHONY: clean-deps
 clean-deps:
@@ -1046,7 +1036,7 @@ lcov_test.info: $(all_gcda_files)
 
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-coverage
+clean distclean: clean-coverage
 
 .PHONY: clean-coverage
 clean-coverage:
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 1c929383c4..023e14c15c 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -138,63 +138,38 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-catalog-headers:
-	$(MAKE) -C catalog distprep generated-header-symlinks
+	$(MAKE) -C catalog generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-nodes-headers:
-	$(MAKE) -C nodes distprep generated-header-symlinks
+	$(MAKE) -C nodes generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-utils-headers:
-	$(MAKE) -C utils distprep generated-header-symlinks
+	$(MAKE) -C utils generated-header-symlinks
 
 .PHONY: submake-catalog-headers submake-nodes-headers submake-utils-headers
 
 # Make symlinks for these headers in the include directory. That way
 # we can cut down on the -I options. Also, a symlink is automatically
 # up to date when we update the base file.
-#
-# The point of the prereqdir incantation in some of the rules below is to
-# force the symlink to use an absolute path rather than a relative path.
-# For headers which are generated by make distprep, the actual header within
-# src/backend will be in the source tree, while the symlink in src/include
-# will be in the build tree, so a simple ../.. reference won't work.
-# For headers generated during regular builds, we prefer a relative symlink.
 
 .PHONY: generated-headers
 
 generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers
 
 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 $(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 utils/probes.o: utils/probes.d $(SUBDIROBJS)
 	$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
 
 
-##########################################################################
-
-# Be sure that these files get removed by the maintainer-clean target
-distprep:
-	$(MAKE) -C parser	gram.c gram.h scan.c
-	$(MAKE) -C bootstrap	bootparse.c bootparse.h bootscanner.c
-	$(MAKE) -C catalog	distprep
-	$(MAKE) -C nodes	distprep
-	$(MAKE) -C replication	repl_gram.c repl_gram.h repl_scanner.c syncrep_gram.c syncrep_gram.h syncrep_scanner.c
-	$(MAKE) -C storage/lmgr	lwlocknames.h lwlocknames.c
-	$(MAKE) -C utils	distprep
-	$(MAKE) -C utils/activity	wait_event_types.h pgstat_wait_event.c
-	$(MAKE) -C utils/adt	jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
-	$(MAKE) -C utils/misc	guc-file.c
-
-
 ##########################################################################
 
 install: all installdirs install-bin
@@ -290,33 +265,9 @@ ifeq ($(PORTNAME), win32)
 endif
 
 distclean: clean
+# generated by configure
 	rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
 
-maintainer-clean: distclean
-	$(MAKE) -C catalog $@
-	$(MAKE) -C nodes $@
-	$(MAKE) -C utils $@
-	rm -f bootstrap/bootparse.c \
-	      bootstrap/bootparse.h \
-	      bootstrap/bootscanner.c \
-	      parser/gram.c \
-	      parser/gram.h \
-	      parser/scan.c \
-	      replication/repl_gram.c \
-	      replication/repl_gram.h \
-	      replication/repl_scanner.c \
-	      replication/syncrep_gram.c \
-	      replication/syncrep_gram.h \
-	      replication/syncrep_scanner.c \
-	      storage/lmgr/lwlocknames.c \
-	      storage/lmgr/lwlocknames.h \
-	      utils/activity/pgstat_wait_event.c \
-	      utils/activity/wait_event_types.h \
-	      utils/adt/jsonpath_gram.c \
-	      utils/adt/jsonpath_gram.h \
-	      utils/adt/jsonpath_scan.c \
-	      utils/misc/guc-file.c
-
 
 ##########################################################################
 #
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile
index 606c8021e7..43dd2bc9aa 100644
--- a/src/backend/bootstrap/Makefile
+++ b/src/backend/bootstrap/Makefile
@@ -28,5 +28,7 @@ bootparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 bootparse.o bootscanner.o: bootparse.h
 
-# bootparse.c and bootscanner.c are in the distribution tarball, so
-# they are not cleaned here.
+clean:
+	rm -f bootstrap/bootparse.c \
+	      bootstrap/bootparse.h \
+	      bootstrap/bootscanner.c
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index a60107bf94..b49666dae2 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -89,9 +89,7 @@ POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
 	pg_ts_template.dat pg_type.dat \
 	)
 
-all: distprep generated-header-symlinks
-
-distprep: bki-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -110,14 +108,12 @@ bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_
 		--set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
 	touch $@
 
-# The generated headers must all be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# The generated headers must all be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than bki-stamp.
 $(top_builddir)/src/include/catalog/header-stamp: bki-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -138,9 +134,5 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
 
-# postgres.bki, system_constraints.sql, and the generated headers are
-# in the distribution tarball, so they are not cleaned here.
 clean:
-
-maintainer-clean: clean
 	rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
index 2da122a391..0036c4f552 100644
--- a/src/backend/jit/llvm/Makefile
+++ b/src/backend/jit/llvm/Makefile
@@ -71,6 +71,6 @@ uninstall-types:
 
 include $(top_srcdir)/src/Makefile.shlib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -f llvmjit_types.bc
diff --git a/src/backend/nls.mk b/src/backend/nls.mk
index 8263527c85..f1464cc5c5 100644
--- a/src/backend/nls.mk
+++ b/src/backend/nls.mk
@@ -22,7 +22,7 @@ GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS) \
     report_invalid_record:2:c-format \
     ereport_startup_progress:1:c-format
 
-gettext-files: distprep
+gettext-files: postgres
 	find $(srcdir) $(srcdir)/../common $(srcdir)/../port -name '*.c' -print | LC_ALL=C sort >$@
 
 my-clean:
diff --git a/src/backend/nodes/Makefile b/src/backend/nodes/Makefile
index 0a95e683d0..ebbe9052cb 100644
--- a/src/backend/nodes/Makefile
+++ b/src/backend/nodes/Makefile
@@ -65,9 +65,7 @@ node_headers = \
 
 # see also catalog/Makefile for an explanation of these make rules
 
-all: distprep generated-header-symlinks
-
-distprep: node-support-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -81,14 +79,12 @@ node-support-stamp: gen_node_support.pl $(addprefix $(top_srcdir)/src/include/,$
 	$(PERL) $^
 	touch $@
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than node-support-stamp.
 $(top_builddir)/src/include/nodes/header-stamp: node-support-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in nodetags.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -98,5 +94,5 @@ outfuncs.o: outfuncs.c outfuncs.funcs.c outfuncs.switch.c | node-support-stamp
 queryjumblefuncs.o: queryjumblefuncs.c queryjumblefuncs.funcs.c queryjumblefuncs.switch.c | node-support-stamp
 readfuncs.o:  readfuncs.c readfuncs.funcs.c readfuncs.switch.c | node-support-stamp
 
-maintainer-clean: clean
+clean:
 	rm -f node-support-stamp $(addsuffix funcs.funcs.c,copy equal out queryjumble read) $(addsuffix funcs.switch.c,copy equal out queryjumble read) nodetags.h
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 9f1c4022bb..3d33b082f2 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -64,8 +64,8 @@ scan.c: FLEX_FIX_WARNING=yes
 # Force these dependencies to be known even without dependency info built:
 gram.o scan.o parser.o: gram.h
 
-
-# gram.c, gram.h, and scan.c are in the distribution tarball, so they
-# are not cleaned here.
-clean distclean maintainer-clean:
+clean:
+	rm -f parser/gram.c \
+	      parser/gram.h \
+	      parser/scan.c
 	rm -f lex.backup
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 2d00b4f05a..47338d9922 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -43,6 +43,6 @@ else
 	$(CC) $(CFLAGS) -c $<
 endif
 
-distclean clean:
+clean:
 	rm -f tas_cpp.s
 	$(MAKE) -C win32 clean
diff --git a/src/backend/replication/Makefile b/src/backend/replication/Makefile
index 23f29ba545..9cc82680ab 100644
--- a/src/backend/replication/Makefile
+++ b/src/backend/replication/Makefile
@@ -48,6 +48,10 @@ syncrep_gram.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 syncrep_gram.o syncrep_scanner.o: syncrep_gram.h
 
-# repl_gram.c, repl_scanner.c, syncrep_gram.c and syncrep_scanner.c
-# are in the distribution tarball, so they are not cleaned here.
-# (Our parent Makefile takes care of them during maintainer-clean.)
+clean:
+	rm -f replication/repl_gram.c \
+	      replication/repl_gram.h \
+	      replication/repl_scanner.c \
+	      replication/syncrep_gram.c \
+	      replication/syncrep_gram.h \
+	      replication/syncrep_scanner.c
diff --git a/src/backend/replication/libpqwalreceiver/Makefile b/src/backend/replication/libpqwalreceiver/Makefile
index f26daa135f..e882907350 100644
--- a/src/backend/replication/libpqwalreceiver/Makefile
+++ b/src/backend/replication/libpqwalreceiver/Makefile
@@ -33,5 +33,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/replication/pgoutput/Makefile b/src/backend/replication/pgoutput/Makefile
index 3b41fbcfac..d89d317fe7 100644
--- a/src/backend/replication/pgoutput/Makefile
+++ b/src/backend/replication/pgoutput/Makefile
@@ -28,5 +28,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/snowball/Makefile b/src/backend/snowball/Makefile
index 4bebfa0250..efc4300eb9 100644
--- a/src/backend/snowball/Makefile
+++ b/src/backend/snowball/Makefile
@@ -104,8 +104,6 @@ include $(top_srcdir)/src/Makefile.shlib
 $(SQLSCRIPT): snowball_create.pl snowball_func.sql.in snowball.sql.in
 	$(PERL) $< --input ${srcdir} --outdir .
 
-distprep: $(SQLSCRIPT)
-
 install: all installdirs install-lib install-script
 	$(INSTALL_DATA) $(addprefix $(srcdir)/stopwords/,$(stop_files)) '$(DESTDIR)$(datadir)/$(DICTDIR)'
 
@@ -122,6 +120,4 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
 	rm -f $(SQLSCRIPT)
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index b25b7ee421..c48ba943c4 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -45,8 +45,6 @@ lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt generate-l
 check: s_lock_test
 	./s_lock_test
 
-clean distclean:
+clean:
 	rm -f s_lock_test
-
-maintainer-clean: clean
 	rm -f lwlocknames.h lwlocknames.c
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index deb901609f..ba82a724f1 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -34,13 +34,11 @@ catalogdir  = $(top_srcdir)/src/backend/catalog
 
 include $(top_srcdir)/src/backend/common.mk
 
-all: distprep probes.h generated-header-symlinks
-
-distprep: fmgr-stamp errcodes.h
+all: probes.h generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
-generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_builddir)/src/include/utils/probes.h
+generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp
 
 $(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h
 
@@ -66,22 +64,15 @@ probes.h: Gen_dummy_probes.sed probes.d
 	sed -f $^ >$@
 endif
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than fmgr-stamp.
-$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h
+	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h; do \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
-# probes.h is handled differently because it's not in the distribution tarball.
-$(top_builddir)/src/include/utils/probes.h: probes.h
-	cd '$(dir $@)' && rm -f $(notdir $@) && \
-	    $(LN_S) "../../../$(subdir)/probes.h" .
-
 # Recipe for rebuilding the Perl version of Gen_dummy_probes
 # Nothing depends on it, so it will never be called unless explicitly requested
 # The last two lines of the recipe format the script according to  our
@@ -104,10 +95,6 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, errcodes.txt)
 
-# fmgroids.h, fmgrprotos.h, fmgrtab.c, fmgr-stamp, and errcodes.h are in the
-# distribution tarball, so they are not cleaned here.
 clean:
 	rm -f probes.h probes.h.tmp
-
-maintainer-clean: clean
 	rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h
diff --git a/src/backend/utils/activity/Makefile b/src/backend/utils/activity/Makefile
index f1117745d4..ac76cf782d 100644
--- a/src/backend/utils/activity/Makefile
+++ b/src/backend/utils/activity/Makefile
@@ -43,5 +43,5 @@ pgstat_wait_event.c: wait_event_types.h
 wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt generate-wait_event_types.pl
 	$(PERL) $(srcdir)/generate-wait_event_types.pl --code $<
 
-maintainer-clean: clean
+clean:
 	rm -f wait_event_types.h pgstat_wait_event.c
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile
index 0de0bbb1b8..199eae525d 100644
--- a/src/backend/utils/adt/Makefile
+++ b/src/backend/utils/adt/Makefile
@@ -132,10 +132,9 @@ jsonpath_scan.c: FLEX_NO_BACKUP=yes
 # Force these dependencies to be known even without dependency info built:
 jsonpath_gram.o jsonpath_scan.o: jsonpath_gram.h
 
-# jsonpath_gram.c and jsonpath_scan.c are in the distribution tarball,
-# so they are not cleaned here.
-clean distclean maintainer-clean:
+clean:
 	rm -f lex.backup
+	rm -f jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
 
 like.o: like.c like_match.c
 
diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile
index b19a125fa2..bbde71b5aa 100644
--- a/src/backend/utils/mb/Makefile
+++ b/src/backend/utils/mb/Makefile
@@ -21,5 +21,5 @@ OBJS = \
 
 include $(top_srcdir)/src/backend/common.mk
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C conversion_procs $@
diff --git a/src/backend/utils/mb/Unicode/Makefile b/src/backend/utils/mb/Unicode/Makefile
index 728ccb99c2..6c0a8150f2 100644
--- a/src/backend/utils/mb/Unicode/Makefile
+++ b/src/backend/utils/mb/Unicode/Makefile
@@ -66,8 +66,6 @@ all: $(MAPS)
 
 distclean: clean
 	rm -f $(TEXTS)
-
-maintainer-clean: distclean
 	rm -f $(MAPS)
 
 
diff --git a/src/backend/utils/mb/conversion_procs/proc.mk b/src/backend/utils/mb/conversion_procs/proc.mk
index e0a3b74b25..2eeae28240 100644
--- a/src/backend/utils/mb/conversion_procs/proc.mk
+++ b/src/backend/utils/mb/conversion_procs/proc.mk
@@ -13,5 +13,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/utils/misc/Makefile b/src/backend/utils/misc/Makefile
index 2910032930..c2971c7678 100644
--- a/src/backend/utils/misc/Makefile
+++ b/src/backend/utils/misc/Makefile
@@ -40,6 +40,5 @@ endif
 
 include $(top_srcdir)/src/backend/common.mk
 
-# Note: guc-file.c is not deleted by 'make clean',
-# since we want to ship it in distribution tarballs.
 clean:
+	rm -f guc-file.c
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index d69bd89572..7043289239 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -55,7 +55,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/initdb$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f initdb$(X) $(OBJS) localtime.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_amcheck/Makefile b/src/bin/pg_amcheck/Makefile
index 947f2267ed..528c588e35 100644
--- a/src/bin/pg_amcheck/Makefile
+++ b/src/bin/pg_amcheck/Makefile
@@ -40,7 +40,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_amcheck$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_amcheck$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index 49935d6dce..93fd703f22 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -25,7 +25,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_archivecleanup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_archivecleanup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile
index 893a75c942..74dc1ddd6d 100644
--- a/src/bin/pg_basebackup/Makefile
+++ b/src/bin/pg_basebackup/Makefile
@@ -71,7 +71,7 @@ uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_receivewal$(X)'
 	rm -f '$(DESTDIR)$(bindir)/pg_recvlogical$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_basebackup$(X) pg_receivewal$(X) pg_recvlogical$(X) \
 		$(BBOBJS) pg_receivewal.o pg_recvlogical.o \
 		$(OBJS)
diff --git a/src/bin/pg_checksums/Makefile b/src/bin/pg_checksums/Makefile
index 4911f6bee2..ac736b2260 100644
--- a/src/bin/pg_checksums/Makefile
+++ b/src/bin/pg_checksums/Makefile
@@ -36,7 +36,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_checksums$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_checksums$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index 1a405f9c97..cb13aceafa 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_config$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_config$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index aa5bd58222..00ee1e25b3 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_controldata$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_controldata$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index 4b6d47a8f8..4d29ca72c1 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -42,7 +42,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_ctl$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_ctl$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 24de7593a6..604cddb997 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -69,6 +69,6 @@ installcheck:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o
 	rm -rf tmp_check
diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile
index a363b948b5..a06e493ba8 100644
--- a/src/bin/pg_resetwal/Makefile
+++ b/src/bin/pg_resetwal/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_resetwal$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_resetwal$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
index bed05f1609..8df1da80cb 100644
--- a/src/bin/pg_rewind/Makefile
+++ b/src/bin/pg_rewind/Makefile
@@ -49,7 +49,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_rewind$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_rewind$(X) $(OBJS) xlogreader.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index 631d0f38a8..4c5e518125 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_fsync$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index 84d84c38aa..7f677edadb 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_timing$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_timing$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 5834513add..f76aca1b1a 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -46,7 +46,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_upgrade$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_upgrade$(X) $(OBJS)
 	rm -rf delete_old_cluster.sh log/ tmp_check/ \
 	       reindex_hash.sql
diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile
index 596df15118..c96323faa9 100644
--- a/src/bin/pg_verifybackup/Makefile
+++ b/src/bin/pg_verifybackup/Makefile
@@ -38,7 +38,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_verifybackup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile
index 0ecf582039..4c1ee64950 100644
--- a/src/bin/pg_waldump/Makefile
+++ b/src/bin/pg_waldump/Makefile
@@ -45,7 +45,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_waldump$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_waldump$(X) $(OBJS) $(RMGRDESCSOURCES) xlogreader.c xlogstats.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index 68b6eb0376..987bf64df9 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -38,8 +38,6 @@ exprparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 exprparse.o exprscan.o: exprparse.h
 
-distprep: exprparse.c exprscan.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pgbench$(X) '$(DESTDIR)$(bindir)/pgbench$(X)'
 
@@ -52,8 +50,6 @@ uninstall:
 clean distclean:
 	rm -f pgbench$(X) $(OBJS)
 	rm -rf tmp_check
-
-maintainer-clean: distclean
 	rm -f exprparse.h exprparse.c exprscan.c
 
 check:
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 1f2bf0c6b0..8ad7c65446 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -62,8 +62,6 @@ psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
 psqlscanslash.c: FLEX_NO_BACKUP=yes
 psqlscanslash.c: FLEX_FIX_WARNING=yes
 
-distprep: sql_help.h sql_help.c psqlscanslash.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
 	$(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
@@ -77,10 +75,6 @@ uninstall:
 clean distclean:
 	rm -f psql$(X) $(OBJS) lex.backup
 	rm -rf tmp_check
-
-# files removed here are supposed to be in the distribution tarball,
-# so do not clean them in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f sql_help.h sql_help.c psqlscanslash.c
 
 check:
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index a7a9d0fea5..20db40b103 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -48,7 +48,7 @@ installdirs:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(addsuffix $(X), $(PROGRAMS)))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS))
 	rm -f common.o $(WIN32RES)
 	rm -rf tmp_check
diff --git a/src/common/Makefile b/src/common/Makefile
index 113029bf7b..ec063c6e18 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -121,8 +121,6 @@ GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
 
 all: libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 
-distprep: kwlist_d.h
-
 # libpgcommon is needed by some contrib
 install: all installdirs
 	$(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
@@ -188,10 +186,7 @@ RYU_OBJS = $(RYU_FILES) $(RYU_FILES:%.o=%_shlib.o) $(RYU_FILES:%.o=%_srv.o)
 
 $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
 
-# kwlist_d.h is in the distribution tarball, so it is not cleaned here.
 clean distclean:
 	rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 	rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)
-
-maintainer-clean: distclean
 	rm -f kwlist_d.h
diff --git a/src/common/unicode/Makefile b/src/common/unicode/Makefile
index 382da476cf..d6e427b582 100644
--- a/src/common/unicode/Makefile
+++ b/src/common/unicode/Makefile
@@ -68,5 +68,3 @@ clean:
 
 distclean: clean
 	rm -f UnicodeData.txt EastAsianWidth.txt CompositionExclusions.txt NormalizationTest.txt norm_test_table.h unicode_norm_table.h
-
-maintainer-clean: distclean
diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile
index 456d6dd390..8accd5906d 100644
--- a/src/fe_utils/Makefile
+++ b/src/fe_utils/Makefile
@@ -48,8 +48,6 @@ psqlscan.c: FLEXFLAGS = -Cfe -p -p
 psqlscan.c: FLEX_NO_BACKUP=yes
 psqlscan.c: FLEX_FIX_WARNING=yes
 
-distprep: psqlscan.c
-
 # libpgfeutils could be useful to contrib, so install it
 install: all installdirs
 	$(INSTALL_STLIB) libpgfeutils.a '$(DESTDIR)$(libdir)/libpgfeutils.a'
@@ -62,8 +60,4 @@ uninstall:
 
 clean distclean:
 	rm -f libpgfeutils.a $(OBJS) lex.backup
-
-# psqlscan.c is supposed to be in the distribution tarball,
-# so do not clean it in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f psqlscan.c
diff --git a/src/include/Makefile b/src/include/Makefile
index 5d213187e2..0dfe7d9e23 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -77,5 +77,5 @@ clean:
 	rm -f catalog/pg_*_d.h catalog/header-stamp
 	rm -f nodes/nodetags.h nodes/header-stamp
 
-distclean maintainer-clean: clean
+distclean: clean
 	rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index e4bbf7b8a8..3002bc3c1b 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -23,7 +23,7 @@ install-pgtypeslib-recurse install-ecpglib-recurse install-compatlib-recurse ins
 install-compatlib-recurse: install-ecpglib-recurse
 install-ecpglib-recurse: install-pgtypeslib-recurse
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C test clean
 
 checktcp: | temp-install
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index b9483fba08..695fd1a080 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -55,5 +55,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 652e023405..103cce393a 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -66,5 +66,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/include/Makefile b/src/interfaces/ecpg/include/Makefile
index 9c68bf3c47..3476409cef 100644
--- a/src/interfaces/ecpg/include/Makefile
+++ b/src/interfaces/ecpg/include/Makefile
@@ -31,5 +31,5 @@ uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers))
 	rm -f '$(DESTDIR)$(includedir)'/$(notdir $(ecpg_config_h))
 
-distclean maintainer-clean:
+distclean:
 	rm -f ecpg_config.h stamp-h
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index b0e154eb15..e56700a12e 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -50,5 +50,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 77ae9ab722..afd46cd17c 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -81,8 +81,6 @@ ecpg_keywords.o: ecpg_kwlist_d.h
 c_keywords.o: c_kwlist_d.h
 keywords.o: $(top_srcdir)/src/include/parser/kwlist.h
 
-distprep: preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
-
 install: all installdirs
 	$(INSTALL_PROGRAM) ecpg$(X) '$(DESTDIR)$(bindir)'
 
@@ -92,11 +90,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/ecpg$(X)'
 
-# preproc.y, preproc.c, preproc.h, pgc.c, c_kwlist_d.h, and ecpg_kwlist_d.h
-# are in the distribution tarball, so they are not cleaned here.
 clean distclean:
 	rm -f *.o ecpg$(X)
 	rm -f typename.c
-
-maintainer-clean: distclean
 	rm -f preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index cf841a3a5b..3769488f16 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -20,7 +20,7 @@ else
 abs_builddir := $(shell sh -c "pwd -W")
 endif
 
-all install installdirs uninstall distprep:
+all install installdirs uninstall:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
@@ -29,7 +29,7 @@ all install installdirs uninstall distprep:
 	$(MAKE) -C compat_oracle $@
 	$(MAKE) -C thread $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 46653682b0..d0a66cfaa0 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -165,6 +165,3 @@ clean distclean: clean-lib
 	rm -f $(OBJS) pthread.h libpq-refs-stamp
 # Might be left over from a Win32 client-only build
 	rm -f pg_config_paths.h
-
-maintainer-clean: distclean
-	$(MAKE) -C test $@
diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile
index 75ac08f943..4e17ec1514 100644
--- a/src/interfaces/libpq/test/Makefile
+++ b/src/interfaces/libpq/test/Makefile
@@ -20,5 +20,5 @@ all: $(PROGS)
 
 $(PROGS): $(WIN32RES)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 7ba8d5bc98..0de3737e78 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -391,7 +391,7 @@ ifdef MODULE_big
 clean: clean-lib
 endif
 
-distclean maintainer-clean: clean
+distclean: clean
 
 
 ifdef REGRESS
diff --git a/src/nls-global.mk b/src/nls-global.mk
index f21bd5ed55..dfff472cb3 100644
--- a/src/nls-global.mk
+++ b/src/nls-global.mk
@@ -171,7 +171,7 @@ all: all-po
 install: install-po
 installdirs: installdirs-po
 uninstall: uninstall-po
-clean distclean maintainer-clean: clean-po
+clean distclean: clean-po
 
 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
         init-po update-po
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index 51f8890d15..975f540b3e 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -127,7 +127,7 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index f7eb42d54f..dfb815212f 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile
@@ -104,14 +104,7 @@ submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
 
-distprep: pl_gram.h pl_gram.c plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
-
-# pl_gram.c, pl_gram.h, plerrcodes.h, pl_reserved_kwlist_d.h, and
-# pl_unreserved_kwlist_d.h are in the distribution tarball, so they
-# are not cleaned here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f pl_gram.c pl_gram.h plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index 6b1865c240..ef0a5905ae 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -142,6 +142,7 @@ clean distclean: clean-lib
 ifeq ($(PORTNAME), win32)
 	rm -f python${pytverstr}.def
 endif
+	rm -f spiexceptions.h
 
 
 # Force this dependency to be known even without dependency info built:
@@ -149,8 +150,3 @@ plpy_plpymodule.o: spiexceptions.h
 
 spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
 	$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
-
-distprep: spiexceptions.h
-
-maintainer-clean: distclean
-	rm -f spiexceptions.h
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index 314f9b2eec..ea52a2efc2 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -63,8 +63,6 @@ pltcl.o: pltclerrcodes.h
 pltclerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-pltclerrcodes.pl
 	$(PERL) $(srcdir)/generate-pltclerrcodes.pl $< > $@
 
-distprep: pltclerrcodes.h
-
 install: all install-lib install-data
 
 installdirs: installdirs-lib
@@ -91,13 +89,10 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-# pltclerrcodes.h is in the distribution tarball, so don't clean it here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
 	rm -f $(tclwithver).def
 endif
-
-maintainer-clean: distclean
 	rm -f pltclerrcodes.h
diff --git a/src/port/Makefile b/src/port/Makefile
index f205c2c9c5..4320dee0d1 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -154,6 +154,6 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
 	echo "#define HTMLDIR \"$(htmldir)\"" >>$@
 	echo "#define MANDIR \"$(mandir)\"" >>$@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f libpgport.a libpgport_shlib.a libpgport_srv.a
 	rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h
diff --git a/src/test/authentication/Makefile b/src/test/authentication/Makefile
index 46fa72052d..a48ce39aaf 100644
--- a/src/test/authentication/Makefile
+++ b/src/test/authentication/Makefile
@@ -19,5 +19,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/examples/Makefile b/src/test/examples/Makefile
index a67f456904..e72d058e0c 100644
--- a/src/test/examples/Makefile
+++ b/src/test/examples/Makefile
@@ -18,5 +18,5 @@ PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo testlo64
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/test/icu/Makefile b/src/test/icu/Makefile
index 033b0d03cc..c4fc8cdb8c 100644
--- a/src/test/icu/Makefile
+++ b/src/test/icu/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index b8738b7c1b..8f5192fb37 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -43,8 +43,6 @@ pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
 isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
 	$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
-distprep: specparse.c specscanner.c
-
 # See notes in src/backend/parser/Makefile about the following two rules
 specparse.h: specparse.c
 	touch $@
@@ -60,8 +58,6 @@ clean distclean:
 	rm -f isolationtester$(X) pg_isolation_regress$(X) $(OBJS) isolation_main.o
 	rm -f pg_regress.o
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f specparse.h specparse.c specscanner.c
 
 installcheck: all
diff --git a/src/test/kerberos/Makefile b/src/test/kerberos/Makefile
index f460d2c0e7..44da65611e 100644
--- a/src/test/kerberos/Makefile
+++ b/src/test/kerberos/Makefile
@@ -24,5 +24,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/ldap/Makefile b/src/test/ldap/Makefile
index 73bc878ea8..d4305ed5eb 100644
--- a/src/test/ldap/Makefile
+++ b/src/test/ldap/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/locale/Makefile b/src/test/locale/Makefile
index 7ba096b542..a40c67af07 100644
--- a/src/test/locale/Makefile
+++ b/src/test/locale/Makefile
@@ -10,7 +10,7 @@ DIRS = de_DE.ISO8859-1 gr_GR.ISO8859-7 koi8-r koi8-to-win1251
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
 	rm -rf tmp_check
 	for d in $(DIRS); do \
diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile
index c60314d195..49f1d1c118 100644
--- a/src/test/recovery/Makefile
+++ b/src/test/recovery/Makefile
@@ -25,5 +25,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 38c3a1f85b..388f2700bd 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -146,7 +146,7 @@ bigcheck: all | temp-install
 ## Clean up
 ##
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 # things built by `all' target
 	rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
 	rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
diff --git a/src/test/ssl/Makefile b/src/test/ssl/Makefile
index af1e06e949..2d7c69068f 100644
--- a/src/test/ssl/Makefile
+++ b/src/test/ssl/Makefile
@@ -23,7 +23,7 @@ export OPENSSL with_ssl
 sslfiles sslfiles-clean:
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
diff --git a/src/test/ssl/sslfiles.mk b/src/test/ssl/sslfiles.mk
index f7ababe42c..62b2272183 100644
--- a/src/test/ssl/sslfiles.mk
+++ b/src/test/ssl/sslfiles.mk
@@ -269,6 +269,6 @@ sslfiles-clean:
 # clean targets will be run during a "standard" recursive clean run from the
 # main build tree. The sslfiles-clean target must be run explicitly from this
 # directory.
-.PHONY: clean distclean maintainer-clean
-clean distclean maintainer-clean:
+.PHONY: clean distclean
+clean distclean:
 	rm -rf ssl/*.old ssl/new_certs_dir ssl/client*_tmp.key
diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile
index 99d1fe012d..36475ffabc 100644
--- a/src/test/subscription/Makefile
+++ b/src/test/subscription/Makefile
@@ -23,5 +23,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/timezone/Makefile b/src/timezone/Makefile
index fbbaae4cc5..c85e831247 100644
--- a/src/timezone/Makefile
+++ b/src/timezone/Makefile
@@ -75,5 +75,5 @@ ifeq (,$(with_system_tzdata))
 endif
 	$(MAKE) -C tznames $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f zic$(X) $(ZICOBJS) abbrevs.txt
diff --git a/src/tools/ifaddrs/Makefile b/src/tools/ifaddrs/Makefile
index e74d754769..ef5e8f0e0e 100644
--- a/src/tools/ifaddrs/Makefile
+++ b/src/tools/ifaddrs/Makefile
@@ -24,5 +24,5 @@ all: test_ifaddrs
 test_ifaddrs: test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o
 	$(CC) $(CFLAGS) test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f test_ifaddrs$(X) $(OBJS)
diff --git a/src/tools/pg_bsd_indent/Makefile b/src/tools/pg_bsd_indent/Makefile
index d176ceb326..ce5d815f07 100644
--- a/src/tools/pg_bsd_indent/Makefile
+++ b/src/tools/pg_bsd_indent/Makefile
@@ -39,7 +39,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_bsd_indent$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_bsd_indent$(X) $(OBJS)
 	rm -rf log/ tmp_check/
 

base-commit: 00f2a2556c9b23050e4f987e5d563b6856b83fc2
-- 
2.41.0

#4Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Peter Eisentraut (#3)
Re: Remove distprep

On 2023-Jul-14, Peter Eisentraut wrote:

diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 9f1c4022bb..3d33b082f2 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -64,8 +64,8 @@ scan.c: FLEX_FIX_WARNING=yes
# Force these dependencies to be known even without dependency info built:
gram.o scan.o parser.o: gram.h
-
-# gram.c, gram.h, and scan.c are in the distribution tarball, so they
-# are not cleaned here.
-clean distclean maintainer-clean:
+clean:
+	rm -f parser/gram.c \
+	      parser/gram.h \
+	      parser/scan.c
rm -f lex.backup

Hmm, this hunk and the equivalents in src/backend/bootstrap and
src/backend/replication are wrong: you moved the rule from the parent
directory's makefile to the directory where the files reside, but didn't
remove the directory name from the command arguments, so the files
aren't actually deleted.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"El destino baraja y nosotros jugamos" (A. Schopenhauer)

#5Peter Eisentraut
peter@eisentraut.org
In reply to: Peter Eisentraut (#3)
1 attachment(s)
Re: Remove distprep

On 14.07.23 09:54, Peter Eisentraut wrote:

diff --git a/src/tools/pginclude/cpluspluscheck 
b/src/tools/pginclude/cpluspluscheck
index 4e09c4686b..287395887c 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -134,6 +134,9 @@ do
      test "$f" = src/interfaces/ecpg/preproc/preproc.h && continue
      test "$f" = src/test/isolation/specparse.h && continue
+    # FIXME
+    test "$f" = src/backend/utils/adt/jsonpath_internal.h && continue
+
      # ppport.h is not under our control, so we can't make it 
standalone.
      test "$f" = src/pl/plperl/ppport.h && continue

Hm, what's that about?

Don't remember ... ;-)  I removed this.

Ah, there was a reason. The headerscheck and cpluspluscheck targets
need jsonpath_gram.h to be built first. Which previously happened
indirectly somehow? I have fixed this in the new patch version. I also
fixed the issue that Álvaro reported nearby.

Attachments:

v3-0001-Remove-distprep.patchtext/plain; charset=UTF-8; name=v3-0001-Remove-distprep.patchDownload
From 5b5e46ea28f4911408eb40936e814b4a05281baa Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 14 Jul 2023 10:53:40 +0200
Subject: [PATCH v3] Remove distprep

A PostgreSQL release tarball contains a number of prebuilt files, in
particular files produced by bison, flex, perl, and well as html and
man documentation.  We have done this consistent with established
practice at the time to not require these tools for building from a
tarball.  Some of these tools were hard to get, or get the right
version of, from time to time, and shipping the prebuilt output was a
convenience to users.

Now this has at least two problems:

One, we have to make the build system(s) work in two modes: Building
from a git checkout and building from a tarball.  This is pretty
complicated, but it works so far for autoconf/make.  It does not
currently work for meson; you can currently only build with meson from
a git checkout.  Making meson builds work from a tarball seems very
difficult or impossible.  One particular problem is that since meson
requires a separate build directory, we cannot make the build update
files like gram.h in the source tree.  So if you were to build from a
tarball and update gram.y, you will have a gram.h in the source tree
and one in the build tree, but the way things work is that the
compiler will always use the one in the source tree.  So you cannot,
for example, make any gram.y changes when building from a tarball.
This seems impossible to fix in a non-horrible way.

Second, there is increased interest nowadays in precisely tracking the
origin of software.  We can reasonably track contributions into the
git tree, and users can reasonably track the path from a tarball to
packages and downloads and installs.  But what happens between the git
tree and the tarball is obscure and in some cases non-reproducible.

The solution for both of these issues is to get rid of the step that
adds prebuilt files to the tarball.  The tarball now only contains
what is in the git tree (*).  Getting the additional build
dependencies is no longer a problem nowadays, and the complications to
keep these dual build modes working are significant.  And of course we
want to get the meson build system working universally.

This commit removes the make distprep target altogether.  The make
dist target continues to do its job, it just doesn't call distprep
anymore.

(*) - The tarball also contains the INSTALL file that is built at make
dist time, but not by distprep.  This is unchanged for now.

The make maintainer-clean target, whose job it is to remove the
prebuilt files in addition to what make distclean does, is now just an
alias to make distprep.  (In practice, it is probably obsolete given
that git clean is available.)

The following programs are now hard build requirements in configure
(they were already required by meson.build):

- bison
- flex
- perl
---
 GNUmakefile.in                                |  6 +-
 config/perl.m4                                |  9 +-
 config/programs.m4                            | 21 +----
 configure                                     | 62 ++------------
 contrib/cube/Makefile                         |  7 +-
 contrib/fuzzystrmatch/Makefile                |  9 +-
 contrib/seg/Makefile                          |  7 +-
 doc/Makefile                                  |  2 +-
 doc/src/Makefile                              |  2 +-
 doc/src/sgml/Makefile                         |  9 +-
 doc/src/sgml/installation.sgml                | 83 ++++++++-----------
 meson.build                                   |  2 +-
 src/Makefile                                  |  5 +-
 src/Makefile.global.in                        | 30 +++----
 src/backend/Makefile                          | 65 ++-------------
 src/backend/bootstrap/Makefile                |  6 +-
 src/backend/catalog/Makefile                  | 14 +---
 src/backend/jit/llvm/Makefile                 |  2 +-
 src/backend/nls.mk                            |  2 +-
 src/backend/nodes/Makefile                    | 12 +--
 src/backend/parser/Makefile                   |  8 +-
 src/backend/port/Makefile                     |  2 +-
 src/backend/replication/Makefile              | 10 ++-
 .../replication/libpqwalreceiver/Makefile     |  2 +-
 src/backend/replication/pgoutput/Makefile     |  2 +-
 src/backend/snowball/Makefile                 |  4 -
 src/backend/storage/lmgr/Makefile             |  4 +-
 src/backend/utils/Makefile                    | 28 ++-----
 src/backend/utils/activity/Makefile           |  2 +-
 src/backend/utils/adt/Makefile                |  5 +-
 src/backend/utils/mb/Makefile                 |  2 +-
 src/backend/utils/mb/Unicode/Makefile         |  2 -
 src/backend/utils/mb/conversion_procs/proc.mk |  2 +-
 src/backend/utils/misc/Makefile               |  3 +-
 src/bin/initdb/Makefile                       |  2 +-
 src/bin/pg_amcheck/Makefile                   |  2 +-
 src/bin/pg_archivecleanup/Makefile            |  2 +-
 src/bin/pg_basebackup/Makefile                |  2 +-
 src/bin/pg_checksums/Makefile                 |  2 +-
 src/bin/pg_config/Makefile                    |  2 +-
 src/bin/pg_controldata/Makefile               |  2 +-
 src/bin/pg_ctl/Makefile                       |  2 +-
 src/bin/pg_dump/Makefile                      |  2 +-
 src/bin/pg_resetwal/Makefile                  |  2 +-
 src/bin/pg_rewind/Makefile                    |  2 +-
 src/bin/pg_test_fsync/Makefile                |  2 +-
 src/bin/pg_test_timing/Makefile               |  2 +-
 src/bin/pg_upgrade/Makefile                   |  2 +-
 src/bin/pg_verifybackup/Makefile              |  2 +-
 src/bin/pg_waldump/Makefile                   |  2 +-
 src/bin/pgbench/Makefile                      |  4 -
 src/bin/psql/Makefile                         |  6 --
 src/bin/scripts/Makefile                      |  2 +-
 src/common/Makefile                           |  5 --
 src/common/unicode/Makefile                   |  2 -
 src/fe_utils/Makefile                         |  6 --
 src/include/Makefile                          |  2 +-
 src/interfaces/ecpg/Makefile                  |  2 +-
 src/interfaces/ecpg/compatlib/Makefile        |  2 -
 src/interfaces/ecpg/ecpglib/Makefile          |  2 -
 src/interfaces/ecpg/include/Makefile          |  2 +-
 src/interfaces/ecpg/pgtypeslib/Makefile       |  2 -
 src/interfaces/ecpg/preproc/Makefile          |  6 --
 src/interfaces/ecpg/test/Makefile             |  4 +-
 src/interfaces/libpq/Makefile                 |  3 -
 src/interfaces/libpq/test/Makefile            |  2 +-
 src/makefiles/pgxs.mk                         |  2 +-
 src/nls-global.mk                             |  2 +-
 src/pl/plperl/GNUmakefile                     |  2 +-
 src/pl/plpgsql/src/Makefile                   |  7 --
 src/pl/plpython/Makefile                      |  6 +-
 src/pl/tcl/Makefile                           |  5 --
 src/port/Makefile                             |  2 +-
 src/test/authentication/Makefile              |  2 +-
 src/test/examples/Makefile                    |  2 +-
 src/test/icu/Makefile                         |  2 +-
 src/test/isolation/Makefile                   |  4 -
 src/test/kerberos/Makefile                    |  2 +-
 src/test/ldap/Makefile                        |  2 +-
 src/test/locale/Makefile                      |  2 +-
 src/test/recovery/Makefile                    |  2 +-
 src/test/regress/GNUmakefile                  |  2 +-
 src/test/ssl/Makefile                         |  2 +-
 src/test/ssl/sslfiles.mk                      |  4 +-
 src/test/subscription/Makefile                |  2 +-
 src/timezone/Makefile                         |  2 +-
 src/tools/ifaddrs/Makefile                    |  2 +-
 src/tools/pg_bsd_indent/Makefile              |  2 +-
 88 files changed, 168 insertions(+), 407 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index 9c18c56233..80db4c73f8 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -41,7 +41,7 @@ install-world-bin-contrib-recurse: install-world-bin-src-recurse
 
 $(call recurse,installdirs uninstall init-po update-po,doc src config)
 
-$(call recurse,distprep coverage,doc src config contrib)
+$(call recurse,coverage,doc src config contrib)
 
 # clean, distclean, etc should apply to contrib too, even though
 # it's not built by default
@@ -53,7 +53,7 @@ clean:
 
 # Important: distclean `src' last, otherwise Makefile.global
 # will be gone too soon.
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C doc $@
 	$(MAKE) -C contrib $@
 	$(MAKE) -C config $@
@@ -109,7 +109,6 @@ distdir:
 	      || cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
 	  fi || exit; \
 	done
-	$(MAKE) -C $(distdir) distprep
 	$(MAKE) -C $(distdir)/doc/src/sgml/ INSTALL
 	cp $(distdir)/doc/src/sgml/INSTALL $(distdir)/
 	$(MAKE) -C $(distdir) distclean
@@ -122,7 +121,6 @@ distcheck: dist
 	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
diff --git a/config/perl.m4 b/config/perl.m4
index 8126e79f67..1a3bb55649 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -13,19 +13,14 @@ if test "$PERL"; then
   if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
     $AWK '{ if ([$]1 == 5 && ([$]2 >= 14)) exit 1; else exit 0;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
 *** Perl version 5.14 or later is required, but this is $pgac_perl_version.])
-    PERL=""
   fi
 fi
 
 if test -z "$PERL"; then
-  AC_MSG_WARN([
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)])
+  AC_MSG_ERROR([Perl not found])
 fi
 ])# PGAC_PATH_PERL
 
diff --git a/config/programs.m4 b/config/programs.m4
index 8a118b4e03..490ec9fe9f 100644
--- a/config/programs.m4
+++ b/config/programs.m4
@@ -33,10 +33,9 @@ if test "$BISON"; then
   AC_MSG_NOTICE([using $pgac_bison_version])
   if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 2.3) exit 0; else exit 1;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
 *** Bison version 2.3 or later is required, but this is $pgac_bison_version.])
-    BISON=""
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -49,12 +48,7 @@ if test "$BISON"; then
 fi
 
 if test -z "$BISON"; then
-  AC_MSG_WARN([
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)])
+  AC_MSG_ERROR([bison not found])
 fi
 dnl We don't need AC_SUBST(BISON) because PGAC_PATH_PROGS did it
 AC_SUBST(BISONFLAGS)
@@ -95,7 +89,7 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            AC_MSG_WARN([
+            AC_MSG_ERROR([
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
 *** Flex version 2.5.35 or later is required, but this is $pgac_flex_version.])
           fi
@@ -109,14 +103,7 @@ fi
 ])[]dnl AC_CACHE_CHECK
 
 if test x"$pgac_cv_path_flex" = x"no"; then
-  AC_MSG_WARN([
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)])
-
-  FLEX=
+  AC_MSG_ERROR([flex not found])
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
diff --git a/configure b/configure
index 2e518c8007..802fc9edc4 100755
--- a/configure
+++ b/configure
@@ -10160,13 +10160,9 @@ if test "$BISON"; then
 $as_echo "$as_me: using $pgac_bison_version" >&6;}
   if echo "$pgac_bison_version" | $AWK '{ if ($4 < 2.3) exit 0; else exit 1;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&2;}
-    BISON=""
+*** Bison version 2.3 or later is required, but this is $pgac_bison_version." "$LINENO" 5
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -10179,18 +10175,7 @@ $as_echo "$as_me: WARNING:
 fi
 
 if test -z "$BISON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&2;}
+  as_fn_error $? "bison not found" "$LINENO" 5
 fi
 
 
@@ -10223,12 +10208,9 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&5
-$as_echo "$as_me: WARNING:
+            as_fn_error $? "
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&2;}
+*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." "$LINENO" 5
           fi
         fi
       fi
@@ -10242,20 +10224,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_path_flex" >&5
 $as_echo "$pgac_cv_path_flex" >&6; }
 if test x"$pgac_cv_path_flex" = x"no"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&2;}
-
-  FLEX=
+  as_fn_error $? "flex not found" "$LINENO" 5
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
@@ -10329,27 +10298,14 @@ $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
   if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
     $AWK '{ if ($1 == 5 && ($2 >= 14)) exit 1; else exit 0;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&2;}
-    PERL=""
+*** Perl version 5.14 or later is required, but this is $pgac_perl_version." "$LINENO" 5
   fi
 fi
 
 if test -z "$PERL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&2;}
+  as_fn_error $? "Perl not found" "$LINENO" 5
 fi
 
 if test "$with_perl" = yes; then
diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 4fd19aac35..dfb0d806e4 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -18,6 +18,8 @@ REGRESS = cube cube_sci
 
 SHLIB_LINK += $(filter -lm, $(LIBS))
 
+EXTRA_CLEAN = cubeparse.h cubeparse.c cubescan.c
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -37,8 +39,3 @@ cubeparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 cubeparse.o cubescan.o: cubeparse.h
-
-distprep: cubeparse.c cubescan.c
-
-maintainer-clean:
-	rm -f cubeparse.h cubeparse.c cubescan.c
diff --git a/contrib/fuzzystrmatch/Makefile b/contrib/fuzzystrmatch/Makefile
index e68bc0e33f..04c83a34a7 100644
--- a/contrib/fuzzystrmatch/Makefile
+++ b/contrib/fuzzystrmatch/Makefile
@@ -15,6 +15,8 @@ PGFILEDESC = "fuzzystrmatch - similarities and distance between strings"
 
 REGRESS = fuzzystrmatch fuzzystrmatch_utf8
 
+EXTRA_CLEAN = daitch_mokotoff.h
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -31,10 +33,3 @@ daitch_mokotoff.o: daitch_mokotoff.h
 
 daitch_mokotoff.h: daitch_mokotoff_header.pl
 	$(PERL) $< $@
-
-# daitch_mokotoff.h is included in tarballs, so it has to be made by
-# "distprep" and not cleaned except by "maintainer-clean".
-distprep: daitch_mokotoff.h
-
-maintainer-clean:
-	rm -f daitch_mokotoff.h
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index a1e49bf051..132ec8dbfe 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -16,7 +16,7 @@ HEADERS = segdata.h
 
 REGRESS = security seg
 
-EXTRA_CLEAN = y.tab.c y.tab.h
+EXTRA_CLEAN = segparse.h segparse.c segscan.c
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
@@ -38,8 +38,3 @@ segparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 segparse.o segscan.o: segparse.h
-
-distprep: segparse.c segscan.c
-
-maintainer-clean:
-	rm -f segparse.h segparse.c segscan.c
diff --git a/doc/Makefile b/doc/Makefile
index aee3cc0965..24370fc903 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -12,5 +12,5 @@ subdir = doc
 top_builddir = ..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C src $@
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 30d883815a..2ed02084ff 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -4,5 +4,5 @@ subdir = doc/src
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C sgml $@
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 1e55e531db..82d57674a2 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -7,8 +7,7 @@
 #----------------------------------------------------------------------------
 
 # This makefile is for building and installing the documentation.
-# When a release tarball is created, the documentation files are
-# prepared using the distprep target.  In Git-based trees these files
+# In Git-based trees these files
 # don't exist, unless explicitly built, so we skip the installation in
 # that case.
 
@@ -28,8 +27,6 @@ include $(top_builddir)/src/Makefile.global
 
 all: html man
 
-distprep: html distprep-man
-
 
 ifndef DBTOEPUB
 DBTOEPUB = $(missing) dbtoepub
@@ -77,7 +74,7 @@ postgres-full.xml: postgres.sgml $(ALLSGML)
 ## Man pages
 ##
 
-man distprep-man: man-stamp
+man: man-stamp
 
 man-stamp: stylesheet-man.xsl postgres-full.xml
 	$(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_MAN_FLAGS) $^
@@ -305,8 +302,6 @@ clean:
 	rm -f *.texixml *.texi *.info db2texi.refs
 
 distclean: clean
-
-maintainer-clean: distclean
 # HTML
 	rm -fr html/ html-stamp
 # man
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index ac8eee47c6..8eb928903e 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -72,8 +72,7 @@ <title>Requirements</title>
 
       Alternatively, <productname>PostgreSQL</productname> can be built using
       <ulink url="https://mesonbuild.com/">Meson</ulink>.  This is currently
-      experimental and only works when building from a Git checkout (not from
-      a distribution tarball).  If you choose to use
+      experimental.  If you choose to use
       <application>Meson</application>, then you don't need
       <acronym>GNU</acronym> <application>make</application>, but the other
       requirements below still apply.
@@ -102,6 +101,41 @@ <title>Requirements</title>
      </para>
     </listitem>
 
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>flex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>lex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>bison</primary>
+      </indexterm>
+      <indexterm>
+       <primary>yacc</primary>
+      </indexterm>
+
+      <application>Flex</application> 2.5.35 or later and
+      <application>Bison</application> 2.3 or later are required.  Other
+      <application>lex</application> and <application>yacc</application>
+      programs cannot be used.
+     </para>
+    </listitem>
+
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>perl</primary>
+      </indexterm>
+
+      <application>Perl</application> 5.14 or later is needed during the build
+      process and to run some test suites.  (This requirement is separate from
+      the requirements for building <application>PL/Perl</application>; see
+      below.)
+     </para>
+    </listitem>
+
     <listitem>
      <para>
       <indexterm>
@@ -315,51 +349,6 @@ <title>Requirements</title>
    </itemizedlist>
   </para>
 
-  <para>
-   If you are building from a <productname>Git</productname> tree instead of
-   using a released source package, or if you want to do server development,
-   you also need the following packages:
-
-   <itemizedlist>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>flex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>lex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>bison</primary>
-      </indexterm>
-      <indexterm>
-       <primary>yacc</primary>
-      </indexterm>
-
-      <application>Flex</application> and <application>Bison</application>
-      are needed to build from a Git checkout, or if you changed the actual
-      scanner and parser definition files. If you need them, be sure
-      to get <application>Flex</application> 2.5.35 or later and
-      <application>Bison</application> 2.3 or later. Other <application>lex</application>
-      and <application>yacc</application> programs cannot be used.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>perl</primary>
-      </indexterm>
-
-      <application>Perl</application> 5.14 or later is needed to build from a Git checkout,
-      or if you changed the input files for any of the build steps that
-      use Perl scripts.  If building on Windows you will need
-      <application>Perl</application> in any case.  <application>Perl</application> is
-      also required to run some test suites.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
-
   <para>
    If you need to get a <acronym>GNU</acronym> package, you can find
    it at your local <acronym>GNU</acronym> mirror site (see <ulink
diff --git a/meson.build b/meson.build
index 04ea348852..0f426d68d6 100644
--- a/meson.build
+++ b/meson.build
@@ -72,7 +72,7 @@ configure. Alternatively use a separate check out for meson based builds.
 @0@
 ****'''
 if fs.exists(meson.current_source_dir() / 'src' / 'include' / 'pg_config.h')
-  errmsg_cleanup = 'To clean up, run make maintainer-clean in the source tree.'
+  errmsg_cleanup = 'To clean up, run make distclean in the source tree.'
   error(errmsg_nonclean_base.format(errmsg_cleanup))
 endif
 
diff --git a/src/Makefile b/src/Makefile
index 94649c36c7..2f31a2f20a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -59,16 +59,13 @@ uninstall: uninstall-local
 uninstall-local:
 	rm -f $(addprefix '$(DESTDIR)$(pgxsdir)/$(subdir)'/, Makefile.global Makefile.port Makefile.shlib nls-global.mk)
 
-distprep:
-	$(MAKE) -C test/isolation $@
-
 clean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
 	$(MAKE) -C tools/pg_bsd_indent $@
 
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index df9f721a41..2159692439 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -19,11 +19,11 @@
 #
 # Meta configuration
 
-standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check checkprep installcheck init-po update-po
+standard_targets = all install installdirs uninstall clean distclean coverage check checkprep installcheck init-po update-po
 # these targets should recurse even into subdirectories not being built:
-standard_always_targets = distprep clean distclean maintainer-clean
+standard_always_targets = clean distclean
 
-.PHONY: $(standard_targets) install-strip html man installcheck-parallel update-unicode
+.PHONY: $(standard_targets) maintainer-clean install-strip html man installcheck-parallel update-unicode
 
 # make `all' the default target
 all:
@@ -35,6 +35,8 @@ all:
 # Never delete any intermediate files automatically.
 .SECONDARY:
 
+maintainer-clean: distclean
+
 # PostgreSQL version number
 VERSION = @PACKAGE_VERSION@
 MAJORVERSION = @PG_MAJORVERSION@
@@ -319,12 +321,8 @@ X = @EXEEXT@
 
 # Perl
 
-ifneq (@PERL@,)
-    # quoted to protect pathname with spaces
-    PERL		= '@PERL@'
-else
-    PERL		= $(missing) perl
-endif
+# quoted to protect pathname with spaces
+PERL		= '@PERL@'
 perl_archlibexp		= @perl_archlibexp@
 perl_privlibexp		= @perl_privlibexp@
 perl_includespec	= @perl_includespec@
@@ -765,21 +763,13 @@ TAS         = @TAS@
 # Global targets and rules
 
 %.c: %.l
-ifdef FLEX
 	$(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
 	@$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
 	$(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
-else
-	@$(missing) flex $< '$@'
-endif
 
 %.c: %.y
 	$(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
-ifdef BISON
 	$(BISON) $(BISONFLAGS) -o $@ $<
-else
-	@$(missing) bison $< $@
-endif
 
 %.i: %.c
 	$(CPP) $(CPPFLAGS) -o $@ $<
@@ -907,7 +897,7 @@ recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if
 # If a makefile's list of SUBDIRS varies depending on configuration, then
 # any subdirectories excluded from SUBDIRS should instead be added to
 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
-# This ensures that distprep, distclean, etc will apply to all subdirectories.
+# This ensures that distclean, etc will apply to all subdirectories.
 # In the normal case all arguments will be defaulted.
 # $1: targets to make recursive (defaults to standard_always_targets)
 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
@@ -962,7 +952,7 @@ include $(Po_files)
 endif
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-deps
+clean distclean: clean-deps
 
 .PHONY: clean-deps
 clean-deps:
@@ -1046,7 +1036,7 @@ lcov_test.info: $(all_gcda_files)
 
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-coverage
+clean distclean: clean-coverage
 
 .PHONY: clean-coverage
 clean-coverage:
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 1c929383c4..023e14c15c 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -138,63 +138,38 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-catalog-headers:
-	$(MAKE) -C catalog distprep generated-header-symlinks
+	$(MAKE) -C catalog generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-nodes-headers:
-	$(MAKE) -C nodes distprep generated-header-symlinks
+	$(MAKE) -C nodes generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-utils-headers:
-	$(MAKE) -C utils distprep generated-header-symlinks
+	$(MAKE) -C utils generated-header-symlinks
 
 .PHONY: submake-catalog-headers submake-nodes-headers submake-utils-headers
 
 # Make symlinks for these headers in the include directory. That way
 # we can cut down on the -I options. Also, a symlink is automatically
 # up to date when we update the base file.
-#
-# The point of the prereqdir incantation in some of the rules below is to
-# force the symlink to use an absolute path rather than a relative path.
-# For headers which are generated by make distprep, the actual header within
-# src/backend will be in the source tree, while the symlink in src/include
-# will be in the build tree, so a simple ../.. reference won't work.
-# For headers generated during regular builds, we prefer a relative symlink.
 
 .PHONY: generated-headers
 
 generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers
 
 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 $(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 utils/probes.o: utils/probes.d $(SUBDIROBJS)
 	$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
 
 
-##########################################################################
-
-# Be sure that these files get removed by the maintainer-clean target
-distprep:
-	$(MAKE) -C parser	gram.c gram.h scan.c
-	$(MAKE) -C bootstrap	bootparse.c bootparse.h bootscanner.c
-	$(MAKE) -C catalog	distprep
-	$(MAKE) -C nodes	distprep
-	$(MAKE) -C replication	repl_gram.c repl_gram.h repl_scanner.c syncrep_gram.c syncrep_gram.h syncrep_scanner.c
-	$(MAKE) -C storage/lmgr	lwlocknames.h lwlocknames.c
-	$(MAKE) -C utils	distprep
-	$(MAKE) -C utils/activity	wait_event_types.h pgstat_wait_event.c
-	$(MAKE) -C utils/adt	jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
-	$(MAKE) -C utils/misc	guc-file.c
-
-
 ##########################################################################
 
 install: all installdirs install-bin
@@ -290,33 +265,9 @@ ifeq ($(PORTNAME), win32)
 endif
 
 distclean: clean
+# generated by configure
 	rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
 
-maintainer-clean: distclean
-	$(MAKE) -C catalog $@
-	$(MAKE) -C nodes $@
-	$(MAKE) -C utils $@
-	rm -f bootstrap/bootparse.c \
-	      bootstrap/bootparse.h \
-	      bootstrap/bootscanner.c \
-	      parser/gram.c \
-	      parser/gram.h \
-	      parser/scan.c \
-	      replication/repl_gram.c \
-	      replication/repl_gram.h \
-	      replication/repl_scanner.c \
-	      replication/syncrep_gram.c \
-	      replication/syncrep_gram.h \
-	      replication/syncrep_scanner.c \
-	      storage/lmgr/lwlocknames.c \
-	      storage/lmgr/lwlocknames.h \
-	      utils/activity/pgstat_wait_event.c \
-	      utils/activity/wait_event_types.h \
-	      utils/adt/jsonpath_gram.c \
-	      utils/adt/jsonpath_gram.h \
-	      utils/adt/jsonpath_scan.c \
-	      utils/misc/guc-file.c
-
 
 ##########################################################################
 #
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile
index 606c8021e7..509b51e648 100644
--- a/src/backend/bootstrap/Makefile
+++ b/src/backend/bootstrap/Makefile
@@ -28,5 +28,7 @@ bootparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 bootparse.o bootscanner.o: bootparse.h
 
-# bootparse.c and bootscanner.c are in the distribution tarball, so
-# they are not cleaned here.
+clean:
+	rm -f bootparse.c \
+	      bootparse.h \
+	      bootscanner.c
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index a60107bf94..b49666dae2 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -89,9 +89,7 @@ POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
 	pg_ts_template.dat pg_type.dat \
 	)
 
-all: distprep generated-header-symlinks
-
-distprep: bki-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -110,14 +108,12 @@ bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_
 		--set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
 	touch $@
 
-# The generated headers must all be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# The generated headers must all be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than bki-stamp.
 $(top_builddir)/src/include/catalog/header-stamp: bki-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -138,9 +134,5 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
 
-# postgres.bki, system_constraints.sql, and the generated headers are
-# in the distribution tarball, so they are not cleaned here.
 clean:
-
-maintainer-clean: clean
 	rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
index 2da122a391..0036c4f552 100644
--- a/src/backend/jit/llvm/Makefile
+++ b/src/backend/jit/llvm/Makefile
@@ -71,6 +71,6 @@ uninstall-types:
 
 include $(top_srcdir)/src/Makefile.shlib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -f llvmjit_types.bc
diff --git a/src/backend/nls.mk b/src/backend/nls.mk
index 8263527c85..f1464cc5c5 100644
--- a/src/backend/nls.mk
+++ b/src/backend/nls.mk
@@ -22,7 +22,7 @@ GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS) \
     report_invalid_record:2:c-format \
     ereport_startup_progress:1:c-format
 
-gettext-files: distprep
+gettext-files: postgres
 	find $(srcdir) $(srcdir)/../common $(srcdir)/../port -name '*.c' -print | LC_ALL=C sort >$@
 
 my-clean:
diff --git a/src/backend/nodes/Makefile b/src/backend/nodes/Makefile
index 0a95e683d0..ebbe9052cb 100644
--- a/src/backend/nodes/Makefile
+++ b/src/backend/nodes/Makefile
@@ -65,9 +65,7 @@ node_headers = \
 
 # see also catalog/Makefile for an explanation of these make rules
 
-all: distprep generated-header-symlinks
-
-distprep: node-support-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -81,14 +79,12 @@ node-support-stamp: gen_node_support.pl $(addprefix $(top_srcdir)/src/include/,$
 	$(PERL) $^
 	touch $@
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than node-support-stamp.
 $(top_builddir)/src/include/nodes/header-stamp: node-support-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in nodetags.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -98,5 +94,5 @@ outfuncs.o: outfuncs.c outfuncs.funcs.c outfuncs.switch.c | node-support-stamp
 queryjumblefuncs.o: queryjumblefuncs.c queryjumblefuncs.funcs.c queryjumblefuncs.switch.c | node-support-stamp
 readfuncs.o:  readfuncs.c readfuncs.funcs.c readfuncs.switch.c | node-support-stamp
 
-maintainer-clean: clean
+clean:
 	rm -f node-support-stamp $(addsuffix funcs.funcs.c,copy equal out queryjumble read) $(addsuffix funcs.switch.c,copy equal out queryjumble read) nodetags.h
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 9f1c4022bb..401c16686c 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -64,8 +64,8 @@ scan.c: FLEX_FIX_WARNING=yes
 # Force these dependencies to be known even without dependency info built:
 gram.o scan.o parser.o: gram.h
 
-
-# gram.c, gram.h, and scan.c are in the distribution tarball, so they
-# are not cleaned here.
-clean distclean maintainer-clean:
+clean:
+	rm -f gram.c \
+	      gram.h \
+	      scan.c
 	rm -f lex.backup
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 2d00b4f05a..47338d9922 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -43,6 +43,6 @@ else
 	$(CC) $(CFLAGS) -c $<
 endif
 
-distclean clean:
+clean:
 	rm -f tas_cpp.s
 	$(MAKE) -C win32 clean
diff --git a/src/backend/replication/Makefile b/src/backend/replication/Makefile
index 23f29ba545..7f867ee91d 100644
--- a/src/backend/replication/Makefile
+++ b/src/backend/replication/Makefile
@@ -48,6 +48,10 @@ syncrep_gram.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 syncrep_gram.o syncrep_scanner.o: syncrep_gram.h
 
-# repl_gram.c, repl_scanner.c, syncrep_gram.c and syncrep_scanner.c
-# are in the distribution tarball, so they are not cleaned here.
-# (Our parent Makefile takes care of them during maintainer-clean.)
+clean:
+	rm -f repl_gram.c \
+	      repl_gram.h \
+	      repl_scanner.c \
+	      syncrep_gram.c \
+	      syncrep_gram.h \
+	      syncrep_scanner.c
diff --git a/src/backend/replication/libpqwalreceiver/Makefile b/src/backend/replication/libpqwalreceiver/Makefile
index f26daa135f..e882907350 100644
--- a/src/backend/replication/libpqwalreceiver/Makefile
+++ b/src/backend/replication/libpqwalreceiver/Makefile
@@ -33,5 +33,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/replication/pgoutput/Makefile b/src/backend/replication/pgoutput/Makefile
index 3b41fbcfac..d89d317fe7 100644
--- a/src/backend/replication/pgoutput/Makefile
+++ b/src/backend/replication/pgoutput/Makefile
@@ -28,5 +28,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/snowball/Makefile b/src/backend/snowball/Makefile
index 4bebfa0250..efc4300eb9 100644
--- a/src/backend/snowball/Makefile
+++ b/src/backend/snowball/Makefile
@@ -104,8 +104,6 @@ include $(top_srcdir)/src/Makefile.shlib
 $(SQLSCRIPT): snowball_create.pl snowball_func.sql.in snowball.sql.in
 	$(PERL) $< --input ${srcdir} --outdir .
 
-distprep: $(SQLSCRIPT)
-
 install: all installdirs install-lib install-script
 	$(INSTALL_DATA) $(addprefix $(srcdir)/stopwords/,$(stop_files)) '$(DESTDIR)$(datadir)/$(DICTDIR)'
 
@@ -122,6 +120,4 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
 	rm -f $(SQLSCRIPT)
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index b25b7ee421..c48ba943c4 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -45,8 +45,6 @@ lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt generate-l
 check: s_lock_test
 	./s_lock_test
 
-clean distclean:
+clean:
 	rm -f s_lock_test
-
-maintainer-clean: clean
 	rm -f lwlocknames.h lwlocknames.c
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index deb901609f..e184e3dfdf 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -34,13 +34,14 @@ catalogdir  = $(top_srcdir)/src/backend/catalog
 
 include $(top_srcdir)/src/backend/common.mk
 
-all: distprep probes.h generated-header-symlinks
+all: probes.h generated-header-symlinks
 
-distprep: fmgr-stamp errcodes.h
+.PHONY: generated-header-symlinks submake-adt-headers
 
-.PHONY: generated-header-symlinks
+generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp submake-adt-headers
 
-generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_builddir)/src/include/utils/probes.h
+submake-adt-headers:
+	$(MAKE) -C adt jsonpath_gram.h
 
 $(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h
 
@@ -66,22 +67,15 @@ probes.h: Gen_dummy_probes.sed probes.d
 	sed -f $^ >$@
 endif
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than fmgr-stamp.
-$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h
+	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h; do \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
-# probes.h is handled differently because it's not in the distribution tarball.
-$(top_builddir)/src/include/utils/probes.h: probes.h
-	cd '$(dir $@)' && rm -f $(notdir $@) && \
-	    $(LN_S) "../../../$(subdir)/probes.h" .
-
 # Recipe for rebuilding the Perl version of Gen_dummy_probes
 # Nothing depends on it, so it will never be called unless explicitly requested
 # The last two lines of the recipe format the script according to  our
@@ -104,10 +98,6 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, errcodes.txt)
 
-# fmgroids.h, fmgrprotos.h, fmgrtab.c, fmgr-stamp, and errcodes.h are in the
-# distribution tarball, so they are not cleaned here.
 clean:
 	rm -f probes.h probes.h.tmp
-
-maintainer-clean: clean
 	rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h
diff --git a/src/backend/utils/activity/Makefile b/src/backend/utils/activity/Makefile
index f1117745d4..ac76cf782d 100644
--- a/src/backend/utils/activity/Makefile
+++ b/src/backend/utils/activity/Makefile
@@ -43,5 +43,5 @@ pgstat_wait_event.c: wait_event_types.h
 wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt generate-wait_event_types.pl
 	$(PERL) $(srcdir)/generate-wait_event_types.pl --code $<
 
-maintainer-clean: clean
+clean:
 	rm -f wait_event_types.h pgstat_wait_event.c
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile
index 0de0bbb1b8..199eae525d 100644
--- a/src/backend/utils/adt/Makefile
+++ b/src/backend/utils/adt/Makefile
@@ -132,10 +132,9 @@ jsonpath_scan.c: FLEX_NO_BACKUP=yes
 # Force these dependencies to be known even without dependency info built:
 jsonpath_gram.o jsonpath_scan.o: jsonpath_gram.h
 
-# jsonpath_gram.c and jsonpath_scan.c are in the distribution tarball,
-# so they are not cleaned here.
-clean distclean maintainer-clean:
+clean:
 	rm -f lex.backup
+	rm -f jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
 
 like.o: like.c like_match.c
 
diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile
index b19a125fa2..bbde71b5aa 100644
--- a/src/backend/utils/mb/Makefile
+++ b/src/backend/utils/mb/Makefile
@@ -21,5 +21,5 @@ OBJS = \
 
 include $(top_srcdir)/src/backend/common.mk
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C conversion_procs $@
diff --git a/src/backend/utils/mb/Unicode/Makefile b/src/backend/utils/mb/Unicode/Makefile
index 728ccb99c2..6c0a8150f2 100644
--- a/src/backend/utils/mb/Unicode/Makefile
+++ b/src/backend/utils/mb/Unicode/Makefile
@@ -66,8 +66,6 @@ all: $(MAPS)
 
 distclean: clean
 	rm -f $(TEXTS)
-
-maintainer-clean: distclean
 	rm -f $(MAPS)
 
 
diff --git a/src/backend/utils/mb/conversion_procs/proc.mk b/src/backend/utils/mb/conversion_procs/proc.mk
index e0a3b74b25..2eeae28240 100644
--- a/src/backend/utils/mb/conversion_procs/proc.mk
+++ b/src/backend/utils/mb/conversion_procs/proc.mk
@@ -13,5 +13,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/utils/misc/Makefile b/src/backend/utils/misc/Makefile
index 2910032930..c2971c7678 100644
--- a/src/backend/utils/misc/Makefile
+++ b/src/backend/utils/misc/Makefile
@@ -40,6 +40,5 @@ endif
 
 include $(top_srcdir)/src/backend/common.mk
 
-# Note: guc-file.c is not deleted by 'make clean',
-# since we want to ship it in distribution tarballs.
 clean:
+	rm -f guc-file.c
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index d69bd89572..7043289239 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -55,7 +55,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/initdb$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f initdb$(X) $(OBJS) localtime.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_amcheck/Makefile b/src/bin/pg_amcheck/Makefile
index 947f2267ed..528c588e35 100644
--- a/src/bin/pg_amcheck/Makefile
+++ b/src/bin/pg_amcheck/Makefile
@@ -40,7 +40,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_amcheck$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_amcheck$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index 49935d6dce..93fd703f22 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -25,7 +25,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_archivecleanup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_archivecleanup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile
index 893a75c942..74dc1ddd6d 100644
--- a/src/bin/pg_basebackup/Makefile
+++ b/src/bin/pg_basebackup/Makefile
@@ -71,7 +71,7 @@ uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_receivewal$(X)'
 	rm -f '$(DESTDIR)$(bindir)/pg_recvlogical$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_basebackup$(X) pg_receivewal$(X) pg_recvlogical$(X) \
 		$(BBOBJS) pg_receivewal.o pg_recvlogical.o \
 		$(OBJS)
diff --git a/src/bin/pg_checksums/Makefile b/src/bin/pg_checksums/Makefile
index 4911f6bee2..ac736b2260 100644
--- a/src/bin/pg_checksums/Makefile
+++ b/src/bin/pg_checksums/Makefile
@@ -36,7 +36,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_checksums$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_checksums$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index 1a405f9c97..cb13aceafa 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_config$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_config$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index aa5bd58222..00ee1e25b3 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_controldata$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_controldata$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index 4b6d47a8f8..4d29ca72c1 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -42,7 +42,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_ctl$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_ctl$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 24de7593a6..604cddb997 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -69,6 +69,6 @@ installcheck:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o
 	rm -rf tmp_check
diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile
index a363b948b5..a06e493ba8 100644
--- a/src/bin/pg_resetwal/Makefile
+++ b/src/bin/pg_resetwal/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_resetwal$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_resetwal$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
index bed05f1609..8df1da80cb 100644
--- a/src/bin/pg_rewind/Makefile
+++ b/src/bin/pg_rewind/Makefile
@@ -49,7 +49,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_rewind$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_rewind$(X) $(OBJS) xlogreader.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index 631d0f38a8..4c5e518125 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_fsync$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index 84d84c38aa..7f677edadb 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_timing$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_timing$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 5834513add..f76aca1b1a 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -46,7 +46,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_upgrade$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_upgrade$(X) $(OBJS)
 	rm -rf delete_old_cluster.sh log/ tmp_check/ \
 	       reindex_hash.sql
diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile
index 596df15118..c96323faa9 100644
--- a/src/bin/pg_verifybackup/Makefile
+++ b/src/bin/pg_verifybackup/Makefile
@@ -38,7 +38,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_verifybackup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile
index 0ecf582039..4c1ee64950 100644
--- a/src/bin/pg_waldump/Makefile
+++ b/src/bin/pg_waldump/Makefile
@@ -45,7 +45,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_waldump$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_waldump$(X) $(OBJS) $(RMGRDESCSOURCES) xlogreader.c xlogstats.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index 68b6eb0376..987bf64df9 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -38,8 +38,6 @@ exprparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 exprparse.o exprscan.o: exprparse.h
 
-distprep: exprparse.c exprscan.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pgbench$(X) '$(DESTDIR)$(bindir)/pgbench$(X)'
 
@@ -52,8 +50,6 @@ uninstall:
 clean distclean:
 	rm -f pgbench$(X) $(OBJS)
 	rm -rf tmp_check
-
-maintainer-clean: distclean
 	rm -f exprparse.h exprparse.c exprscan.c
 
 check:
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 1f2bf0c6b0..8ad7c65446 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -62,8 +62,6 @@ psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
 psqlscanslash.c: FLEX_NO_BACKUP=yes
 psqlscanslash.c: FLEX_FIX_WARNING=yes
 
-distprep: sql_help.h sql_help.c psqlscanslash.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
 	$(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
@@ -77,10 +75,6 @@ uninstall:
 clean distclean:
 	rm -f psql$(X) $(OBJS) lex.backup
 	rm -rf tmp_check
-
-# files removed here are supposed to be in the distribution tarball,
-# so do not clean them in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f sql_help.h sql_help.c psqlscanslash.c
 
 check:
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index a7a9d0fea5..20db40b103 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -48,7 +48,7 @@ installdirs:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(addsuffix $(X), $(PROGRAMS)))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS))
 	rm -f common.o $(WIN32RES)
 	rm -rf tmp_check
diff --git a/src/common/Makefile b/src/common/Makefile
index 113029bf7b..ec063c6e18 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -121,8 +121,6 @@ GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
 
 all: libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 
-distprep: kwlist_d.h
-
 # libpgcommon is needed by some contrib
 install: all installdirs
 	$(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
@@ -188,10 +186,7 @@ RYU_OBJS = $(RYU_FILES) $(RYU_FILES:%.o=%_shlib.o) $(RYU_FILES:%.o=%_srv.o)
 
 $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
 
-# kwlist_d.h is in the distribution tarball, so it is not cleaned here.
 clean distclean:
 	rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 	rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)
-
-maintainer-clean: distclean
 	rm -f kwlist_d.h
diff --git a/src/common/unicode/Makefile b/src/common/unicode/Makefile
index 382da476cf..d6e427b582 100644
--- a/src/common/unicode/Makefile
+++ b/src/common/unicode/Makefile
@@ -68,5 +68,3 @@ clean:
 
 distclean: clean
 	rm -f UnicodeData.txt EastAsianWidth.txt CompositionExclusions.txt NormalizationTest.txt norm_test_table.h unicode_norm_table.h
-
-maintainer-clean: distclean
diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile
index 456d6dd390..8accd5906d 100644
--- a/src/fe_utils/Makefile
+++ b/src/fe_utils/Makefile
@@ -48,8 +48,6 @@ psqlscan.c: FLEXFLAGS = -Cfe -p -p
 psqlscan.c: FLEX_NO_BACKUP=yes
 psqlscan.c: FLEX_FIX_WARNING=yes
 
-distprep: psqlscan.c
-
 # libpgfeutils could be useful to contrib, so install it
 install: all installdirs
 	$(INSTALL_STLIB) libpgfeutils.a '$(DESTDIR)$(libdir)/libpgfeutils.a'
@@ -62,8 +60,4 @@ uninstall:
 
 clean distclean:
 	rm -f libpgfeutils.a $(OBJS) lex.backup
-
-# psqlscan.c is supposed to be in the distribution tarball,
-# so do not clean it in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f psqlscan.c
diff --git a/src/include/Makefile b/src/include/Makefile
index 5d213187e2..0dfe7d9e23 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -77,5 +77,5 @@ clean:
 	rm -f catalog/pg_*_d.h catalog/header-stamp
 	rm -f nodes/nodetags.h nodes/header-stamp
 
-distclean maintainer-clean: clean
+distclean: clean
 	rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index e4bbf7b8a8..3002bc3c1b 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -23,7 +23,7 @@ install-pgtypeslib-recurse install-ecpglib-recurse install-compatlib-recurse ins
 install-compatlib-recurse: install-ecpglib-recurse
 install-ecpglib-recurse: install-pgtypeslib-recurse
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C test clean
 
 checktcp: | temp-install
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index b9483fba08..695fd1a080 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -55,5 +55,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 652e023405..103cce393a 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -66,5 +66,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/include/Makefile b/src/interfaces/ecpg/include/Makefile
index 9c68bf3c47..3476409cef 100644
--- a/src/interfaces/ecpg/include/Makefile
+++ b/src/interfaces/ecpg/include/Makefile
@@ -31,5 +31,5 @@ uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers))
 	rm -f '$(DESTDIR)$(includedir)'/$(notdir $(ecpg_config_h))
 
-distclean maintainer-clean:
+distclean:
 	rm -f ecpg_config.h stamp-h
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index b0e154eb15..e56700a12e 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -50,5 +50,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 77ae9ab722..afd46cd17c 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -81,8 +81,6 @@ ecpg_keywords.o: ecpg_kwlist_d.h
 c_keywords.o: c_kwlist_d.h
 keywords.o: $(top_srcdir)/src/include/parser/kwlist.h
 
-distprep: preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
-
 install: all installdirs
 	$(INSTALL_PROGRAM) ecpg$(X) '$(DESTDIR)$(bindir)'
 
@@ -92,11 +90,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/ecpg$(X)'
 
-# preproc.y, preproc.c, preproc.h, pgc.c, c_kwlist_d.h, and ecpg_kwlist_d.h
-# are in the distribution tarball, so they are not cleaned here.
 clean distclean:
 	rm -f *.o ecpg$(X)
 	rm -f typename.c
-
-maintainer-clean: distclean
 	rm -f preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index cf841a3a5b..3769488f16 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -20,7 +20,7 @@ else
 abs_builddir := $(shell sh -c "pwd -W")
 endif
 
-all install installdirs uninstall distprep:
+all install installdirs uninstall:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
@@ -29,7 +29,7 @@ all install installdirs uninstall distprep:
 	$(MAKE) -C compat_oracle $@
 	$(MAKE) -C thread $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 46653682b0..d0a66cfaa0 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -165,6 +165,3 @@ clean distclean: clean-lib
 	rm -f $(OBJS) pthread.h libpq-refs-stamp
 # Might be left over from a Win32 client-only build
 	rm -f pg_config_paths.h
-
-maintainer-clean: distclean
-	$(MAKE) -C test $@
diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile
index 75ac08f943..4e17ec1514 100644
--- a/src/interfaces/libpq/test/Makefile
+++ b/src/interfaces/libpq/test/Makefile
@@ -20,5 +20,5 @@ all: $(PROGS)
 
 $(PROGS): $(WIN32RES)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 7ba8d5bc98..0de3737e78 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -391,7 +391,7 @@ ifdef MODULE_big
 clean: clean-lib
 endif
 
-distclean maintainer-clean: clean
+distclean: clean
 
 
 ifdef REGRESS
diff --git a/src/nls-global.mk b/src/nls-global.mk
index f21bd5ed55..dfff472cb3 100644
--- a/src/nls-global.mk
+++ b/src/nls-global.mk
@@ -171,7 +171,7 @@ all: all-po
 install: install-po
 installdirs: installdirs-po
 uninstall: uninstall-po
-clean distclean maintainer-clean: clean-po
+clean distclean: clean-po
 
 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
         init-po update-po
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index 51f8890d15..975f540b3e 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -127,7 +127,7 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index f7eb42d54f..dfb815212f 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile
@@ -104,14 +104,7 @@ submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
 
-distprep: pl_gram.h pl_gram.c plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
-
-# pl_gram.c, pl_gram.h, plerrcodes.h, pl_reserved_kwlist_d.h, and
-# pl_unreserved_kwlist_d.h are in the distribution tarball, so they
-# are not cleaned here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f pl_gram.c pl_gram.h plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index 6b1865c240..ef0a5905ae 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -142,6 +142,7 @@ clean distclean: clean-lib
 ifeq ($(PORTNAME), win32)
 	rm -f python${pytverstr}.def
 endif
+	rm -f spiexceptions.h
 
 
 # Force this dependency to be known even without dependency info built:
@@ -149,8 +150,3 @@ plpy_plpymodule.o: spiexceptions.h
 
 spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
 	$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
-
-distprep: spiexceptions.h
-
-maintainer-clean: distclean
-	rm -f spiexceptions.h
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index 314f9b2eec..ea52a2efc2 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -63,8 +63,6 @@ pltcl.o: pltclerrcodes.h
 pltclerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-pltclerrcodes.pl
 	$(PERL) $(srcdir)/generate-pltclerrcodes.pl $< > $@
 
-distprep: pltclerrcodes.h
-
 install: all install-lib install-data
 
 installdirs: installdirs-lib
@@ -91,13 +89,10 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-# pltclerrcodes.h is in the distribution tarball, so don't clean it here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
 	rm -f $(tclwithver).def
 endif
-
-maintainer-clean: distclean
 	rm -f pltclerrcodes.h
diff --git a/src/port/Makefile b/src/port/Makefile
index f205c2c9c5..4320dee0d1 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -154,6 +154,6 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
 	echo "#define HTMLDIR \"$(htmldir)\"" >>$@
 	echo "#define MANDIR \"$(mandir)\"" >>$@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f libpgport.a libpgport_shlib.a libpgport_srv.a
 	rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h
diff --git a/src/test/authentication/Makefile b/src/test/authentication/Makefile
index 46fa72052d..a48ce39aaf 100644
--- a/src/test/authentication/Makefile
+++ b/src/test/authentication/Makefile
@@ -19,5 +19,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/examples/Makefile b/src/test/examples/Makefile
index a67f456904..e72d058e0c 100644
--- a/src/test/examples/Makefile
+++ b/src/test/examples/Makefile
@@ -18,5 +18,5 @@ PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo testlo64
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/test/icu/Makefile b/src/test/icu/Makefile
index 033b0d03cc..c4fc8cdb8c 100644
--- a/src/test/icu/Makefile
+++ b/src/test/icu/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index b8738b7c1b..8f5192fb37 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -43,8 +43,6 @@ pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
 isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
 	$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
-distprep: specparse.c specscanner.c
-
 # See notes in src/backend/parser/Makefile about the following two rules
 specparse.h: specparse.c
 	touch $@
@@ -60,8 +58,6 @@ clean distclean:
 	rm -f isolationtester$(X) pg_isolation_regress$(X) $(OBJS) isolation_main.o
 	rm -f pg_regress.o
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f specparse.h specparse.c specscanner.c
 
 installcheck: all
diff --git a/src/test/kerberos/Makefile b/src/test/kerberos/Makefile
index f460d2c0e7..44da65611e 100644
--- a/src/test/kerberos/Makefile
+++ b/src/test/kerberos/Makefile
@@ -24,5 +24,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/ldap/Makefile b/src/test/ldap/Makefile
index 73bc878ea8..d4305ed5eb 100644
--- a/src/test/ldap/Makefile
+++ b/src/test/ldap/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/locale/Makefile b/src/test/locale/Makefile
index 7ba096b542..a40c67af07 100644
--- a/src/test/locale/Makefile
+++ b/src/test/locale/Makefile
@@ -10,7 +10,7 @@ DIRS = de_DE.ISO8859-1 gr_GR.ISO8859-7 koi8-r koi8-to-win1251
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
 	rm -rf tmp_check
 	for d in $(DIRS); do \
diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile
index c60314d195..49f1d1c118 100644
--- a/src/test/recovery/Makefile
+++ b/src/test/recovery/Makefile
@@ -25,5 +25,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 38c3a1f85b..388f2700bd 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -146,7 +146,7 @@ bigcheck: all | temp-install
 ## Clean up
 ##
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 # things built by `all' target
 	rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
 	rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
diff --git a/src/test/ssl/Makefile b/src/test/ssl/Makefile
index af1e06e949..2d7c69068f 100644
--- a/src/test/ssl/Makefile
+++ b/src/test/ssl/Makefile
@@ -23,7 +23,7 @@ export OPENSSL with_ssl
 sslfiles sslfiles-clean:
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
diff --git a/src/test/ssl/sslfiles.mk b/src/test/ssl/sslfiles.mk
index f7ababe42c..62b2272183 100644
--- a/src/test/ssl/sslfiles.mk
+++ b/src/test/ssl/sslfiles.mk
@@ -269,6 +269,6 @@ sslfiles-clean:
 # clean targets will be run during a "standard" recursive clean run from the
 # main build tree. The sslfiles-clean target must be run explicitly from this
 # directory.
-.PHONY: clean distclean maintainer-clean
-clean distclean maintainer-clean:
+.PHONY: clean distclean
+clean distclean:
 	rm -rf ssl/*.old ssl/new_certs_dir ssl/client*_tmp.key
diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile
index 99d1fe012d..36475ffabc 100644
--- a/src/test/subscription/Makefile
+++ b/src/test/subscription/Makefile
@@ -23,5 +23,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/timezone/Makefile b/src/timezone/Makefile
index fbbaae4cc5..c85e831247 100644
--- a/src/timezone/Makefile
+++ b/src/timezone/Makefile
@@ -75,5 +75,5 @@ ifeq (,$(with_system_tzdata))
 endif
 	$(MAKE) -C tznames $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f zic$(X) $(ZICOBJS) abbrevs.txt
diff --git a/src/tools/ifaddrs/Makefile b/src/tools/ifaddrs/Makefile
index e74d754769..ef5e8f0e0e 100644
--- a/src/tools/ifaddrs/Makefile
+++ b/src/tools/ifaddrs/Makefile
@@ -24,5 +24,5 @@ all: test_ifaddrs
 test_ifaddrs: test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o
 	$(CC) $(CFLAGS) test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f test_ifaddrs$(X) $(OBJS)
diff --git a/src/tools/pg_bsd_indent/Makefile b/src/tools/pg_bsd_indent/Makefile
index d176ceb326..ce5d815f07 100644
--- a/src/tools/pg_bsd_indent/Makefile
+++ b/src/tools/pg_bsd_indent/Makefile
@@ -39,7 +39,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_bsd_indent$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_bsd_indent$(X) $(OBJS)
 	rm -rf log/ tmp_check/
 

base-commit: 00f2a2556c9b23050e4f987e5d563b6856b83fc2
-- 
2.41.0

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#5)
Re: Remove distprep

Peter Eisentraut <peter@eisentraut.org> writes:

Ah, there was a reason. The headerscheck and cpluspluscheck targets
need jsonpath_gram.h to be built first. Which previously happened
indirectly somehow? I have fixed this in the new patch version. I also
fixed the issue that Álvaro reported nearby.

Have we yet run this concept past the packagers list? I'm still
wondering if they will raise any objection to getting rid of all
the prebuilt files.

Also, I personally don't like the fact that you have removed the
distinction between distclean and maintainer-clean. I use
distclean-and-reconfigure quite a lot to avoid having to rebuild
bison/flex outputs. This patch seems to have destroyed that
workflow optimization in return for not much.

regards, tom lane

#7Christoph Berg
myon@debian.org
In reply to: Tom Lane (#6)
Re: Remove distprep

Re: Tom Lane

Have we yet run this concept past the packagers list? I'm still
wondering if they will raise any objection to getting rid of all
the prebuilt files.

No problem for Debian, we are building snapshot releases from plain
git already without issues. In fact, there are already some explicit
rm/clean rules in the packages to force rebuilding some (most?) of the
pre-built files.

Most notably, we are also rebuilding "configure" using autoconf 2.71
without issues. Perhaps we can get rid of the 2.69 hardcoding there?

Thanks for the heads-up,
Christoph

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christoph Berg (#7)
Re: Remove distprep

Christoph Berg <myon@debian.org> writes:

Most notably, we are also rebuilding "configure" using autoconf 2.71
without issues. Perhaps we can get rid of the 2.69 hardcoding there?

Meh ... the fact that it works fine for you doesn't mean it will work
fine elsewhere. Since we're trying to get out from under maintaining
the autoconf build system, I don't think it makes sense to open
ourselves up to having to do more work on it. A policy of benign
neglect seems appropriate to me.

regards, tom lane

#9Christoph Berg
myon@debian.org
In reply to: Tom Lane (#8)
Re: Remove distprep

Re: Tom Lane

Meh ... the fact that it works fine for you doesn't mean it will work
fine elsewhere. Since we're trying to get out from under maintaining
the autoconf build system, I don't think it makes sense to open
ourselves up to having to do more work on it. A policy of benign
neglect seems appropriate to me.

Understood, I was just pointing out there are more types of generated
files in there.

Christoph

#10Andres Freund
andres@anarazel.de
In reply to: Christoph Berg (#9)
Re: Remove distprep

Hi,

Thanks for sending the -packagers email Peter!

On 2023-08-09 16:25:28 +0200, Christoph Berg wrote:

Re: Tom Lane

Meh ... the fact that it works fine for you doesn't mean it will work
fine elsewhere. Since we're trying to get out from under maintaining
the autoconf build system, I don't think it makes sense to open
ourselves up to having to do more work on it. A policy of benign
neglect seems appropriate to me.

Understood, I was just pointing out there are more types of generated
files in there.

The situation for configure is somewhat different, due to being maintained in
the repository, rather than just being included in the tarball...

Greetings,

Andres Freund

#11Peter Eisentraut
peter@eisentraut.org
In reply to: Tom Lane (#6)
Re: Remove distprep

On 14.07.23 11:48, Tom Lane wrote:

Peter Eisentraut <peter@eisentraut.org> writes:

Ah, there was a reason. The headerscheck and cpluspluscheck targets
need jsonpath_gram.h to be built first. Which previously happened
indirectly somehow? I have fixed this in the new patch version. I also
fixed the issue that Álvaro reported nearby.

Have we yet run this concept past the packagers list? I'm still
wondering if they will raise any objection to getting rid of all
the prebuilt files.

So far there hasn't been any feedback from packagers that would appear
to affect the outcome here.

Also, I personally don't like the fact that you have removed the
distinction between distclean and maintainer-clean. I use
distclean-and-reconfigure quite a lot to avoid having to rebuild
bison/flex outputs. This patch seems to have destroyed that
workflow optimization in return for not much.

The distclean target has a standard meaning that is baked into
downstream build systems, so it would be pretty disruptive if distclean
didn't actually clean everything back down to what was in the
distribution tarball. We could add a different clean target that cleans
not quite everything, if you can suggest a definition of what that
should do.

#12Michael Paquier
michael@paquier.xyz
In reply to: Andres Freund (#10)
Re: Remove distprep

On Wed, Aug 09, 2023 at 07:38:40AM -0700, Andres Freund wrote:

On 2023-08-09 16:25:28 +0200, Christoph Berg wrote:

Understood, I was just pointing out there are more types of generated
files in there.

The situation for configure is somewhat different, due to being maintained in
the repository, rather than just being included in the tarball...

This one comes down to Debian that patches autoconf with its own set
of options, requiring a new ./configure in the tree, right?
--
Michael

#13Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#12)
Re: Remove distprep

On 2023-08-18 10:11:12 +0900, Michael Paquier wrote:

On Wed, Aug 09, 2023 at 07:38:40AM -0700, Andres Freund wrote:

On 2023-08-09 16:25:28 +0200, Christoph Berg wrote:

Understood, I was just pointing out there are more types of generated
files in there.

The situation for configure is somewhat different, due to being maintained in
the repository, rather than just being included in the tarball...

This one comes down to Debian that patches autoconf with its own set
of options, requiring a new ./configure in the tree, right?

I'm not sure what you're really asking here?

#14Christoph Berg
myon@debian.org
In reply to: Michael Paquier (#12)
Re: Remove distprep

Re: Michael Paquier

This one comes down to Debian that patches autoconf with its own set
of options, requiring a new ./configure in the tree, right?

Yes, mostly. Since autoconf had not seen a new release for so long,
everyone started to patch it, and one of the things that Debian and
others added was --runstatedir=DIR. The toolchain is also using it,
it's part of the default set of options used by dh_auto_configure.

In parallel, the standard debhelper toolchain also started to run
autoreconf by default, so instead of telling dh_auto_configure to omit
--runstatedir, it was really easier to patch configure.ac to remove
the autoconf 2.69 check.

Two of the other patches are touching configure(.ac) anyway to tweak
compiler flags (reproducibility, aarch64 tweaks).

Christoph

#15Michael Paquier
michael@paquier.xyz
In reply to: Christoph Berg (#14)
Re: Remove distprep

On Fri, Aug 18, 2023 at 10:22:47AM +0200, Christoph Berg wrote:

Yes, mostly. Since autoconf had not seen a new release for so long,
everyone started to patch it, and one of the things that Debian and
others added was --runstatedir=DIR. The toolchain is also using it,
it's part of the default set of options used by dh_auto_configure.

In parallel, the standard debhelper toolchain also started to run
autoreconf by default, so instead of telling dh_auto_configure to omit
--runstatedir, it was really easier to patch configure.ac to remove
the autoconf 2.69 check.

Ah, I didn't know this part of the story. Thanks for the insights.

Two of the other patches are touching configure(.ac) anyway to tweak
compiler flags (reproducibility, aarch64 tweaks).

Is reproducibility something you've brought to a separate thread?
FWIW, I'd be interested in improving this area for the in-core code,
if need be. (Not material for this thread, of course).
--
Michael

#16Christoph Berg
myon@debian.org
In reply to: Michael Paquier (#15)
Reproducibility (Re: Remove distprep)

Re: Michael Paquier

Is reproducibility something you've brought to a separate thread?
FWIW, I'd be interested in improving this area for the in-core code,
if need be. (Not material for this thread, of course).

All the "normal" things like C compilation are actually already
reproducible.

The bit addressed by the mentioned patch is that the compiler flags
are recorded for later output by pg_config, and that includes
-ffile-prefix-map=/path/to/source=. which does improve C
reproducibility, but ironically is itself not reproducible when the
source is then compiled in a different directory. The patch simply
removes that flag from the information stored.

https://salsa.debian.org/postgresql/postgresql/-/blob/15/debian/patches/filter-debug-prefix-map

Not sure not much of that would be material for inclusion in PG.

This fix made PG 10 reproducible in Debian for about a week. Then LLVM
happened :D. The .bc files still record the build path, and so far no
one has found a way to prevent that:

https://tests.reproducible-builds.org/debian/rb-pkg/unstable/arm64/diffoscope-results/postgresql-15.html

Afaict that's the last part to be resolved (but it's been a while
since I checked). clang seems to have learned about -ffile-prefix-map=
in the meantime, that needs to be tested.

Christoph

#17Peter Eisentraut
peter@eisentraut.org
In reply to: Peter Eisentraut (#5)
1 attachment(s)
Re: Remove distprep

On 14.07.23 10:56, Peter Eisentraut wrote:

On 14.07.23 09:54, Peter Eisentraut wrote:

diff --git a/src/tools/pginclude/cpluspluscheck 
b/src/tools/pginclude/cpluspluscheck
index 4e09c4686b..287395887c 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -134,6 +134,9 @@ do
      test "$f" = src/interfaces/ecpg/preproc/preproc.h && continue
      test "$f" = src/test/isolation/specparse.h && continue
+    # FIXME
+    test "$f" = src/backend/utils/adt/jsonpath_internal.h && continue
+
      # ppport.h is not under our control, so we can't make it 
standalone.
      test "$f" = src/pl/plperl/ppport.h && continue

Hm, what's that about?

Don't remember ... ;-)  I removed this.

Ah, there was a reason.  The headerscheck and cpluspluscheck targets
need jsonpath_gram.h to be built first.  Which previously happened
indirectly somehow?  I have fixed this in the new patch version.  I also
fixed the issue that Álvaro reported nearby.

Apparently, the headerscheck and cpluspluscheck targets still didn't
work right in the Cirrus jobs. Here is an updated patch to address
that. This is also rebased over some recent changes that affected this
patch (generated wait events stuff).

Attachments:

v4-0001-Remove-distprep.patchtext/plain; charset=UTF-8; name=v4-0001-Remove-distprep.patchDownload
From c386175ab4194aa2b17a8374f73a9de4aa0edb56 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 23 Aug 2023 12:15:42 +0200
Subject: [PATCH v4] Remove distprep

A PostgreSQL release tarball contains a number of prebuilt files, in
particular files produced by bison, flex, perl, and well as html and
man documentation.  We have done this consistent with established
practice at the time to not require these tools for building from a
tarball.  Some of these tools were hard to get, or get the right
version of, from time to time, and shipping the prebuilt output was a
convenience to users.

Now this has at least two problems:

One, we have to make the build system(s) work in two modes: Building
from a git checkout and building from a tarball.  This is pretty
complicated, but it works so far for autoconf/make.  It does not
currently work for meson; you can currently only build with meson from
a git checkout.  Making meson builds work from a tarball seems very
difficult or impossible.  One particular problem is that since meson
requires a separate build directory, we cannot make the build update
files like gram.h in the source tree.  So if you were to build from a
tarball and update gram.y, you will have a gram.h in the source tree
and one in the build tree, but the way things work is that the
compiler will always use the one in the source tree.  So you cannot,
for example, make any gram.y changes when building from a tarball.
This seems impossible to fix in a non-horrible way.

Second, there is increased interest nowadays in precisely tracking the
origin of software.  We can reasonably track contributions into the
git tree, and users can reasonably track the path from a tarball to
packages and downloads and installs.  But what happens between the git
tree and the tarball is obscure and in some cases non-reproducible.

The solution for both of these issues is to get rid of the step that
adds prebuilt files to the tarball.  The tarball now only contains
what is in the git tree (*).  Getting the additional build
dependencies is no longer a problem nowadays, and the complications to
keep these dual build modes working are significant.  And of course we
want to get the meson build system working universally.

This commit removes the make distprep target altogether.  The make
dist target continues to do its job, it just doesn't call distprep
anymore.

(*) - The tarball also contains the INSTALL file that is built at make
dist time, but not by distprep.  This is unchanged for now.

The make maintainer-clean target, whose job it is to remove the
prebuilt files in addition to what make distclean does, is now just an
alias to make distprep.  (In practice, it is probably obsolete given
that git clean is available.)

The following programs are now hard build requirements in configure
(they were already required by meson.build):

- bison
- flex
- perl
---
 GNUmakefile.in                                |  6 +-
 config/perl.m4                                |  9 +-
 config/programs.m4                            | 21 +----
 configure                                     | 62 ++------------
 contrib/cube/Makefile                         |  7 +-
 contrib/fuzzystrmatch/Makefile                |  9 +-
 contrib/seg/Makefile                          |  7 +-
 doc/Makefile                                  |  2 +-
 doc/src/Makefile                              |  2 +-
 doc/src/sgml/Makefile                         |  9 +-
 doc/src/sgml/installation.sgml                | 83 ++++++++-----------
 meson.build                                   |  2 +-
 src/Makefile                                  |  5 +-
 src/Makefile.global.in                        | 30 +++----
 src/backend/Makefile                          | 68 ++-------------
 src/backend/bootstrap/Makefile                |  6 +-
 src/backend/catalog/Makefile                  | 14 +---
 src/backend/jit/llvm/Makefile                 |  2 +-
 src/backend/nls.mk                            |  2 +-
 src/backend/nodes/Makefile                    | 12 +--
 src/backend/parser/Makefile                   |  8 +-
 src/backend/port/Makefile                     |  2 +-
 src/backend/replication/Makefile              | 10 ++-
 .../replication/libpqwalreceiver/Makefile     |  2 +-
 src/backend/replication/pgoutput/Makefile     |  2 +-
 src/backend/snowball/Makefile                 |  4 -
 src/backend/storage/lmgr/Makefile             |  4 +-
 src/backend/utils/Makefile                    | 28 ++-----
 src/backend/utils/activity/Makefile           |  2 +-
 src/backend/utils/adt/Makefile                |  5 +-
 src/backend/utils/mb/Makefile                 |  2 +-
 src/backend/utils/mb/Unicode/Makefile         |  2 -
 src/backend/utils/mb/conversion_procs/proc.mk |  2 +-
 src/backend/utils/misc/Makefile               |  3 +-
 src/bin/initdb/Makefile                       |  2 +-
 src/bin/pg_amcheck/Makefile                   |  2 +-
 src/bin/pg_archivecleanup/Makefile            |  2 +-
 src/bin/pg_basebackup/Makefile                |  2 +-
 src/bin/pg_checksums/Makefile                 |  2 +-
 src/bin/pg_config/Makefile                    |  2 +-
 src/bin/pg_controldata/Makefile               |  2 +-
 src/bin/pg_ctl/Makefile                       |  2 +-
 src/bin/pg_dump/Makefile                      |  2 +-
 src/bin/pg_resetwal/Makefile                  |  2 +-
 src/bin/pg_rewind/Makefile                    |  2 +-
 src/bin/pg_test_fsync/Makefile                |  2 +-
 src/bin/pg_test_timing/Makefile               |  2 +-
 src/bin/pg_upgrade/Makefile                   |  2 +-
 src/bin/pg_verifybackup/Makefile              |  2 +-
 src/bin/pg_waldump/Makefile                   |  2 +-
 src/bin/pgbench/Makefile                      |  4 -
 src/bin/psql/Makefile                         |  6 --
 src/bin/scripts/Makefile                      |  2 +-
 src/common/Makefile                           |  5 --
 src/common/unicode/Makefile                   |  2 -
 src/fe_utils/Makefile                         |  6 --
 src/include/Makefile                          |  2 +-
 src/interfaces/ecpg/Makefile                  |  2 +-
 src/interfaces/ecpg/compatlib/Makefile        |  2 -
 src/interfaces/ecpg/ecpglib/Makefile          |  2 -
 src/interfaces/ecpg/include/Makefile          |  2 +-
 src/interfaces/ecpg/pgtypeslib/Makefile       |  2 -
 src/interfaces/ecpg/preproc/Makefile          |  6 --
 src/interfaces/ecpg/test/Makefile             |  4 +-
 src/interfaces/libpq/Makefile                 |  3 -
 src/interfaces/libpq/test/Makefile            |  2 +-
 src/makefiles/pgxs.mk                         |  2 +-
 src/nls-global.mk                             |  2 +-
 src/pl/plperl/GNUmakefile                     |  2 +-
 src/pl/plpgsql/src/Makefile                   |  7 --
 src/pl/plpython/Makefile                      |  6 +-
 src/pl/tcl/Makefile                           |  5 --
 src/port/Makefile                             |  2 +-
 src/test/authentication/Makefile              |  2 +-
 src/test/examples/Makefile                    |  2 +-
 src/test/icu/Makefile                         |  2 +-
 src/test/isolation/Makefile                   |  4 -
 src/test/kerberos/Makefile                    |  2 +-
 src/test/ldap/Makefile                        |  2 +-
 src/test/locale/Makefile                      |  2 +-
 src/test/recovery/Makefile                    |  2 +-
 src/test/regress/GNUmakefile                  |  2 +-
 src/test/ssl/Makefile                         |  2 +-
 src/test/ssl/sslfiles.mk                      |  4 +-
 src/test/subscription/Makefile                |  2 +-
 src/timezone/Makefile                         |  2 +-
 src/tools/ifaddrs/Makefile                    |  2 +-
 src/tools/pg_bsd_indent/Makefile              |  2 +-
 88 files changed, 169 insertions(+), 409 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index 9c18c56233..80db4c73f8 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -41,7 +41,7 @@ install-world-bin-contrib-recurse: install-world-bin-src-recurse
 
 $(call recurse,installdirs uninstall init-po update-po,doc src config)
 
-$(call recurse,distprep coverage,doc src config contrib)
+$(call recurse,coverage,doc src config contrib)
 
 # clean, distclean, etc should apply to contrib too, even though
 # it's not built by default
@@ -53,7 +53,7 @@ clean:
 
 # Important: distclean `src' last, otherwise Makefile.global
 # will be gone too soon.
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C doc $@
 	$(MAKE) -C contrib $@
 	$(MAKE) -C config $@
@@ -109,7 +109,6 @@ distdir:
 	      || cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
 	  fi || exit; \
 	done
-	$(MAKE) -C $(distdir) distprep
 	$(MAKE) -C $(distdir)/doc/src/sgml/ INSTALL
 	cp $(distdir)/doc/src/sgml/INSTALL $(distdir)/
 	$(MAKE) -C $(distdir) distclean
@@ -122,7 +121,6 @@ distcheck: dist
 	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
diff --git a/config/perl.m4 b/config/perl.m4
index 8126e79f67..1a3bb55649 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -13,19 +13,14 @@ if test "$PERL"; then
   if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
     $AWK '{ if ([$]1 == 5 && ([$]2 >= 14)) exit 1; else exit 0;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
 *** Perl version 5.14 or later is required, but this is $pgac_perl_version.])
-    PERL=""
   fi
 fi
 
 if test -z "$PERL"; then
-  AC_MSG_WARN([
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)])
+  AC_MSG_ERROR([Perl not found])
 fi
 ])# PGAC_PATH_PERL
 
diff --git a/config/programs.m4 b/config/programs.m4
index 8a118b4e03..490ec9fe9f 100644
--- a/config/programs.m4
+++ b/config/programs.m4
@@ -33,10 +33,9 @@ if test "$BISON"; then
   AC_MSG_NOTICE([using $pgac_bison_version])
   if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 2.3) exit 0; else exit 1;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
 *** Bison version 2.3 or later is required, but this is $pgac_bison_version.])
-    BISON=""
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -49,12 +48,7 @@ if test "$BISON"; then
 fi
 
 if test -z "$BISON"; then
-  AC_MSG_WARN([
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)])
+  AC_MSG_ERROR([bison not found])
 fi
 dnl We don't need AC_SUBST(BISON) because PGAC_PATH_PROGS did it
 AC_SUBST(BISONFLAGS)
@@ -95,7 +89,7 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            AC_MSG_WARN([
+            AC_MSG_ERROR([
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
 *** Flex version 2.5.35 or later is required, but this is $pgac_flex_version.])
           fi
@@ -109,14 +103,7 @@ fi
 ])[]dnl AC_CACHE_CHECK
 
 if test x"$pgac_cv_path_flex" = x"no"; then
-  AC_MSG_WARN([
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)])
-
-  FLEX=
+  AC_MSG_ERROR([flex not found])
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
diff --git a/configure b/configure
index d47e0f8b26..514cee190d 100755
--- a/configure
+++ b/configure
@@ -10160,13 +10160,9 @@ if test "$BISON"; then
 $as_echo "$as_me: using $pgac_bison_version" >&6;}
   if echo "$pgac_bison_version" | $AWK '{ if ($4 < 2.3) exit 0; else exit 1;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&2;}
-    BISON=""
+*** Bison version 2.3 or later is required, but this is $pgac_bison_version." "$LINENO" 5
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -10179,18 +10175,7 @@ $as_echo "$as_me: WARNING:
 fi
 
 if test -z "$BISON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&2;}
+  as_fn_error $? "bison not found" "$LINENO" 5
 fi
 
 
@@ -10223,12 +10208,9 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&5
-$as_echo "$as_me: WARNING:
+            as_fn_error $? "
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&2;}
+*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." "$LINENO" 5
           fi
         fi
       fi
@@ -10242,20 +10224,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_path_flex" >&5
 $as_echo "$pgac_cv_path_flex" >&6; }
 if test x"$pgac_cv_path_flex" = x"no"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&2;}
-
-  FLEX=
+  as_fn_error $? "flex not found" "$LINENO" 5
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
@@ -10329,27 +10298,14 @@ $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
   if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
     $AWK '{ if ($1 == 5 && ($2 >= 14)) exit 1; else exit 0;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&2;}
-    PERL=""
+*** Perl version 5.14 or later is required, but this is $pgac_perl_version." "$LINENO" 5
   fi
 fi
 
 if test -z "$PERL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&2;}
+  as_fn_error $? "Perl not found" "$LINENO" 5
 fi
 
 if test "$with_perl" = yes; then
diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 4fd19aac35..dfb0d806e4 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -18,6 +18,8 @@ REGRESS = cube cube_sci
 
 SHLIB_LINK += $(filter -lm, $(LIBS))
 
+EXTRA_CLEAN = cubeparse.h cubeparse.c cubescan.c
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -37,8 +39,3 @@ cubeparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 cubeparse.o cubescan.o: cubeparse.h
-
-distprep: cubeparse.c cubescan.c
-
-maintainer-clean:
-	rm -f cubeparse.h cubeparse.c cubescan.c
diff --git a/contrib/fuzzystrmatch/Makefile b/contrib/fuzzystrmatch/Makefile
index e68bc0e33f..04c83a34a7 100644
--- a/contrib/fuzzystrmatch/Makefile
+++ b/contrib/fuzzystrmatch/Makefile
@@ -15,6 +15,8 @@ PGFILEDESC = "fuzzystrmatch - similarities and distance between strings"
 
 REGRESS = fuzzystrmatch fuzzystrmatch_utf8
 
+EXTRA_CLEAN = daitch_mokotoff.h
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -31,10 +33,3 @@ daitch_mokotoff.o: daitch_mokotoff.h
 
 daitch_mokotoff.h: daitch_mokotoff_header.pl
 	$(PERL) $< $@
-
-# daitch_mokotoff.h is included in tarballs, so it has to be made by
-# "distprep" and not cleaned except by "maintainer-clean".
-distprep: daitch_mokotoff.h
-
-maintainer-clean:
-	rm -f daitch_mokotoff.h
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index a1e49bf051..132ec8dbfe 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -16,7 +16,7 @@ HEADERS = segdata.h
 
 REGRESS = security seg
 
-EXTRA_CLEAN = y.tab.c y.tab.h
+EXTRA_CLEAN = segparse.h segparse.c segscan.c
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
@@ -38,8 +38,3 @@ segparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 segparse.o segscan.o: segparse.h
-
-distprep: segparse.c segscan.c
-
-maintainer-clean:
-	rm -f segparse.h segparse.c segscan.c
diff --git a/doc/Makefile b/doc/Makefile
index aee3cc0965..24370fc903 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -12,5 +12,5 @@ subdir = doc
 top_builddir = ..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C src $@
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 30d883815a..2ed02084ff 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -4,5 +4,5 @@ subdir = doc/src
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C sgml $@
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 1e55e531db..82d57674a2 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -7,8 +7,7 @@
 #----------------------------------------------------------------------------
 
 # This makefile is for building and installing the documentation.
-# When a release tarball is created, the documentation files are
-# prepared using the distprep target.  In Git-based trees these files
+# In Git-based trees these files
 # don't exist, unless explicitly built, so we skip the installation in
 # that case.
 
@@ -28,8 +27,6 @@ include $(top_builddir)/src/Makefile.global
 
 all: html man
 
-distprep: html distprep-man
-
 
 ifndef DBTOEPUB
 DBTOEPUB = $(missing) dbtoepub
@@ -77,7 +74,7 @@ postgres-full.xml: postgres.sgml $(ALLSGML)
 ## Man pages
 ##
 
-man distprep-man: man-stamp
+man: man-stamp
 
 man-stamp: stylesheet-man.xsl postgres-full.xml
 	$(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_MAN_FLAGS) $^
@@ -305,8 +302,6 @@ clean:
 	rm -f *.texixml *.texi *.info db2texi.refs
 
 distclean: clean
-
-maintainer-clean: distclean
 # HTML
 	rm -fr html/ html-stamp
 # man
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index ac8eee47c6..8eb928903e 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -72,8 +72,7 @@ <title>Requirements</title>
 
       Alternatively, <productname>PostgreSQL</productname> can be built using
       <ulink url="https://mesonbuild.com/">Meson</ulink>.  This is currently
-      experimental and only works when building from a Git checkout (not from
-      a distribution tarball).  If you choose to use
+      experimental.  If you choose to use
       <application>Meson</application>, then you don't need
       <acronym>GNU</acronym> <application>make</application>, but the other
       requirements below still apply.
@@ -102,6 +101,41 @@ <title>Requirements</title>
      </para>
     </listitem>
 
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>flex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>lex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>bison</primary>
+      </indexterm>
+      <indexterm>
+       <primary>yacc</primary>
+      </indexterm>
+
+      <application>Flex</application> 2.5.35 or later and
+      <application>Bison</application> 2.3 or later are required.  Other
+      <application>lex</application> and <application>yacc</application>
+      programs cannot be used.
+     </para>
+    </listitem>
+
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>perl</primary>
+      </indexterm>
+
+      <application>Perl</application> 5.14 or later is needed during the build
+      process and to run some test suites.  (This requirement is separate from
+      the requirements for building <application>PL/Perl</application>; see
+      below.)
+     </para>
+    </listitem>
+
     <listitem>
      <para>
       <indexterm>
@@ -315,51 +349,6 @@ <title>Requirements</title>
    </itemizedlist>
   </para>
 
-  <para>
-   If you are building from a <productname>Git</productname> tree instead of
-   using a released source package, or if you want to do server development,
-   you also need the following packages:
-
-   <itemizedlist>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>flex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>lex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>bison</primary>
-      </indexterm>
-      <indexterm>
-       <primary>yacc</primary>
-      </indexterm>
-
-      <application>Flex</application> and <application>Bison</application>
-      are needed to build from a Git checkout, or if you changed the actual
-      scanner and parser definition files. If you need them, be sure
-      to get <application>Flex</application> 2.5.35 or later and
-      <application>Bison</application> 2.3 or later. Other <application>lex</application>
-      and <application>yacc</application> programs cannot be used.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>perl</primary>
-      </indexterm>
-
-      <application>Perl</application> 5.14 or later is needed to build from a Git checkout,
-      or if you changed the input files for any of the build steps that
-      use Perl scripts.  If building on Windows you will need
-      <application>Perl</application> in any case.  <application>Perl</application> is
-      also required to run some test suites.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
-
   <para>
    If you need to get a <acronym>GNU</acronym> package, you can find
    it at your local <acronym>GNU</acronym> mirror site (see <ulink
diff --git a/meson.build b/meson.build
index f5ec442f9a..040d5c869b 100644
--- a/meson.build
+++ b/meson.build
@@ -72,7 +72,7 @@ configure. Alternatively use a separate check out for meson based builds.
 @0@
 ****'''
 if fs.exists(meson.current_source_dir() / 'src' / 'include' / 'pg_config.h')
-  errmsg_cleanup = 'To clean up, run make maintainer-clean in the source tree.'
+  errmsg_cleanup = 'To clean up, run make distclean in the source tree.'
   error(errmsg_nonclean_base.format(errmsg_cleanup))
 endif
 
diff --git a/src/Makefile b/src/Makefile
index 94649c36c7..2f31a2f20a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -59,16 +59,13 @@ uninstall: uninstall-local
 uninstall-local:
 	rm -f $(addprefix '$(DESTDIR)$(pgxsdir)/$(subdir)'/, Makefile.global Makefile.port Makefile.shlib nls-global.mk)
 
-distprep:
-	$(MAKE) -C test/isolation $@
-
 clean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
 	$(MAKE) -C tools/pg_bsd_indent $@
 
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index df9f721a41..2159692439 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -19,11 +19,11 @@
 #
 # Meta configuration
 
-standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check checkprep installcheck init-po update-po
+standard_targets = all install installdirs uninstall clean distclean coverage check checkprep installcheck init-po update-po
 # these targets should recurse even into subdirectories not being built:
-standard_always_targets = distprep clean distclean maintainer-clean
+standard_always_targets = clean distclean
 
-.PHONY: $(standard_targets) install-strip html man installcheck-parallel update-unicode
+.PHONY: $(standard_targets) maintainer-clean install-strip html man installcheck-parallel update-unicode
 
 # make `all' the default target
 all:
@@ -35,6 +35,8 @@ all:
 # Never delete any intermediate files automatically.
 .SECONDARY:
 
+maintainer-clean: distclean
+
 # PostgreSQL version number
 VERSION = @PACKAGE_VERSION@
 MAJORVERSION = @PG_MAJORVERSION@
@@ -319,12 +321,8 @@ X = @EXEEXT@
 
 # Perl
 
-ifneq (@PERL@,)
-    # quoted to protect pathname with spaces
-    PERL		= '@PERL@'
-else
-    PERL		= $(missing) perl
-endif
+# quoted to protect pathname with spaces
+PERL		= '@PERL@'
 perl_archlibexp		= @perl_archlibexp@
 perl_privlibexp		= @perl_privlibexp@
 perl_includespec	= @perl_includespec@
@@ -765,21 +763,13 @@ TAS         = @TAS@
 # Global targets and rules
 
 %.c: %.l
-ifdef FLEX
 	$(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
 	@$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
 	$(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
-else
-	@$(missing) flex $< '$@'
-endif
 
 %.c: %.y
 	$(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
-ifdef BISON
 	$(BISON) $(BISONFLAGS) -o $@ $<
-else
-	@$(missing) bison $< $@
-endif
 
 %.i: %.c
 	$(CPP) $(CPPFLAGS) -o $@ $<
@@ -907,7 +897,7 @@ recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if
 # If a makefile's list of SUBDIRS varies depending on configuration, then
 # any subdirectories excluded from SUBDIRS should instead be added to
 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
-# This ensures that distprep, distclean, etc will apply to all subdirectories.
+# This ensures that distclean, etc will apply to all subdirectories.
 # In the normal case all arguments will be defaulted.
 # $1: targets to make recursive (defaults to standard_always_targets)
 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
@@ -962,7 +952,7 @@ include $(Po_files)
 endif
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-deps
+clean distclean: clean-deps
 
 .PHONY: clean-deps
 clean-deps:
@@ -1046,7 +1036,7 @@ lcov_test.info: $(all_gcda_files)
 
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-coverage
+clean distclean: clean-coverage
 
 .PHONY: clean-coverage
 clean-coverage:
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 3e275ac759..b62ced35cc 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -138,63 +138,38 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-catalog-headers:
-	$(MAKE) -C catalog distprep generated-header-symlinks
+	$(MAKE) -C catalog generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-nodes-headers:
-	$(MAKE) -C nodes distprep generated-header-symlinks
+	$(MAKE) -C nodes generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-utils-headers:
-	$(MAKE) -C utils distprep generated-header-symlinks
+	$(MAKE) -C utils generated-header-symlinks
 
 .PHONY: submake-catalog-headers submake-nodes-headers submake-utils-headers
 
 # Make symlinks for these headers in the include directory. That way
 # we can cut down on the -I options. Also, a symlink is automatically
 # up to date when we update the base file.
-#
-# The point of the prereqdir incantation in some of the rules below is to
-# force the symlink to use an absolute path rather than a relative path.
-# For headers which are generated by make distprep, the actual header within
-# src/backend will be in the source tree, while the symlink in src/include
-# will be in the build tree, so a simple ../.. reference won't work.
-# For headers generated during regular builds, we prefer a relative symlink.
 
 .PHONY: generated-headers
 
-generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers
+generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers parser/gram.h
 
 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 $(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 utils/probes.o: utils/probes.d $(SUBDIROBJS)
 	$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
 
 
-##########################################################################
-
-# Be sure that these files get removed by the maintainer-clean target
-distprep:
-	$(MAKE) -C parser	gram.c gram.h scan.c
-	$(MAKE) -C bootstrap	bootparse.c bootparse.h bootscanner.c
-	$(MAKE) -C catalog	distprep
-	$(MAKE) -C nodes	distprep
-	$(MAKE) -C replication	repl_gram.c repl_gram.h repl_scanner.c syncrep_gram.c syncrep_gram.h syncrep_scanner.c
-	$(MAKE) -C storage/lmgr	lwlocknames.h lwlocknames.c
-	$(MAKE) -C utils	distprep
-	$(MAKE) -C utils/activity	wait_event_types.h pgstat_wait_event.c
-	$(MAKE) -C utils/adt	jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
-	$(MAKE) -C utils/misc	guc-file.c
-
-
 ##########################################################################
 
 install: all installdirs install-bin
@@ -290,34 +265,9 @@ ifeq ($(PORTNAME), win32)
 endif
 
 distclean: clean
+# generated by configure
 	rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
 
-maintainer-clean: distclean
-	$(MAKE) -C catalog $@
-	$(MAKE) -C nodes $@
-	$(MAKE) -C utils $@
-	rm -f bootstrap/bootparse.c \
-	      bootstrap/bootparse.h \
-	      bootstrap/bootscanner.c \
-	      parser/gram.c \
-	      parser/gram.h \
-	      parser/scan.c \
-	      replication/repl_gram.c \
-	      replication/repl_gram.h \
-	      replication/repl_scanner.c \
-	      replication/syncrep_gram.c \
-	      replication/syncrep_gram.h \
-	      replication/syncrep_scanner.c \
-	      storage/lmgr/lwlocknames.c \
-	      storage/lmgr/lwlocknames.h \
-	      utils/activity/pgstat_wait_event.c \
-	      utils/activity/wait_event_funcs_data.c \
-	      utils/activity/wait_event_types.h \
-	      utils/adt/jsonpath_gram.c \
-	      utils/adt/jsonpath_gram.h \
-	      utils/adt/jsonpath_scan.c \
-	      utils/misc/guc-file.c
-
 
 ##########################################################################
 #
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile
index 606c8021e7..509b51e648 100644
--- a/src/backend/bootstrap/Makefile
+++ b/src/backend/bootstrap/Makefile
@@ -28,5 +28,7 @@ bootparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 bootparse.o bootscanner.o: bootparse.h
 
-# bootparse.c and bootscanner.c are in the distribution tarball, so
-# they are not cleaned here.
+clean:
+	rm -f bootparse.c \
+	      bootparse.h \
+	      bootscanner.c
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index a60107bf94..b49666dae2 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -89,9 +89,7 @@ POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
 	pg_ts_template.dat pg_type.dat \
 	)
 
-all: distprep generated-header-symlinks
-
-distprep: bki-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -110,14 +108,12 @@ bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_
 		--set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
 	touch $@
 
-# The generated headers must all be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# The generated headers must all be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than bki-stamp.
 $(top_builddir)/src/include/catalog/header-stamp: bki-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -138,9 +134,5 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
 
-# postgres.bki, system_constraints.sql, and the generated headers are
-# in the distribution tarball, so they are not cleaned here.
 clean:
-
-maintainer-clean: clean
 	rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
index 2da122a391..0036c4f552 100644
--- a/src/backend/jit/llvm/Makefile
+++ b/src/backend/jit/llvm/Makefile
@@ -71,6 +71,6 @@ uninstall-types:
 
 include $(top_srcdir)/src/Makefile.shlib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -f llvmjit_types.bc
diff --git a/src/backend/nls.mk b/src/backend/nls.mk
index 8263527c85..f1464cc5c5 100644
--- a/src/backend/nls.mk
+++ b/src/backend/nls.mk
@@ -22,7 +22,7 @@ GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS) \
     report_invalid_record:2:c-format \
     ereport_startup_progress:1:c-format
 
-gettext-files: distprep
+gettext-files: postgres
 	find $(srcdir) $(srcdir)/../common $(srcdir)/../port -name '*.c' -print | LC_ALL=C sort >$@
 
 my-clean:
diff --git a/src/backend/nodes/Makefile b/src/backend/nodes/Makefile
index 0a95e683d0..ebbe9052cb 100644
--- a/src/backend/nodes/Makefile
+++ b/src/backend/nodes/Makefile
@@ -65,9 +65,7 @@ node_headers = \
 
 # see also catalog/Makefile for an explanation of these make rules
 
-all: distprep generated-header-symlinks
-
-distprep: node-support-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -81,14 +79,12 @@ node-support-stamp: gen_node_support.pl $(addprefix $(top_srcdir)/src/include/,$
 	$(PERL) $^
 	touch $@
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than node-support-stamp.
 $(top_builddir)/src/include/nodes/header-stamp: node-support-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in nodetags.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -98,5 +94,5 @@ outfuncs.o: outfuncs.c outfuncs.funcs.c outfuncs.switch.c | node-support-stamp
 queryjumblefuncs.o: queryjumblefuncs.c queryjumblefuncs.funcs.c queryjumblefuncs.switch.c | node-support-stamp
 readfuncs.o:  readfuncs.c readfuncs.funcs.c readfuncs.switch.c | node-support-stamp
 
-maintainer-clean: clean
+clean:
 	rm -f node-support-stamp $(addsuffix funcs.funcs.c,copy equal out queryjumble read) $(addsuffix funcs.switch.c,copy equal out queryjumble read) nodetags.h
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 9f1c4022bb..401c16686c 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -64,8 +64,8 @@ scan.c: FLEX_FIX_WARNING=yes
 # Force these dependencies to be known even without dependency info built:
 gram.o scan.o parser.o: gram.h
 
-
-# gram.c, gram.h, and scan.c are in the distribution tarball, so they
-# are not cleaned here.
-clean distclean maintainer-clean:
+clean:
+	rm -f gram.c \
+	      gram.h \
+	      scan.c
 	rm -f lex.backup
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 2d00b4f05a..47338d9922 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -43,6 +43,6 @@ else
 	$(CC) $(CFLAGS) -c $<
 endif
 
-distclean clean:
+clean:
 	rm -f tas_cpp.s
 	$(MAKE) -C win32 clean
diff --git a/src/backend/replication/Makefile b/src/backend/replication/Makefile
index 23f29ba545..7f867ee91d 100644
--- a/src/backend/replication/Makefile
+++ b/src/backend/replication/Makefile
@@ -48,6 +48,10 @@ syncrep_gram.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 syncrep_gram.o syncrep_scanner.o: syncrep_gram.h
 
-# repl_gram.c, repl_scanner.c, syncrep_gram.c and syncrep_scanner.c
-# are in the distribution tarball, so they are not cleaned here.
-# (Our parent Makefile takes care of them during maintainer-clean.)
+clean:
+	rm -f repl_gram.c \
+	      repl_gram.h \
+	      repl_scanner.c \
+	      syncrep_gram.c \
+	      syncrep_gram.h \
+	      syncrep_scanner.c
diff --git a/src/backend/replication/libpqwalreceiver/Makefile b/src/backend/replication/libpqwalreceiver/Makefile
index f26daa135f..e882907350 100644
--- a/src/backend/replication/libpqwalreceiver/Makefile
+++ b/src/backend/replication/libpqwalreceiver/Makefile
@@ -33,5 +33,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/replication/pgoutput/Makefile b/src/backend/replication/pgoutput/Makefile
index 3b41fbcfac..d89d317fe7 100644
--- a/src/backend/replication/pgoutput/Makefile
+++ b/src/backend/replication/pgoutput/Makefile
@@ -28,5 +28,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/snowball/Makefile b/src/backend/snowball/Makefile
index 4bebfa0250..efc4300eb9 100644
--- a/src/backend/snowball/Makefile
+++ b/src/backend/snowball/Makefile
@@ -104,8 +104,6 @@ include $(top_srcdir)/src/Makefile.shlib
 $(SQLSCRIPT): snowball_create.pl snowball_func.sql.in snowball.sql.in
 	$(PERL) $< --input ${srcdir} --outdir .
 
-distprep: $(SQLSCRIPT)
-
 install: all installdirs install-lib install-script
 	$(INSTALL_DATA) $(addprefix $(srcdir)/stopwords/,$(stop_files)) '$(DESTDIR)$(datadir)/$(DICTDIR)'
 
@@ -122,6 +120,4 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
 	rm -f $(SQLSCRIPT)
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index b25b7ee421..c48ba943c4 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -45,8 +45,6 @@ lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt generate-l
 check: s_lock_test
 	./s_lock_test
 
-clean distclean:
+clean:
 	rm -f s_lock_test
-
-maintainer-clean: clean
 	rm -f lwlocknames.h lwlocknames.c
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index deb901609f..e184e3dfdf 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -34,13 +34,14 @@ catalogdir  = $(top_srcdir)/src/backend/catalog
 
 include $(top_srcdir)/src/backend/common.mk
 
-all: distprep probes.h generated-header-symlinks
+all: probes.h generated-header-symlinks
 
-distprep: fmgr-stamp errcodes.h
+.PHONY: generated-header-symlinks submake-adt-headers
 
-.PHONY: generated-header-symlinks
+generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp submake-adt-headers
 
-generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_builddir)/src/include/utils/probes.h
+submake-adt-headers:
+	$(MAKE) -C adt jsonpath_gram.h
 
 $(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h
 
@@ -66,22 +67,15 @@ probes.h: Gen_dummy_probes.sed probes.d
 	sed -f $^ >$@
 endif
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than fmgr-stamp.
-$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h
+	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h; do \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
-# probes.h is handled differently because it's not in the distribution tarball.
-$(top_builddir)/src/include/utils/probes.h: probes.h
-	cd '$(dir $@)' && rm -f $(notdir $@) && \
-	    $(LN_S) "../../../$(subdir)/probes.h" .
-
 # Recipe for rebuilding the Perl version of Gen_dummy_probes
 # Nothing depends on it, so it will never be called unless explicitly requested
 # The last two lines of the recipe format the script according to  our
@@ -104,10 +98,6 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, errcodes.txt)
 
-# fmgroids.h, fmgrprotos.h, fmgrtab.c, fmgr-stamp, and errcodes.h are in the
-# distribution tarball, so they are not cleaned here.
 clean:
 	rm -f probes.h probes.h.tmp
-
-maintainer-clean: clean
 	rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h
diff --git a/src/backend/utils/activity/Makefile b/src/backend/utils/activity/Makefile
index f57cf3958c..a4397ef907 100644
--- a/src/backend/utils/activity/Makefile
+++ b/src/backend/utils/activity/Makefile
@@ -47,5 +47,5 @@ pgstat_wait_event.c: wait_event_types.h
 wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt generate-wait_event_types.pl
 	$(PERL) $(srcdir)/generate-wait_event_types.pl --code $<
 
-maintainer-clean: clean
+clean:
 	rm -f wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile
index 0de0bbb1b8..199eae525d 100644
--- a/src/backend/utils/adt/Makefile
+++ b/src/backend/utils/adt/Makefile
@@ -132,10 +132,9 @@ jsonpath_scan.c: FLEX_NO_BACKUP=yes
 # Force these dependencies to be known even without dependency info built:
 jsonpath_gram.o jsonpath_scan.o: jsonpath_gram.h
 
-# jsonpath_gram.c and jsonpath_scan.c are in the distribution tarball,
-# so they are not cleaned here.
-clean distclean maintainer-clean:
+clean:
 	rm -f lex.backup
+	rm -f jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
 
 like.o: like.c like_match.c
 
diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile
index b19a125fa2..bbde71b5aa 100644
--- a/src/backend/utils/mb/Makefile
+++ b/src/backend/utils/mb/Makefile
@@ -21,5 +21,5 @@ OBJS = \
 
 include $(top_srcdir)/src/backend/common.mk
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C conversion_procs $@
diff --git a/src/backend/utils/mb/Unicode/Makefile b/src/backend/utils/mb/Unicode/Makefile
index 728ccb99c2..6c0a8150f2 100644
--- a/src/backend/utils/mb/Unicode/Makefile
+++ b/src/backend/utils/mb/Unicode/Makefile
@@ -66,8 +66,6 @@ all: $(MAPS)
 
 distclean: clean
 	rm -f $(TEXTS)
-
-maintainer-clean: distclean
 	rm -f $(MAPS)
 
 
diff --git a/src/backend/utils/mb/conversion_procs/proc.mk b/src/backend/utils/mb/conversion_procs/proc.mk
index e0a3b74b25..2eeae28240 100644
--- a/src/backend/utils/mb/conversion_procs/proc.mk
+++ b/src/backend/utils/mb/conversion_procs/proc.mk
@@ -13,5 +13,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/utils/misc/Makefile b/src/backend/utils/misc/Makefile
index 2910032930..c2971c7678 100644
--- a/src/backend/utils/misc/Makefile
+++ b/src/backend/utils/misc/Makefile
@@ -40,6 +40,5 @@ endif
 
 include $(top_srcdir)/src/backend/common.mk
 
-# Note: guc-file.c is not deleted by 'make clean',
-# since we want to ship it in distribution tarballs.
 clean:
+	rm -f guc-file.c
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index d69bd89572..7043289239 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -55,7 +55,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/initdb$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f initdb$(X) $(OBJS) localtime.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_amcheck/Makefile b/src/bin/pg_amcheck/Makefile
index 947f2267ed..528c588e35 100644
--- a/src/bin/pg_amcheck/Makefile
+++ b/src/bin/pg_amcheck/Makefile
@@ -40,7 +40,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_amcheck$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_amcheck$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index 49935d6dce..93fd703f22 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -25,7 +25,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_archivecleanup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_archivecleanup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile
index 893a75c942..74dc1ddd6d 100644
--- a/src/bin/pg_basebackup/Makefile
+++ b/src/bin/pg_basebackup/Makefile
@@ -71,7 +71,7 @@ uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_receivewal$(X)'
 	rm -f '$(DESTDIR)$(bindir)/pg_recvlogical$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_basebackup$(X) pg_receivewal$(X) pg_recvlogical$(X) \
 		$(BBOBJS) pg_receivewal.o pg_recvlogical.o \
 		$(OBJS)
diff --git a/src/bin/pg_checksums/Makefile b/src/bin/pg_checksums/Makefile
index 4911f6bee2..ac736b2260 100644
--- a/src/bin/pg_checksums/Makefile
+++ b/src/bin/pg_checksums/Makefile
@@ -36,7 +36,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_checksums$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_checksums$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index 1a405f9c97..cb13aceafa 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_config$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_config$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index aa5bd58222..00ee1e25b3 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_controldata$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_controldata$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index 4b6d47a8f8..4d29ca72c1 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -42,7 +42,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_ctl$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_ctl$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 24de7593a6..604cddb997 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -69,6 +69,6 @@ installcheck:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o
 	rm -rf tmp_check
diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile
index a363b948b5..a06e493ba8 100644
--- a/src/bin/pg_resetwal/Makefile
+++ b/src/bin/pg_resetwal/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_resetwal$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_resetwal$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
index bed05f1609..8df1da80cb 100644
--- a/src/bin/pg_rewind/Makefile
+++ b/src/bin/pg_rewind/Makefile
@@ -49,7 +49,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_rewind$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_rewind$(X) $(OBJS) xlogreader.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index 631d0f38a8..4c5e518125 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_fsync$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index 84d84c38aa..7f677edadb 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_timing$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_timing$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 5834513add..f76aca1b1a 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -46,7 +46,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_upgrade$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_upgrade$(X) $(OBJS)
 	rm -rf delete_old_cluster.sh log/ tmp_check/ \
 	       reindex_hash.sql
diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile
index 596df15118..c96323faa9 100644
--- a/src/bin/pg_verifybackup/Makefile
+++ b/src/bin/pg_verifybackup/Makefile
@@ -38,7 +38,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_verifybackup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile
index 0ecf582039..4c1ee64950 100644
--- a/src/bin/pg_waldump/Makefile
+++ b/src/bin/pg_waldump/Makefile
@@ -45,7 +45,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_waldump$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_waldump$(X) $(OBJS) $(RMGRDESCSOURCES) xlogreader.c xlogstats.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index 68b6eb0376..987bf64df9 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -38,8 +38,6 @@ exprparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 exprparse.o exprscan.o: exprparse.h
 
-distprep: exprparse.c exprscan.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pgbench$(X) '$(DESTDIR)$(bindir)/pgbench$(X)'
 
@@ -52,8 +50,6 @@ uninstall:
 clean distclean:
 	rm -f pgbench$(X) $(OBJS)
 	rm -rf tmp_check
-
-maintainer-clean: distclean
 	rm -f exprparse.h exprparse.c exprscan.c
 
 check:
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 1f2bf0c6b0..8ad7c65446 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -62,8 +62,6 @@ psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
 psqlscanslash.c: FLEX_NO_BACKUP=yes
 psqlscanslash.c: FLEX_FIX_WARNING=yes
 
-distprep: sql_help.h sql_help.c psqlscanslash.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
 	$(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
@@ -77,10 +75,6 @@ uninstall:
 clean distclean:
 	rm -f psql$(X) $(OBJS) lex.backup
 	rm -rf tmp_check
-
-# files removed here are supposed to be in the distribution tarball,
-# so do not clean them in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f sql_help.h sql_help.c psqlscanslash.c
 
 check:
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index a7a9d0fea5..20db40b103 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -48,7 +48,7 @@ installdirs:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(addsuffix $(X), $(PROGRAMS)))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS))
 	rm -f common.o $(WIN32RES)
 	rm -rf tmp_check
diff --git a/src/common/Makefile b/src/common/Makefile
index 113029bf7b..ec063c6e18 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -121,8 +121,6 @@ GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
 
 all: libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 
-distprep: kwlist_d.h
-
 # libpgcommon is needed by some contrib
 install: all installdirs
 	$(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
@@ -188,10 +186,7 @@ RYU_OBJS = $(RYU_FILES) $(RYU_FILES:%.o=%_shlib.o) $(RYU_FILES:%.o=%_srv.o)
 
 $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
 
-# kwlist_d.h is in the distribution tarball, so it is not cleaned here.
 clean distclean:
 	rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 	rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)
-
-maintainer-clean: distclean
 	rm -f kwlist_d.h
diff --git a/src/common/unicode/Makefile b/src/common/unicode/Makefile
index 382da476cf..d6e427b582 100644
--- a/src/common/unicode/Makefile
+++ b/src/common/unicode/Makefile
@@ -68,5 +68,3 @@ clean:
 
 distclean: clean
 	rm -f UnicodeData.txt EastAsianWidth.txt CompositionExclusions.txt NormalizationTest.txt norm_test_table.h unicode_norm_table.h
-
-maintainer-clean: distclean
diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile
index 456d6dd390..8accd5906d 100644
--- a/src/fe_utils/Makefile
+++ b/src/fe_utils/Makefile
@@ -48,8 +48,6 @@ psqlscan.c: FLEXFLAGS = -Cfe -p -p
 psqlscan.c: FLEX_NO_BACKUP=yes
 psqlscan.c: FLEX_FIX_WARNING=yes
 
-distprep: psqlscan.c
-
 # libpgfeutils could be useful to contrib, so install it
 install: all installdirs
 	$(INSTALL_STLIB) libpgfeutils.a '$(DESTDIR)$(libdir)/libpgfeutils.a'
@@ -62,8 +60,4 @@ uninstall:
 
 clean distclean:
 	rm -f libpgfeutils.a $(OBJS) lex.backup
-
-# psqlscan.c is supposed to be in the distribution tarball,
-# so do not clean it in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f psqlscan.c
diff --git a/src/include/Makefile b/src/include/Makefile
index 2d5242561c..743de5abe4 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -78,5 +78,5 @@ clean:
 	rm -f catalog/pg_*_d.h catalog/header-stamp
 	rm -f nodes/nodetags.h nodes/header-stamp
 
-distclean maintainer-clean: clean
+distclean: clean
 	rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index e4bbf7b8a8..3002bc3c1b 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -23,7 +23,7 @@ install-pgtypeslib-recurse install-ecpglib-recurse install-compatlib-recurse ins
 install-compatlib-recurse: install-ecpglib-recurse
 install-ecpglib-recurse: install-pgtypeslib-recurse
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C test clean
 
 checktcp: | temp-install
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index b9483fba08..695fd1a080 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -55,5 +55,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 652e023405..103cce393a 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -66,5 +66,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/include/Makefile b/src/interfaces/ecpg/include/Makefile
index 9c68bf3c47..3476409cef 100644
--- a/src/interfaces/ecpg/include/Makefile
+++ b/src/interfaces/ecpg/include/Makefile
@@ -31,5 +31,5 @@ uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers))
 	rm -f '$(DESTDIR)$(includedir)'/$(notdir $(ecpg_config_h))
 
-distclean maintainer-clean:
+distclean:
 	rm -f ecpg_config.h stamp-h
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index b0e154eb15..e56700a12e 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -50,5 +50,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 77ae9ab722..afd46cd17c 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -81,8 +81,6 @@ ecpg_keywords.o: ecpg_kwlist_d.h
 c_keywords.o: c_kwlist_d.h
 keywords.o: $(top_srcdir)/src/include/parser/kwlist.h
 
-distprep: preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
-
 install: all installdirs
 	$(INSTALL_PROGRAM) ecpg$(X) '$(DESTDIR)$(bindir)'
 
@@ -92,11 +90,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/ecpg$(X)'
 
-# preproc.y, preproc.c, preproc.h, pgc.c, c_kwlist_d.h, and ecpg_kwlist_d.h
-# are in the distribution tarball, so they are not cleaned here.
 clean distclean:
 	rm -f *.o ecpg$(X)
 	rm -f typename.c
-
-maintainer-clean: distclean
 	rm -f preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index cf841a3a5b..3769488f16 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -20,7 +20,7 @@ else
 abs_builddir := $(shell sh -c "pwd -W")
 endif
 
-all install installdirs uninstall distprep:
+all install installdirs uninstall:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
@@ -29,7 +29,7 @@ all install installdirs uninstall distprep:
 	$(MAKE) -C compat_oracle $@
 	$(MAKE) -C thread $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 46653682b0..d0a66cfaa0 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -165,6 +165,3 @@ clean distclean: clean-lib
 	rm -f $(OBJS) pthread.h libpq-refs-stamp
 # Might be left over from a Win32 client-only build
 	rm -f pg_config_paths.h
-
-maintainer-clean: distclean
-	$(MAKE) -C test $@
diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile
index 75ac08f943..4e17ec1514 100644
--- a/src/interfaces/libpq/test/Makefile
+++ b/src/interfaces/libpq/test/Makefile
@@ -20,5 +20,5 @@ all: $(PROGS)
 
 $(PROGS): $(WIN32RES)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 7ba8d5bc98..0de3737e78 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -391,7 +391,7 @@ ifdef MODULE_big
 clean: clean-lib
 endif
 
-distclean maintainer-clean: clean
+distclean: clean
 
 
 ifdef REGRESS
diff --git a/src/nls-global.mk b/src/nls-global.mk
index f21bd5ed55..dfff472cb3 100644
--- a/src/nls-global.mk
+++ b/src/nls-global.mk
@@ -171,7 +171,7 @@ all: all-po
 install: install-po
 installdirs: installdirs-po
 uninstall: uninstall-po
-clean distclean maintainer-clean: clean-po
+clean distclean: clean-po
 
 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
         init-po update-po
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index 51f8890d15..975f540b3e 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -127,7 +127,7 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index f7eb42d54f..dfb815212f 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile
@@ -104,14 +104,7 @@ submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
 
-distprep: pl_gram.h pl_gram.c plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
-
-# pl_gram.c, pl_gram.h, plerrcodes.h, pl_reserved_kwlist_d.h, and
-# pl_unreserved_kwlist_d.h are in the distribution tarball, so they
-# are not cleaned here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f pl_gram.c pl_gram.h plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index 6b1865c240..ef0a5905ae 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -142,6 +142,7 @@ clean distclean: clean-lib
 ifeq ($(PORTNAME), win32)
 	rm -f python${pytverstr}.def
 endif
+	rm -f spiexceptions.h
 
 
 # Force this dependency to be known even without dependency info built:
@@ -149,8 +150,3 @@ plpy_plpymodule.o: spiexceptions.h
 
 spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
 	$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
-
-distprep: spiexceptions.h
-
-maintainer-clean: distclean
-	rm -f spiexceptions.h
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index 314f9b2eec..ea52a2efc2 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -63,8 +63,6 @@ pltcl.o: pltclerrcodes.h
 pltclerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-pltclerrcodes.pl
 	$(PERL) $(srcdir)/generate-pltclerrcodes.pl $< > $@
 
-distprep: pltclerrcodes.h
-
 install: all install-lib install-data
 
 installdirs: installdirs-lib
@@ -91,13 +89,10 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-# pltclerrcodes.h is in the distribution tarball, so don't clean it here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
 	rm -f $(tclwithver).def
 endif
-
-maintainer-clean: distclean
 	rm -f pltclerrcodes.h
diff --git a/src/port/Makefile b/src/port/Makefile
index f205c2c9c5..4320dee0d1 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -154,6 +154,6 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
 	echo "#define HTMLDIR \"$(htmldir)\"" >>$@
 	echo "#define MANDIR \"$(mandir)\"" >>$@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f libpgport.a libpgport_shlib.a libpgport_srv.a
 	rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h
diff --git a/src/test/authentication/Makefile b/src/test/authentication/Makefile
index 46fa72052d..a48ce39aaf 100644
--- a/src/test/authentication/Makefile
+++ b/src/test/authentication/Makefile
@@ -19,5 +19,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/examples/Makefile b/src/test/examples/Makefile
index a67f456904..e72d058e0c 100644
--- a/src/test/examples/Makefile
+++ b/src/test/examples/Makefile
@@ -18,5 +18,5 @@ PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo testlo64
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/test/icu/Makefile b/src/test/icu/Makefile
index 033b0d03cc..c4fc8cdb8c 100644
--- a/src/test/icu/Makefile
+++ b/src/test/icu/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index b8738b7c1b..8f5192fb37 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -43,8 +43,6 @@ pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
 isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
 	$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
-distprep: specparse.c specscanner.c
-
 # See notes in src/backend/parser/Makefile about the following two rules
 specparse.h: specparse.c
 	touch $@
@@ -60,8 +58,6 @@ clean distclean:
 	rm -f isolationtester$(X) pg_isolation_regress$(X) $(OBJS) isolation_main.o
 	rm -f pg_regress.o
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f specparse.h specparse.c specscanner.c
 
 installcheck: all
diff --git a/src/test/kerberos/Makefile b/src/test/kerberos/Makefile
index f460d2c0e7..44da65611e 100644
--- a/src/test/kerberos/Makefile
+++ b/src/test/kerberos/Makefile
@@ -24,5 +24,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/ldap/Makefile b/src/test/ldap/Makefile
index 73bc878ea8..d4305ed5eb 100644
--- a/src/test/ldap/Makefile
+++ b/src/test/ldap/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/locale/Makefile b/src/test/locale/Makefile
index 7ba096b542..a40c67af07 100644
--- a/src/test/locale/Makefile
+++ b/src/test/locale/Makefile
@@ -10,7 +10,7 @@ DIRS = de_DE.ISO8859-1 gr_GR.ISO8859-7 koi8-r koi8-to-win1251
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
 	rm -rf tmp_check
 	for d in $(DIRS); do \
diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile
index c60314d195..49f1d1c118 100644
--- a/src/test/recovery/Makefile
+++ b/src/test/recovery/Makefile
@@ -25,5 +25,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 38c3a1f85b..388f2700bd 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -146,7 +146,7 @@ bigcheck: all | temp-install
 ## Clean up
 ##
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 # things built by `all' target
 	rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
 	rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
diff --git a/src/test/ssl/Makefile b/src/test/ssl/Makefile
index af1e06e949..2d7c69068f 100644
--- a/src/test/ssl/Makefile
+++ b/src/test/ssl/Makefile
@@ -23,7 +23,7 @@ export OPENSSL with_ssl
 sslfiles sslfiles-clean:
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
diff --git a/src/test/ssl/sslfiles.mk b/src/test/ssl/sslfiles.mk
index f7ababe42c..62b2272183 100644
--- a/src/test/ssl/sslfiles.mk
+++ b/src/test/ssl/sslfiles.mk
@@ -269,6 +269,6 @@ sslfiles-clean:
 # clean targets will be run during a "standard" recursive clean run from the
 # main build tree. The sslfiles-clean target must be run explicitly from this
 # directory.
-.PHONY: clean distclean maintainer-clean
-clean distclean maintainer-clean:
+.PHONY: clean distclean
+clean distclean:
 	rm -rf ssl/*.old ssl/new_certs_dir ssl/client*_tmp.key
diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile
index 99d1fe012d..36475ffabc 100644
--- a/src/test/subscription/Makefile
+++ b/src/test/subscription/Makefile
@@ -23,5 +23,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/timezone/Makefile b/src/timezone/Makefile
index fbbaae4cc5..c85e831247 100644
--- a/src/timezone/Makefile
+++ b/src/timezone/Makefile
@@ -75,5 +75,5 @@ ifeq (,$(with_system_tzdata))
 endif
 	$(MAKE) -C tznames $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f zic$(X) $(ZICOBJS) abbrevs.txt
diff --git a/src/tools/ifaddrs/Makefile b/src/tools/ifaddrs/Makefile
index e74d754769..ef5e8f0e0e 100644
--- a/src/tools/ifaddrs/Makefile
+++ b/src/tools/ifaddrs/Makefile
@@ -24,5 +24,5 @@ all: test_ifaddrs
 test_ifaddrs: test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o
 	$(CC) $(CFLAGS) test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f test_ifaddrs$(X) $(OBJS)
diff --git a/src/tools/pg_bsd_indent/Makefile b/src/tools/pg_bsd_indent/Makefile
index d176ceb326..ce5d815f07 100644
--- a/src/tools/pg_bsd_indent/Makefile
+++ b/src/tools/pg_bsd_indent/Makefile
@@ -39,7 +39,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_bsd_indent$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_bsd_indent$(X) $(OBJS)
 	rm -rf log/ tmp_check/
 
-- 
2.41.0

#18Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#17)
Re: Remove distprep

On Wed, Aug 23, 2023 at 12:46:45PM +0200, Peter Eisentraut wrote:

Apparently, the headerscheck and cpluspluscheck targets still didn't work
right in the Cirrus jobs. Here is an updated patch to address that. This
is also rebased over some recent changes that affected this patch (generated
wait events stuff).

-gettext-files: distprep
+gettext-files: postgres

This bit in src/backend/nls.mk does not seem right to me. The
following sequence works on HEAD, but breaks with the patch because
the files that should be automatically generated from the perl scripts
aren't anymore:
$ ./configure ...
$ make -C src/backend/ gettext-files
[...]
In file included from ../../../../src/include/postgres.h:46,
from brin.c:16:
../../../../src/include/utils/elog.h:79:10: fatal error:
utils/errcodes.h: No such file or directory
79 | #include "utils/errcodes.h"

# Technically, this should depend on Makefile.global, but then
# version.sgml would need to be rebuilt after every configure run,
# even in distribution tarballs. So this is cheating a bit, but it

There is this comment in doc/src/sgml/Makefile. Does it still apply?

Note that building <productname>PostgreSQL</productname> from the source
repository requires reasonably up-to-date versions of <application>bison</application>,
<application>flex</application>, and <application>Perl</application>.
These tools are not needed to build from a distribution tarball, because
the files generated with these tools are included in the tarball.
Other tool requirements

This paragraph exists in sourcerepo.sgml, but it should be updated, I
guess, because now these three binaries would be required when
building from a tarball.

# specparse.c and specscanner.c are in the distribution tarball,
# so do not clean them here

This comment in src/test/isolation/Makefile should be removed.
--
Michael

#19Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#17)
Re: Remove distprep

Hi,

On 2023-08-23 12:46:45 +0200, Peter Eisentraut wrote:

Subject: [PATCH v4] Remove distprep

A PostgreSQL release tarball contains a number of prebuilt files, in
particular files produced by bison, flex, perl, and well as html and
man documentation. We have done this consistent with established
practice at the time to not require these tools for building from a
tarball. Some of these tools were hard to get, or get the right
version of, from time to time, and shipping the prebuilt output was a
convenience to users.

Now this has at least two problems:

One, we have to make the build system(s) work in two modes: Building
from a git checkout and building from a tarball. This is pretty
complicated, but it works so far for autoconf/make. It does not
currently work for meson; you can currently only build with meson from
a git checkout. Making meson builds work from a tarball seems very
difficult or impossible. One particular problem is that since meson
requires a separate build directory, we cannot make the build update
files like gram.h in the source tree. So if you were to build from a
tarball and update gram.y, you will have a gram.h in the source tree
and one in the build tree, but the way things work is that the
compiler will always use the one in the source tree. So you cannot,
for example, make any gram.y changes when building from a tarball.
This seems impossible to fix in a non-horrible way.

I think it might be possible to fix in a non-horrible way, just that the
effort doing so could be much better spent on other things.

It's maybe also worth mentioning that this does *not* work reliably with vpath
make builds either...

The make maintainer-clean target, whose job it is to remove the
prebuilt files in addition to what make distclean does, is now just an
alias to make distprep. (In practice, it is probably obsolete given
that git clean is available.)

FWIW, I find a "full clean" target useful to be sure that we don't produce
"untracked" build products. Do a full build, then run "full clean", then see
what remains.

88 files changed, 169 insertions(+), 409 deletions(-)

It might be worthwhile to split this into a bit smaller chunks, e.g. depending
on perl, bison, flex, and then separately the various makefile bits that are
all over the tree.

Greetings,

Andres Freund

#20Peter Eisentraut
peter@eisentraut.org
In reply to: Michael Paquier (#18)
2 attachment(s)
Re: Remove distprep

On 26.09.23 06:49, Michael Paquier wrote:

On Wed, Aug 23, 2023 at 12:46:45PM +0200, Peter Eisentraut wrote:

Apparently, the headerscheck and cpluspluscheck targets still didn't work
right in the Cirrus jobs. Here is an updated patch to address that. This
is also rebased over some recent changes that affected this patch (generated
wait events stuff).

-gettext-files: distprep
+gettext-files: postgres

This bit in src/backend/nls.mk does not seem right to me. The
following sequence works on HEAD, but breaks with the patch because
the files that should be automatically generated from the perl scripts
aren't anymore:
$ ./configure ...
$ make -C src/backend/ gettext-files
[...]
In file included from ../../../../src/include/postgres.h:46,
from brin.c:16:
../../../../src/include/utils/elog.h:79:10: fatal error:
utils/errcodes.h: No such file or directory
79 | #include "utils/errcodes.h"

Ok, I think I found a better way to address this. It requires keeping a
subset of the old distprep target in src/backend/Makefile for use by
nls.mk. I have checked that the above sequence now works, and that the
generated .pot files are identical to before this patch.

# Technically, this should depend on Makefile.global, but then
# version.sgml would need to be rebuilt after every configure run,
# even in distribution tarballs. So this is cheating a bit, but it

There is this comment in doc/src/sgml/Makefile. Does it still apply?

I have removed the "even in distribution tarballs" bit, but the general
idea is still valid I think.

Note that building <productname>PostgreSQL</productname> from the source
repository requires reasonably up-to-date versions of <application>bison</application>,
<application>flex</application>, and <application>Perl</application>.
These tools are not needed to build from a distribution tarball, because
the files generated with these tools are included in the tarball.
Other tool requirements

This paragraph exists in sourcerepo.sgml, but it should be updated, I
guess, because now these three binaries would be required when
building from a tarball.

I have removed that paragraph.

# specparse.c and specscanner.c are in the distribution tarball,
# so do not clean them here

This comment in src/test/isolation/Makefile should be removed.

done

The attached updated patch is also split up like Andres suggested
nearby. (Not sure if it would be good to commit it that way, but it's
easier to look at for now for sure.)

Attachments:

v5-0001-Make-bison-flex-perl-hard-build-requirements.patchtext/plain; charset=UTF-8; name=v5-0001-Make-bison-flex-perl-hard-build-requirements.patchDownload
From 9b4504ce0e247b840b8cef424e44d922bc7cde88 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Thu, 5 Oct 2023 17:39:24 +0200
Subject: [PATCH v5 1/2] Make bison, flex, perl hard build requirements

... see next patch
---
 config/perl.m4                 |  9 +---
 config/programs.m4             | 21 ++-------
 configure                      | 62 ++++----------------------
 doc/src/sgml/installation.sgml | 80 +++++++++++++++-------------------
 doc/src/sgml/sourcerepo.sgml   | 10 -----
 src/Makefile.global.in         | 16 +------
 6 files changed, 52 insertions(+), 146 deletions(-)

diff --git a/config/perl.m4 b/config/perl.m4
index 8126e79f67..1a3bb55649 100644
--- a/config/perl.m4
+++ b/config/perl.m4
@@ -13,19 +13,14 @@ if test "$PERL"; then
   if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
     $AWK '{ if ([$]1 == 5 && ([$]2 >= 14)) exit 1; else exit 0;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
 *** Perl version 5.14 or later is required, but this is $pgac_perl_version.])
-    PERL=""
   fi
 fi
 
 if test -z "$PERL"; then
-  AC_MSG_WARN([
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)])
+  AC_MSG_ERROR([Perl not found])
 fi
 ])# PGAC_PATH_PERL
 
diff --git a/config/programs.m4 b/config/programs.m4
index 8a118b4e03..490ec9fe9f 100644
--- a/config/programs.m4
+++ b/config/programs.m4
@@ -33,10 +33,9 @@ if test "$BISON"; then
   AC_MSG_NOTICE([using $pgac_bison_version])
   if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 2.3) exit 0; else exit 1;}'
   then
-    AC_MSG_WARN([
+    AC_MSG_ERROR([
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
 *** Bison version 2.3 or later is required, but this is $pgac_bison_version.])
-    BISON=""
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -49,12 +48,7 @@ if test "$BISON"; then
 fi
 
 if test -z "$BISON"; then
-  AC_MSG_WARN([
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)])
+  AC_MSG_ERROR([bison not found])
 fi
 dnl We don't need AC_SUBST(BISON) because PGAC_PATH_PROGS did it
 AC_SUBST(BISONFLAGS)
@@ -95,7 +89,7 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            AC_MSG_WARN([
+            AC_MSG_ERROR([
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
 *** Flex version 2.5.35 or later is required, but this is $pgac_flex_version.])
           fi
@@ -109,14 +103,7 @@ fi
 ])[]dnl AC_CACHE_CHECK
 
 if test x"$pgac_cv_path_flex" = x"no"; then
-  AC_MSG_WARN([
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)])
-
-  FLEX=
+  AC_MSG_ERROR([flex not found])
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
diff --git a/configure b/configure
index d47e0f8b26..514cee190d 100755
--- a/configure
+++ b/configure
@@ -10160,13 +10160,9 @@ if test "$BISON"; then
 $as_echo "$as_me: using $pgac_bison_version" >&6;}
   if echo "$pgac_bison_version" | $AWK '{ if ($4 < 2.3) exit 0; else exit 1;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
-*** Bison version 2.3 or later is required, but this is $pgac_bison_version." >&2;}
-    BISON=""
+*** Bison version 2.3 or later is required, but this is $pgac_bison_version." "$LINENO" 5
   fi
   # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
   # of the now preferred %name-prefix "base_yy", but the latter
@@ -10179,18 +10175,7 @@ $as_echo "$as_me: WARNING:
 fi
 
 if test -z "$BISON"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Bison you will not be able to build PostgreSQL from Git nor
-*** change any of the parser definition files.  You can obtain Bison from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this, because the Bison
-*** output is pre-generated.)" >&2;}
+  as_fn_error $? "bison not found" "$LINENO" 5
 fi
 
 
@@ -10223,12 +10208,9 @@ else
             pgac_cv_path_flex=$pgac_candidate
             break 2
           else
-            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&5
-$as_echo "$as_me: WARNING:
+            as_fn_error $? "
 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
-*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." >&2;}
+*** Flex version 2.5.35 or later is required, but this is $pgac_flex_version." "$LINENO" 5
           fi
         fi
       fi
@@ -10242,20 +10224,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_path_flex" >&5
 $as_echo "$pgac_cv_path_flex" >&6; }
 if test x"$pgac_cv_path_flex" = x"no"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Flex you will not be able to build PostgreSQL from Git nor
-*** change any of the scanner definition files.  You can obtain Flex from
-*** a GNU mirror site.  (If you are using the official distribution of
-*** PostgreSQL then you do not need to worry about this because the Flex
-*** output is pre-generated.)" >&2;}
-
-  FLEX=
+  as_fn_error $? "flex not found" "$LINENO" 5
 else
   FLEX=$pgac_cv_path_flex
   pgac_flex_version=`$FLEX --version 2>/dev/null`
@@ -10329,27 +10298,14 @@ $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
   if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
     $AWK '{ if ($1 == 5 && ($2 >= 14)) exit 1; else exit 0;}'
   then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&5
-$as_echo "$as_me: WARNING:
+    as_fn_error $? "
 *** The installed version of Perl, $PERL, is too old to use with PostgreSQL.
-*** Perl version 5.14 or later is required, but this is $pgac_perl_version." >&2;}
-    PERL=""
+*** Perl version 5.14 or later is required, but this is $pgac_perl_version." "$LINENO" 5
   fi
 fi
 
 if test -z "$PERL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&5
-$as_echo "$as_me: WARNING:
-*** Without Perl you will not be able to build PostgreSQL from Git.
-*** You can obtain Perl from any CPAN mirror site.
-*** (If you are using the official distribution of PostgreSQL then you do not
-*** need to worry about this, because the Perl output is pre-generated.)" >&2;}
+  as_fn_error $? "Perl not found" "$LINENO" 5
 fi
 
 if test "$with_perl" = yes; then
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index f4b1f81189..468759583c 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -102,6 +102,41 @@ <title>Requirements</title>
      </para>
     </listitem>
 
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>flex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>lex</primary>
+      </indexterm>
+      <indexterm>
+       <primary>bison</primary>
+      </indexterm>
+      <indexterm>
+       <primary>yacc</primary>
+      </indexterm>
+
+      <application>Flex</application> 2.5.35 or later and
+      <application>Bison</application> 2.3 or later are required.  Other
+      <application>lex</application> and <application>yacc</application>
+      programs cannot be used.
+     </para>
+    </listitem>
+
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>perl</primary>
+      </indexterm>
+
+      <application>Perl</application> 5.14 or later is needed during the build
+      process and to run some test suites.  (This requirement is separate from
+      the requirements for building <application>PL/Perl</application>; see
+      below.)
+     </para>
+    </listitem>
+
     <listitem>
      <para>
       <indexterm>
@@ -315,51 +350,6 @@ <title>Requirements</title>
    </itemizedlist>
   </para>
 
-  <para>
-   If you are building from a <productname>Git</productname> tree instead of
-   using a released source package, or if you want to do server development,
-   you also need the following packages:
-
-   <itemizedlist>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>flex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>lex</primary>
-      </indexterm>
-      <indexterm>
-       <primary>bison</primary>
-      </indexterm>
-      <indexterm>
-       <primary>yacc</primary>
-      </indexterm>
-
-      <application>Flex</application> and <application>Bison</application>
-      are needed to build from a Git checkout, or if you changed the actual
-      scanner and parser definition files. If you need them, be sure
-      to get <application>Flex</application> 2.5.35 or later and
-      <application>Bison</application> 2.3 or later. Other <application>lex</application>
-      and <application>yacc</application> programs cannot be used.
-     </para>
-    </listitem>
-    <listitem>
-     <para>
-      <indexterm>
-       <primary>perl</primary>
-      </indexterm>
-
-      <application>Perl</application> 5.14 or later is needed to build from a Git checkout,
-      or if you changed the input files for any of the build steps that
-      use Perl scripts.  If building on Windows you will need
-      <application>Perl</application> in any case.  <application>Perl</application> is
-      also required to run some test suites.
-     </para>
-    </listitem>
-   </itemizedlist>
-  </para>
-
   <para>
    If you need to get a <acronym>GNU</acronym> package, you can find
    it at your local <acronym>GNU</acronym> mirror site (see <ulink
diff --git a/doc/src/sgml/sourcerepo.sgml b/doc/src/sgml/sourcerepo.sgml
index 07b003a794..6c13c5a30c 100644
--- a/doc/src/sgml/sourcerepo.sgml
+++ b/doc/src/sgml/sourcerepo.sgml
@@ -16,16 +16,6 @@ <title>The Source Code Repository</title>
   has some discussion on working with Git.
  </para>
 
-  <para>
-   Note that building <productname>PostgreSQL</productname> from the source
-   repository requires reasonably up-to-date versions of <application>bison</application>,
-   <application>flex</application>, and <application>Perl</application>.
-   These tools are not needed to build from a distribution tarball, because
-   the files generated with these tools are included in the tarball.
-   Other tool requirements
-   are the same as shown in <xref linkend="install-requirements"/>.
-  </para>
-
  <sect1 id="git">
   <title>Getting the Source via <productname>Git</productname></title>
 
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 7b66590801..985b3ea62b 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -319,12 +319,8 @@ X = @EXEEXT@
 
 # Perl
 
-ifneq (@PERL@,)
-    # quoted to protect pathname with spaces
-    PERL		= '@PERL@'
-else
-    PERL		= $(missing) perl
-endif
+# quoted to protect pathname with spaces
+PERL		= '@PERL@'
 perl_archlibexp		= @perl_archlibexp@
 perl_privlibexp		= @perl_privlibexp@
 perl_includespec	= @perl_includespec@
@@ -777,21 +773,13 @@ TAS         = @TAS@
 # Global targets and rules
 
 %.c: %.l
-ifdef FLEX
 	$(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
 	@$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
 	$(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
-else
-	@$(missing) flex $< '$@'
-endif
 
 %.c: %.y
 	$(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
-ifdef BISON
 	$(BISON) $(BISONFLAGS) -o $@ $<
-else
-	@$(missing) bison $< $@
-endif
 
 %.i: %.c
 	$(CPP) $(CPPFLAGS) -o $@ $<
-- 
2.42.0

v5-0002-Remove-distprep.patchtext/plain; charset=UTF-8; name=v5-0002-Remove-distprep.patchDownload
From 42b5812cacb97746aec2f7c7a54dafba10437e24 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Wed, 23 Aug 2023 12:15:42 +0200
Subject: [PATCH v5 2/2] Remove distprep

A PostgreSQL release tarball contains a number of prebuilt files, in
particular files produced by bison, flex, perl, and well as html and
man documentation.  We have done this consistent with established
practice at the time to not require these tools for building from a
tarball.  Some of these tools were hard to get, or get the right
version of, from time to time, and shipping the prebuilt output was a
convenience to users.

Now this has at least two problems:

One, we have to make the build system(s) work in two modes: Building
from a git checkout and building from a tarball.  This is pretty
complicated, but it works so far for autoconf/make.  It does not
currently work for meson; you can currently only build with meson from
a git checkout.  Making meson builds work from a tarball seems very
difficult or impossible.  One particular problem is that since meson
requires a separate build directory, we cannot make the build update
files like gram.h in the source tree.  So if you were to build from a
tarball and update gram.y, you will have a gram.h in the source tree
and one in the build tree, but the way things work is that the
compiler will always use the one in the source tree.  So you cannot,
for example, make any gram.y changes when building from a tarball.
This seems impossible to fix in a non-horrible way.

Second, there is increased interest nowadays in precisely tracking the
origin of software.  We can reasonably track contributions into the
git tree, and users can reasonably track the path from a tarball to
packages and downloads and installs.  But what happens between the git
tree and the tarball is obscure and in some cases non-reproducible.

The solution for both of these issues is to get rid of the step that
adds prebuilt files to the tarball.  The tarball now only contains
what is in the git tree (*).  Getting the additional build
dependencies is no longer a problem nowadays, and the complications to
keep these dual build modes working are significant.  And of course we
want to get the meson build system working universally.

This commit removes the make distprep target altogether.  The make
dist target continues to do its job, it just doesn't call distprep
anymore.

(*) - The tarball also contains the INSTALL file that is built at make
dist time, but not by distprep.  This is unchanged for now.

The make maintainer-clean target, whose job it is to remove the
prebuilt files in addition to what make distclean does, is now just an
alias to make distprep.  (In practice, it is probably obsolete given
that git clean is available.)

The following programs are now hard build requirements in configure
(they were already required by meson.build):

- bison
- flex
- perl
---
 GNUmakefile.in                                |  6 +-
 contrib/cube/Makefile                         |  7 +--
 contrib/fuzzystrmatch/Makefile                |  9 +--
 contrib/seg/Makefile                          |  7 +--
 doc/Makefile                                  |  2 +-
 doc/src/Makefile                              |  2 +-
 doc/src/sgml/Makefile                         | 16 ++---
 doc/src/sgml/installation.sgml                |  3 +-
 meson.build                                   |  2 +-
 src/Makefile                                  |  5 +-
 src/Makefile.global.in                        | 14 +++--
 src/backend/Makefile                          | 62 ++++---------------
 src/backend/bootstrap/Makefile                |  6 +-
 src/backend/catalog/Makefile                  | 14 +----
 src/backend/jit/llvm/Makefile                 |  2 +-
 src/backend/nls.mk                            |  2 +-
 src/backend/nodes/Makefile                    | 12 ++--
 src/backend/parser/Makefile                   |  8 +--
 src/backend/port/Makefile                     |  2 +-
 src/backend/replication/Makefile              | 10 ++-
 .../replication/libpqwalreceiver/Makefile     |  2 +-
 src/backend/replication/pgoutput/Makefile     |  2 +-
 src/backend/snowball/Makefile                 |  4 --
 src/backend/storage/lmgr/Makefile             |  4 +-
 src/backend/utils/Makefile                    | 28 +++------
 src/backend/utils/activity/Makefile           |  2 +-
 src/backend/utils/adt/Makefile                |  5 +-
 src/backend/utils/mb/Makefile                 |  2 +-
 src/backend/utils/mb/Unicode/Makefile         |  2 -
 src/backend/utils/mb/conversion_procs/proc.mk |  2 +-
 src/backend/utils/misc/Makefile               |  3 +-
 src/bin/initdb/Makefile                       |  2 +-
 src/bin/pg_amcheck/Makefile                   |  2 +-
 src/bin/pg_archivecleanup/Makefile            |  2 +-
 src/bin/pg_basebackup/Makefile                |  2 +-
 src/bin/pg_checksums/Makefile                 |  2 +-
 src/bin/pg_config/Makefile                    |  2 +-
 src/bin/pg_controldata/Makefile               |  2 +-
 src/bin/pg_ctl/Makefile                       |  2 +-
 src/bin/pg_dump/Makefile                      |  2 +-
 src/bin/pg_resetwal/Makefile                  |  2 +-
 src/bin/pg_rewind/Makefile                    |  2 +-
 src/bin/pg_test_fsync/Makefile                |  2 +-
 src/bin/pg_test_timing/Makefile               |  2 +-
 src/bin/pg_upgrade/Makefile                   |  2 +-
 src/bin/pg_verifybackup/Makefile              |  2 +-
 src/bin/pg_waldump/Makefile                   |  2 +-
 src/bin/pgbench/Makefile                      |  4 --
 src/bin/psql/Makefile                         |  6 --
 src/bin/scripts/Makefile                      |  2 +-
 src/common/Makefile                           |  5 --
 src/common/unicode/Makefile                   |  2 -
 src/fe_utils/Makefile                         |  6 --
 src/include/Makefile                          |  2 +-
 src/interfaces/ecpg/Makefile                  |  2 +-
 src/interfaces/ecpg/compatlib/Makefile        |  2 -
 src/interfaces/ecpg/ecpglib/Makefile          |  2 -
 src/interfaces/ecpg/include/Makefile          |  2 +-
 src/interfaces/ecpg/pgtypeslib/Makefile       |  2 -
 src/interfaces/ecpg/preproc/Makefile          |  6 --
 src/interfaces/ecpg/test/Makefile             |  4 +-
 src/interfaces/libpq/Makefile                 |  3 -
 src/interfaces/libpq/test/Makefile            |  2 +-
 src/makefiles/pgxs.mk                         |  2 +-
 src/nls-global.mk                             |  2 +-
 src/pl/plperl/GNUmakefile                     |  2 +-
 src/pl/plpgsql/src/Makefile                   |  7 ---
 src/pl/plpython/Makefile                      |  6 +-
 src/pl/tcl/Makefile                           |  5 --
 src/port/Makefile                             |  2 +-
 src/test/authentication/Makefile              |  2 +-
 src/test/examples/Makefile                    |  2 +-
 src/test/icu/Makefile                         |  2 +-
 src/test/isolation/Makefile                   |  6 --
 src/test/kerberos/Makefile                    |  2 +-
 src/test/ldap/Makefile                        |  2 +-
 src/test/locale/Makefile                      |  2 +-
 src/test/recovery/Makefile                    |  2 +-
 src/test/regress/GNUmakefile                  |  2 +-
 src/test/ssl/Makefile                         |  2 +-
 src/test/ssl/sslfiles.mk                      |  4 +-
 src/test/subscription/Makefile                |  2 +-
 src/timezone/Makefile                         |  2 +-
 src/tools/ifaddrs/Makefile                    |  2 +-
 src/tools/pg_bsd_indent/Makefile              |  2 +-
 85 files changed, 123 insertions(+), 270 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index 9c18c56233..80db4c73f8 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -41,7 +41,7 @@ install-world-bin-contrib-recurse: install-world-bin-src-recurse
 
 $(call recurse,installdirs uninstall init-po update-po,doc src config)
 
-$(call recurse,distprep coverage,doc src config contrib)
+$(call recurse,coverage,doc src config contrib)
 
 # clean, distclean, etc should apply to contrib too, even though
 # it's not built by default
@@ -53,7 +53,7 @@ clean:
 
 # Important: distclean `src' last, otherwise Makefile.global
 # will be gone too soon.
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C doc $@
 	$(MAKE) -C contrib $@
 	$(MAKE) -C config $@
@@ -109,7 +109,6 @@ distdir:
 	      || cp "$(top_srcdir)/$$file" "$(distdir)/$$file"; \
 	  fi || exit; \
 	done
-	$(MAKE) -C $(distdir) distprep
 	$(MAKE) -C $(distdir)/doc/src/sgml/ INSTALL
 	cp $(distdir)/doc/src/sgml/INSTALL $(distdir)/
 	$(MAKE) -C $(distdir) distclean
@@ -122,7 +121,6 @@ distcheck: dist
 	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
diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 4fd19aac35..dfb0d806e4 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -18,6 +18,8 @@ REGRESS = cube cube_sci
 
 SHLIB_LINK += $(filter -lm, $(LIBS))
 
+EXTRA_CLEAN = cubeparse.h cubeparse.c cubescan.c
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -37,8 +39,3 @@ cubeparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 cubeparse.o cubescan.o: cubeparse.h
-
-distprep: cubeparse.c cubescan.c
-
-maintainer-clean:
-	rm -f cubeparse.h cubeparse.c cubescan.c
diff --git a/contrib/fuzzystrmatch/Makefile b/contrib/fuzzystrmatch/Makefile
index e68bc0e33f..04c83a34a7 100644
--- a/contrib/fuzzystrmatch/Makefile
+++ b/contrib/fuzzystrmatch/Makefile
@@ -15,6 +15,8 @@ PGFILEDESC = "fuzzystrmatch - similarities and distance between strings"
 
 REGRESS = fuzzystrmatch fuzzystrmatch_utf8
 
+EXTRA_CLEAN = daitch_mokotoff.h
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
@@ -31,10 +33,3 @@ daitch_mokotoff.o: daitch_mokotoff.h
 
 daitch_mokotoff.h: daitch_mokotoff_header.pl
 	$(PERL) $< $@
-
-# daitch_mokotoff.h is included in tarballs, so it has to be made by
-# "distprep" and not cleaned except by "maintainer-clean".
-distprep: daitch_mokotoff.h
-
-maintainer-clean:
-	rm -f daitch_mokotoff.h
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index a1e49bf051..132ec8dbfe 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -16,7 +16,7 @@ HEADERS = segdata.h
 
 REGRESS = security seg
 
-EXTRA_CLEAN = y.tab.c y.tab.h
+EXTRA_CLEAN = segparse.h segparse.c segscan.c
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
@@ -38,8 +38,3 @@ segparse.c: BISONFLAGS += -d
 
 # Force these dependencies to be known even without dependency info built:
 segparse.o segscan.o: segparse.h
-
-distprep: segparse.c segscan.c
-
-maintainer-clean:
-	rm -f segparse.h segparse.c segscan.c
diff --git a/doc/Makefile b/doc/Makefile
index aee3cc0965..24370fc903 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -12,5 +12,5 @@ subdir = doc
 top_builddir = ..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C src $@
diff --git a/doc/src/Makefile b/doc/src/Makefile
index 30d883815a..2ed02084ff 100644
--- a/doc/src/Makefile
+++ b/doc/src/Makefile
@@ -4,5 +4,5 @@ subdir = doc/src
 top_builddir = ../..
 include $(top_builddir)/src/Makefile.global
 
-all distprep html man install installdirs uninstall clean distclean maintainer-clean:
+all html man install installdirs uninstall clean distclean:
 	$(MAKE) -C sgml $@
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 1e55e531db..49d35dd0d6 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -7,8 +7,7 @@
 #----------------------------------------------------------------------------
 
 # This makefile is for building and installing the documentation.
-# When a release tarball is created, the documentation files are
-# prepared using the distprep target.  In Git-based trees these files
+# In Git-based trees these files
 # don't exist, unless explicitly built, so we skip the installation in
 # that case.
 
@@ -28,8 +27,6 @@ include $(top_builddir)/src/Makefile.global
 
 all: html man
 
-distprep: html distprep-man
-
 
 ifndef DBTOEPUB
 DBTOEPUB = $(missing) dbtoepub
@@ -77,7 +74,7 @@ postgres-full.xml: postgres.sgml $(ALLSGML)
 ## Man pages
 ##
 
-man distprep-man: man-stamp
+man: man-stamp
 
 man-stamp: stylesheet-man.xsl postgres-full.xml
 	$(XSLTPROC) $(XMLINCLUDE) $(XSLTPROCFLAGS) $(XSLTPROC_MAN_FLAGS) $^
@@ -89,10 +86,9 @@ man-stamp: stylesheet-man.xsl postgres-full.xml
 ##
 
 # Technically, this should depend on Makefile.global, but then
-# version.sgml would need to be rebuilt after every configure run,
-# even in distribution tarballs.  So this is cheating a bit, but it
-# will achieve the goal of updating the version number when it
-# changes.
+# version.sgml would need to be rebuilt after every configure run.  So
+# this is cheating a bit, but it will achieve the goal of updating the
+# version number when it changes.
 version.sgml: $(top_srcdir)/configure
 	{ \
 	  echo "<!ENTITY version \"$(VERSION)\">"; \
@@ -305,8 +301,6 @@ clean:
 	rm -f *.texixml *.texi *.info db2texi.refs
 
 distclean: clean
-
-maintainer-clean: distclean
 # HTML
 	rm -fr html/ html-stamp
 # man
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 468759583c..36c1ec2918 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -72,8 +72,7 @@ <title>Requirements</title>
 
       Alternatively, <productname>PostgreSQL</productname> can be built using
       <ulink url="https://mesonbuild.com/">Meson</ulink>.  This is currently
-      experimental and only works when building from a Git checkout (not from
-      a distribution tarball).  If you choose to use
+      experimental.  If you choose to use
       <application>Meson</application>, then you don't need
       <acronym>GNU</acronym> <application>make</application>, but the other
       requirements below still apply.
diff --git a/meson.build b/meson.build
index 862c955453..a8a4344e00 100644
--- a/meson.build
+++ b/meson.build
@@ -72,7 +72,7 @@ configure. Alternatively use a separate check out for meson based builds.
 @0@
 ****'''
 if fs.exists(meson.current_source_dir() / 'src' / 'include' / 'pg_config.h')
-  errmsg_cleanup = 'To clean up, run make maintainer-clean in the source tree.'
+  errmsg_cleanup = 'To clean up, run make distclean in the source tree.'
   error(errmsg_nonclean_base.format(errmsg_cleanup))
 endif
 
diff --git a/src/Makefile b/src/Makefile
index 94649c36c7..2f31a2f20a 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -59,16 +59,13 @@ uninstall: uninstall-local
 uninstall-local:
 	rm -f $(addprefix '$(DESTDIR)$(pgxsdir)/$(subdir)'/, Makefile.global Makefile.port Makefile.shlib nls-global.mk)
 
-distprep:
-	$(MAKE) -C test/isolation $@
-
 clean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
 	$(MAKE) -C tools/pg_bsd_indent $@
 
-distclean maintainer-clean:
+distclean:
 	$(MAKE) -C test $@
 	$(MAKE) -C tutorial NO_PGXS=1 $@
 	$(MAKE) -C test/isolation $@
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 985b3ea62b..b3ca6392a6 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -19,11 +19,11 @@
 #
 # Meta configuration
 
-standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check checkprep installcheck init-po update-po
+standard_targets = all install installdirs uninstall clean distclean coverage check checkprep installcheck init-po update-po
 # these targets should recurse even into subdirectories not being built:
-standard_always_targets = distprep clean distclean maintainer-clean
+standard_always_targets = clean distclean
 
-.PHONY: $(standard_targets) install-strip html man installcheck-parallel update-unicode
+.PHONY: $(standard_targets) maintainer-clean install-strip html man installcheck-parallel update-unicode
 
 # make `all' the default target
 all:
@@ -35,6 +35,8 @@ all:
 # Never delete any intermediate files automatically.
 .SECONDARY:
 
+maintainer-clean: distclean
+
 # PostgreSQL version number
 VERSION = @PACKAGE_VERSION@
 MAJORVERSION = @PG_MAJORVERSION@
@@ -907,7 +909,7 @@ recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if
 # If a makefile's list of SUBDIRS varies depending on configuration, then
 # any subdirectories excluded from SUBDIRS should instead be added to
 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
-# This ensures that distprep, distclean, etc will apply to all subdirectories.
+# This ensures that distclean, etc will apply to all subdirectories.
 # In the normal case all arguments will be defaulted.
 # $1: targets to make recursive (defaults to standard_always_targets)
 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
@@ -962,7 +964,7 @@ include $(Po_files)
 endif
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-deps
+clean distclean: clean-deps
 
 .PHONY: clean-deps
 clean-deps:
@@ -1046,7 +1048,7 @@ lcov_test.info: $(all_gcda_files)
 
 
 # hook for clean-up
-clean distclean maintainer-clean: clean-coverage
+clean distclean: clean-coverage
 
 .PHONY: clean-coverage
 clean-coverage:
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 3e275ac759..0a475f01a4 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -138,42 +138,33 @@ utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl u
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-catalog-headers:
-	$(MAKE) -C catalog distprep generated-header-symlinks
+	$(MAKE) -C catalog generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-nodes-headers:
-	$(MAKE) -C nodes distprep generated-header-symlinks
+	$(MAKE) -C nodes generated-header-symlinks
 
 # run this unconditionally to avoid needing to know its dependencies here:
 submake-utils-headers:
-	$(MAKE) -C utils distprep generated-header-symlinks
+	$(MAKE) -C utils generated-header-symlinks
 
 .PHONY: submake-catalog-headers submake-nodes-headers submake-utils-headers
 
 # Make symlinks for these headers in the include directory. That way
 # we can cut down on the -I options. Also, a symlink is automatically
 # up to date when we update the base file.
-#
-# The point of the prereqdir incantation in some of the rules below is to
-# force the symlink to use an absolute path rather than a relative path.
-# For headers which are generated by make distprep, the actual header within
-# src/backend will be in the source tree, while the symlink in src/include
-# will be in the build tree, so a simple ../.. reference won't work.
-# For headers generated during regular builds, we prefer a relative symlink.
 
 .PHONY: generated-headers
 
-generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers
+generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers parser/gram.h
 
 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 $(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
 
 utils/probes.o: utils/probes.d $(SUBDIROBJS)
 	$(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
@@ -181,16 +172,12 @@ utils/probes.o: utils/probes.d $(SUBDIROBJS)
 
 ##########################################################################
 
-# Be sure that these files get removed by the maintainer-clean target
-distprep:
+# This target is only needed by nls.mk.
+.PHONY: generated-parser-sources
+generated-parser-sources:
 	$(MAKE) -C parser	gram.c gram.h scan.c
 	$(MAKE) -C bootstrap	bootparse.c bootparse.h bootscanner.c
-	$(MAKE) -C catalog	distprep
-	$(MAKE) -C nodes	distprep
 	$(MAKE) -C replication	repl_gram.c repl_gram.h repl_scanner.c syncrep_gram.c syncrep_gram.h syncrep_scanner.c
-	$(MAKE) -C storage/lmgr	lwlocknames.h lwlocknames.c
-	$(MAKE) -C utils	distprep
-	$(MAKE) -C utils/activity	wait_event_types.h pgstat_wait_event.c
 	$(MAKE) -C utils/adt	jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
 	$(MAKE) -C utils/misc	guc-file.c
 
@@ -290,34 +277,9 @@ ifeq ($(PORTNAME), win32)
 endif
 
 distclean: clean
+# generated by configure
 	rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
 
-maintainer-clean: distclean
-	$(MAKE) -C catalog $@
-	$(MAKE) -C nodes $@
-	$(MAKE) -C utils $@
-	rm -f bootstrap/bootparse.c \
-	      bootstrap/bootparse.h \
-	      bootstrap/bootscanner.c \
-	      parser/gram.c \
-	      parser/gram.h \
-	      parser/scan.c \
-	      replication/repl_gram.c \
-	      replication/repl_gram.h \
-	      replication/repl_scanner.c \
-	      replication/syncrep_gram.c \
-	      replication/syncrep_gram.h \
-	      replication/syncrep_scanner.c \
-	      storage/lmgr/lwlocknames.c \
-	      storage/lmgr/lwlocknames.h \
-	      utils/activity/pgstat_wait_event.c \
-	      utils/activity/wait_event_funcs_data.c \
-	      utils/activity/wait_event_types.h \
-	      utils/adt/jsonpath_gram.c \
-	      utils/adt/jsonpath_gram.h \
-	      utils/adt/jsonpath_scan.c \
-	      utils/misc/guc-file.c
-
 
 ##########################################################################
 #
diff --git a/src/backend/bootstrap/Makefile b/src/backend/bootstrap/Makefile
index 606c8021e7..509b51e648 100644
--- a/src/backend/bootstrap/Makefile
+++ b/src/backend/bootstrap/Makefile
@@ -28,5 +28,7 @@ bootparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 bootparse.o bootscanner.o: bootparse.h
 
-# bootparse.c and bootscanner.c are in the distribution tarball, so
-# they are not cleaned here.
+clean:
+	rm -f bootparse.c \
+	      bootparse.h \
+	      bootscanner.c
diff --git a/src/backend/catalog/Makefile b/src/backend/catalog/Makefile
index 3e9994793d..ec7b6f5362 100644
--- a/src/backend/catalog/Makefile
+++ b/src/backend/catalog/Makefile
@@ -152,9 +152,7 @@ POSTGRES_BKI_DATA = $(addprefix $(top_srcdir)/src/include/catalog/,\
 	pg_type.dat \
 	)
 
-all: distprep generated-header-symlinks
-
-distprep: bki-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -173,14 +171,12 @@ bki-stamp: genbki.pl Catalog.pm $(POSTGRES_BKI_SRCS) $(POSTGRES_BKI_DATA) $(top_
 		--set-version=$(MAJORVERSION) $(POSTGRES_BKI_SRCS)
 	touch $@
 
-# The generated headers must all be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# The generated headers must all be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than bki-stamp.
 $(top_builddir)/src/include/catalog/header-stamp: bki-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in $(GENERATED_HEADERS); do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -201,9 +197,5 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, postgres.bki system_constraints.sql system_functions.sql system_views.sql information_schema.sql sql_features.txt)
 
-# postgres.bki, system_constraints.sql, and the generated headers are
-# in the distribution tarball, so they are not cleaned here.
 clean:
-
-maintainer-clean: clean
 	rm -f bki-stamp postgres.bki system_constraints.sql $(GENERATED_HEADERS)
diff --git a/src/backend/jit/llvm/Makefile b/src/backend/jit/llvm/Makefile
index 2da122a391..0036c4f552 100644
--- a/src/backend/jit/llvm/Makefile
+++ b/src/backend/jit/llvm/Makefile
@@ -71,6 +71,6 @@ uninstall-types:
 
 include $(top_srcdir)/src/Makefile.shlib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -f llvmjit_types.bc
diff --git a/src/backend/nls.mk b/src/backend/nls.mk
index 8263527c85..dfb053c2a7 100644
--- a/src/backend/nls.mk
+++ b/src/backend/nls.mk
@@ -22,7 +22,7 @@ GETTEXT_FLAGS    = $(BACKEND_COMMON_GETTEXT_FLAGS) \
     report_invalid_record:2:c-format \
     ereport_startup_progress:1:c-format
 
-gettext-files: distprep
+gettext-files: generated-parser-sources generated-headers
 	find $(srcdir) $(srcdir)/../common $(srcdir)/../port -name '*.c' -print | LC_ALL=C sort >$@
 
 my-clean:
diff --git a/src/backend/nodes/Makefile b/src/backend/nodes/Makefile
index 0a95e683d0..ebbe9052cb 100644
--- a/src/backend/nodes/Makefile
+++ b/src/backend/nodes/Makefile
@@ -65,9 +65,7 @@ node_headers = \
 
 # see also catalog/Makefile for an explanation of these make rules
 
-all: distprep generated-header-symlinks
-
-distprep: node-support-stamp
+all: generated-header-symlinks
 
 .PHONY: generated-header-symlinks
 
@@ -81,14 +79,12 @@ node-support-stamp: gen_node_support.pl $(addprefix $(top_srcdir)/src/include/,$
 	$(PERL) $^
 	touch $@
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than node-support-stamp.
 $(top_builddir)/src/include/nodes/header-stamp: node-support-stamp
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
 	cd '$(dir $@)' && for file in nodetags.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
@@ -98,5 +94,5 @@ outfuncs.o: outfuncs.c outfuncs.funcs.c outfuncs.switch.c | node-support-stamp
 queryjumblefuncs.o: queryjumblefuncs.c queryjumblefuncs.funcs.c queryjumblefuncs.switch.c | node-support-stamp
 readfuncs.o:  readfuncs.c readfuncs.funcs.c readfuncs.switch.c | node-support-stamp
 
-maintainer-clean: clean
+clean:
 	rm -f node-support-stamp $(addsuffix funcs.funcs.c,copy equal out queryjumble read) $(addsuffix funcs.switch.c,copy equal out queryjumble read) nodetags.h
diff --git a/src/backend/parser/Makefile b/src/backend/parser/Makefile
index 9f1c4022bb..401c16686c 100644
--- a/src/backend/parser/Makefile
+++ b/src/backend/parser/Makefile
@@ -64,8 +64,8 @@ scan.c: FLEX_FIX_WARNING=yes
 # Force these dependencies to be known even without dependency info built:
 gram.o scan.o parser.o: gram.h
 
-
-# gram.c, gram.h, and scan.c are in the distribution tarball, so they
-# are not cleaned here.
-clean distclean maintainer-clean:
+clean:
+	rm -f gram.c \
+	      gram.h \
+	      scan.c
 	rm -f lex.backup
diff --git a/src/backend/port/Makefile b/src/backend/port/Makefile
index 2d00b4f05a..47338d9922 100644
--- a/src/backend/port/Makefile
+++ b/src/backend/port/Makefile
@@ -43,6 +43,6 @@ else
 	$(CC) $(CFLAGS) -c $<
 endif
 
-distclean clean:
+clean:
 	rm -f tas_cpp.s
 	$(MAKE) -C win32 clean
diff --git a/src/backend/replication/Makefile b/src/backend/replication/Makefile
index 23f29ba545..7f867ee91d 100644
--- a/src/backend/replication/Makefile
+++ b/src/backend/replication/Makefile
@@ -48,6 +48,10 @@ syncrep_gram.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 syncrep_gram.o syncrep_scanner.o: syncrep_gram.h
 
-# repl_gram.c, repl_scanner.c, syncrep_gram.c and syncrep_scanner.c
-# are in the distribution tarball, so they are not cleaned here.
-# (Our parent Makefile takes care of them during maintainer-clean.)
+clean:
+	rm -f repl_gram.c \
+	      repl_gram.h \
+	      repl_scanner.c \
+	      syncrep_gram.c \
+	      syncrep_gram.h \
+	      syncrep_scanner.c
diff --git a/src/backend/replication/libpqwalreceiver/Makefile b/src/backend/replication/libpqwalreceiver/Makefile
index f26daa135f..e882907350 100644
--- a/src/backend/replication/libpqwalreceiver/Makefile
+++ b/src/backend/replication/libpqwalreceiver/Makefile
@@ -33,5 +33,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/replication/pgoutput/Makefile b/src/backend/replication/pgoutput/Makefile
index 3b41fbcfac..d89d317fe7 100644
--- a/src/backend/replication/pgoutput/Makefile
+++ b/src/backend/replication/pgoutput/Makefile
@@ -28,5 +28,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/snowball/Makefile b/src/backend/snowball/Makefile
index 4bebfa0250..efc4300eb9 100644
--- a/src/backend/snowball/Makefile
+++ b/src/backend/snowball/Makefile
@@ -104,8 +104,6 @@ include $(top_srcdir)/src/Makefile.shlib
 $(SQLSCRIPT): snowball_create.pl snowball_func.sql.in snowball.sql.in
 	$(PERL) $< --input ${srcdir} --outdir .
 
-distprep: $(SQLSCRIPT)
-
 install: all installdirs install-lib install-script
 	$(INSTALL_DATA) $(addprefix $(srcdir)/stopwords/,$(stop_files)) '$(DESTDIR)$(datadir)/$(DICTDIR)'
 
@@ -122,6 +120,4 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
 	rm -f $(SQLSCRIPT)
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index b25b7ee421..c48ba943c4 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -45,8 +45,6 @@ lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt generate-l
 check: s_lock_test
 	./s_lock_test
 
-clean distclean:
+clean:
 	rm -f s_lock_test
-
-maintainer-clean: clean
 	rm -f lwlocknames.h lwlocknames.c
diff --git a/src/backend/utils/Makefile b/src/backend/utils/Makefile
index deb901609f..e184e3dfdf 100644
--- a/src/backend/utils/Makefile
+++ b/src/backend/utils/Makefile
@@ -34,13 +34,14 @@ catalogdir  = $(top_srcdir)/src/backend/catalog
 
 include $(top_srcdir)/src/backend/common.mk
 
-all: distprep probes.h generated-header-symlinks
+all: probes.h generated-header-symlinks
 
-distprep: fmgr-stamp errcodes.h
+.PHONY: generated-header-symlinks submake-adt-headers
 
-.PHONY: generated-header-symlinks
+generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp submake-adt-headers
 
-generated-header-symlinks: $(top_builddir)/src/include/utils/header-stamp $(top_builddir)/src/include/utils/probes.h
+submake-adt-headers:
+	$(MAKE) -C adt jsonpath_gram.h
 
 $(SUBDIRS:%=%-recursive): fmgr-stamp errcodes.h
 
@@ -66,22 +67,15 @@ probes.h: Gen_dummy_probes.sed probes.d
 	sed -f $^ >$@
 endif
 
-# These generated headers must be symlinked into builddir/src/include/,
-# using absolute links for the reasons explained in src/backend/Makefile.
+# These generated headers must be symlinked into src/include/.
 # We use header-stamp to record that we've done this because the symlinks
 # themselves may appear older than fmgr-stamp.
-$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h; do \
-	  rm -f $$file && $(LN_S) "$$prereqdir/$$file" . ; \
+$(top_builddir)/src/include/utils/header-stamp: fmgr-stamp errcodes.h probes.h
+	cd '$(dir $@)' && for file in fmgroids.h fmgrprotos.h errcodes.h probes.h; do \
+	  rm -f $$file && $(LN_S) "../../../$(subdir)/$$file" . ; \
 	done
 	touch $@
 
-# probes.h is handled differently because it's not in the distribution tarball.
-$(top_builddir)/src/include/utils/probes.h: probes.h
-	cd '$(dir $@)' && rm -f $(notdir $@) && \
-	    $(LN_S) "../../../$(subdir)/probes.h" .
-
 # Recipe for rebuilding the Perl version of Gen_dummy_probes
 # Nothing depends on it, so it will never be called unless explicitly requested
 # The last two lines of the recipe format the script according to  our
@@ -104,10 +98,6 @@ installdirs:
 uninstall-data:
 	rm -f $(addprefix '$(DESTDIR)$(datadir)'/, errcodes.txt)
 
-# fmgroids.h, fmgrprotos.h, fmgrtab.c, fmgr-stamp, and errcodes.h are in the
-# distribution tarball, so they are not cleaned here.
 clean:
 	rm -f probes.h probes.h.tmp
-
-maintainer-clean: clean
 	rm -f fmgroids.h fmgrprotos.h fmgrtab.c fmgr-stamp errcodes.h
diff --git a/src/backend/utils/activity/Makefile b/src/backend/utils/activity/Makefile
index f57cf3958c..a4397ef907 100644
--- a/src/backend/utils/activity/Makefile
+++ b/src/backend/utils/activity/Makefile
@@ -47,5 +47,5 @@ pgstat_wait_event.c: wait_event_types.h
 wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt generate-wait_event_types.pl
 	$(PERL) $(srcdir)/generate-wait_event_types.pl --code $<
 
-maintainer-clean: clean
+clean:
 	rm -f wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile
index 0de0bbb1b8..199eae525d 100644
--- a/src/backend/utils/adt/Makefile
+++ b/src/backend/utils/adt/Makefile
@@ -132,10 +132,9 @@ jsonpath_scan.c: FLEX_NO_BACKUP=yes
 # Force these dependencies to be known even without dependency info built:
 jsonpath_gram.o jsonpath_scan.o: jsonpath_gram.h
 
-# jsonpath_gram.c and jsonpath_scan.c are in the distribution tarball,
-# so they are not cleaned here.
-clean distclean maintainer-clean:
+clean:
 	rm -f lex.backup
+	rm -f jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
 
 like.o: like.c like_match.c
 
diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile
index b19a125fa2..bbde71b5aa 100644
--- a/src/backend/utils/mb/Makefile
+++ b/src/backend/utils/mb/Makefile
@@ -21,5 +21,5 @@ OBJS = \
 
 include $(top_srcdir)/src/backend/common.mk
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C conversion_procs $@
diff --git a/src/backend/utils/mb/Unicode/Makefile b/src/backend/utils/mb/Unicode/Makefile
index ea930a7b95..c540f34649 100644
--- a/src/backend/utils/mb/Unicode/Makefile
+++ b/src/backend/utils/mb/Unicode/Makefile
@@ -66,8 +66,6 @@ all: $(MAPS)
 
 distclean: clean
 	rm -f $(TEXTS)
-
-maintainer-clean: distclean
 	rm -f $(MAPS)
 
 
diff --git a/src/backend/utils/mb/conversion_procs/proc.mk b/src/backend/utils/mb/conversion_procs/proc.mk
index e0a3b74b25..2eeae28240 100644
--- a/src/backend/utils/mb/conversion_procs/proc.mk
+++ b/src/backend/utils/mb/conversion_procs/proc.mk
@@ -13,5 +13,5 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f $(OBJS)
diff --git a/src/backend/utils/misc/Makefile b/src/backend/utils/misc/Makefile
index 2910032930..c2971c7678 100644
--- a/src/backend/utils/misc/Makefile
+++ b/src/backend/utils/misc/Makefile
@@ -40,6 +40,5 @@ endif
 
 include $(top_srcdir)/src/backend/common.mk
 
-# Note: guc-file.c is not deleted by 'make clean',
-# since we want to ship it in distribution tarballs.
 clean:
+	rm -f guc-file.c
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile
index d69bd89572..7043289239 100644
--- a/src/bin/initdb/Makefile
+++ b/src/bin/initdb/Makefile
@@ -55,7 +55,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/initdb$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f initdb$(X) $(OBJS) localtime.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_amcheck/Makefile b/src/bin/pg_amcheck/Makefile
index 947f2267ed..528c588e35 100644
--- a/src/bin/pg_amcheck/Makefile
+++ b/src/bin/pg_amcheck/Makefile
@@ -40,7 +40,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_amcheck$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_amcheck$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_archivecleanup/Makefile b/src/bin/pg_archivecleanup/Makefile
index 49935d6dce..93fd703f22 100644
--- a/src/bin/pg_archivecleanup/Makefile
+++ b/src/bin/pg_archivecleanup/Makefile
@@ -25,7 +25,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_archivecleanup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_archivecleanup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_basebackup/Makefile b/src/bin/pg_basebackup/Makefile
index 893a75c942..74dc1ddd6d 100644
--- a/src/bin/pg_basebackup/Makefile
+++ b/src/bin/pg_basebackup/Makefile
@@ -71,7 +71,7 @@ uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_receivewal$(X)'
 	rm -f '$(DESTDIR)$(bindir)/pg_recvlogical$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_basebackup$(X) pg_receivewal$(X) pg_recvlogical$(X) \
 		$(BBOBJS) pg_receivewal.o pg_recvlogical.o \
 		$(OBJS)
diff --git a/src/bin/pg_checksums/Makefile b/src/bin/pg_checksums/Makefile
index 4911f6bee2..ac736b2260 100644
--- a/src/bin/pg_checksums/Makefile
+++ b/src/bin/pg_checksums/Makefile
@@ -36,7 +36,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_checksums$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_checksums$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_config/Makefile b/src/bin/pg_config/Makefile
index 1a405f9c97..cb13aceafa 100644
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_config$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_config$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile
index aa5bd58222..00ee1e25b3 100644
--- a/src/bin/pg_controldata/Makefile
+++ b/src/bin/pg_controldata/Makefile
@@ -33,7 +33,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_controldata$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_controldata$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_ctl/Makefile b/src/bin/pg_ctl/Makefile
index 4b6d47a8f8..4d29ca72c1 100644
--- a/src/bin/pg_ctl/Makefile
+++ b/src/bin/pg_ctl/Makefile
@@ -42,7 +42,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_ctl$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_ctl$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_dump/Makefile b/src/bin/pg_dump/Makefile
index 24de7593a6..604cddb997 100644
--- a/src/bin/pg_dump/Makefile
+++ b/src/bin/pg_dump/Makefile
@@ -69,6 +69,6 @@ installcheck:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_dump$(X) pg_restore$(X) pg_dumpall$(X) $(OBJS) pg_dump.o common.o pg_dump_sort.o pg_restore.o pg_dumpall.o
 	rm -rf tmp_check
diff --git a/src/bin/pg_resetwal/Makefile b/src/bin/pg_resetwal/Makefile
index 5c86435e22..a93e6611af 100644
--- a/src/bin/pg_resetwal/Makefile
+++ b/src/bin/pg_resetwal/Makefile
@@ -35,7 +35,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_resetwal$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_resetwal$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_rewind/Makefile b/src/bin/pg_rewind/Makefile
index bed05f1609..8df1da80cb 100644
--- a/src/bin/pg_rewind/Makefile
+++ b/src/bin/pg_rewind/Makefile
@@ -49,7 +49,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_rewind$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_rewind$(X) $(OBJS) xlogreader.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_test_fsync/Makefile b/src/bin/pg_test_fsync/Makefile
index 631d0f38a8..4c5e518125 100644
--- a/src/bin/pg_test_fsync/Makefile
+++ b/src/bin/pg_test_fsync/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_fsync$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_fsync$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_test_timing/Makefile b/src/bin/pg_test_timing/Makefile
index 84d84c38aa..7f677edadb 100644
--- a/src/bin/pg_test_timing/Makefile
+++ b/src/bin/pg_test_timing/Makefile
@@ -31,6 +31,6 @@ installcheck:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_test_timing$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_test_timing$(X) $(OBJS)
 	rm -rf tmp_check
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 5834513add..f76aca1b1a 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -46,7 +46,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_upgrade$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_upgrade$(X) $(OBJS)
 	rm -rf delete_old_cluster.sh log/ tmp_check/ \
 	       reindex_hash.sql
diff --git a/src/bin/pg_verifybackup/Makefile b/src/bin/pg_verifybackup/Makefile
index 596df15118..c96323faa9 100644
--- a/src/bin/pg_verifybackup/Makefile
+++ b/src/bin/pg_verifybackup/Makefile
@@ -38,7 +38,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_verifybackup$(X) $(OBJS)
 	rm -rf tmp_check
 
diff --git a/src/bin/pg_waldump/Makefile b/src/bin/pg_waldump/Makefile
index 0ecf582039..4c1ee64950 100644
--- a/src/bin/pg_waldump/Makefile
+++ b/src/bin/pg_waldump/Makefile
@@ -45,7 +45,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_waldump$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_waldump$(X) $(OBJS) $(RMGRDESCSOURCES) xlogreader.c xlogstats.c
 	rm -rf tmp_check
 
diff --git a/src/bin/pgbench/Makefile b/src/bin/pgbench/Makefile
index 68b6eb0376..987bf64df9 100644
--- a/src/bin/pgbench/Makefile
+++ b/src/bin/pgbench/Makefile
@@ -38,8 +38,6 @@ exprparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 exprparse.o exprscan.o: exprparse.h
 
-distprep: exprparse.c exprscan.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) pgbench$(X) '$(DESTDIR)$(bindir)/pgbench$(X)'
 
@@ -52,8 +50,6 @@ uninstall:
 clean distclean:
 	rm -f pgbench$(X) $(OBJS)
 	rm -rf tmp_check
-
-maintainer-clean: distclean
 	rm -f exprparse.h exprparse.c exprscan.c
 
 check:
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index 1f2bf0c6b0..8ad7c65446 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -62,8 +62,6 @@ psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
 psqlscanslash.c: FLEX_NO_BACKUP=yes
 psqlscanslash.c: FLEX_FIX_WARNING=yes
 
-distprep: sql_help.h sql_help.c psqlscanslash.c
-
 install: all installdirs
 	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
 	$(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
@@ -77,10 +75,6 @@ uninstall:
 clean distclean:
 	rm -f psql$(X) $(OBJS) lex.backup
 	rm -rf tmp_check
-
-# files removed here are supposed to be in the distribution tarball,
-# so do not clean them in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f sql_help.h sql_help.c psqlscanslash.c
 
 check:
diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile
index a7a9d0fea5..20db40b103 100644
--- a/src/bin/scripts/Makefile
+++ b/src/bin/scripts/Makefile
@@ -48,7 +48,7 @@ installdirs:
 uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(addsuffix $(X), $(PROGRAMS)))
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(addsuffix $(X), $(PROGRAMS)) $(addsuffix .o, $(PROGRAMS))
 	rm -f common.o $(WIN32RES)
 	rm -rf tmp_check
diff --git a/src/common/Makefile b/src/common/Makefile
index cc5c54dcee..36eae518b9 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -122,8 +122,6 @@ GEN_KEYWORDLIST_DEPS = $(TOOLSDIR)/gen_keywordlist.pl $(TOOLSDIR)/PerfectHash.pm
 
 all: libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 
-distprep: kwlist_d.h
-
 # libpgcommon is needed by some contrib
 install: all installdirs
 	$(INSTALL_STLIB) libpgcommon.a '$(DESTDIR)$(libdir)/libpgcommon.a'
@@ -189,10 +187,7 @@ RYU_OBJS = $(RYU_FILES) $(RYU_FILES:%.o=%_shlib.o) $(RYU_FILES:%.o=%_srv.o)
 
 $(RYU_OBJS): CFLAGS += $(PERMIT_DECLARATION_AFTER_STATEMENT)
 
-# kwlist_d.h is in the distribution tarball, so it is not cleaned here.
 clean distclean:
 	rm -f libpgcommon.a libpgcommon_shlib.a libpgcommon_srv.a
 	rm -f $(OBJS_FRONTEND) $(OBJS_SHLIB) $(OBJS_SRV)
-
-maintainer-clean: distclean
 	rm -f kwlist_d.h
diff --git a/src/common/unicode/Makefile b/src/common/unicode/Makefile
index 382da476cf..d6e427b582 100644
--- a/src/common/unicode/Makefile
+++ b/src/common/unicode/Makefile
@@ -68,5 +68,3 @@ clean:
 
 distclean: clean
 	rm -f UnicodeData.txt EastAsianWidth.txt CompositionExclusions.txt NormalizationTest.txt norm_test_table.h unicode_norm_table.h
-
-maintainer-clean: distclean
diff --git a/src/fe_utils/Makefile b/src/fe_utils/Makefile
index 456d6dd390..8accd5906d 100644
--- a/src/fe_utils/Makefile
+++ b/src/fe_utils/Makefile
@@ -48,8 +48,6 @@ psqlscan.c: FLEXFLAGS = -Cfe -p -p
 psqlscan.c: FLEX_NO_BACKUP=yes
 psqlscan.c: FLEX_FIX_WARNING=yes
 
-distprep: psqlscan.c
-
 # libpgfeutils could be useful to contrib, so install it
 install: all installdirs
 	$(INSTALL_STLIB) libpgfeutils.a '$(DESTDIR)$(libdir)/libpgfeutils.a'
@@ -62,8 +60,4 @@ uninstall:
 
 clean distclean:
 	rm -f libpgfeutils.a $(OBJS) lex.backup
-
-# psqlscan.c is supposed to be in the distribution tarball,
-# so do not clean it in the clean/distclean rules
-maintainer-clean: distclean
 	rm -f psqlscan.c
diff --git a/src/include/Makefile b/src/include/Makefile
index 2d5242561c..743de5abe4 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -78,5 +78,5 @@ clean:
 	rm -f catalog/pg_*_d.h catalog/header-stamp
 	rm -f nodes/nodetags.h nodes/header-stamp
 
-distclean maintainer-clean: clean
+distclean: clean
 	rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/interfaces/ecpg/Makefile b/src/interfaces/ecpg/Makefile
index e4bbf7b8a8..3002bc3c1b 100644
--- a/src/interfaces/ecpg/Makefile
+++ b/src/interfaces/ecpg/Makefile
@@ -23,7 +23,7 @@ install-pgtypeslib-recurse install-ecpglib-recurse install-compatlib-recurse ins
 install-compatlib-recurse: install-ecpglib-recurse
 install-ecpglib-recurse: install-pgtypeslib-recurse
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C test clean
 
 checktcp: | temp-install
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index b9483fba08..695fd1a080 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -55,5 +55,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 652e023405..103cce393a 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -66,5 +66,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/include/Makefile b/src/interfaces/ecpg/include/Makefile
index 9c68bf3c47..3476409cef 100644
--- a/src/interfaces/ecpg/include/Makefile
+++ b/src/interfaces/ecpg/include/Makefile
@@ -31,5 +31,5 @@ uninstall:
 	rm -f $(addprefix '$(DESTDIR)$(informix_esql_dir)'/, $(informix_headers))
 	rm -f '$(DESTDIR)$(includedir)'/$(notdir $(ecpg_config_h))
 
-distclean maintainer-clean:
+distclean:
 	rm -f ecpg_config.h stamp-h
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index b0e154eb15..e56700a12e 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -50,5 +50,3 @@ uninstall: uninstall-lib
 
 clean distclean: clean-lib
 	rm -f $(OBJS)
-
-maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile
index 77ae9ab722..afd46cd17c 100644
--- a/src/interfaces/ecpg/preproc/Makefile
+++ b/src/interfaces/ecpg/preproc/Makefile
@@ -81,8 +81,6 @@ ecpg_keywords.o: ecpg_kwlist_d.h
 c_keywords.o: c_kwlist_d.h
 keywords.o: $(top_srcdir)/src/include/parser/kwlist.h
 
-distprep: preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
-
 install: all installdirs
 	$(INSTALL_PROGRAM) ecpg$(X) '$(DESTDIR)$(bindir)'
 
@@ -92,11 +90,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/ecpg$(X)'
 
-# preproc.y, preproc.c, preproc.h, pgc.c, c_kwlist_d.h, and ecpg_kwlist_d.h
-# are in the distribution tarball, so they are not cleaned here.
 clean distclean:
 	rm -f *.o ecpg$(X)
 	rm -f typename.c
-
-maintainer-clean: distclean
 	rm -f preproc.y preproc.c preproc.h pgc.c c_kwlist_d.h ecpg_kwlist_d.h
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index cf841a3a5b..3769488f16 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -20,7 +20,7 @@ else
 abs_builddir := $(shell sh -c "pwd -W")
 endif
 
-all install installdirs uninstall distprep:
+all install installdirs uninstall:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
@@ -29,7 +29,7 @@ all install installdirs uninstall distprep:
 	$(MAKE) -C compat_oracle $@
 	$(MAKE) -C thread $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	$(MAKE) -C connect $@
 	$(MAKE) -C sql $@
 	$(MAKE) -C pgtypeslib $@
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 46653682b0..d0a66cfaa0 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -165,6 +165,3 @@ clean distclean: clean-lib
 	rm -f $(OBJS) pthread.h libpq-refs-stamp
 # Might be left over from a Win32 client-only build
 	rm -f pg_config_paths.h
-
-maintainer-clean: distclean
-	$(MAKE) -C test $@
diff --git a/src/interfaces/libpq/test/Makefile b/src/interfaces/libpq/test/Makefile
index 75ac08f943..4e17ec1514 100644
--- a/src/interfaces/libpq/test/Makefile
+++ b/src/interfaces/libpq/test/Makefile
@@ -20,5 +20,5 @@ all: $(PROGS)
 
 $(PROGS): $(WIN32RES)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 7ba8d5bc98..0de3737e78 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -391,7 +391,7 @@ ifdef MODULE_big
 clean: clean-lib
 endif
 
-distclean maintainer-clean: clean
+distclean: clean
 
 
 ifdef REGRESS
diff --git a/src/nls-global.mk b/src/nls-global.mk
index f21bd5ed55..dfff472cb3 100644
--- a/src/nls-global.mk
+++ b/src/nls-global.mk
@@ -171,7 +171,7 @@ all: all-po
 install: install-po
 installdirs: installdirs-po
 uninstall: uninstall-po
-clean distclean maintainer-clean: clean-po
+clean distclean: clean-po
 
 .PHONY: all-po install-po installdirs-po uninstall-po clean-po \
         init-po update-po
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index 51f8890d15..975f540b3e 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -127,7 +127,7 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 	rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
diff --git a/src/pl/plpgsql/src/Makefile b/src/pl/plpgsql/src/Makefile
index f7eb42d54f..dfb815212f 100644
--- a/src/pl/plpgsql/src/Makefile
+++ b/src/pl/plpgsql/src/Makefile
@@ -104,14 +104,7 @@ submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
 
-distprep: pl_gram.h pl_gram.c plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
-
-# pl_gram.c, pl_gram.h, plerrcodes.h, pl_reserved_kwlist_d.h, and
-# pl_unreserved_kwlist_d.h are in the distribution tarball, so they
-# are not cleaned here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f pl_gram.c pl_gram.h plerrcodes.h pl_reserved_kwlist_d.h pl_unreserved_kwlist_d.h
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index 6b1865c240..ef0a5905ae 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -142,6 +142,7 @@ clean distclean: clean-lib
 ifeq ($(PORTNAME), win32)
 	rm -f python${pytverstr}.def
 endif
+	rm -f spiexceptions.h
 
 
 # Force this dependency to be known even without dependency info built:
@@ -149,8 +150,3 @@ plpy_plpymodule.o: spiexceptions.h
 
 spiexceptions.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-spiexceptions.pl
 	$(PERL) $(srcdir)/generate-spiexceptions.pl $< > $@
-
-distprep: spiexceptions.h
-
-maintainer-clean: distclean
-	rm -f spiexceptions.h
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index 314f9b2eec..ea52a2efc2 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -63,8 +63,6 @@ pltcl.o: pltclerrcodes.h
 pltclerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-pltclerrcodes.pl
 	$(PERL) $(srcdir)/generate-pltclerrcodes.pl $< > $@
 
-distprep: pltclerrcodes.h
-
 install: all install-lib install-data
 
 installdirs: installdirs-lib
@@ -91,13 +89,10 @@ installcheck: submake
 submake:
 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
 
-# pltclerrcodes.h is in the distribution tarball, so don't clean it here.
 clean distclean: clean-lib
 	rm -f $(OBJS)
 	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
 	rm -f $(tclwithver).def
 endif
-
-maintainer-clean: distclean
 	rm -f pltclerrcodes.h
diff --git a/src/port/Makefile b/src/port/Makefile
index f205c2c9c5..4320dee0d1 100644
--- a/src/port/Makefile
+++ b/src/port/Makefile
@@ -154,6 +154,6 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
 	echo "#define HTMLDIR \"$(htmldir)\"" >>$@
 	echo "#define MANDIR \"$(mandir)\"" >>$@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f libpgport.a libpgport_shlib.a libpgport_srv.a
 	rm -f $(OBJS) $(OBJS_SHLIB) $(OBJS_SRV) pg_config_paths.h
diff --git a/src/test/authentication/Makefile b/src/test/authentication/Makefile
index 46fa72052d..a48ce39aaf 100644
--- a/src/test/authentication/Makefile
+++ b/src/test/authentication/Makefile
@@ -19,5 +19,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/examples/Makefile b/src/test/examples/Makefile
index a67f456904..e72d058e0c 100644
--- a/src/test/examples/Makefile
+++ b/src/test/examples/Makefile
@@ -18,5 +18,5 @@ PROGS = testlibpq testlibpq2 testlibpq3 testlibpq4 testlo testlo64
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
diff --git a/src/test/icu/Makefile b/src/test/icu/Makefile
index 033b0d03cc..c4fc8cdb8c 100644
--- a/src/test/icu/Makefile
+++ b/src/test/icu/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/isolation/Makefile b/src/test/isolation/Makefile
index b8738b7c1b..11c48fed5b 100644
--- a/src/test/isolation/Makefile
+++ b/src/test/isolation/Makefile
@@ -43,8 +43,6 @@ pg_isolation_regress$(X): isolation_main.o pg_regress.o $(WIN32RES)
 isolationtester$(X): $(OBJS) | submake-libpq submake-libpgport
 	$(CC) $(CFLAGS) $^ $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
 
-distprep: specparse.c specscanner.c
-
 # See notes in src/backend/parser/Makefile about the following two rules
 specparse.h: specparse.c
 	touch $@
@@ -54,14 +52,10 @@ specparse.c: BISONFLAGS += -d
 # Force these dependencies to be known even without dependency info built:
 specparse.o specscanner.o: specparse.h
 
-# specparse.c and specscanner.c are in the distribution tarball,
-# so do not clean them here
 clean distclean:
 	rm -f isolationtester$(X) pg_isolation_regress$(X) $(OBJS) isolation_main.o
 	rm -f pg_regress.o
 	rm -rf $(pg_regress_clean_files)
-
-maintainer-clean: distclean
 	rm -f specparse.h specparse.c specscanner.c
 
 installcheck: all
diff --git a/src/test/kerberos/Makefile b/src/test/kerberos/Makefile
index f460d2c0e7..44da65611e 100644
--- a/src/test/kerberos/Makefile
+++ b/src/test/kerberos/Makefile
@@ -24,5 +24,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/ldap/Makefile b/src/test/ldap/Makefile
index 73bc878ea8..d4305ed5eb 100644
--- a/src/test/ldap/Makefile
+++ b/src/test/ldap/Makefile
@@ -21,5 +21,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/locale/Makefile b/src/test/locale/Makefile
index 7ba096b542..a40c67af07 100644
--- a/src/test/locale/Makefile
+++ b/src/test/locale/Makefile
@@ -10,7 +10,7 @@ DIRS = de_DE.ISO8859-1 gr_GR.ISO8859-7 koi8-r koi8-to-win1251
 
 all: $(PROGS)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f $(PROGS) *.o
 	rm -rf tmp_check
 	for d in $(DIRS); do \
diff --git a/src/test/recovery/Makefile b/src/test/recovery/Makefile
index c60314d195..49f1d1c118 100644
--- a/src/test/recovery/Makefile
+++ b/src/test/recovery/Makefile
@@ -25,5 +25,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 38c3a1f85b..388f2700bd 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -146,7 +146,7 @@ bigcheck: all | temp-install
 ## Clean up
 ##
 
-clean distclean maintainer-clean: clean-lib
+clean distclean: clean-lib
 # things built by `all' target
 	rm -f $(OBJS) refint$(DLSUFFIX) autoinc$(DLSUFFIX)
 	rm -f pg_regress_main.o pg_regress.o pg_regress$(X)
diff --git a/src/test/ssl/Makefile b/src/test/ssl/Makefile
index af1e06e949..2d7c69068f 100644
--- a/src/test/ssl/Makefile
+++ b/src/test/ssl/Makefile
@@ -23,7 +23,7 @@ export OPENSSL with_ssl
 sslfiles sslfiles-clean:
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
 	$(MAKE) -f $(srcdir)/sslfiles.mk $@
 
diff --git a/src/test/ssl/sslfiles.mk b/src/test/ssl/sslfiles.mk
index 569f1731cd..89ba2d193b 100644
--- a/src/test/ssl/sslfiles.mk
+++ b/src/test/ssl/sslfiles.mk
@@ -269,6 +269,6 @@ sslfiles-clean:
 # clean targets will be run during a "standard" recursive clean run from the
 # main build tree. The sslfiles-clean target must be run explicitly from this
 # directory.
-.PHONY: clean distclean maintainer-clean
-clean distclean maintainer-clean:
+.PHONY: clean distclean
+clean distclean:
 	rm -rf ssl/*.old ssl/new_certs_dir ssl/client*_tmp.key
diff --git a/src/test/subscription/Makefile b/src/test/subscription/Makefile
index 99d1fe012d..36475ffabc 100644
--- a/src/test/subscription/Makefile
+++ b/src/test/subscription/Makefile
@@ -23,5 +23,5 @@ check:
 installcheck:
 	$(prove_installcheck)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -rf tmp_check
diff --git a/src/timezone/Makefile b/src/timezone/Makefile
index fbbaae4cc5..c85e831247 100644
--- a/src/timezone/Makefile
+++ b/src/timezone/Makefile
@@ -75,5 +75,5 @@ ifeq (,$(with_system_tzdata))
 endif
 	$(MAKE) -C tznames $@
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f zic$(X) $(ZICOBJS) abbrevs.txt
diff --git a/src/tools/ifaddrs/Makefile b/src/tools/ifaddrs/Makefile
index e74d754769..ef5e8f0e0e 100644
--- a/src/tools/ifaddrs/Makefile
+++ b/src/tools/ifaddrs/Makefile
@@ -24,5 +24,5 @@ all: test_ifaddrs
 test_ifaddrs: test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o
 	$(CC) $(CFLAGS) test_ifaddrs.o $(libpq_backend_dir)/ifaddr.o $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f test_ifaddrs$(X) $(OBJS)
diff --git a/src/tools/pg_bsd_indent/Makefile b/src/tools/pg_bsd_indent/Makefile
index d176ceb326..ce5d815f07 100644
--- a/src/tools/pg_bsd_indent/Makefile
+++ b/src/tools/pg_bsd_indent/Makefile
@@ -39,7 +39,7 @@ installdirs:
 uninstall:
 	rm -f '$(DESTDIR)$(bindir)/pg_bsd_indent$(X)'
 
-clean distclean maintainer-clean:
+clean distclean:
 	rm -f pg_bsd_indent$(X) $(OBJS)
 	rm -rf log/ tmp_check/
 
-- 
2.42.0

#21Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#20)
Re: Remove distprep

On Thu, Oct 05, 2023 at 05:46:46PM +0200, Peter Eisentraut wrote:

Ok, I think I found a better way to address this. It requires keeping a
subset of the old distprep target in src/backend/Makefile for use by nls.mk.
I have checked that the above sequence now works, and that the generated
.pot files are identical to before this patch.

generated-parser-sources looks like an elegant split.

(Not sure if it would be good to commit it that way, but it's easier to look
at for now for sure.)

Not sure. I'd be OK if the patch set is committed into two pieces as
well. I guess that's up to how you feel about that at the end ;)

While looking at the last references of the distribution tarball, this
came out:
# This allows removing some files from the distribution tarballs while
# keeping the dependencies satisfied.
.SECONDARY: $(GENERATED_SGML)
.SECONDARY: postgres-full.xml
.SECONDARY: INSTALL.html INSTALL.xml
.SECONDARY: postgres-A4.fo postgres-US.fo

That's not really something for this patch, but I got to ask. What's
the final plan for the documentation when it comes to releases? A
second tarball separated from the git-only tarball that includes all
that and the HTML docs, generated with a new "doc-only" set of meson
commands?
--
Michael

#22Peter Eisentraut
peter@eisentraut.org
In reply to: Michael Paquier (#21)
Re: Remove distprep

On 06.10.23 04:00, Michael Paquier wrote:

That's not really something for this patch, but I got to ask. What's
the final plan for the documentation when it comes to releases? A
second tarball separated from the git-only tarball that includes all
that and the HTML docs, generated with a new "doc-only" set of meson
commands?

Yes, something like that. Some people wanted a tarball of just the HTML
docs for download. Similar to the PDFs currently, I suppose.

#23Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#22)
Re: Remove distprep

On Fri, Oct 06, 2023 at 08:38:31AM +0200, Peter Eisentraut wrote:

Yes, something like that. Some people wanted a tarball of just the HTML
docs for download. Similar to the PDFs currently, I suppose.

I suspected so.

I've marked the patch as RfC for now.
--
Michael

#24Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#20)
Re: Remove distprep

Hi,

On 2023-10-05 17:46:46 +0200, Peter Eisentraut wrote:

The attached updated patch is also split up like Andres suggested nearby.

Thanks.

(Not sure if it would be good to commit it that way, but it's easier to look
at for now for sure.)

I'd push together, but I think the split is useful when looking later as well.

I played around with these for a bit without finding an issue.

The only thing I wonder is whether we ought to keep a maintainer-clean target
(as an alias to distclean), so that extensions that added things to
maintainer-clean continue to work.

Greetings,

Andres Freund

#25Peter Eisentraut
peter@eisentraut.org
In reply to: Andres Freund (#24)
Re: Remove distprep

On 06.10.23 20:50, Andres Freund wrote:

The only thing I wonder is whether we ought to keep a maintainer-clean
target (as an alias to distclean), so that extensions that added things
to maintainer-clean continue to work.

The patch does do that.

#26Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#25)
Re: Remove distprep

Hi,

On 2023-10-09 12:16:23 +0200, Peter Eisentraut wrote:

On 06.10.23 20:50, Andres Freund wrote:

The only thing I wonder is whether we ought to keep a maintainer-clean
target (as an alias to distclean), so that extensions that added things
to maintainer-clean continue to work.

The patch does do that.

It kinda works, but I'm not sure how well. Because the aliasing happens in
Makefile.global, we won't know about the "original" maintainer-clean target
once recursing into a subdir.

That's perhaps OK, because extensions likely won't utilize subdirectories? But
I'm not sure. I know that some people build postgres extensions by adding them
to contrib/, in those cases it won't work.

OTOH, it seems somewhat unlikely that maintainer-clean is utilized much in
extensions. I see it in things like postgis, but that has it's own configure
etc, even though it also invokes pgxs.

I wish we had an easy way of
a) downloading most working open-source extensions
b) building many of those

Greetings,

Andres Freund

#27Peter Eisentraut
peter@eisentraut.org
In reply to: Andres Freund (#26)
Re: Remove distprep

On 09.10.23 17:14, Andres Freund wrote:

It kinda works, but I'm not sure how well. Because the aliasing happens in
Makefile.global, we won't know about the "original" maintainer-clean target
once recursing into a subdir.

That's perhaps OK, because extensions likely won't utilize subdirectories? But
I'm not sure. I know that some people build postgres extensions by adding them
to contrib/, in those cases it won't work.

OTOH, it seems somewhat unlikely that maintainer-clean is utilized much in
extensions. I see it in things like postgis, but that has it's own configure
etc, even though it also invokes pgxs.

I thought about this. I don't think this is something that any
extension would use. If they care about the distinction between
distclean and maintainer-clean, are they also doing their own distprep
and dist? Seems unlikely. I mean, if some extension is actually
affected, I'm happy to accommodate, but we can deal with that when we
learn about it. Moreover, if we are moving forward in this direction,
we would presumably also like the extensions to get rid of their
distprep step.

So I think we are ready to move ahead with this patch. There have been
some light complaints earlier in this thread that people wanted to keep
some way to clean only some of the files. But there hasn't been any
concrete follow-up on that, as far as I can see, so I don't know what to
do about that.

#28Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#27)
Re: Remove distprep

On 2023-11-01 16:39:24 -0400, Peter Eisentraut wrote:

OTOH, it seems somewhat unlikely that maintainer-clean is utilized much in
extensions. I see it in things like postgis, but that has it's own configure
etc, even though it also invokes pgxs.

I thought about this. I don't think this is something that any extension
would use. If they care about the distinction between distclean and
maintainer-clean, are they also doing their own distprep and dist? Seems
unlikely. I mean, if some extension is actually affected, I'm happy to
accommodate, but we can deal with that when we learn about it. Moreover, if
we are moving forward in this direction, we would presumably also like the
extensions to get rid of their distprep step.

So I think we are ready to move ahead with this patch. There have been some
light complaints earlier in this thread that people wanted to keep some way
to clean only some of the files. But there hasn't been any concrete
follow-up on that, as far as I can see, so I don't know what to do about
that.

+1, let's do this. We can add dedicated target for more specific cases later
if we decide we want that.

#29Peter Eisentraut
peter@eisentraut.org
In reply to: Andres Freund (#28)
Re: Remove distprep

On 02.11.23 23:34, Andres Freund wrote:

On 2023-11-01 16:39:24 -0400, Peter Eisentraut wrote:

OTOH, it seems somewhat unlikely that maintainer-clean is utilized much in
extensions. I see it in things like postgis, but that has it's own configure
etc, even though it also invokes pgxs.

I thought about this. I don't think this is something that any extension
would use. If they care about the distinction between distclean and
maintainer-clean, are they also doing their own distprep and dist? Seems
unlikely. I mean, if some extension is actually affected, I'm happy to
accommodate, but we can deal with that when we learn about it. Moreover, if
we are moving forward in this direction, we would presumably also like the
extensions to get rid of their distprep step.

So I think we are ready to move ahead with this patch. There have been some
light complaints earlier in this thread that people wanted to keep some way
to clean only some of the files. But there hasn't been any concrete
follow-up on that, as far as I can see, so I don't know what to do about
that.

+1, let's do this. We can add dedicated target for more specific cases later
if we decide we want that.

done

#30Michael Paquier
michael@paquier.xyz
In reply to: Peter Eisentraut (#29)
Re: Remove distprep

On Mon, Nov 06, 2023 at 04:21:40PM +0100, Peter Eisentraut wrote:

done

Nice to see 721856ff24b3 in, thanks!
--
Michael

#31Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Michael Paquier (#30)
Re: Remove distprep

On 2023-Nov-07, Michael Paquier wrote:

On Mon, Nov 06, 2023 at 04:21:40PM +0100, Peter Eisentraut wrote:

done

Nice to see 721856ff24b3 in, thanks!

Hmm, do we still need to have README.git as a separate file from README?

Also, looking at README, I see it refers to the INSTALL file in the
root, but that doesn't exist. "make -C doc/src/sgml INSTALL" creates
it, but it's not copied to the root directory. Do we need some fixup
for that?

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Learn about compilers. Then everything looks like either a compiler or
a database, and now you have two problems but one of them is fun."
https://twitter.com/thingskatedid/status/1456027786158776329

#32Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#31)
Re: Remove distprep

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:

Hmm, do we still need to have README.git as a separate file from README?

Also, looking at README, I see it refers to the INSTALL file in the
root, but that doesn't exist. "make -C doc/src/sgml INSTALL" creates
it, but it's not copied to the root directory. Do we need some fixup
for that?

Yeah, we clearly need to rethink this area if the plan is that tarballs
will be pristine git pulls. I think we want just README at the top
level, and I propose we give up on the text INSTALL file altogether
(thereby removing a documentation build gotcha that catches people
every so often). I propose that in 2023 it ought to be sufficient
for the README file to point at build instructions on the web.

regards, tom lane

#33Andrew Dunstan
andrew@dunslane.net
In reply to: Tom Lane (#32)
Re: Remove distprep

On 2023-11-21 Tu 13:23, Tom Lane wrote:

Alvaro Herrera <alvherre@alvh.no-ip.org> writes:

Hmm, do we still need to have README.git as a separate file from README?
Also, looking at README, I see it refers to the INSTALL file in the
root, but that doesn't exist. "make -C doc/src/sgml INSTALL" creates
it, but it's not copied to the root directory. Do we need some fixup
for that?

Yeah, we clearly need to rethink this area if the plan is that tarballs
will be pristine git pulls. I think we want just README at the top
level, and I propose we give up on the text INSTALL file altogether
(thereby removing a documentation build gotcha that catches people
every so often). I propose that in 2023 it ought to be sufficient
for the README file to point at build instructions on the web.

+1

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

#34Noah Misch
noah@leadboat.com
In reply to: Peter Eisentraut (#20)
Re: Remove distprep

On Thu, Oct 05, 2023 at 05:46:46PM +0200, Peter Eisentraut wrote:

--- a/src/backend/Makefile
+++ b/src/backend/Makefile
$(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
$(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'

These broke the
https://www.postgresql.org/docs/17/installation-platform-notes.html#INSTALLATION-NOTES-MINGW
build, where LN_S='cp -pR'. On other platforms, "make LN_S='cp -pR'"
reproduces this. Reverting the above lines fixes things. The buildfarm has
no coverage for that build scenario (fairywren uses Meson).

#35Alvaro Herrera
alvherre@alvh.no-ip.org
In reply to: Noah Misch (#34)
Re: Remove distprep

On 2024-Jun-16, Noah Misch wrote:

These broke the
https://www.postgresql.org/docs/17/installation-platform-notes.html#INSTALLATION-NOTES-MINGW
build, where LN_S='cp -pR'. On other platforms, "make LN_S='cp -pR'"
reproduces this. Reverting the above lines fixes things. The buildfarm has
no coverage for that build scenario (fairywren uses Meson).

I agree we should revert this change. I had commented on this:
/messages/by-id/202404051810.et6ufj5snhmt@alvherre.pgsql

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"La rebeldía es la virtud original del hombre" (Arthur Schopenhauer)

#36Peter Eisentraut
peter@eisentraut.org
In reply to: Noah Misch (#34)
Re: Remove distprep

On 16.06.24 21:34, Noah Misch wrote:

On Thu, Oct 05, 2023 at 05:46:46PM +0200, Peter Eisentraut wrote:

--- a/src/backend/Makefile
+++ b/src/backend/Makefile
$(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
$(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'

These broke the
https://www.postgresql.org/docs/17/installation-platform-notes.html#INSTALLATION-NOTES-MINGW
build, where LN_S='cp -pR'. On other platforms, "make LN_S='cp -pR'"
reproduces this. Reverting the above lines fixes things. The buildfarm has
no coverage for that build scenario (fairywren uses Meson).

Is it just these two instances?

Commit 721856ff24b contains a few more hunks that change something about
LN_S. Are those ok?

#37Noah Misch
noah@leadboat.com
In reply to: Peter Eisentraut (#36)
Re: Remove distprep

On Thu, Jun 20, 2024 at 09:29:45AM +0200, Peter Eisentraut wrote:

On 16.06.24 21:34, Noah Misch wrote:

On Thu, Oct 05, 2023 at 05:46:46PM +0200, Peter Eisentraut wrote:

--- a/src/backend/Makefile
+++ b/src/backend/Makefile
$(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
$(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'

These broke the
https://www.postgresql.org/docs/17/installation-platform-notes.html#INSTALLATION-NOTES-MINGW
build, where LN_S='cp -pR'. On other platforms, "make LN_S='cp -pR'"
reproduces this. Reverting the above lines fixes things. The buildfarm has
no coverage for that build scenario (fairywren uses Meson).

Is it just these two instances?

Yes.

Commit 721856ff24b contains a few more hunks that change something about
LN_S. Are those ok?

I'm guessing "make LN_S='cp -pR'" didn't have a problem with those because
they have "." as the second argument. "cp -pR ../foo ." is compatible with
"ln -s ../foo ." in that both are interpreting "../bar" relative to the same
directory. Not so for "cp -pR ../foo bar/baz" vs. "ln -s ../foo bar/baz".

#38Peter Eisentraut
peter@eisentraut.org
In reply to: Noah Misch (#37)
Re: Remove distprep

On 20.06.24 16:34, Noah Misch wrote:

On Thu, Jun 20, 2024 at 09:29:45AM +0200, Peter Eisentraut wrote:

On 16.06.24 21:34, Noah Misch wrote:

On Thu, Oct 05, 2023 at 05:46:46PM +0200, Peter Eisentraut wrote:

--- a/src/backend/Makefile
+++ b/src/backend/Makefile
$(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'
$(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
-	prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
-	  cd '$(dir $@)' && rm -f $(notdir $@) && \
-	  $(LN_S) "$$prereqdir/$(notdir $<)" .
+	rm -f '$@'
+	$(LN_S) ../../backend/$< '$@'

These broke the
https://www.postgresql.org/docs/17/installation-platform-notes.html#INSTALLATION-NOTES-MINGW
build, where LN_S='cp -pR'. On other platforms, "make LN_S='cp -pR'"
reproduces this. Reverting the above lines fixes things. The buildfarm has
no coverage for that build scenario (fairywren uses Meson).

Is it just these two instances?

Yes.

Commit 721856ff24b contains a few more hunks that change something about
LN_S. Are those ok?

I'm guessing "make LN_S='cp -pR'" didn't have a problem with those because
they have "." as the second argument. "cp -pR ../foo ." is compatible with
"ln -s ../foo ." in that both are interpreting "../bar" relative to the same
directory. Not so for "cp -pR ../foo bar/baz" vs. "ln -s ../foo bar/baz".

Ok, fix pushed.