Backpatch pgxs vpath build and installation fixes.

This is a backpatch of commits d942f9d9, 82b01026, and 6697aa2bc, back
to release 9.1 where we introduced extensions which make heavy use of
the PGXS infrastructure.
This commit is contained in:
Andrew Dunstan 2013-09-29 17:28:16 -04:00
parent 32d8602852
commit f8110c5f66
2 changed files with 50 additions and 20 deletions

View File

@ -415,13 +415,23 @@ libpq_pgport = -L$(top_builddir)/src/port -lpgport \
-L$(top_builddir)/src/common -lpgcommon $(libpq) -L$(top_builddir)/src/common -lpgcommon $(libpq)
endif endif
# If PGXS is not defined, build libpq and libpgport dependancies as required.
# If the build is with PGXS, then these are supposed to be already built and
# installed, and we just ensure that the expected files exist.
ifndef PGXS
submake-libpq: submake-libpq:
$(MAKE) -C $(libpq_builddir) all $(MAKE) -C $(libpq_builddir) all
else
submake-libpq: $(libdir)/libpq.so ;
endif
ifndef PGXS
submake-libpgport: submake-libpgport:
$(MAKE) -C $(top_builddir)/src/port all $(MAKE) -C $(top_builddir)/src/port all
$(MAKE) -C $(top_builddir)/src/common all $(MAKE) -C $(top_builddir)/src/common all
else
submake-libpgport: $(libdir)/libpgport.a $(libdir)/libpgcommon.a ;
endif
.PHONY: submake-libpq submake-libpgport .PHONY: submake-libpq submake-libpgport

View File

@ -62,8 +62,20 @@ top_builddir := $(dir $(PGXS))../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
top_srcdir = $(top_builddir) top_srcdir = $(top_builddir)
# If USE_VPATH is set or Makefile is not in current directory we are building
# the extension with VPATH so we set the variable here
ifdef USE_VPATH
srcdir = $(USE_VPATH)
VPATH = $(USE_VPATH)
else
ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
srcdir = . srcdir = .
VPATH = VPATH =
else
srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
VPATH = $(srcdir)
endif
endif
# These might be set in Makefile.global, but if they were not found # These might be set in Makefile.global, but if they were not found
# during the build of PostgreSQL, supply default values so that users # during the build of PostgreSQL, supply default values so that users
@ -112,33 +124,40 @@ all: all-lib
endif # MODULE_big endif # MODULE_big
install: all installdirs install: all installcontrol installdata installdatatsearch installdocs installscripts | installdirs
ifneq (,$(EXTENSION))
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(addsuffix .control, $(EXTENSION))) '$(DESTDIR)$(datadir)/extension/'
endif # EXTENSION
ifneq (,$(DATA)$(DATA_built))
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) $(DATA_built) '$(DESTDIR)$(datadir)/$(datamoduledir)/'
endif # DATA
ifneq (,$(DATA_TSEARCH))
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA_TSEARCH)) '$(DESTDIR)$(datadir)/tsearch_data/'
endif # DATA_TSEARCH
ifdef MODULES ifdef MODULES
$(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglibdir)/' $(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglibdir)/'
endif # MODULES endif # MODULES
ifdef DOCS
ifdef docdir
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DOCS)) '$(DESTDIR)$(docdir)/$(docmoduledir)/'
endif # docdir
endif # DOCS
ifdef PROGRAM ifdef PROGRAM
$(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)' $(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)'
endif # PROGRAM endif # PROGRAM
installcontrol: $(addsuffix .control, $(EXTENSION))
ifneq (,$(EXTENSION))
$(INSTALL_DATA) $^ '$(DESTDIR)$(datadir)/extension/'
endif
installdata: $(DATA) $(DATA_built)
ifneq (,$(DATA)$(DATA_built))
$(INSTALL_DATA) $^ '$(DESTDIR)$(datadir)/$(datamoduledir)/'
endif
installdatatsearch: $(DATA_TSEARCH)
ifneq (,$(DATA_TSEARCH))
$(INSTALL_DATA) $^ '$(DESTDIR)$(datadir)/tsearch_data/'
endif
installdocs: $(DOCS)
ifdef DOCS
ifdef docdir
$(INSTALL_DATA) $^ '$(DESTDIR)$(docdir)/$(docmoduledir)/'
endif # docdir
endif # DOCS
installscripts: $(SCRIPTS) $(SCRIPTS_built)
ifdef SCRIPTS ifdef SCRIPTS
$(INSTALL_SCRIPT) $(addprefix $(srcdir)/, $(SCRIPTS)) '$(DESTDIR)$(bindir)/' $(INSTALL_SCRIPT) $^ '$(DESTDIR)$(bindir)/'
endif # SCRIPTS endif # SCRIPTS
ifdef SCRIPTS_built
$(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/'
endif # SCRIPTS_built
ifdef MODULE_big ifdef MODULE_big
install: install-lib install: install-lib
@ -263,6 +282,7 @@ test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src)
all: $(test_files_build) all: $(test_files_build)
$(test_files_build): $(abs_builddir)/%: $(srcdir)/% $(test_files_build): $(abs_builddir)/%: $(srcdir)/%
$(MKDIR_P) $(dir $@)
ln -s $< $@ ln -s $< $@
endif # VPATH endif # VPATH