Skip to content

Commit 0efa0f6

Browse files
committed
Consolidate makefile code for setting top_srcdir, srcdir and VPATH.
Responsibility was formerly split between Makefile.global and pgxs.mk. As a result of commit b58233c, 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.
1 parent 3b4a9db commit 0efa0f6

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/Makefile.global.in

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,24 @@ VERSION = @PACKAGE_VERSION@
4040
MAJORVERSION = @PG_MAJORVERSION@
4141
VERSION_NUM = @PG_VERSION_NUM@
4242

43-
# Support for VPATH builds
44-
# (PGXS VPATH support is handled separately in pgxs.mk)
45-
ifndef PGXS
43+
# Set top_srcdir, srcdir, and VPATH.
44+
ifdef PGXS
45+
top_srcdir = $(top_builddir)
46+
47+
# If VPATH is set or Makefile is not in current directory we are building
48+
# the extension with VPATH so we set the variable here.
49+
ifdef VPATH
50+
srcdir = $(VPATH)
51+
else
52+
ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
53+
srcdir = .
54+
VPATH =
55+
else
56+
srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
57+
VPATH = $(srcdir)
58+
endif
59+
endif
60+
else # not PGXS
4661
vpath_build = @vpath_build@
4762
abs_top_srcdir = @abs_top_srcdir@
4863

src/makefiles/pgxs.mk

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,6 @@ ifdef PGXS
6161
top_builddir := $(dir $(PGXS))../..
6262
include $(top_builddir)/src/Makefile.global
6363

64-
top_srcdir = $(top_builddir)
65-
# If VPATH is set or Makefile is not in current directory we are building
66-
# the extension with VPATH so we set the variable here.
67-
ifdef VPATH
68-
srcdir = $(VPATH)
69-
else
70-
ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
71-
srcdir = .
72-
VPATH =
73-
else
74-
srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
75-
VPATH = $(srcdir)
76-
endif
77-
endif
78-
7964
# These might be set in Makefile.global, but if they were not found
8065
# during the build of PostgreSQL, supply default values so that users
8166
# of pgxs can use the variables.

0 commit comments

Comments
 (0)