Consolidate makefile code for setting top_srcdir, srcdir and VPATH.
authorNoah Misch
Fri, 31 Jul 2015 00:48:41 +0000 (20:48 -0400)
committerNoah Misch
Fri, 31 Jul 2015 00:49:22 +0000 (20:49 -0400)
Responsibility was formerly split between Makefile.global and pgxs.mk.
As a result of commit b58233c71b93a32fcab7219585cafc25a27eb769, in the
PGXS case, these variables were unset while parsing Makefile.global and
callees.  Inclusion of Makefile.custom did not work from PGXS, and the
subtle difference seemed like a recipe for future bugs.  Back-patch to
9.4, where that commit first appeared.

src/Makefile.global.in
src/makefiles/pgxs.mk

index 18c653bd210a692a95fdb03228be61e2456d5f4f..13d4aa371e10cec0a81bb32a503dd4b964ab65ce 100644 (file)
@@ -40,9 +40,24 @@ VERSION = @PACKAGE_VERSION@
 MAJORVERSION = @PG_MAJORVERSION@
 VERSION_NUM = @PG_VERSION_NUM@
 
-# Support for VPATH builds
-# (PGXS VPATH support is handled separately in pgxs.mk)
-ifndef PGXS
+# Set top_srcdir, srcdir, and VPATH.
+ifdef PGXS
+top_srcdir = $(top_builddir)
+
+# If VPATH is set or Makefile is not in current directory we are building
+# the extension with VPATH so we set the variable here.
+ifdef VPATH
+srcdir = $(VPATH)
+else
+ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
+srcdir = .
+VPATH =
+else
+srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
+VPATH = $(srcdir)
+endif
+endif
+else # not PGXS
 vpath_build = @vpath_build@
 abs_top_srcdir = @abs_top_srcdir@
 
index 60cccddb72b00d8a85d2534c79ae384abfa42802..2cc7699824ca162f4911db50806061eab6f704b4 100644 (file)
@@ -61,21 +61,6 @@ ifdef PGXS
 top_builddir := $(dir $(PGXS))../..
 include $(top_builddir)/src/Makefile.global
 
-top_srcdir = $(top_builddir)
-# If VPATH is set or Makefile is not in current directory we are building
-# the extension with VPATH so we set the variable here.
-ifdef VPATH
-srcdir = $(VPATH)
-else
-ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
-srcdir = .
-VPATH =
-else
-srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
-VPATH = $(srcdir)
-endif
-endif
-
 # These might be set in Makefile.global, but if they were not found
 # during the build of PostgreSQL, supply default values so that users
 # of pgxs can use the variables.