From 32792393d58540c4435e89df4e3b82d9800954c4 Mon Sep 17 00:00:00 2001
From: Craig Ringer <craig@2ndquadrant.com>
Date: Thu, 9 Apr 2020 12:29:21 +0800
Subject: [PATCH 1/4] Fix install-tests target for vpath builds

The prefixing of $(srcdir) on test file names in src/test/regress's
make install-tests target broke on vpath builds. Fix it so that the
tests install properly.

Add the install-tests target to the top-level Makefile too, so it's
more easily found and used.
---
 GNUmakefile.in               | 1 +
 src/test/regress/GNUmakefile | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/GNUmakefile.in b/GNUmakefile.in
index ee636e3b50..bcbed94041 100644
--- a/GNUmakefile.in
+++ b/GNUmakefile.in
@@ -71,6 +71,7 @@ $(call recurse,check-world,src/test src/pl src/interfaces/ecpg contrib src/bin,c
 $(call recurse,checkprep,  src/test src/pl src/interfaces/ecpg contrib src/bin)
 
 $(call recurse,installcheck-world,src/test src/pl src/interfaces/ecpg contrib src/bin,installcheck)
+$(call recurse,install-tests,src/test/regress,install-tests)
 
 GNUmakefile: GNUmakefile.in $(top_builddir)/config.status
 	./config.status $@
diff --git a/src/test/regress/GNUmakefile b/src/test/regress/GNUmakefile
index 1a3164065f..2100850528 100644
--- a/src/test/regress/GNUmakefile
+++ b/src/test/regress/GNUmakefile
@@ -87,9 +87,9 @@ regress_data_files = \
 
 install-tests: all install install-lib installdirs-tests
 	$(MAKE) -C $(top_builddir)/contrib/spi install
-	for file in $(regress_data_files); do \
-	  $(INSTALL_DATA) $$file '$(DESTDIR)$(pkglibdir)/regress/'$$file || exit; \
-	done
+	$(foreach datafile,$(regress_data_files), \
+	  $(INSTALL_DATA) $(datafile) '$(DESTDIR)$(pkglibdir)/regress/$(subst $(srcdir),,$(datafile))'; \
+	)
 
 installdirs-tests: installdirs
 	$(MKDIR_P)  $(patsubst $(srcdir)/%/,'$(DESTDIR)$(pkglibdir)/regress/%',$(sort $(dir $(regress_data_files))))
-- 
2.25.1

