Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UowKe-0002zV-W7 for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2013 13:52:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UowKe-00065G-FS for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jun 2013 13:52:24 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UowKc-00065A-Rc for pgsql-hackers@postgresql.org; Tue, 18 Jun 2013 13:52:23 +0000 Received: from moutng.kundenserver.de ([212.227.17.10]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UowKZ-00083V-3N for pgsql-hackers@postgresql.org; Tue, 18 Jun 2013 13:52:22 +0000 Received: from obelix.localnet (AToulouse-556-1-274-157.w90-45.abo.wanadoo.fr [90.45.62.157]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MJF5W-1UrhDn2Gmw-002mZ9; Tue, 18 Jun 2013 15:52:17 +0200 From: =?iso-8859-1?q?C=E9dric_Villemain?= Reply-To: cedric@2ndquadrant.com Organization: 2ndQuadrant To: pgsql-hackers@postgresql.org Subject: Bugfix and new feature for PGXS Date: Tue, 18 Jun 2013 15:52:27 +0200 User-Agent: KMail/1.13.7 (Linux/3.8-2-amd64; KDE/4.8.4; x86_64; ; ) Cc: Craig Ringer MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2016448.58d1UmYa7s"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201306181552.36673.cedric@2ndquadrant.com> X-Provags-ID: V02:K0:JlbcK82+uvM+e4jeGSBxHsB2WJldBq3GrNvhKeVY3Ra 3A3BrXgh7KRTJcr181MgbLGKEXsJN6ltnWNP5h/d3fBq8uUyuk +NMOOVcIQsrEdnQ5hRNeVF/LQa+lZNjDAkVN+FoXgg6vkHZmKM FRGQ+uCjbtmBIK4Uo33rcoBQ/YDiaVgkUf8SZa+WBHVtPZoU4W uXUzDf/2Xqa6amt6En9zBZFDTcV3olRmji5ui+wKD56eMLg8xK jCMLAMGYc0mZzOKJzGPotuuRRKR8UlwudPx0m1X4FGZbmB7mmE 1g/NBPmxptPiZSyIw71XQKxiRssU2uZPezsbL9pMhB4TB1Za4f uP16QemeNzp6w+aOM+nlOXmZ9YjdqD3oMto2XXlUB X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --nextPart2016448.58d1UmYa7s Content-Type: multipart/mixed; boundary="Boundary-01=_cYGwRnNDkK3riu7" Content-Transfer-Encoding: 7bit --Boundary-01=_cYGwRnNDkK3riu7 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I've rebased the current set of pending patches I had, to fix pgxs and adde= d 2=20 new patches. Bugfixes have already been presented and sent in another thread, except the= =20 last one which only fix comment in pgxs.mk. The new feature consists in a new variable to allow the installation of=20 contrib header files. A new variable MODULEHEADER can be used in extension Makefile to list the header files to install. The installation path default to $includedir/$includedir_contrib/$extension. 2 new variables are set to define directories: $includedir_contrib and $includedir_extension, the former default to include/contrib and the later = to $includedir_contrib/$extension ($extension is the name of the extension). This allows for example to install hstore header and be able to include them in another extension like that: # include "contrib/hstore/hstore.h" =46or packagers of PostgreSQL, this allows to have a postgresql-X.Y-contrib= =2Ddev=20 package. =46or developers of extension it's killing the copy-and-paste-this-function= =20 dance previously required. I've not updated contribs' Makfefile: I'm not sure what we want to expose. I've 2 other patches to write to automatize a bit more the detection of thi= ngs=20 to do when building with USE_PGXS, based on the layout. Better get a good=20 consensus on this before writing them. Bugfix: 0001-fix-SHLIB_PREREQS-when-building-with-USE_PGXS.patch 0002-Create-data-directory-if-extension-when-required.patch 0003-set-VPATH-for-out-of-tree-extension-builds.patch 0004-adds-support-for-VPATH-with-USE_PGXS.patch 0006-Fix-suggested-layout-for-extension.patch New feature: 0005-Allows-extensions-to-install-header-file.patch I'll do a documentation patch based on what is accepted in HEAD and/or=20 previous branches. =2D-=20 C=E9dric Villemain +33 (0)6 20 30 22 52 http://2ndQuadrant.fr/ PostgreSQL: Support 24x7 - D=E9veloppement, Expertise et Formation --Boundary-01=_cYGwRnNDkK3riu7 Content-Type: text/x-patch; charset="UTF-8"; name="0001-fix-SHLIB_PREREQS-when-building-with-USE_PGXS.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-fix-SHLIB_PREREQS-when-building-with-USE_PGXS.patch" =46rom c23041f31b5a312702d79bbe759a56628f3e37e5 Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?C=3DC3=3DA9dric=3D20Villemain?=3D Date: Tue, 28 May 2013 14:11:18 +0200 Subject: [PATCH 1/6] fix SHLIB_PREREQS when building with USE_PGXS commit 19e231b introduced SHLIB_PREREQS but failed to port that to PGXS bui= ld. The issue is that "submake-*" can not be built with PGXS, in this case they must check that expected files are present (and installed). Maybe it is better to only check if they have been built ? This fix the build of dblink and postgres_fdw (make USE_PGXS=3D1) =2D-- src/Makefile.global.in | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 8bfb77d..c3c595e 100644 =2D-- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -415,13 +415,24 @@ libpq_pgport =3D -L$(top_builddir)/src/port -lpgport \ -L$(top_builddir)/src/common -lpgcommon $(libpq) endif =20 =2D +# If PGXS is not defined, builds as usual: +# build dependancies required by SHLIB_PREREQS +# If the build is with PGXS, then any requirement is supposed to be already +# build and we just take care that the expected files exist +ifndef PGXS submake-libpq: $(MAKE) -C $(libpq_builddir) all +else +submake-libpq: $(libdir)/libpq.so ; +endif =20 +ifndef PGXS submake-libpgport: $(MAKE) -C $(top_builddir)/src/port all $(MAKE) -C $(top_builddir)/src/common all +else +submake-libpgport: $(libdir)/libpgport.a $(libdir)/libpgcommon.a ; +endif =20 .PHONY: submake-libpq submake-libpgport =20 =2D-=20 1.7.10.4 --Boundary-01=_cYGwRnNDkK3riu7 Content-Type: text/x-patch; charset="UTF-8"; name="0002-Create-data-directory-if-extension-when-required.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-Create-data-directory-if-extension-when-required.patch" =46rom 3d3f4df6792c0e98b0a915b8704504f27738bf26 Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?C=3DC3=3DA9dric=3D20Villemain?=3D Date: Tue, 28 May 2013 14:17:04 +0200 Subject: [PATCH 2/6] Create data directory if extension when required There is a hack to link the regression data files from the srcdir to the builddir when doing 'make VPATH'. but it failed when used in conjunction with USE_PGXS and out-of-tree build of an extension. Issue is the absence of the data/ directory in the builddir. =2D-- src/makefiles/pgxs.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index bbcfe04..6a19b0f 100644 =2D-- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -263,6 +263,7 @@ test_files_build :=3D $(patsubst $(srcdir)/%, $(abs_bui= lddir)/%, $(test_files_src) =20 all: $(test_files_build) $(test_files_build): $(abs_builddir)/%: $(srcdir)/% + $(MKDIR_P) $(dir $@) ln -s $< $@ endif # VPATH =20 =2D-=20 1.7.10.4 --Boundary-01=_cYGwRnNDkK3riu7 Content-Type: text/x-patch; charset="UTF-8"; name="0003-set-VPATH-for-out-of-tree-extension-builds.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-set-VPATH-for-out-of-tree-extension-builds.patch" =46rom 66b394ae867bde2ad968027f0708ae59a140d81b Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?C=3DC3=3DA9dric=3D20Villemain?=3D Date: Tue, 28 May 2013 14:51:43 +0200 Subject: [PATCH 3/6] set VPATH for out-of-tree extension builds If the makefile is not in the current directory (where we launch 'make') then assume we are building out-of-src tree and set the VPATH to the directory of the first makefile... Thus it fixes: mkdir /tmp/a && cd /tmp/a make -f extension_src/Makefile USE_PGXS=3D1 =2D-- src/makefiles/pgxs.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index 6a19b0f..50fd99d 100644 =2D-- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -61,9 +61,18 @@ ifdef PGXS top_builddir :=3D $(dir $(PGXS))../.. include $(top_builddir)/src/Makefile.global =20 +# If Makefile is not in current directory we are building the extension wi= th +# VPATH so we set the variable here +# XXX what about top_srcdir ? +ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST)))) top_srcdir =3D $(top_builddir) srcdir =3D . VPATH =3D +else +top_srcdir =3D $(top_builddir) +srcdir =3D $(dir $(firstword $(MAKEFILE_LIST))) +VPATH =3D $(srcdir) +endif =20 # These might be set in Makefile.global, but if they were not found # during the build of PostgreSQL, supply default values so that users =2D-=20 1.7.10.4 --Boundary-01=_cYGwRnNDkK3riu7 Content-Type: text/x-patch; charset="UTF-8"; name="0004-adds-support-for-VPATH-with-USE_PGXS.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0004-adds-support-for-VPATH-with-USE_PGXS.patch" =46rom f446d646c3459c9ec81856b3b3ab0560a419d29e Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?C=3DC3=3DA9dric=3D20Villemain?=3D Date: Tue, 28 May 2013 15:17:27 +0200 Subject: [PATCH 4/6] adds support for VPATH with USE_PGXS It just change recipe for install: in pgxs.mk. I didn't touch MODULE and PROGRAM (yet) =2D-- src/makefiles/pgxs.mk | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index 50fd99d..f70d5f7 100644 =2D-- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -121,33 +121,40 @@ all: all-lib endif # MODULE_big =20 =20 =2Dinstall: all installdirs =2Difneq (,$(EXTENSION)) =2D $(INSTALL_DATA) $(addprefix $(srcdir)/, $(addsuffix .control, $(EXTENSI= ON))) '$(DESTDIR)$(datadir)/extension/' =2Dendif # EXTENSION =2Difneq (,$(DATA)$(DATA_built)) =2D $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) $(DATA_built) '$(DESTD= IR)$(datadir)/$(datamoduledir)/' =2Dendif # DATA =2Difneq (,$(DATA_TSEARCH)) =2D $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA_TSEARCH)) '$(DESTDIR)$(d= atadir)/tsearch_data/' =2Dendif # DATA_TSEARCH +install: all installdirs installcontrol installdata installdatatsearch ins= talldocs installscripts ifdef MODULES $(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglib= dir)/' endif # MODULES +ifdef PROGRAM + $(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)' +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 =2D $(INSTALL_DATA) $(addprefix $(srcdir)/, $(DOCS)) '$(DESTDIR)$(docdir)/$= (docmoduledir)/' + $(INSTALL_DATA) $^ '$(DESTDIR)$(docdir)/$(docmoduledir)/' endif # docdir endif # DOCS =2Difdef PROGRAM =2D $(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)' =2Dendif # PROGRAM + +installscripts: $(SCRIPTS) $(SCRIPTS_built) ifdef SCRIPTS =2D $(INSTALL_SCRIPT) $(addprefix $(srcdir)/, $(SCRIPTS)) '$(DESTDIR)$(bind= ir)/' + $(INSTALL_SCRIPT) $^ '$(DESTDIR)$(bindir)/' endif # SCRIPTS =2Difdef SCRIPTS_built =2D $(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/' =2Dendif # SCRIPTS_built =20 ifdef MODULE_big install: install-lib =2D-=20 1.7.10.4 --Boundary-01=_cYGwRnNDkK3riu7 Content-Type: text/x-patch; charset="UTF-8"; name="0006-Fix-suggested-layout-for-extension.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0006-Fix-suggested-layout-for-extension.patch" =46rom b9d215eaced393a61c1b4398b7cbb164aa3cefdd Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?C=3DC3=3DA9dric=3D20Villemain?=3D Date: Tue, 18 Jun 2013 15:19:22 +0200 Subject: [PATCH 6/6] Fix suggested layout for extension custom rules must come after pgxs inclusion, not before. It is because any rule added before pgxs will break the default 'all' target. =2D-- src/makefiles/pgxs.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index 4f25890..0842c77 100644 =2D-- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -9,12 +9,13 @@ # Use the following layout for your Makefile: # # [variable assignments, see below] =2D# [custom rules, rarely necessary] # # PG_CONFIG =3D pg_config # PGXS :=3D $(shell $(PG_CONFIG) --pgxs) # include $(PGXS) # +# [custom rules, rarely necessary] +# # Set one of these three variables to specify what is built: # # MODULES -- list of shared-library objects to be built from source files =2D-=20 1.7.10.4 --Boundary-01=_cYGwRnNDkK3riu7 Content-Type: text/x-patch; charset="UTF-8"; name="0005-Allows-extensions-to-install-header-file.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0005-Allows-extensions-to-install-header-file.patch" =46rom 04b3da98d3526fdf8c3d3650a49381e4633ff3ec Mon Sep 17 00:00:00 2001 =46rom: =3D?UTF-8?q?C=3DC3=3DA9dric=3D20Villemain?=3D Date: Tue, 18 Jun 2013 15:08:27 +0200 Subject: [PATCH 5/6] Allows extensions to install header file MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit A new variable MODULEHEADER can be used in extension Makefile to list the header files to install. The installation path default to $includedir/$includedir_contrib/$extension. 2 new variables are set to define directories: $includedir_contrib and $includedir_extension, the former default to include/contrib and the later = to $includedir_contrib/$extension ($extension is the name of the extension). This allows for example to install hstore header and be able to include them in another extension like that: #=C2=A0include "contrib/hstore/hstore.h" =2D-- src/Makefile.global.in | 1 + src/makefiles/pgxs.mk | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Makefile.global.in b/src/Makefile.global.in index c3c595e..96fd0f6 100644 =2D-- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -149,6 +149,7 @@ endif # PGXS =20 includedir_server =3D $(pkgincludedir)/server includedir_internal =3D $(pkgincludedir)/internal +includedir_contrib =3D $(pkgincludedir)/contrib pgxsdir =3D $(pkglibdir)/pgxs =20 =20 diff --git a/src/makefiles/pgxs.mk b/src/makefiles/pgxs.mk index f70d5f7..4f25890 100644 =2D-- a/src/makefiles/pgxs.mk +++ b/src/makefiles/pgxs.mk @@ -39,6 +39,7 @@ # which need to be built first # REGRESS -- list of regression test cases (without suffix) # REGRESS_OPTS -- additional switches to pass to pg_regress +# MODULEHEADER -- list of header to install in $INCLUDEDIR_CONTRIB/$EXTE= NSION # EXTRA_CLEAN -- extra files to remove in 'make clean' # PG_CPPFLAGS -- will be added to CPPFLAGS # PG_LIBS -- will be added to PROGRAM link line @@ -105,6 +106,10 @@ docmoduledir :=3D contrib endif endif =20 +ifdef MODULEHEADER +includedir_extension :=3D $(includedir_contrib)/$(EXTENSION) +endif + ifdef PG_CPPFLAGS override CPPFLAGS :=3D $(PG_CPPFLAGS) $(CPPFLAGS) endif @@ -121,7 +126,7 @@ all: all-lib endif # MODULE_big =20 =20 =2Dinstall: all installdirs installcontrol installdata installdatatsearch i= nstalldocs installscripts +install: all installdirs installcontrol installdata installdatatsearch ins= talldocs installscripts installheader ifdef MODULES $(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglib= dir)/' endif # MODULES @@ -156,6 +161,11 @@ ifdef SCRIPTS $(INSTALL_SCRIPT) $^ '$(DESTDIR)$(bindir)/' endif # SCRIPTS =20 +installheader: $(MODULEHEADER) +ifneq (,$(MODULEHEADER)) + $(INSTALL_DATA) $^ '$(DESTDIR)$(includedir_extension)/' +endif + ifdef MODULE_big install: install-lib endif # MODULE_big @@ -182,6 +192,9 @@ endif # DOCS ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built)) $(MKDIR_P) '$(DESTDIR)$(bindir)' endif +ifneq (,$(MODULEHEADER)) + $(MKDIR_P) '$(DESTDIR)/$(includedir_extension)' +endif =20 ifdef MODULE_big installdirs: installdirs-lib =2D-=20 1.7.10.4 --Boundary-01=_cYGwRnNDkK3riu7-- --nextPart2016448.58d1UmYa7s Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQEcBAABAgAGBQJRwGYkAAoJENsgH0yzVBebaTgH/ReKem6aQPWF7ts6MGKNS71D 5EnLzMOr7ziBokvRXPNVFR+oI/zzeLsKyOdaRVsv3DHmD4ro8bmvFWPht99bYF3N ncR8FM9tSHsWyebYknRK6UxCdhIbNj5yEUQLu+97riGkHluB1ZTRUXBvuvP73xy+ 3ybs7zcxNjQDbUWAuSdp6SfJfHq+nhAojNM+iAlIv6G+zHw3iVa6Mgett2b4p+Fm z02cwDCQ3rziRwDuRHNiWpC2Sw0CAIMQIYHHUpf4ef2gQpPGbGUzTi9AX0BbMEaV TqLRKvqX7E+sHe/CiZxJUvbilWEJ3FzazwtjF1hB8GEbdflCUMYwn4kiuRvgsnE= =D1cV -----END PGP SIGNATURE----- --nextPart2016448.58d1UmYa7s--