diff --git a/GNUmakefile.in b/GNUmakefile.in
index 8ccbdcc49fb802acc8cbec6194b397ba38fbafac..b9c5f317b6479b1141a304ec9a4567ff9f947d60 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -60,6 +60,9 @@ check: all
 check installcheck installcheck-parallel:
 	$(MAKE) -C src/test $@
 
+# TODO: add contrib
+$(call recurse,check-world,src/test src/pl src/interfaces/ecpg,check)
+
 $(call recurse,installcheck-world,src/test src/pl src/interfaces/ecpg contrib,installcheck)
 
 GNUmakefile: GNUmakefile.in $(top_builddir)/config.status
@@ -121,4 +124,4 @@ distcheck: dist
 	rm -rf $(distdir) $(dummy)
 	@echo "Distribution integrity checks out."
 
-.PHONY: dist distdir distcheck docs install-docs world install-world installcheck-world
+.PHONY: dist distdir distcheck docs install-docs world check-world install-world installcheck-world
diff --git a/Makefile b/Makefile
index b5b2ea54c063bf49035b63248dbdff8dfc61651e..72e9c837330401969c10a37fb45395d260bf2894 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
 # GNUmakefile won't exist yet, so we catch that case as well.
 
 
-all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheck world install-world installcheck-world:
+all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheck world check-world install-world installcheck-world:
 	@if [ ! -f GNUmakefile ] ; then \
 	   echo "You need to run the 'configure' program first. See the file"; \
 	   echo "'INSTALL' for installation instructions." ; \
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index d6b7b4769df8cea78bb98a4d68c014b1265149e6..2eff4d4067f156d986684aabc875146b9dc7da11 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -285,9 +285,6 @@ XGETTEXT = @XGETTEXT@
 GZIP	= gzip
 BZIP2	= bzip2
 
-PL_TESTDB = pl_regression
-CONTRIB_TESTDB = contrib_regression
-
 # Installation.
 
 INSTALL	= $(SHELL) $(top_srcdir)/config/install-sh -c
@@ -426,6 +423,19 @@ submake-libpgport:
 .PHONY: submake-libpq submake-libpgport
 
 
+##########################################################################
+#
+# Testing support
+
+PL_TESTDB = pl_regression
+CONTRIB_TESTDB = contrib_regression
+
+pg_regress_check = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --temp-install=./tmp_check --top-builddir=$(top_builddir)
+pg_regress_installcheck = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir=$(PSQLDIR)
+
+pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ log/
+
+
 ##########################################################################
 #
 # Customization
diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk
index 412bf5c93010e896c77f817db6a2eb567bc5abf1..87ade0a420f1eba356b2a61727fd7b21dc2bd3e1 100644
--- a/src/makefiles/pgxs.mk
+++ b/src/makefiles/pgxs.mk
@@ -231,8 +231,7 @@ ifdef EXTRA_CLEAN
 endif
 ifdef REGRESS
 # things created by various check targets
-	rm -rf results tmp_check log
-	rm -f regression.diffs regression.out regress.out run_check.out
+	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win)
 	rm -f regress.def
 endif
@@ -280,12 +279,11 @@ endif
 
 # against installed postmaster
 installcheck: submake
