@@ -43,6 +43,7 @@ MAJORVERSION = @PG_MAJORVERSION@
4343# (PGXS VPATH support is handled separately in pgxs.mk)
4444ifndef PGXS
4545vpath_build = @vpath_build@
46+ abs_top_builddir = @abs_top_builddir@
4647abs_top_srcdir = @abs_top_srcdir@
4748
4849ifneq ($(vpath_build ) ,yes)
@@ -301,6 +302,17 @@ BZIP2= bzip2
301302
302303# Testing
303304
305+ check : temp-install
306+
307+ .PHONY : temp-install
308+ temp-install :
309+ ifeq ($(MAKELEVEL ) ,0)
310+ rm -rf '$(abs_top_builddir)'/tmp_install
311+ $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log
312+ $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
313+ endif
314+ for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install >>'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1 || exit; done
315+
304316PROVE = @PROVE@
305317PG_PROVE_FLAGS = -I$(top_srcdir ) /src/test/perl/
306318PROVE_FLAGS = --verbose
@@ -315,16 +327,18 @@ define ld_library_path_var
315327$(if $(filter $(PORTNAME ) ,darwin) ,DYLD_LIBRARY_PATH,$(if $(filter $(PORTNAME ) ,aix) ,LIBPATH,LD_LIBRARY_PATH) )
316328endef
317329
330+ define with_temp_install
331+ PATH="$(abs_top_builddir ) /tmp_install$(bindir ) :$$PATH"$(call add_to_path,$(ld_library_path_var ) ,$(abs_top_builddir ) /tmp_install$(libdir ) )
332+ endef
333+
318334ifeq ($(enable_tap_tests ) ,yes)
319335
320336define prove_installcheck
321337cd$(srcdir ) && TESTDIR='$(CURDIR ) ' PATH="$(bindir ) :$$PATH" PGPORT='6$(DEF_PGPORT ) ' top_builddir='$(CURDIR ) /$(top_builddir ) '$(PROVE ) $(PG_PROVE_FLAGS ) $(PROVE_FLAGS ) t/*.pl
322338endef
323339
324340define prove_check
325- $(MKDIR_P ) tmp_check/log
326- $(MAKE ) -C$(top_builddir ) DESTDIR='$(CURDIR ) '/tmp_check/install install >'$(CURDIR ) '/tmp_check/log/install.log 2>&1
327- cd$(srcdir ) && TESTDIR='$(CURDIR ) ' PATH="$(CURDIR ) /tmp_check/install$(bindir ) :$$PATH"$(call add_to_path,$(ld_library_path_var ) ,$(CURDIR ) /tmp_check/install$(libdir ) ) top_builddir='$(CURDIR ) /$(top_builddir ) ' PGPORT='6$(DEF_PGPORT ) '$(PROVE ) $(PG_PROVE_FLAGS ) $(PROVE_FLAGS ) t/*.pl
341+ cd$(srcdir ) && TESTDIR='$(CURDIR ) '$(with_temp_install ) PGPORT='6$(DEF_PGPORT ) ' top_builddir='$(CURDIR ) /$(top_builddir ) '$(PROVE ) $(PG_PROVE_FLAGS ) $(PROVE_FLAGS ) t/*.pl
328342endef
329343
330344else
@@ -495,13 +509,13 @@ endif
495509
496510pg_regress_locale_flags =$(if $(ENCODING ) ,--encoding=$(ENCODING ) ) $(NOLOCALE )
497511
498- pg_regress_check =$(top_builddir ) /src/test/regress/pg_regress --inputdir=$(srcdir ) --temp-install =./tmp_check --top-builddir= $( top_builddir ) $(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
499- pg_regress_installcheck =$(top_builddir ) /src/test/regress/pg_regress --inputdir=$(srcdir ) --psqldir ='$(PSQLDIR ) '$(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
512+ pg_regress_check =$(with_temp_install ) $( top_builddir ) /src/test/regress/pg_regress --inputdir=$(srcdir ) --temp-instance =./tmp_check --bindir= $(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
513+ pg_regress_installcheck =$(top_builddir ) /src/test/regress/pg_regress --inputdir=$(srcdir ) --bindir ='$(bindir ) '$(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
500514
501515pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ log/
502516
503- pg_isolation_regress_check =$(top_builddir ) /src/test/isolation/pg_isolation_regress --inputdir=$(srcdir ) --temp-install =./tmp_check --top-builddir= $( top_builddir ) $(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
504- pg_isolation_regress_installcheck =$(top_builddir ) /src/test/isolation/pg_isolation_regress --inputdir=$(srcdir ) --top-builddir= $( top_builddir ) $(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
517+ pg_isolation_regress_check =$(with_temp_install ) $( top_builddir ) /src/test/isolation/pg_isolation_regress --inputdir=$(srcdir ) --temp-instance =./tmp_check --bindir= $(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
518+ pg_isolation_regress_installcheck =$(top_builddir ) /src/test/isolation/pg_isolation_regress --inputdir=$(srcdir ) $(pg_regress_locale_flags ) $(EXTRA_REGRESS_OPTS )
505519
506520# #########################################################################
507521#
@@ -683,7 +697,7 @@ endif
683697define _create_recursive_target
684698.PHONY:$(1 ) -$(2 ) -recurse
685699$(1 ) :$(1 ) -$(2 ) -recurse
686- $(1 ) -$(2 ) -recurse:
700+ $(1 ) -$(2 ) -recurse:$( if $( filter check, $( 3 ) ) , temp-install)
687701$$(MAKE ) -C$(2 ) $(3 )
688702endef
689703# Note that the use of $$ on the last line above is important; we want