Skip to content

Commit 176c70b

Browse files
committed
Backpatch pgxs vpath build and installation fixes (v2)
This time with the better installation fix, which I hope won't break the buildfarm.
1 parent cd6c03b commit 176c70b

File tree

2 files changed

+49
-19
lines changed

2 files changed

+49
-19
lines changed

src/Makefile.global.in

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,22 @@ else
415415
libpq_pgport = -L$(top_builddir)/src/port -lpgport $(libpq)
416416
endif
417417

418-
418+
# If PGXS is not defined, build libpq and libpgport dependancies as required.
419+
# If the build is with PGXS, then these are supposed to be already built and
420+
# installed, and we just ensure that the expected files exist.
421+
ifndef PGXS
419422
submake-libpq:
420423
$(MAKE) -C $(libpq_builddir) all
424+
else
425+
submake-libpq: $(libdir)/libpq.so ;
426+
endif
421427

428+
ifndef PGXS
422429
submake-libpgport:
423430
$(MAKE) -C $(top_builddir)/src/port all
431+
else
432+
submake-libpgport: $(libdir)/libpgport.a
433+
endif
424434

425435
.PHONY: submake-libpq submake-libpgport
426436

src/makefiles/pgxs.mk

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,20 @@ top_builddir := $(dir $(PGXS))../..
6262
include $(top_builddir)/src/Makefile.global
6363

6464
top_srcdir = $(top_builddir)
65+
# If USE_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 USE_VPATH
68+
srcdir = $(USE_VPATH)
69+
VPATH = $(USE_VPATH)
70+
else
71+
ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
6572
srcdir = .
6673
VPATH =
74+
else
75+
srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
76+
VPATH = $(srcdir)
77+
endif
78+
endif
6779
endif
6880

6981

@@ -102,33 +114,40 @@ all: all-lib
102114
endif # MODULE_big
103115

104116

105-
install: all installdirs
106-
ifneq (,$(EXTENSION))
107-
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(addsuffix .control, $(EXTENSION))) '$(DESTDIR)$(datadir)/extension/'
108-
endif # EXTENSION
109-
ifneq (,$(DATA)$(DATA_built))
110-
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) $(DATA_built) '$(DESTDIR)$(datadir)/$(datamoduledir)/'
111-
endif # DATA
112-
ifneq (,$(DATA_TSEARCH))
113-
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA_TSEARCH)) '$(DESTDIR)$(datadir)/tsearch_data/'
114-
endif # DATA_TSEARCH
117+
install: all installdirs installcontrol installdata installdatatsearch installdocs installscripts
115118
ifdef MODULES
116119
$(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglibdir)/'
117120
endif # MODULES
121+
ifdef PROGRAM
122+
$(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)'
123+
endif # PROGRAM
124+
125+
installcontrol: $(addsuffix .control, $(EXTENSION)) | installdirs
126+
ifneq (,$(EXTENSION))
127+
$(INSTALL_DATA) $^ '$(DESTDIR)$(datadir)/extension/'
128+
endif
129+
130+
installdata: $(DATA) $(DATA_built) | installdirs
131+
ifneq (,$(DATA)$(DATA_built))
132+
$(INSTALL_DATA) $^ '$(DESTDIR)$(datadir)/$(datamoduledir)/'
133+
endif
134+
135+
installdatatsearch: $(DATA_TSEARCH) | installdirs
136+
ifneq (,$(DATA_TSEARCH))
137+
$(INSTALL_DATA) $^ '$(DESTDIR)$(datadir)/tsearch_data/'
138+
endif
139+
140+
installdocs: $(DOCS) | installdirs
118141
ifdef DOCS
119142
ifdef docdir
120-
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DOCS)) '$(DESTDIR)$(docdir)/$(docmoduledir)/'
143+
$(INSTALL_DATA) $^ '$(DESTDIR)$(docdir)/$(docmoduledir)/'
121144
endif # docdir
122145
endif # DOCS
123-
ifdef PROGRAM
124-
$(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)'
125-
endif # PROGRAM
146+
147+
installscripts: $(SCRIPTS) $(SCRIPTS_built) | installdirs
126148
ifdef SCRIPTS
127-
$(INSTALL_SCRIPT) $(addprefix $(srcdir)/, $(SCRIPTS)) '$(DESTDIR)$(bindir)/'
149+
$(INSTALL_SCRIPT) $^ '$(DESTDIR)$(bindir)/'
128150
endif # SCRIPTS
129-
ifdef SCRIPTS_built
130-
$(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/'
131-
endif # SCRIPTS_built
132151

133152
ifdef MODULE_big
134153
install: install-lib
@@ -253,6 +272,7 @@ test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src)
253272

254273
all: $(test_files_build)
255274
$(test_files_build): $(abs_builddir)/%: $(srcdir)/%
275+
$(MKDIR_P) $(dir $@)
256276
ln -s $< $@
257277
endif # VPATH
258278

0 commit comments

Comments
 (0)