-	$(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
+	$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
 
 # in-tree test doesn't work yet (no way to install my shared library)
 #check: all submake
-#	$(top_builddir)/src/test/regress/pg_regress --temp-install \
-#	  --top-builddir=$(top_builddir) $(REGRESS_OPTS) $(REGRESS)
+#	$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
 check:
 	@echo "'make check' is not supported."
 	@echo "Do 'make install', then 'make installcheck' instead."
diff --git a/src/pl/plperl/.gitignore b/src/pl/plperl/.gitignore
index c04f42ba07a41dccd30554081b252bea0d1ee036..1a798733ac529309f50fca61ea18e70b830b3f7b 100644
--- a/src/pl/plperl/.gitignore
+++ b/src/pl/plperl/.gitignore
@@ -4,4 +4,6 @@
 /plperl_opmask.h
 
 # Generated subdirectories
+/log/
 /results/
+/tmp_check/
diff --git a/src/pl/plperl/GNUmakefile b/src/pl/plperl/GNUmakefile
index 85cf9a8f930543b33196d30f69f65050bb21c143..01e585e42804d02a2aa9c59655467d98f4307814 100644
--- a/src/pl/plperl/GNUmakefile
+++ b/src/pl/plperl/GNUmakefile
@@ -76,8 +76,11 @@ installdirs: installdirs-lib
 
 uninstall: uninstall-lib
 
+check: submake
+	$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
+
 installcheck: submake
-	$(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
+	$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
 
 .PHONY: submake
 submake:
@@ -85,8 +88,7 @@ submake:
 
 clean distclean maintainer-clean: clean-lib
 	rm -f SPI.c Util.c $(OBJS) perlchunks.h plperl_opmask.h
-	rm -rf results
-	rm -f regression.diffs regression.out
+	rm -rf $(pg_regress_clean_files)
 
 else # can't build
 
diff --git a/src/pl/plpython/.gitignore b/src/pl/plpython/.gitignore
index 19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a..5dcb3ff9723501c3fe639bee1c1435e47a580a6f 100644
--- a/src/pl/plpython/.gitignore
+++ b/src/pl/plpython/.gitignore
@@ -1,2 +1,4 @@
 # Generated subdirectories
+/log/
 /results/
+/tmp_check/
diff --git a/src/pl/plpython/Makefile b/src/pl/plpython/Makefile
index 16d78ae0e28654c0777f10f273dadf8301f7d90b..3a2411bea180b66bbbe2bf4e50b17e7cceb94f5a 100644
--- a/src/pl/plpython/Makefile
+++ b/src/pl/plpython/Makefile
@@ -120,13 +120,19 @@ prep3:
 clean3:
 	rm -rf python3/
 
+check: submake prep3
+	$(pg_regress_check) --inputdir=./python3 --outputdir=./python3 $(REGRESS_OPTS) $(REGRESS)
+
 installcheck: submake prep3
-	$(top_builddir)/src/test/regress/pg_regress --inputdir=./python3 --outputdir=./python3 --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
+	$(pg_regress_installcheck) --inputdir=./python3 --outputdir=./python3 $(REGRESS_OPTS) $(REGRESS)
 
 clean: clean3
 else
+check: submake
+	$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
+
 installcheck: submake
-	$(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
+	$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
 endif
 
 .PHONY: submake
@@ -135,8 +141,7 @@ submake:
 
 clean distclean maintainer-clean: clean-lib
 	rm -f $(OBJS)
-	rm -rf results
-	rm -f regression.diffs regression.out
+	rm -rf $(pg_regress_clean_files)
 ifeq ($(PORTNAME), win32)
 	rm -f python${pytverstr}.def
 endif
diff --git a/src/pl/tcl/.gitignore b/src/pl/tcl/.gitignore
index 19b6c5ba425ca92d1bb371bf43d9cdae372f8c1a..5dcb3ff9723501c3fe639bee1c1435e47a580a6f 100644
--- a/src/pl/tcl/.gitignore
+++ b/src/pl/tcl/.gitignore
@@ -1,2 +1,4 @@
 # Generated subdirectories
+/log/
 /results/
+/tmp_check/
diff --git a/src/pl/tcl/Makefile b/src/pl/tcl/Makefile
index 24be38ff69b068ab5767b9408a069f661410acd0..b29478dd6fd135d4b1803bffe1da29d3dc546f0d 100644
--- a/src/pl/tcl/Makefile
+++ b/src/pl/tcl/Makefile
@@ -58,8 +58,11 @@ installdirs: installdirs-lib
 uninstall: uninstall-lib
 	$(MAKE) -C modules $@
 
+check: submake
+	$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
+
 installcheck: submake
-	$(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
+	$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
 
 .PHONY: submake
 submake:
@@ -77,6 +80,5 @@ endif # TCL_SHARED_BUILD = 0
 
 clean distclean maintainer-clean: clean-lib
 	rm -f $(OBJS)
-	rm -rf results
-	rm -f regression.diffs regression.out
+	rm -rf $(pg_regress_clean_files)
 	$(MAKE) -C modules $@
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 4c8af0f1b66d33ac98557f11acc13c370225ea6a..120d07087ccf4211eea771cfb26727234e1819c4 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -138,19 +138,19 @@ tablespace-setup:
 ## Run tests
 ##
 
-pg_regress_call = ./pg_regress --inputdir=$(srcdir) --dlpath=. $(if $(MULTIBYTE),--multibyte=$(MULTIBYTE)) $(NOLOCALE)
+REGRESS_OPTS = --dlpath=. $(if $(MULTIBYTE),--multibyte=$(MULTIBYTE)) $(NOLOCALE)
 
 check: all tablespace-setup
-	$(pg_regress_call) --temp-install=./tmp_check --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(TEMP_CONF) $(EXTRA_TESTS)
+	$(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(TEMP_CONF) $(EXTRA_TESTS)
 
 installcheck: all tablespace-setup
-	$(pg_regress_call) --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule $(EXTRA_TESTS)
+	$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/serial_schedule $(EXTRA_TESTS)
 
 installcheck-parallel: all tablespace-setup
-	$(pg_regress_call) --psqldir=$(PSQLDIR) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
+	$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) $(EXTRA_TESTS)
 
 standbycheck: all
-	$(pg_regress_call) --psqldir=$(PSQLDIR) --schedule=$(srcdir)/standby_schedule --use-existing
+	$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/standby_schedule --use-existing
 
 # old interfaces follow...
 
@@ -159,10 +159,10 @@ runtest: installcheck
 runtest-parallel: installcheck-parallel
 
 bigtest: all tablespace-setup
-	$(pg_regress_call) --psqldir=$(PSQLDIR) --schedule=$(srcdir)/serial_schedule numeric_big
+	$(pg_regress_installcheck) $(REGRESS_OPTS) --schedule=$(srcdir)/serial_schedule numeric_big
 
 bigcheck: all tablespace-setup
-	$(pg_regress_call) --temp-install=./tmp_check --top-builddir=$(top_builddir) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) numeric_big
+	$(pg_regress_check) $(REGRESS_OPTS) --schedule=$(srcdir)/parallel_schedule $(MAXCONNOPT) numeric_big
 
 
 ##
@@ -176,5 +176,4 @@ clean distclean maintainer-clean: clean-lib
 # things created by various check targets
 	rm -f $(output_files) $(input_files)
 	rm -rf testtablespace
-	rm -rf results tmp_check log
-	rm -f regression.diffs regression.out regress.out run_check.out
+	rm -rf $(pg_regress_clean_files)
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index a3211622b9e4d71cbce296d1902b0de7b7997287..a6160298efb4590708085c8c7347b3033fcb08d0 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -2094,7 +2094,7 @@ regression_main(int argc, char *argv[], init_function ifunc, test_function tfunc
 		/* "make install" */
 #ifndef WIN32_ONLY_COMPILER
 		snprintf(buf, sizeof(buf),
-				 SYSTEMQUOTE "\"%s\" -C \"%s\" DESTDIR=\"%s/install\" install with_perl=no with_python=no > \"%s/log/install.log\" 2>&1" SYSTEMQUOTE,
+				 SYSTEMQUOTE "\"%s\" -C \"%s\" DESTDIR=\"%s/install\" install > \"%s/log/install.log\" 2>&1" SYSTEMQUOTE,
 				 makeprog, top_builddir, temp_install, outputdir);
 #else
 		snprintf(buf, sizeof(buf),