diff --git a/README.CVS b/README.CVS
index 37daaf6bc30ab3a26763fb0fb48b0c29b64e7430..4eb8377a5008054894ae9bc71abef909b662aefb 100644
--- a/README.CVS
+++ b/README.CVS
@@ -8,7 +8,7 @@ If you are using CVS, you can view the most recent install instructions at:
 and the current release notes at:
 	http://developer.postgresql.org/docs/postgres/release.html
 
-Users compiling from CVS will also need compatible versions of Bison and
-Flex, as discussed in the install documentation.  Bison and Flex are not
+Users compiling from CVS will also need compatible versions of Bison, Flex,
+and Perl, as discussed in the install documentation.  These programs are not
 needed when using a tarball, since the files they are needed to build are
-already present in the tarball.
+already present in the tarball.  (On Windows, however, you need Perl anyway.)
diff --git a/config/missing b/config/missing
index 2d47501bb537df4c024bd537ac13fea502dafebe..16e31756f6a341faa3c792ae55eb28dc520dd59a 100755
--- a/config/missing
+++ b/config/missing
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $PostgreSQL: pgsql/config/missing,v 1.4 2006/03/11 04:38:28 momjian Exp $
+# $PostgreSQL: pgsql/config/missing,v 1.5 2009/06/23 03:46:00 tgl Exp $
 
 # This is *not* the GNU `missing' script, although it is similar in
 # concept. You can call it from the makefiles to get consistent
@@ -17,7 +17,7 @@ case $1 in
 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
@@ -28,8 +28,27 @@ 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/doc/src/sgml/cvs.sgml b/doc/src/sgml/cvs.sgml
index 83b721cdb97db340ca3be668b95885eb8009aade..55b17a23d31a508bff2cb82578a8f03ecf1d5262 100644
--- a/doc/src/sgml/cvs.sgml
+++ b/doc/src/sgml/cvs.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/cvs.sgml,v 1.50 2008/04/21 11:06:13 mha Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/cvs.sgml,v 1.51 2009/06/23 03:46:00 tgl Exp $ -->
 
 <appendix id="cvs">
  <appendixinfo>
@@ -171,6 +171,7 @@ cvs update
    pull requires reasonably up-to-date versions of <application>bison</>
    and <application>flex</>, which are not needed to build from a distribution
    tarball because the files made with them are pre-built in a tarball.
+   You will need Perl as well.
    Otherwise the tool requirements are the same as building from source.
   </para>
  </sect1>
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index f6f5166adac54f73047e645795d40922aab62a0a..0f9ce3eeee0dd4fdfb1ba22809ccdb6be6b972f1 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.324 2009/06/17 21:58:49 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.325 2009/06/23 03:46:00 tgl Exp $ -->
 
 <chapter id="installation">
  <title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -294,13 +294,25 @@ su - postgres
       </indexterm>
 
       GNU <application>Flex</> and <application>Bison</>
-      are needed to build a CVS checkout or if you changed the actual
+      are needed to build from a CVS checkout, or if you changed the actual
       scanner and parser definition files. If you need them, be sure
       to get <application>Flex</> 2.5.4 or later and
       <application>Bison</> 1.875 or later. Other <application>lex</>
       and <application>yacc</> programs cannot be used.
      </para>
     </listitem>
+    <listitem>
+     <para>
+      <indexterm>
+       <primary>perl</primary>
+      </indexterm>
+
+      <application>Perl</> is also needed to build from a CVS 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</> in any case.
+     </para>
+    </listitem>
    </itemizedlist>
   </para>
 
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 1facf7c315ee4f17c2d219b7497af4d97fd02c3c..763bdc004a04a2da4e19598c4f81230bbb88f3c5 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -1,5 +1,5 @@
 # -*-makefile-*-
-# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.253 2009/02/19 10:32:30 petere Exp $
+# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.254 2009/06/23 03:46:00 tgl Exp $
 
 #------------------------------------------------------------------------------
 # All PostgreSQL makefiles include this file and use the variables it sets,
@@ -248,8 +248,12 @@ X = @EXEEXT@
 
 # Perl 
 
-# quoted for pathname with spaces
-PERL			= "@PERL@"
+ifneq (@PERL@,)
+    # quoted to protect pathname with spaces
+    PERL		= "@PERL@"
+else
+    PERL		= $(missing) perl
+endif
 perl_archlibexp		= @perl_archlibexp@
 perl_privlibexp		= @perl_privlibexp@
 perl_useshrplib		= @perl_useshrplib@
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile
index d8a1f60c47cb16bb13e1a5e6eed8f1f0cd809d38..01049d8af24df873e938cbf0dc93100cb3146244 100644
--- a/src/bin/psql/Makefile
+++ b/src/bin/psql/Makefile
@@ -5,7 +5,7 @@
 # Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 # Portions Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.62 2009/03/07 00:13:58 alvherre Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.63 2009/06/23 03:46:00 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -40,13 +40,8 @@ dumputils.c keywords.c: % : $(top_srcdir)/src/bin/pg_dump/%
 kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
 	rm -f $@ && $(LN_S) $< .
 
-ifdef PERL
 $(srcdir)/sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
 	$(PERL) $< $(REFDOCDIR) $@
-else
-$(srcdir)/sql_help.h:
-	@echo "*** Perl is needed to build psql help."
-endif
 
 $(srcdir)/psqlscan.c: psqlscan.l
 ifdef FLEX