pgxs: build infrastructure for extensions v4

Started by Fabien COELHOover 21 years ago21 messages
#1Fabien COELHO
coelho@cri.ensmp.fr
1 attachment(s)

Dear patchers,

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions. I hope it addresses all of
Peter's comments. I'll be away for the next 3 weeks, so if minor changes
are required it would be best if you could proceed without me...

The infrastructure is a simple reworking of the already available internal
infrastructure for contrib, so that it can be used outside of the
postgresql source tree after installation, without gory details being in
sight of the user. The documentation is added as a new section in
"xfunc.sgml".

I updated all contrib makefiles so that they can be used either the
standard way after a configure, or the new way without needing a configure
but with an already installed postgreSQL. Just try them with

"cd contrib/foo ; make USE_PGXS=1 install"

*AFTER* postgresql has been configure, compiled and installed. It should
be compiled and installed wrt to the first "pg_config" which is found in
the path.

How it works:

- necessary files (includes, scripts, makefiles...) are copied under
$(pkglibdir)/pgxs on the initial "make install".

due to gnu-make restriction on how its includes work, these files must
be copied with the *same* directory structure as the pg source tree.
The fact does not appear at all in the actual infrastructure from the
user point of view, but it explains why subdirectories are necessary
under pgxs, if you care to have a look.

- the makefile of any extension is expected to set macro PGXS to
"pg_config --pgxs", to include a special makefile, and to
set some macros depending on what is to be built, just like in
current contrib.

- I've added two PGXS-triggered conditionnals in Makefile.global,
so that includes and libraries are taken where needed.

Notes:

- there is still a "light-install" target that matches the previous
"install" behavior, as new "install" matches previous "server-install".

- I'm not sure the sgml is ok. It looks ok, but is it enough.

- It validates and works for me.

Have a nice day,

--
Fabien Coelho - coelho@cri.ensmp.fr

Attachments:

install_build.patchtext/plain; charset=US-ASCII; name=install_build.patchDownload
*** ./GNUmakefile.in.orig	Mon Jun 14 15:33:06 2004
--- ./GNUmakefile.in	Fri Jul 16 11:22:58 2004
***************
*** 13,29 ****
  	$(MAKE) -C src all
  	@echo "All of PostgreSQL successfully made. Ready to install."
  
! install:
  	$(MAKE) -C doc install
  	$(MAKE) -C src install
- 	@echo "PostgreSQL installation complete."
  
! installdirs uninstall distprep:
  	$(MAKE) -C doc $@
  	$(MAKE) -C src $@
  
! install-all-headers:
  	$(MAKE) -C src $@
  
  # clean, distclean, etc should apply to contrib too, even though
  # it's not built by default
--- 13,44 ----
  	$(MAKE) -C src all
  	@echo "All of PostgreSQL successfully made. Ready to install."
  
! install: light-install install-all-headers
! 	@echo "PostgreSQL installation complete."
! 
! light-install:
  	$(MAKE) -C doc install
  	$(MAKE) -C src install
  
! distprep:
! 	$(MAKE) -C doc $@
! 	$(MAKE) -C src $@
! 
! installdirs:
! 	$(MAKE) -C doc $@
! 	$(MAKE) -C src $@
! 	$(MAKE) -C config $@
! 	$(mkinstalldirs) $(DESTDIR)$(pgxsdir)
! 
! uninstall:
  	$(MAKE) -C doc $@
  	$(MAKE) -C src $@
+ 	$(MAKE) -C config $@
  
! install-all-headers: installdirs
  	$(MAKE) -C src $@
+ 	$(MAKE) -C config $@
+ 	$(INSTALL_DATA) config.status $(DESTDIR)$(pgxsdir)
  
  # clean, distclean, etc should apply to contrib too, even though
  # it's not built by default
*** ./config/Makefile.orig	Fri Jul 16 11:19:26 2004
--- ./config/Makefile	Fri Jul 16 16:14:45 2004
***************
*** 0 ****
--- 1,19 ----
+ # $PostgreSQL$
+ 
+ subdir = config
+ top_builddir = ..
+ include $(top_builddir)/src/Makefile.global
+ 
+ ins_files	= install-sh mkinstalldirs
+ ins_dir		= $(DESTDIR)$(pgxsdir)/config
+ 
+ install-all-headers: install
+ 
+ install: installdirs
+ 	for f in $(ins_files) ; do $(INSTALL_DATA) $$f $(ins_dir) ; done;
+ 
+ installdirs:
+ 	$(mkinstalldirs) $(ins_dir)
+ 
+ uninstall:
+ 	for f in $(ins_files) ; do $(RM) $(ins_dir)/$$f ; done;
*** ./contrib/btree_gist/Makefile.orig	Fri May 28 15:09:43 2004
--- ./contrib/btree_gist/Makefile	Fri Jul 16 16:22:17 2004
***************
*** 1,7 ****
  
  subdir = contrib/btree_gist
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big  = btree_gist
  
--- 1,6 ----
***************
*** 16,19 ****
  REGRESS     = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz time timetz \
                date interval macaddr inet cidr text varchar char bytea bit varbit numeric
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 15,18 ----
  REGRESS     = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz time timetz \
                date interval macaddr inet cidr text varchar char bytea bit varbit numeric
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/chkpass/Makefile.orig	Sat Nov 29 20:51:19 2003
--- ./contrib/chkpass/Makefile	Fri Jul 16 16:22:08 2004
***************
*** 2,8 ****
  
  subdir = contrib/chkpass
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = chkpass
  OBJS = chkpass.o
--- 2,7 ----
***************
*** 10,13 ****
  DATA_built = chkpass.sql
  DOCS = README.chkpass
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 9,12 ----
  DATA_built = chkpass.sql
  DOCS = README.chkpass
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/contrib-global.mk.orig	Sat Nov 29 20:51:18 2003
--- ./contrib/contrib-global.mk	Fri Jul 16 16:17:25 2004
***************
*** 23,28 ****
--- 23,29 ----
  #   DATA_built -- random files to install into $PREFIX/share/contrib,
  #     which need to be built first
  #   DOCS -- random files to install under $PREFIX/doc/contrib
+ 
  #   SCRIPTS -- script files (not binaries) to install into $PREFIX/bin
  #   SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin,
  #     which need to be built first
***************
*** 42,234 ****
  #
  # Better look at some of the existing uses for examples...
  
! 
! override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
! 
! ifdef MODULES
! override CFLAGS += $(CFLAGS_SL)
! SHLIB_LINK += $(BE_DLLLIBS)
! endif
! 
! ifdef PG_CPPFLAGS
! override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
! endif
! 
! all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES))
! 
! ifdef MODULE_big
! # shared library parameters
! NAME = $(MODULE_big)
! SO_MAJOR_VERSION= 0
! SO_MINOR_VERSION= 0
! rpath =
! 
! SHLIB_LINK += $(BE_DLLLIBS)
! 
! include $(top_srcdir)/src/Makefile.shlib
! 
! all: all-lib
! endif # MODULE_big
! 
! 
! install: all installdirs
! ifneq (,$(DATA)$(DATA_built))
! 	@for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \
! 	  echo "$(INSTALL_DATA) $$file $(DESTDIR)$(datadir)/contrib"; \
! 	  $(INSTALL_DATA) $$file $(DESTDIR)$(datadir)/contrib; \
! 	done
! endif # DATA
! ifdef MODULES
! 	@for file in $(addsuffix $(DLSUFFIX), $(MODULES)); do \
! 	  echo "$(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir)"; \
! 	  $(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir); \
! 	done
! endif # MODULES
! ifdef DOCS
! 	@for file in $(addprefix $(srcdir)/, $(DOCS)); do \
! 	  echo "$(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/contrib"; \
! 	  $(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/contrib; \
! 	done
! endif # DOCS
! ifdef PROGRAM
! 	$(INSTALL_PROGRAM) $(PROGRAM)$(X) $(DESTDIR)$(bindir)
! endif # PROGRAM
! ifdef MODULE_big
! 	$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
! endif # MODULE_big
! ifdef SCRIPTS
! 	@for file in $(addprefix $(srcdir)/, $(SCRIPTS)); do \
! 	  echo "$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir)"; \
! 	  $(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir); \
! 	done
! endif # SCRIPTS
! ifdef SCRIPTS_built
! 	@for file in $(SCRIPTS_built); do \
! 	  echo "$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir)"; \
! 	  $(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir); \
! 	done
! endif # SCRIPTS_built
! 
! 
! installdirs:
! ifneq (,$(DATA)$(DATA_built))
! 	$(mkinstalldirs) $(DESTDIR)$(datadir)/contrib
! endif
! ifneq (,$(MODULES)$(MODULE_big))
! 	$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
! endif
! ifdef DOCS
! 	$(mkinstalldirs) $(DESTDIR)$(docdir)/contrib
! endif
! ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built))
! 	$(mkinstalldirs) $(DESTDIR)$(bindir)
! endif
! 
! 
! uninstall:
! ifneq (,$(DATA)$(DATA_built))
! 	rm -f $(addprefix $(DESTDIR)$(datadir)/contrib/, $(notdir $(DATA) $(DATA_built)))
! endif
! ifdef MODULES
! 	rm -f $(addprefix $(DESTDIR)$(pkglibdir)/, $(addsuffix $(DLSUFFIX), $(MODULES)))
! endif
! ifdef DOCS
! 	rm -f $(addprefix $(DESTDIR)$(docdir)/contrib/, $(DOCS))
! endif
! ifdef PROGRAM
! 	rm -f $(DESTDIR)$(bindir)/$(PROGRAM)$(X)
! endif
! ifdef MODULE_big
! 	rm -f $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
! endif
! ifdef SCRIPTS
! 	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
! endif
! ifdef SCRIPTS_built
! 	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS_built))
! endif
! 
! 
! clean:
! ifdef MODULES
! 	rm -f $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .o, $(MODULES))
! endif
! ifdef DATA_built
! 	rm -f $(DATA_built)
! endif
! ifdef SCRIPTS_built
! 	rm -f $(SCRIPTS_built)
! endif
! ifdef PROGRAM
! 	rm -f $(PROGRAM)$(X)
! endif
! ifdef OBJS
! 	rm -f $(OBJS)
! endif
! ifdef EXTRA_CLEAN
! 	rm -f $(EXTRA_CLEAN)
! endif
! ifdef REGRESS
! # things created by various check targets
! 	rm -rf results tmp_check log
! 	rm -f regression.diffs regression.out regress.out run_check.out
! ifeq ($(PORTNAME), win)
! 	rm -f regress.def
! endif
! endif # REGRESS
! 
! ifdef MODULE_big
! clean: clean-lib
! endif
! 
! distclean maintainer-clean: clean
! 
! 
! ifdef REGRESS
! 
! # When doing a VPATH build, must copy over the test .sql and .out
! # files so that the driver script can find them.  We have to use an
! # absolute path for the targets, because otherwise make will try to
! # locate the missing files using VPATH, and will find them in
! # $(srcdir), but the point here is that we want to copy them from
! # $(srcdir) to the build directory.
! 
! ifdef VPATH
! abs_builddir := $(shell pwd)
! test_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out) $(wildcard $(srcdir)/data/*.data)
! test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src))
! 
! all: $(test_files_build)
! $(test_files_build): $(abs_builddir)/%: $(srcdir)/%
! 	ln -s $< $@
! endif # VPATH
! 
! .PHONY: submake
! submake:
! 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress
! 
! # against installed postmaster
! installcheck: submake
! 	$(top_builddir)/src/test/regress/pg_regress $(REGRESS)
! 
! # in-tree test doesn't work yet (no way to install my shared library)
! #check: all submake
! #	$(top_builddir)/src/test/regress/pg_regress --temp-install \
! #	  --top-builddir=$(top_builddir) $(REGRESS)
! check:
! 	@echo "'make check' is not supported."
! 	@echo "Do 'make install', then 'make installcheck' instead."
! endif # REGRESS
! 
! 
! # STANDARD RULES
! 
! ifneq (,$(MODULES)$(MODULE_big))
! %.sql: %.sql.in
! 	sed 's,MODULE_PATHNAME,$$libdir/$*,g' $< >$@
! endif
! 
! ifdef PROGRAM
! $(PROGRAM): $(OBJS)
! 	$(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LIBS) -o $@
  endif
--- 43,55 ----
  #
  # Better look at some of the existing uses for examples...
  
! ifdef USE_PGXS
! # we use a dynamic pgxs configuration...
! # intallation depends on the pg_config in PATH
! PGXS	:= $(shell pg_config --pgxs)
! include $(PGXS)
! else
! # we use static files, after a configure...
! NO_PGXS	= 1
! include $(top_builddir)/src/makefiles/pgxs.mk
  endif
*** ./contrib/cube/Makefile.orig	Sat Nov 29 20:51:21 2003
--- ./contrib/cube/Makefile	Fri Jul 16 16:22:03 2004
***************
*** 2,8 ****
  
  subdir = contrib/cube
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = cube
  OBJS= cube.o cubeparse.o
--- 2,7 ----
***************
*** 11,16 ****
--- 10,18 ----
  DOCS = README.cube
  REGRESS = cube
  
+ EXTRA_CLEAN = cubeparse.c cubeparse.h cubescan.c y.tab.c y.tab.h
+ 
+ include $(top_builddir)/contrib/contrib-global.mk
  
  # cubescan is compiled as part of cubeparse
  cubeparse.o: cubescan.c
***************
*** 32,39 ****
  else
  	@$(missing) flex $< $@
  endif
- 
- EXTRA_CLEAN = cubeparse.c cubeparse.h cubescan.c y.tab.c y.tab.h
- 
- 
- include $(top_srcdir)/contrib/contrib-global.mk
--- 34,36 ----
*** ./contrib/dbase/Makefile.orig	Sat Nov 29 20:51:22 2003
--- ./contrib/dbase/Makefile	Fri Jul 16 16:21:47 2004
***************
*** 2,8 ****
  
  subdir = contrib/dbase
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PROGRAM = dbf2pg
  OBJS	= dbf.o dbf2pg.o endian.o
--- 2,7 ----
***************
*** 18,21 ****
  DOCS = README.dbf2pg
  MAN = dbf2pg.1			# XXX not implemented
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 17,20 ----
  DOCS = README.dbf2pg
  MAN = dbf2pg.1			# XXX not implemented
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/dblink/Makefile.orig	Sat Nov 29 20:51:34 2003
--- ./contrib/dblink/Makefile	Fri Jul 16 16:21:41 2004
***************
*** 2,8 ****
  
  subdir = contrib/dblink
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = dblink
  PG_CPPFLAGS = -I$(libpq_srcdir)
--- 2,7 ----
***************
*** 13,16 ****
  DOCS = README.dblink
  REGRESS = dblink
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 12,15 ----
  DOCS = README.dblink
  REGRESS = dblink
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/dbsize/Makefile.orig	Sat Feb 23 00:05:35 2002
--- ./contrib/dbsize/Makefile	Fri Jul 16 16:21:34 2004
***************
*** 1,9 ****
  subdir = contrib/dbsize
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = dbsize
  DATA_built = dbsize.sql
  DOCS = README.dbsize
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 1,8 ----
  subdir = contrib/dbsize
  top_builddir = ../..
  
  MODULES = dbsize
  DATA_built = dbsize.sql
  DOCS = README.dbsize
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/earthdistance/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/earthdistance/Makefile	Fri Jul 16 16:21:27 2004
***************
*** 2,12 ****
  
  subdir = contrib/earthdistance
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = earthdistance
  DATA_built = earthdistance.sql
  DOCS = README.earthdistance
  REGRESS = earthdistance
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,11 ----
  
  subdir = contrib/earthdistance
  top_builddir = ../..
  
  MODULES = earthdistance
  DATA_built = earthdistance.sql
  DOCS = README.earthdistance
  REGRESS = earthdistance
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/findoidjoins/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/findoidjoins/Makefile	Fri Jul 16 16:21:21 2004
***************
*** 2,8 ****
  
  subdir = contrib/findoidjoins
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PROGRAM = findoidjoins
  OBJS	= findoidjoins.o
--- 2,7 ----
***************
*** 13,16 ****
  SCRIPTS = make_oidjoins_check
  DOCS = README.findoidjoins
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 12,15 ----
  SCRIPTS = make_oidjoins_check
  DOCS = README.findoidjoins
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/fulltextindex/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/fulltextindex/Makefile	Fri Jul 16 16:22:28 2004
***************
*** 2,12 ****
  
  subdir = contrib/fulltextindex
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = fti
  DATA_built = fti.sql
  DOCS = README.fti
  SCRIPTS = fti.pl
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,11 ----
  
  subdir = contrib/fulltextindex
  top_builddir = ../..
  
  MODULES = fti
  DATA_built = fti.sql
  DOCS = README.fti
  SCRIPTS = fti.pl
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/fuzzystrmatch/Makefile.orig	Thu Jul  1 13:18:22 2004
--- ./contrib/fuzzystrmatch/Makefile	Fri Jul 16 16:21:15 2004
***************
*** 2,8 ****
  
  subdir = contrib/fuzzystrmatch
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = fuzzystrmatch
  SRCS += fuzzystrmatch.c dmetaphone.c
--- 2,7 ----
***************
*** 10,13 ****
  DATA_built = fuzzystrmatch.sql
  DOCS = README.fuzzystrmatch README.soundex
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 9,12 ----
  DATA_built = fuzzystrmatch.sql
  DOCS = README.fuzzystrmatch README.soundex
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/intagg/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/intagg/Makefile	Fri Jul 16 16:21:09 2004
***************
*** 6,15 ****
  
  subdir = contrib/intagg
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = int_aggregate
  DATA_built = int_aggregate.sql
  DOCS = README.int_aggregate
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 6,14 ----
  
  subdir = contrib/intagg
  top_builddir = ../..
  
  MODULES = int_aggregate
  DATA_built = int_aggregate.sql
  DOCS = README.int_aggregate
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/intarray/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/intarray/Makefile	Fri Jul 16 16:21:02 2004
***************
*** 2,8 ****
  
  subdir = contrib/intarray
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = _int
  OBJS = _int_bool.o _int_gist.o _int_op.o _int_tool.o _intbig_gist.o 
--- 2,7 ----
***************
*** 10,13 ****
  DOCS = README.intarray
  REGRESS = _int
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 9,12 ----
  DOCS = README.intarray
  REGRESS = _int
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/isbn_issn/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/isbn_issn/Makefile	Fri Jul 16 16:16:30 2004
***************
*** 2,11 ****
  
  subdir = contrib/isbn_issn
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = isbn_issn
  DATA_built = isbn_issn.sql
  DOCS = README.isbn_issn
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,10 ----
  
  subdir = contrib/isbn_issn
  top_builddir = ../..
  
  MODULES = isbn_issn
  DATA_built = isbn_issn.sql
  DOCS = README.isbn_issn
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/lo/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/lo/Makefile	Fri Jul 16 16:20:56 2004
***************
*** 2,12 ****
  
  subdir = contrib/lo
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = lo
  DATA_built = lo.sql
  DATA = lo_drop.sql lo_test.sql
  DOCS = README.lo
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,11 ----
  
  subdir = contrib/lo
  top_builddir = ../..
  
  MODULES = lo
  DATA_built = lo.sql
  DATA = lo_drop.sql lo_test.sql
  DOCS = README.lo
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/ltree/Makefile.orig	Sat Nov  2 00:16:52 2002
--- ./contrib/ltree/Makefile	Fri Jul 16 16:20:45 2004
***************
*** 1,6 ****
  subdir = contrib/ltree
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PG_CPPFLAGS = -DLOWER_NODE
  MODULE_big = ltree
--- 1,5 ----
***************
*** 10,13 ****
  DOCS = README.ltree
  REGRESS = ltree
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 9,12 ----
  DOCS = README.ltree
  REGRESS = ltree
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/mSQL-interface/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/mSQL-interface/Makefile	Fri Jul 16 16:20:37 2004
***************
*** 4,19 ****
  
  subdir = contrib/mSQL-interface
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  NAME	:= mpgsql
  SO_MAJOR_VERSION := 0
  SO_MINOR_VERSION := 0
  OBJS	:= mpgsql.o
  
! override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
  
! include $(top_srcdir)/src/Makefile.shlib
  
  all: all-lib
  
--- 4,18 ----
  
  subdir = contrib/mSQL-interface
  top_builddir = ../..
  
  NAME	:= mpgsql
  SO_MAJOR_VERSION := 0
  SO_MINOR_VERSION := 0
  OBJS	:= mpgsql.o
  
! include $(top_builddir)/contrib/contrib-global.mk
  
! override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
  
  all: all-lib
  
*** ./contrib/miscutil/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/miscutil/Makefile	Fri Jul 16 16:20:28 2004
***************
*** 2,11 ****
  
  subdir = contrib/miscutil
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = misc_utils
  DATA_built = misc_utils.sql
  DOCS = README.misc_utils
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,10 ----
  
  subdir = contrib/miscutil
  top_builddir = ../..
  
  MODULES = misc_utils
  DATA_built = misc_utils.sql
  DOCS = README.misc_utils
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/noupdate/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/noupdate/Makefile	Fri Jul 16 16:20:21 2004
***************
*** 2,11 ****
  
  subdir = contrib/noupdate
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = noup
  DATA_built = noup.sql
  DOCS = README.noup
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,10 ----
  
  subdir = contrib/noupdate
  top_builddir = ../..
  
  MODULES = noup
  DATA_built = noup.sql
  DOCS = README.noup
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/oid2name/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/oid2name/Makefile	Fri Jul 16 16:20:11 2004
***************
*** 2,8 ****
  
  subdir = contrib/oid2name
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PROGRAM = oid2name
  OBJS	= oid2name.o
--- 2,7 ----
***************
*** 12,15 ****
  
  DOCS = README.oid2name
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 11,14 ----
  
  DOCS = README.oid2name
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/pg_autovacuum/Makefile.orig	Thu Mar 20 19:14:46 2003
--- ./contrib/pg_autovacuum/Makefile	Fri Jul 16 16:20:05 2004
***************
*** 1,7 ****
  
  subdir = contrib/pg_autovacuum
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PROGRAM = pg_autovacuum
  OBJS	= pg_autovacuum.o
--- 1,6 ----
***************
*** 11,14 ****
  
  DOCS = README.pg_autovacuum
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 10,13 ----
  
  DOCS = README.pg_autovacuum
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/pg_dumplo/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/pg_dumplo/Makefile	Fri Jul 16 16:19:59 2004
***************
*** 2,8 ****
  
  subdir = contrib/pg_dumplo
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PROGRAM = pg_dumplo
  OBJS	= main.o lo_export.o lo_import.o utils.o
--- 2,7 ----
***************
*** 12,15 ****
  
  DOCS = README.pg_dumplo
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 11,14 ----
  
  DOCS = README.pg_dumplo
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/pg_logger/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/pg_logger/Makefile	Fri Jul 16 16:19:53 2004
***************
*** 2,12 ****
  
  subdir = contrib/pg_logger
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PROGRAM = pg_logger
  OBJS	= pg_logger.o
  
  DOCS = README.pg_logger
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,11 ----
  
  subdir = contrib/pg_logger
  top_builddir = ../..
  
  PROGRAM = pg_logger
  OBJS	= pg_logger.o
  
  DOCS = README.pg_logger
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/pgbench/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/pgbench/Makefile	Fri Jul 16 16:19:46 2004
***************
*** 2,8 ****
  
  subdir = contrib/pgbench
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  PROGRAM = pgbench
  OBJS	= pgbench.o
--- 2,7 ----
***************
*** 12,15 ****
  
  DOCS = README.pgbench README.pgbench_jis
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 11,14 ----
  
  DOCS = README.pgbench README.pgbench_jis
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/pgcrypto/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/pgcrypto/Makefile	Fri Jul 16 16:19:39 2004
***************
*** 4,10 ****
  
  subdir = contrib/pgcrypto
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  # either 'builtin', 'mhash', 'openssl'
  cryptolib = builtin
--- 4,9 ----
***************
*** 74,80 ****
  REGRESS := init md5 sha1 hmac-md5 hmac-sha1 blowfish rijndael \
  		crypt-des crypt-md5 crypt-blowfish crypt-xdes 
  
! include $(top_srcdir)/contrib/contrib-global.mk
  
  rijndael.o: rijndael.tbl
  
--- 73,79 ----
  REGRESS := init md5 sha1 hmac-md5 hmac-sha1 blowfish rijndael \
  		crypt-des crypt-md5 crypt-blowfish crypt-xdes 
  
! include $(top_builddir)/contrib/contrib-global.mk
  
  rijndael.o: rijndael.tbl
  
*** ./contrib/pgstattuple/Makefile.orig	Sat Nov 29 23:39:29 2003
--- ./contrib/pgstattuple/Makefile	Fri Jul 16 16:19:28 2004
***************
*** 8,14 ****
  
  subdir = contrib/pgstattuple
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big	:= pgstattuple
  SRCS		+= pgstattuple.c
--- 8,13 ----
***************
*** 19,22 ****
  PG_CPPFLAGS	:=
  SHLIB_LINK 	:=
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 18,21 ----
  PG_CPPFLAGS	:=
  SHLIB_LINK 	:=
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/rserv/Makefile.orig	Sat Nov  2 00:45:37 2002
--- ./contrib/rserv/Makefile	Fri Jul 16 16:19:19 2004
***************
*** 3,9 ****
  
  subdir = contrib/rserv
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  NAME	= rserv
  MODULES	= rserv
--- 3,8 ----
***************
*** 17,22 ****
--- 16,22 ----
  SCRIPTS_built	+= PrepareSnapshot ApplySnapshot
  SCRIPTS_built	+= InitRservTest
  
+ include $(top_builddir)/contrib/contrib-global.mk
  
  $(SQLS): %.sql: %.sql.in
  	sed 's,@MODULE_FILENAME@,$$libdir/$(NAME),g' $< >$@
***************
*** 27,31 ****
  	    -e 's:@BINDIR@:$(bindir):g' \
  	    -e 's:@LIBDIR@:$(datadir)/contrib:g' $< >$@
  	chmod a+x $@
- 
- include $(top_srcdir)/contrib/contrib-global.mk
--- 27,29 ----
*** ./contrib/rtree_gist/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/rtree_gist/Makefile	Fri Jul 16 16:19:05 2004
***************
*** 2,12 ****
  
  subdir = contrib/rtree_gist
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = rtree_gist
  DATA_built = rtree_gist.sql
  DOCS = README.rtree_gist
  REGRESS = rtree_gist
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,11 ----
  
  subdir = contrib/rtree_gist
  top_builddir = ../..
  
  MODULES = rtree_gist
  DATA_built = rtree_gist.sql
  DOCS = README.rtree_gist
  REGRESS = rtree_gist
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/seg/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/seg/Makefile	Fri Jul 16 16:18:59 2004
***************
*** 2,8 ****
  
  subdir = contrib/seg
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = seg
  OBJS = seg.o segparse.o
--- 2,7 ----
***************
*** 10,15 ****
--- 9,19 ----
  DOCS = README.seg
  REGRESS = seg
  
+ EXTRA_CLEAN = segparse.c segparse.h segscan.c y.tab.c y.tab.h
+ 
+ 
+ include $(top_builddir)/contrib/contrib-global.mk
+ 
  
  # segscan is compiled as part of segparse
  segparse.o: segscan.c
***************
*** 31,38 ****
  else
  	@$(missing) flex $< $@
  endif
- 
- EXTRA_CLEAN = segparse.c segparse.h segscan.c y.tab.c y.tab.h
- 
- 
- include $(top_srcdir)/contrib/contrib-global.mk
--- 35,37 ----
*** ./contrib/spi/Makefile.orig	Sat Nov 29 20:51:35 2003
--- ./contrib/spi/Makefile	Fri Jul 16 16:18:53 2004
***************
*** 2,8 ****
  
  subdir = contrib/spi
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = autoinc insert_username moddatetime refint timetravel
  DATA_built = $(addsuffix .sql, $(MODULES))
--- 2,7 ----
***************
*** 12,15 ****
  # comment out if you want a quieter refint package for other uses
  PG_CPPFLAGS = -DREFINT_VERBOSE
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 11,14 ----
  # comment out if you want a quieter refint package for other uses
  PG_CPPFLAGS = -DREFINT_VERBOSE
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/string/Makefile.orig	Sat Nov 29 20:51:36 2003
--- ./contrib/string/Makefile	Fri Jul 16 16:18:48 2004
***************
*** 2,11 ****
  
  subdir = contrib/string
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = string_io
  DATA_built = string_io.sql
  DOCS = README.string_io
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,10 ----
  
  subdir = contrib/string
  top_builddir = ../..
  
  MODULES = string_io
  DATA_built = string_io.sql
  DOCS = README.string_io
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/tablefunc/Makefile.orig	Thu Sep 12 02:14:40 2002
--- ./contrib/tablefunc/Makefile	Fri Jul 16 16:18:39 2004
***************
*** 1,10 ****
  subdir = contrib/tablefunc
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = tablefunc
  DATA_built = tablefunc.sql
  DOCS = README.tablefunc
  REGRESS = tablefunc
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 1,9 ----
  subdir = contrib/tablefunc
  top_builddir = ../..
  
  MODULES = tablefunc
  DATA_built = tablefunc.sql
  DOCS = README.tablefunc
  REGRESS = tablefunc
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/tips/Makefile.orig	Sat Nov 29 20:51:36 2003
--- ./contrib/tips/Makefile	Fri Jul 16 16:18:33 2004
***************
*** 2,9 ****
  
  subdir = contrib/tips
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  DOCS = README.apachelog
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,8 ----
  
  subdir = contrib/tips
  top_builddir = ../..
  
  DOCS = README.apachelog
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/tsearch/Makefile.orig	Sat Nov 29 20:51:36 2003
--- ./contrib/tsearch/Makefile	Fri Jul 16 16:18:27 2004
***************
*** 2,10 ****
  
  subdir = contrib/tsearch
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
- 
- override CPPFLAGS := -I. $(CPPFLAGS)
  
  MODULE_big = tsearch
  OBJS = crc32.o morph.o txtidx.o query.o gistidx.o rewrite.o
--- 2,7 ----
***************
*** 13,18 ****
--- 10,21 ----
  DOCS = README.tsearch
  REGRESS = tsearch
  
+ EXTRA_CLEAN = parser.c
+ 
+ include $(top_builddir)/contrib/contrib-global.mk
+ 
+ override CPPFLAGS := -I. $(CPPFLAGS)
+ 
  # parser is compiled as part of query
  query.o: parser.c
  
***************
*** 23,29 ****
  	@$(missing) flex $< $@
  endif
  
- EXTRA_CLEAN = parser.c
- 
- include $(top_srcdir)/contrib/contrib-global.mk
  # DO NOT DELETE
--- 26,29 ----
*** ./contrib/tsearch2/Makefile.orig	Sat Nov 29 20:51:36 2003
--- ./contrib/tsearch2/Makefile	Fri Jul 16 16:18:19 2004
***************
*** 2,10 ****
  
  subdir = contrib/tsearch2
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
- 
  
  MODULE_big = tsearch2
  OBJS = dict_ex.o dict.o snmap.o stopword.o common.o prs_dcfg.o \
         dict_snowball.o dict_ispell.o dict_syn.o \
--- 2,9 ----
  
  subdir = contrib/tsearch2
  top_builddir = ../..
  
+ # make macro definitions
  MODULE_big = tsearch2
  OBJS = dict_ex.o dict.o snmap.o stopword.o common.o prs_dcfg.o \
         dict_snowball.o dict_ispell.o dict_syn.o \
***************
*** 17,27 ****
  
  OBJS:= $(OBJS) $(SUBDIROBJS)
  
- $(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ;
- 
- $(SUBDIRS:%=%-recursive):
- 	$(MAKE) -C $(subst -recursive,,$@) SUBSYS.o
- 
  PG_CPPFLAGS = -I$(srcdir)/snowball -I$(srcdir)/ispell -I$(srcdir)/wordparser
  
  DATA = stopword/english.stop stopword/russian.stop
--- 16,21 ----
***************
*** 31,36 ****
--- 25,39 ----
  
  SHLIB_LINK := -lm
  
+ # infrastructure
+ include $(top_builddir)/contrib/contrib-global.mk
+ 
+ # local rules
+ $(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ;
+ 
+ $(SUBDIRS:%=%-recursive):
+ 	$(MAKE) -C $(subst -recursive,,$@) SUBSYS.o
+ 
  tsearch2.sql: tsearch.sql.in
  	sed -e 's,MODULE_PATHNAME,$$libdir/$(MODULE_big),g' \
  	    -e 's,DATA_PATH,$(datadir)/contrib,g' $< >$@
***************
*** 43,47 ****
  
  subclean:
  	for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean || exit; done
-  
- include $(top_srcdir)/contrib/contrib-global.mk
--- 46,48 ----
*** ./contrib/userlock/Makefile.orig	Sat Nov 29 20:51:36 2003
--- ./contrib/userlock/Makefile	Fri Jul 16 16:18:05 2004
***************
*** 2,11 ****
  
  subdir = contrib/userlock
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULES = user_locks
  DATA_built = user_locks.sql
  DOCS = README.user_locks
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 2,10 ----
  
  subdir = contrib/userlock
  top_builddir = ../..
  
  MODULES = user_locks
  DATA_built = user_locks.sql
  DOCS = README.user_locks
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/xml/Makefile.orig	Mon Mar 15 10:22:03 2004
--- ./contrib/xml/Makefile	Fri Jul 16 16:17:57 2004
***************
*** 2,8 ****
  
  subdir = contrib/xml
  top_builddir = ../..
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = pgxml_dom
  OBJS = pgxml_dom.o
--- 2,7 ----
***************
*** 10,13 ****
  DATA_built = pgxml_dom.sql
  DOCS = README.xml
  
! include $(top_srcdir)/contrib/contrib-global.mk
--- 9,12 ----
  DATA_built = pgxml_dom.sql
  DOCS = README.xml
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./contrib/xml2/Makefile.orig	Mon Mar 15 10:22:03 2004
--- ./contrib/xml2/Makefile	Fri Jul 16 16:17:47 2004
***************
*** 1,7 ****
  # This makefile will build the new XML and XSLT routines.
  subdir = contrib/xml2
  top_builddir = ../../
- include $(top_builddir)/src/Makefile.global
  
  MODULE_big = pgxml
  
--- 1,7 ----
  # This makefile will build the new XML and XSLT routines.
+ 
  subdir = contrib/xml2
  top_builddir = ../../
  
  MODULE_big = pgxml
  
***************
*** 14,18 ****
  DATA_built = pgxml.sql
  DOCS = README.xml2
  
! include $(top_builddir)contrib/contrib-global.mk
! 
--- 14,17 ----
  DATA_built = pgxml.sql
  DOCS = README.xml2
  
! include $(top_builddir)/contrib/contrib-global.mk
*** ./doc/src/sgml/installation.sgml.orig	Mon Jun 21 08:36:52 2004
--- ./doc/src/sgml/installation.sgml	Fri Jul 16 11:23:40 2004
***************
*** 1042,1059 ****
     </para>
  
     <para>
!     The standard installation provides only the header files needed for client
!     application development.  If you plan to do any server-side program
!     development (such as custom functions or data types written in C),
!     then you may want to install the entire <productname>PostgreSQL</>
!     include tree into your target include directory.  To do that, enter
  <screen>
! <userinput>gmake install-all-headers</userinput>
  </screen>
!     This adds a megabyte or two to the installation footprint, and is only
!     useful if you don't plan to keep the whole source tree around for
!     reference.  (If you do, you can just use the source's include
!     directory when building server-side software.)
     </para>
  
     <formalpara>
--- 1042,1059 ----
     </para>
  
     <para>
!     The standard installation provides all the header files needed for client
!     application development, as well as headers for server-side program
!     development such as custom functions or data types written in C.
!     If you do not want to install the entire <productname>PostgreSQL</>
!     include tree into your target include directory.  Enter
  <screen>
! <userinput>gmake light-install</userinput>
  </screen>
!     rather than the <literal>install</literal> target.
!     This reduce by two megabytes the installation footprint, at the price
!     of having to recover the whole source tree if you need
!     to add extensions such as new data types or custom functions.
     </para>
  
     <formalpara>
*** ./doc/src/sgml/xfunc.sgml.orig	Mon May 17 14:00:06 2004
--- ./doc/src/sgml/xfunc.sgml	Fri Jul 16 15:24:35 2004
***************
*** 2257,2262 ****
--- 2257,2416 ----
     </para>
    </sect1>
  
+   <sect1 id="xfunc-pgxs">
+   <title><productname>PostgreSQL</productname> extension build infrastructure
+   </title>
+ 
+   <!-- other indexes? -->
+   <indexterm zone="xfunc">
+   <primary>pgxs</primary>
+   </indexterm>
+   <indexterm zone="xfunc">
+   <primary>extending PostgreSQL</primary>
+   </indexterm>
+ 
+ <para>
+ This section describes the <productname>PostgreSQL</productname>
+ build infrastructure for extensions, so that new contributions
+ can be built simply against an already installed server.
+ 
+ Such contributions include: new types, functions, gist-based
+ indexes, and so on.
+ 
+ Extensions can be compiled and installed as if it would have
+ been directly done during server installation, by reusing
+ postgresql build infrastructure.
+ </para>
+ 
+ <sect2>
+ <title>How to use <productname>PostgreSQL</productname> extension
+ build infrastructure</title>
+ 
+ <para>
+ In order to use the infrastructure for your extension, you must 
+ use a specific makefile and tailor it to your needs. 
+ A ready to use template makefile is available under the
+ same directory as file <literal>pg_config --pgxs</literal>,
+ see file <literal>pgxs_template.mk</literal>.
+ 
+ The following variables can be set:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>MODULES</literal>
+ list of shared objects to be build from source file with
+ same stem (do not include suffix in this list)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>DATA</literal>
+ random files to install into <literal>$PREFIX/share/contrib</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>DATA_built</literal>
+ random files to install into <literal>$PREFIX/share/contrib</literal>,
+ which need to be built first
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>DOCS</literal>
+ random files to install under <literal>$PREFIX/doc/contrib</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>SCRIPTS</literal>
+ script files (not binaries) to install into <literal>$PREFIX/bin</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>SCRIPTS_built</literal>
+ script files (not binaries) to install into <literal>$PREFIX/bin</literal>,
+ which need to be built first
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>REGRESS</literal>
+ list of regression test cases (without suffix)
+ </para>
+ </listitem>
+ </itemizedlist>
+ 
+ or at most one of these two:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>PROGRAM</literal>
+ a binary program to build (list objects files in <literal>OBJS</literal>).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>MODULE_big</literal>
+ a shared object to build (list object files in <literal>OBJS</literal>).
+ </para>
+ </listitem>
+ </itemizedlist>
+ 
+ The following can also be set:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>EXTRA_CLEAN</literal>
+ extra files to remove in <literal>make clean</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PG_CPPFLAGS</literal>
+ will be added to <literal>CPPFLAGS</literal>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>PG_LIBS</literal>
+ will be added to <literal>PROGRAM</literal> link line
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>SHLIB_LINK</literal>
+ will be added to <literal>MODULE_big</literal> link line
+ </para>
+ </listitem>
+ </itemizedlist>
+ 
+ <para>
+ Copy this makefile as <literal>Makefile</literal> in the directory 
+ which holds your extension. Comments in this makefile indicates 
+ which macros can be set and which effect is to be expected. 
+ Then you can do <literal>make</literal> to compile, and later
+ <literal>make install</literal> to install your contribution.
+ </para>
+ 
+ <para>
+ The extension is compiled and installed for the 
+ <productname>PostgreSQL</productname> which correspond to the
+ first <literal>pg_config</literal> command found in your 
+ <literal>PATH</literal>.
+ </para>
+ 
+ <para>
+ <literal>pgxs</literal> can also be used in <literal>contrib</literal> 
+ directories, without having to re-configure postgresql.
+ Just type <literal>make USE_PGXS=1 ...</literal> to use the 
+ <literal>pgxs</literal> infrastructure of the first
+ <literal>pg_config</literal> found in your path.
+ </para>
+ </sect2>
+ </sect1>
+ 
  <!-- Keep this comment at the end of the file
  Local variables:
  mode:sgml
*** ./src/Makefile.global.in.orig	Thu Jun  3 15:05:55 2004
--- ./src/Makefile.global.in	Fri Jul 16 16:31:15 2004
***************
*** 116,121 ****
--- 116,123 ----
  
  localedir := @localedir@
  
+ # where the postgres extension framework is to be put:
+ pgxsdir := $(pkglibdir)/pgxs
  
  ##########################################################################
  #
***************
*** 166,172 ****
--- 168,180 ----
  
  CPP = @CPP@
  CPPFLAGS = @CPPFLAGS@
+ 
+ ifdef PGXS
+ override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
+ else
  override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
+ endif
+ 
  ifdef VPATH
  override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
  endif
***************
*** 366,371 ****
--- 374,382 ----
  %.bz2: %
  	$(BZIP2) -f $<
  
+ 
+ ifndef PGXS
+ 
  # Remake Makefile.global from Makefile.global.in if the latter
  # changed. In order to trigger this rule, the including file must
  # write `include $(top_builddir)/src/Makefile.global', not some
***************
*** 393,398 ****
--- 404,410 ----
  $(top_builddir)/config.status: $(top_srcdir)/configure
  	cd $(top_builddir) && ./config.status --recheck
  
+ endif
  
  install-strip:
  	@$(MAKE) INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
*** ./src/Makefile.orig	Fri Apr 30 17:18:16 2004
--- ./src/Makefile	Fri Jul 16 11:25:31 2004
***************
*** 12,17 ****
--- 12,19 ----
  top_builddir = ..
  include Makefile.global
  
+ ins_files	= Makefile.global Makefile.port Makefile.shlib nls-global.mk 
+ ins_dir		= $(DESTDIR)$(pgxsdir)/src
  
  all install installdirs uninstall dep depend distprep:
  	$(MAKE) -C port $@
***************
*** 25,30 ****
--- 27,49 ----
  
  install-all-headers:
  	$(MAKE) -C include $@
+ 	$(MAKE) -C utils $@
+ 	$(MAKE) -C makefiles $@
+ 	$(MAKE) -C port $@
+ 	for f in $(ins_files) ; do $(INSTALL_DATA) $$f $(ins_dir) ; done
+ 
+ uninstall: uninstall-local
+ 
+ uninstall-local:
+ 	$(MAKE) -C utils $@
+ 	$(MAKE) -C makefiles $@
+ 	for f in $(ins_files) ; do $(RM) $(ins_dir)/$$f ; done
+ 
+ installdirs: installdirs-local
+ 
+ installdirs-local:
+ 	$(mkinstalldirs) $(DESTDIR)$(pgxsdir)
+ 	$(mkinstalldirs) $(DESTDIR)$(pgxsdir)/src
  
  clean:
  	$(MAKE) -C port $@
*** ./src/bin/pg_config/Makefile.orig	Sat Nov 29 20:52:04 2003
--- ./src/bin/pg_config/Makefile	Fri Jul 16 11:19:27 2004
***************
*** 14,19 ****
--- 14,20 ----
  	    -e 's,@pkglibdir@,$(pkglibdir),g' \
  	    -e "s|@configure@|$(configure_args)|g" \
  	    -e 's,@version@,$(VERSION),g' \
+ 	    -e 's,@pgxsdir@,$(pgxsdir),g' \
  	  $< >$@
  	chmod a+x $@
  
*** ./src/bin/pg_config/pg_config.sh.orig	Sat Nov 29 20:52:04 2003
--- ./src/bin/pg_config/pg_config.sh	Fri Jul 16 11:19:27 2004
***************
*** 19,24 ****
--- 19,25 ----
  val_pkglibdir='@pkglibdir@'
  val_configure="@configure@"
  val_version='@version@'
+ val_pgxsdir='@pgxsdir@'
  
  help="\
  $me provides information about the installed version of PostgreSQL.
***************
*** 35,40 ****
--- 36,42 ----
    --pkglibdir           show location of dynamically loadable modules
    --configure           show options given to 'configure' script when
                          PostgreSQL was built
+   --pgxs		show location of extension makefile
    --version             show the PostgreSQL version, then exit
    --help                show this help, then exit
  
***************
*** 61,66 ****
--- 63,69 ----
          --libdir)       show="$show \$val_libdir";;
          --pkglibdir)    show="$show \$val_pkglibdir";;
          --configure)    show="$show \$val_configure";;
+ 	--pgxs)         show="$show \$val_pgxsdir/src/makefiles/pgxs.mk";;
  
  	--version)      echo "PostgreSQL $val_version"
                          exit 0;;
*** ./src/makefiles/Makefile.orig	Fri Jul 16 11:19:27 2004
--- ./src/makefiles/Makefile	Fri Jul 16 11:25:50 2004
***************
*** 0 ****
--- 1,18 ----
+ # Makefile for src/makefiles
+ 
+ subdir = src/makefiles
+ top_builddir = ../..
+ include $(top_builddir)/src/Makefile.global
+ 
+ ins_files =	pgxs.mk pgxs_template.mk
+ 
+ ins_dir		= $(DESTDIR)$(pgxsdir)/$(subdir)
+ 
+ install-all-headers: installdirs
+ 	for f in $(ins_files) ; do $(INSTALL_DATA) $$f $(ins_dir) ; done;
+ 
+ installdirs:
+ 	$(mkinstalldirs) $(ins_dir)
+ 
+ uninstall:
+ 	for f in $(ins_files) ; do $(RM) $(ins_dir)/$$f ; done;
*** ./src/makefiles/pgxs.mk.orig	Fri Jul 16 11:19:27 2004
--- ./src/makefiles/pgxs.mk	Fri Jul 16 15:12:45 2004
***************
*** 0 ****
--- 1,214 ----
+ # $PostgreSQL$ 
+ #
+ # PGXS: PostGreSQL eXtensionS initial directory
+ #
+ 
+ ifndef PGXS
+ ifndef NO_PGXS
+ $(error pgxs error: PGXS or NO_PGXS makefile macro must be set)
+ endif
+ endif
+ 
+ ifdef PGXS
+   # we assume that we are in ./src/makefiles, so top is:
+   top_builddir := $(dir $(PGXS))/../..
+ endif
+ 
+ # are other macros needed? subdir??
+ 
+ # now we assume we're in the main tree.
+ include $(top_builddir)/src/Makefile.global
+ 
+ # issues:
+ # - what about includes? fixed with "ifdef PGXS" in Makefile.global
+ # - others?
+ 
+ override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
+ 
+ ifdef MODULES
+ override CFLAGS += $(CFLAGS_SL)
+ SHLIB_LINK += $(BE_DLLLIBS)
+ endif
+ 
+ ifdef PG_CPPFLAGS
+ override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
+ endif
+ 
+ all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES))
+ 
+ ifdef MODULE_big
+ # shared library parameters
+ NAME = $(MODULE_big)
+ SO_MAJOR_VERSION= 0
+ SO_MINOR_VERSION= 0
+ rpath =
+ 
+ SHLIB_LINK += $(BE_DLLLIBS)
+ 
+ include $(top_srcdir)/src/Makefile.shlib
+ 
+ all: all-lib
+ endif # MODULE_big
+ 
+ 
+ install: all installdirs
+ ifneq (,$(DATA)$(DATA_built))
+ 	@for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \
+ 	  echo "$(INSTALL_DATA) $$file $(DESTDIR)$(datadir)/contrib"; \
+ 	  $(INSTALL_DATA) $$file $(DESTDIR)$(datadir)/contrib; \
+ 	done
+ endif # DATA
+ ifdef MODULES
+ 	@for file in $(addsuffix $(DLSUFFIX), $(MODULES)); do \
+ 	  echo "$(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir)"; \
+ 	  $(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir); \
+ 	done
+ endif # MODULES
+ ifdef DOCS
+ 	@for file in $(addprefix $(srcdir)/, $(DOCS)); do \
+ 	  echo "$(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/contrib"; \
+ 	  $(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/contrib; \
+ 	done
+ endif # DOCS
+ ifdef PROGRAM
+ 	$(INSTALL_PROGRAM) $(PROGRAM)$(X) $(DESTDIR)$(bindir)
+ endif # PROGRAM
+ ifdef MODULE_big
+ 	$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
+ endif # MODULE_big
+ ifdef SCRIPTS
+ 	@for file in $(addprefix $(srcdir)/, $(SCRIPTS)); do \
+ 	  echo "$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir)"; \
+ 	  $(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir); \
+ 	done
+ endif # SCRIPTS
+ ifdef SCRIPTS_built
+ 	@for file in $(SCRIPTS_built); do \
+ 	  echo "$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir)"; \
+ 	  $(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir); \
+ 	done
+ endif # SCRIPTS_built
+ 
+ 
+ installdirs:
+ ifneq (,$(DATA)$(DATA_built))
+ 	$(mkinstalldirs) $(DESTDIR)$(datadir)/contrib
+ endif
+ ifneq (,$(MODULES)$(MODULE_big))
+ 	$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
+ endif
+ ifdef DOCS
+ 	$(mkinstalldirs) $(DESTDIR)$(docdir)/contrib
+ endif
+ ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built))
+ 	$(mkinstalldirs) $(DESTDIR)$(bindir)
+ endif
+ 
+ 
+ uninstall:
+ ifneq (,$(DATA)$(DATA_built))
+ 	rm -f $(addprefix $(DESTDIR)$(datadir)/contrib/, $(notdir $(DATA) $(DATA_built)))
+ endif
+ ifdef MODULES
+ 	rm -f $(addprefix $(DESTDIR)$(pkglibdir)/, $(addsuffix $(DLSUFFIX), $(MODULES)))
+ endif
+ ifdef DOCS
+ 	rm -f $(addprefix $(DESTDIR)$(docdir)/contrib/, $(DOCS))
+ endif
+ ifdef PROGRAM
+ 	rm -f $(DESTDIR)$(bindir)/$(PROGRAM)$(X)
+ endif
+ ifdef MODULE_big
+ 	rm -f $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
+ endif
+ ifdef SCRIPTS
+ 	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
+ endif
+ ifdef SCRIPTS_built
+ 	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS_built))
+ endif
+ 
+ 
+ clean:
+ ifdef MODULES
+ 	rm -f $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .o, $(MODULES))
+ endif
+ ifdef DATA_built
+ 	rm -f $(DATA_built)
+ endif
+ ifdef SCRIPTS_built
+ 	rm -f $(SCRIPTS_built)
+ endif
+ ifdef PROGRAM
+ 	rm -f $(PROGRAM)$(X)
+ endif
+ ifdef OBJS
+ 	rm -f $(OBJS)
+ endif
+ ifdef EXTRA_CLEAN
+ 	rm -f $(EXTRA_CLEAN)
+ endif
+ ifdef REGRESS
+ # things created by various check targets
+ 	rm -rf results tmp_check log
+ 	rm -f regression.diffs regression.out regress.out run_check.out
+ ifeq ($(PORTNAME), win)
+ 	rm -f regress.def
+ endif
+ endif # REGRESS
+ 
+ ifdef MODULE_big
+ clean: clean-lib
+ endif
+ 
+ distclean maintainer-clean: clean
+ 
+ 
+ ifdef REGRESS
+ 
+ # When doing a VPATH build, must copy over the test .sql and .out
+ # files so that the driver script can find them.  We have to use an
+ # absolute path for the targets, because otherwise make will try to
+ # locate the missing files using VPATH, and will find them in
+ # $(srcdir), but the point here is that we want to copy them from
+ # $(srcdir) to the build directory.
+ 
+ ifdef VPATH
+ abs_builddir := $(shell pwd)
+ test_files_src := $(wildcard $(srcdir)/sql/*.sql) $(wildcard $(srcdir)/expected/*.out) $(wildcard $(srcdir)/data/*.data)
+ test_files_build := $(patsubst $(srcdir)/%, $(abs_builddir)/%, $(test_files_src))
+ 
+ all: $(test_files_build)
+ $(test_files_build): $(abs_builddir)/%: $(srcdir)/%
+ 	ln -s $< $@
+ endif # VPATH
+ 
+ .PHONY: submake
+ submake:
+ 	$(MAKE) -C $(top_builddir)/src/test/regress pg_regress
+ 
+ # against installed postmaster
+ installcheck: submake
+ 	$(top_builddir)/src/test/regress/pg_regress $(REGRESS)
+ 
+ # in-tree test doesn't work yet (no way to install my shared library)
+ #check: all submake
+ #	$(top_builddir)/src/test/regress/pg_regress --temp-install \
+ #	  --top-builddir=$(top_builddir) $(REGRESS)
+ check:
+ 	@echo "'make check' is not supported."
+ 	@echo "Do 'make install', then 'make installcheck' instead."
+ endif # REGRESS
+ 
+ 
+ # STANDARD RULES
+ 
+ ifneq (,$(MODULES)$(MODULE_big))
+ %.sql: %.sql.in
+ 	sed 's,MODULE_PATHNAME,$$libdir/$*,g' $< >$@
+ endif
+ 
+ ifdef PROGRAM
+ $(PROGRAM): $(OBJS)
+ 	$(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LIBS) -o $@
+ endif
*** ./src/makefiles/pgxs_template.mk.orig	Fri Jul 16 11:19:27 2004
--- ./src/makefiles/pgxs_template.mk	Fri Jul 16 11:19:27 2004
***************
*** 0 ****
--- 1,40 ----
+ # PGXS: PostgreSQL extensions template makefile
+ #
+ # This file contains generic rules to build many kinds of simple
+ # contrib modules.  You only need to set a few variables and include
+ # this file, the rest will be done here.
+ #
+ #   MODULES -- list of shared objects to be build from source file with
+ #     same stem (do not include suffix in this list)
+ #   DATA -- random files to install into $PREFIX/share/contrib
+ #   DATA_built -- random files to install into $PREFIX/share/contrib,
+ #     which need to be built first
+ #   DOCS -- random files to install under $PREFIX/doc/contrib
+ #   SCRIPTS -- script files (not binaries) to install into $PREFIX/bin
+ #   SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin,
+ #     which need to be built first
+ #   REGRESS -- list of regression test cases (without suffix)
+ #
+ # or at most one of these two:
+ #
+ #   PROGRAM -- a binary program to build (list objects files in OBJS)
+ #   MODULE_big -- a shared object to build (list object files in OBJS)
+ #
+ # The following can also be set:
+ #
+ #   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
+ #   SHLIB_LINK -- will be added to MODULE_big link line
+ #
+ # Better look at some of the existing uses for examples in contrib/
+ #
+ # isbn_issn type contribution:
+ #MODULES = isbn_issn
+ #DATA_built = isbn_issn.sql
+ #DOCS = README.isbn_issn
+ 
+ PGXS := $(shell pg_config --pgxs)
+ include $(PGXS)
+ 
+ # put here any specific rules.
*** ./src/port/Makefile.orig	Tue Jun  1 10:21:24 2004
--- ./src/port/Makefile	Fri Jul 16 11:30:13 2004
***************
*** 40,42 ****
--- 40,51 ----
  
  clean distclean maintainer-clean:
  	rm -f libpgport.a $(LIBOBJS) pg_config_paths.h
+ 
+ install-all-headers: installdirs
+ 	$(INSTALL_STLIB) libpgport.a $(DESTDIR)$(pkglibdir)
+ 
+ installdirs:
+ 	$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
+ 
+ uninstall:
+ 	$(RM) $(DESTDIR)$(pkglibdir)/libpgport.a
*** ./src/utils/Makefile.orig	Sat Nov 29 20:52:15 2003
--- ./src/utils/Makefile	Fri Jul 16 11:30:55 2004
***************
*** 12,18 ****
--- 12,30 ----
  top_builddir = ../..
  include $(top_builddir)/src/Makefile.global
  
+ ins_dir	= $(DESTDIR)$(pkglibdir)
+ 
  all:
  
  clean distclean maintainer-clean:
  	rm -f dllinit.o
+ 
+ uninstall:
+ 	$(RM) $(ins_dir)/dllinit.o
+ 
+ install-all-headers: installdirs
+ 	-[ -f dllinit.o ] && \
+ 		$(INSTALL_DATA) dllinit.o $(ins_dir)
+ 
+ installdirs:
+ 	$(mkinstalldirs) $(ins_dir)
#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Fabien COELHO (#1)
Re: pgxs: build infrastructure for extensions v4

I have Peter reviewing this.

---------------------------------------------------------------------------

Fabien COELHO wrote:

Dear patchers,

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions. I hope it addresses all of
Peter's comments. I'll be away for the next 3 weeks, so if minor changes
are required it would be best if you could proceed without me...

The infrastructure is a simple reworking of the already available internal
infrastructure for contrib, so that it can be used outside of the
postgresql source tree after installation, without gory details being in
sight of the user. The documentation is added as a new section in
"xfunc.sgml".

I updated all contrib makefiles so that they can be used either the
standard way after a configure, or the new way without needing a configure
but with an already installed postgreSQL. Just try them with

"cd contrib/foo ; make USE_PGXS=1 install"

*AFTER* postgresql has been configure, compiled and installed. It should
be compiled and installed wrt to the first "pg_config" which is found in
the path.

How it works:

- necessary files (includes, scripts, makefiles...) are copied under
$(pkglibdir)/pgxs on the initial "make install".

due to gnu-make restriction on how its includes work, these files must
be copied with the *same* directory structure as the pg source tree.
The fact does not appear at all in the actual infrastructure from the
user point of view, but it explains why subdirectories are necessary
under pgxs, if you care to have a look.

- the makefile of any extension is expected to set macro PGXS to
"pg_config --pgxs", to include a special makefile, and to
set some macros depending on what is to be built, just like in
current contrib.

- I've added two PGXS-triggered conditionnals in Makefile.global,
so that includes and libraries are taken where needed.

Notes:

- there is still a "light-install" target that matches the previous
"install" behavior, as new "install" matches previous "server-install".

- I'm not sure the sgml is ok. It looks ok, but is it enough.

- It validates and works for me.

Have a nice day,

--
Fabien Coelho - coelho@cri.ensmp.fr

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Peter Eisentraut
peter_e@gmx.net
In reply to: Fabien COELHO (#1)
Re: pgxs: build infrastructure for extensions v4

Fabien COELHO wrote:

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions. I hope it addresses all of
Peter's comments. I'll be away for the next 3 weeks, so if minor
changes are required it would be best if you could proceed without
me...

This patch breaks building outside the source tree in a very elaborate
and obvious way. Unfortunately, this is all tied together so I haven't
figured out yet if it can be fixed easily.

Also, the use of the install targets is a bit strange
(install-all-headers install libpgport.a). I would simply not bother
and install everything all the time. However, those who advocate the
install-all-headers target may want to propose a different scheme.

I updated all contrib makefiles so that they can be used either the
standard way after a configure, or the new way without needing a
configure but with an already installed postgreSQL. Just try them
with

"cd contrib/foo ; make USE_PGXS=1 install"

*AFTER* postgresql has been configure, compiled and installed. It
should be compiled and installed wrt to the first "pg_config" which
is found in the path.

This is redundant. I think by now I'm looking for a patch that does not
touch contrib at all (except perhaps contrib-global.mk). Much of the
trouble arises from being too clever around there. We're trying to
allow external modules to build, not internal ones.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#3)
Re: pgxs: build infrastructure for extensions v4

Peter Eisentraut <peter_e@gmx.net> writes:

Fabien COELHO wrote:

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions.

This patch breaks building outside the source tree in a very elaborate
and obvious way. Unfortunately, this is all tied together so I haven't
figured out yet if it can be fixed easily.

Peter, do you have time before the end of the month to sort this out?
It would be nice to have a real solution in this area, because certainly
we have some problems here.

I think by now I'm looking for a patch that does not
touch contrib at all (except perhaps contrib-global.mk).

I would think that we'd want to make the contrib tree use whatever
solution is developed for building outside the main source tree, simply
because that's a handy test case for verifying that it's not broken.

I won't commit hara-kiri if this is not solved for 7.5, but it is an
open issue, especially for RPM and similar package installations.
If Fabien's work is at all close to a usable solution, it'd be a shame
not to get it done in this release cycle.

regards, tom lane

#5Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#4)
Re: pgxs: build infrastructure for extensions v4

Tom Lane wrote:

Peter, do you have time before the end of the month to sort this out?
It would be nice to have a real solution in this area, because
certainly we have some problems here.

Yes, I'll make sure it gets done. By the way, extra credit for someone
who manages to get slony1 to build using this framework. I'm not sure
it's possible, though.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#6Fabien COELHO
coelho@cri.ensmp.fr
In reply to: Peter Eisentraut (#3)
Re: pgxs: build infrastructure for extensions v4

Dear peter,

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions. I hope it addresses all of
Peter's comments. I'll be away for the next 3 weeks, so if minor
changes are required it would be best if you could proceed without
me...

This patch breaks building outside the source tree in a very elaborate
and obvious way. Unfortunately, this is all tied together so I haven't
figured out yet if it can be fixed easily.

I do not get your point. the aim is to be able to build outside the source
tree as well?

Also, the use of the install targets is a bit strange
(install-all-headers install libpgport.a). I would simply not bother
and install everything all the time. However, those who advocate the
install-all-headers target may want to propose a different scheme.

part of this existed before the patch. I tried to make the best of
existing targets, especially as you requested that less targets should be
used. I do agree with you that installing libgport.a under
install-all-headers looks stupid, but the idea behind all-headers is that
all which is required for extensions is installed.

What about install-dev-files? or anything less misleading?

I updated all contrib makefiles so that they can be used either the
standard way after a configure, or the new way without needing a
configure but with an already installed postgreSQL. Just try them
with

"cd contrib/foo ; make USE_PGXS=1 install"

*AFTER* postgresql has been configure, compiled and installed. It
should be compiled and installed wrt to the first "pg_config" which
is found in the path.

This is redundant. I think by now I'm looking for a patch that does not
touch contrib at all (except perhaps contrib-global.mk).

I really just touch that file in contrib. The only other exceptions are
when other files were directly included or to reorder include wrt mqcro
definitions, as far as I can remember.

Much of the trouble arises from being too clever around there. We're
trying to allow external modules to build, not internal ones.

I really want to be able to install contribs as an afterthought and
without reconfiguring.

anyway, sorry I cannot really help as I m away from home.
Have a nice day,

--
Fabien Coelho - coelho@cri.ensmp.fr

#7Peter Eisentraut
peter_e@gmx.net
In reply to: Fabien COELHO (#1)
Re: pgxs: build infrastructure for extensions v4

Am Freitag, 16. Juli 2004 16:34 schrieb Fabien COELHO:

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions. I hope it addresses all of
Peter's comments. I'll be away for the next 3 weeks, so if minor changes
are required it would be best if you could proceed without me...

Done.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#8Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Fabien COELHO (#1)
Re: pgxs: build infrastructure for extensions v4

Applied by Peter.

---------------------------------------------------------------------------

Fabien COELHO wrote:

Dear patchers,

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions. I hope it addresses all of
Peter's comments. I'll be away for the next 3 weeks, so if minor changes
are required it would be best if you could proceed without me...

The infrastructure is a simple reworking of the already available internal
infrastructure for contrib, so that it can be used outside of the
postgresql source tree after installation, without gory details being in
sight of the user. The documentation is added as a new section in
"xfunc.sgml".

I updated all contrib makefiles so that they can be used either the
standard way after a configure, or the new way without needing a configure
but with an already installed postgreSQL. Just try them with

"cd contrib/foo ; make USE_PGXS=1 install"

*AFTER* postgresql has been configure, compiled and installed. It should
be compiled and installed wrt to the first "pg_config" which is found in
the path.

How it works:

- necessary files (includes, scripts, makefiles...) are copied under
$(pkglibdir)/pgxs on the initial "make install".

due to gnu-make restriction on how its includes work, these files must
be copied with the *same* directory structure as the pg source tree.
The fact does not appear at all in the actual infrastructure from the
user point of view, but it explains why subdirectories are necessary
under pgxs, if you care to have a look.

- the makefile of any extension is expected to set macro PGXS to
"pg_config --pgxs", to include a special makefile, and to
set some macros depending on what is to be built, just like in
current contrib.

- I've added two PGXS-triggered conditionnals in Makefile.global,
so that includes and libraries are taken where needed.

Notes:

- there is still a "light-install" target that matches the previous
"install" behavior, as new "install" matches previous "server-install".

- I'm not sure the sgml is ok. It looks ok, but is it enough.

- It validates and works for me.

Have a nice day,

--
Fabien Coelho - coelho@cri.ensmp.fr

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#9Joe Conway
mail@joeconway.com
In reply to: Peter Eisentraut (#7)
Re: pgxs: build infrastructure for extensions v4

Peter Eisentraut wrote:

Am Freitag, 16. Juli 2004 16:34 schrieb Fabien COELHO:

Please find attached another new version of a patch which provides a
working infrastructure for pg extensions. I hope it addresses all of
Peter's comments. I'll be away for the next 3 weeks, so if minor changes
are required it would be best if you could proceed without me...

Done.

I've tested pgxs with PL/R and it allows me to build successfully
without using a Postgres source tree. Many thanks to both Fabien and
Peter for this!

One question did arise, however. In order to use pgxs I needed to do:
make install-all-headers
instead of:
make install

I seem to recall some discussion about this, but at the time didn't
realize the impact. IMHO pgxs support (including all needed headers)
should be installed by default, else we won't be able to count on it
being there when needed. Any chance we can revisit this?

Thanks,

Joe

#10Peter Eisentraut
peter_e@gmx.net
In reply to: Joe Conway (#9)
Re: pgxs: build infrastructure for extensions v4

Joe Conway wrote:

One question did arise, however. In order to use pgxs I needed to do:
make install-all-headers
instead of:
make install

Yes, I forgot to mention that the install targets still need to be
sorted out. FWIW, I've always been in favor of installing everything
all the time, even more so now.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joe Conway (#9)
Re: pgxs: build infrastructure for extensions v4

Joe Conway <mail@joeconway.com> writes:

One question did arise, however. In order to use pgxs I needed to do:
make install-all-headers
instead of:
make install

I seem to recall some discussion about this, but at the time didn't
realize the impact. IMHO pgxs support (including all needed headers)
should be installed by default, else we won't be able to count on it
being there when needed. Any chance we can revisit this?

AFAICS the packagers (RPM etc) will continue to think that these files
belong in a postgresql-devel RPM, and will not include them in a base
package. I'm not sure of the point of trying to force installation in
a build from source given that much of the world isn't going to be using
a source package anyway.

However, we could certainly talk about altering the default behavior
(eg, install becomes install-no-headers and install-all-headers becomes
part of the default install target).

regards, tom lane

#12Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Tom Lane (#11)
Re: pgxs: build infrastructure for extensions v4

However, we could certainly talk about altering the default behavior
(eg, install becomes install-no-headers and install-all-headers becomes
part of the default install target).

Seems like a good idea to me.

Chris

#13Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#11)
Re: pgxs: build infrastructure for extensions v4

Tom Lane wrote:

Joe Conway <mail@joeconway.com> writes:

One question did arise, however. In order to use pgxs I needed to do:
make install-all-headers
instead of:
make install

I seem to recall some discussion about this, but at the time didn't
realize the impact. IMHO pgxs support (including all needed headers)
should be installed by default, else we won't be able to count on it
being there when needed. Any chance we can revisit this?

AFAICS the packagers (RPM etc) will continue to think that these files
belong in a postgresql-devel RPM, and will not include them in a base
package. I'm not sure of the point of trying to force installation in
a build from source given that much of the world isn't going to be using
a source package anyway.

However, we could certainly talk about altering the default behavior
(eg, install becomes install-no-headers and install-all-headers becomes
part of the default install target).

Agreed. Added to open items list.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#14Mark Cave-Ayland
m.cave-ayland@webbased.co.uk
In reply to: Bruce Momjian (#13)
Re: pgxs: build infrastructure for extensions v4

Peter/Fabien,

Just to say thank you for all your hard work in getting pgxs working in
CVS. I've successfully managed to get a contrib module to build outside
of the source tree, which will help simplify a lot of things.

I have one question though: the comments in pgxs.mk suggested that I
needed to do the following to include the pgxs.mk:

# Use the following layout for your Makefile:
#
# [variable assignments, see below]
# [custom rules, rarely necessary]
#
# PGXS := $(shell pg_config --pgxs)
# include $(PGXS)

However, on my CVS version from about an hour ago, I needed to change
this to:

PGXS := $(shell pg_config --pgxs)/src/makefiles/pgxs.mk
include $(PGXS)

This is because I only get the pgxs directory returned by "pgconfig
--pgxs" as opposed to the path to the pgxs.mk file itself - is that the
correct thing to do (i.e. the comment is wrong?) or is "pgconfig --pgxs"
returning the wrong thing?

Kind regards,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.

#15Andrew Dunstan
andrew@dunslane.net
In reply to: Mark Cave-Ayland (#14)
Re: pgxs: build infrastructure for extensions v4

Mark Cave-Ayland wrote:

Peter/Fabien,

Just to say thank you for all your hard work in getting pgxs working in
CVS. I've successfully managed to get a contrib module to build outside
of the source tree, which will help simplify a lot of things.

I have one question though: the comments in pgxs.mk suggested that I
needed to do the following to include the pgxs.mk:

# Use the following layout for your Makefile:
#
# [variable assignments, see below]
# [custom rules, rarely necessary]
#
# PGXS := $(shell pg_config --pgxs)
# include $(PGXS)

However, on my CVS version from about an hour ago, I needed to change
this to:

PGXS := $(shell pg_config --pgxs)/src/makefiles/pgxs.mk
include $(PGXS)

This is because I only get the pgxs directory returned by "pgconfig
--pgxs" as opposed to the path to the pgxs.mk file itself - is that the
correct thing to do (i.e. the comment is wrong?) or is "pgconfig --pgxs"
returning the wrong thing?

needs to be fixed in pg_config.c I think - should be a one-liner.

cheers

andrew

#16Joe Conway
mail@joeconway.com
In reply to: Andrew Dunstan (#15)
1 attachment(s)
Re: pgxs: build infrastructure for extensions v4

Andrew Dunstan wrote:

Mark Cave-Ayland wrote:

This is because I only get the pgxs directory returned by "pgconfig
--pgxs" as opposed to the path to the pgxs.mk file itself - is that the
correct thing to do (i.e. the comment is wrong?) or is "pgconfig --pgxs"
returning the wrong thing?

needs to be fixed in pg_config.c I think - should be a one-liner.

If the attached looks correct I'll apply it.

Joe

Attachments:

pg_config-fix.patchtext/x-patch; name=pg_config-fix.patchDownload
Index: src/bin/pg_config/pg_config.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/pg_config/pg_config.c,v
retrieving revision 1.3
diff -c -r1.3 pg_config.c
*** src/bin/pg_config/pg_config.c	2 Aug 2004 12:34:14 -0000	1.3
--- src/bin/pg_config/pg_config.c	4 Aug 2004 18:00:51 -0000
***************
*** 141,147 ****
  		else if (strcmp(argv[i],"--pgxs") == 0)
  		{
  			get_pkglib_path(mypath,otherpath);
! 			strncat(otherpath, "/pgxs", MAXPGPATH-1);
  		}
  
  		printf("%s\n",otherpath);
--- 141,147 ----
  		else if (strcmp(argv[i],"--pgxs") == 0)
  		{
  			get_pkglib_path(mypath,otherpath);
! 			strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH-1);
  		}
  
  		printf("%s\n",otherpath);
#17Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Joe Conway (#16)
Re: pgxs: build infrastructure for extensions v4

FYI, I couldn't find anything in the shell pg_config with this path:

strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH-1);

Did you find a mention of this? I looked in pg_config.sh and
Makefile.global.in.

I am not saying your change is wrong, just that it is new, I think.

---------------------------------------------------------------------------

Joe Conway wrote:

Andrew Dunstan wrote:

Mark Cave-Ayland wrote:

This is because I only get the pgxs directory returned by "pgconfig
--pgxs" as opposed to the path to the pgxs.mk file itself - is that the
correct thing to do (i.e. the comment is wrong?) or is "pgconfig --pgxs"
returning the wrong thing?

needs to be fixed in pg_config.c I think - should be a one-liner.

If the attached looks correct I'll apply it.

Joe

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#18Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#17)
Re: pgxs: build infrastructure for extensions v4

Bruce Momjian <pgman@candle.pha.pa.us> writes:

FYI, I couldn't find anything in the shell pg_config with this path:
strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH-1);
Did you find a mention of this? I looked in pg_config.sh and
Makefile.global.in.

The original coding concatenated "src/makefiles/pgxs.mk" to a path value
derived elsewhere (pgxsdir). I was planning to bug Peter about just how
correct this patch is --- it's essentially hardwiring an assumption
about the construction of pgxsdir.

regards, tom lane

#19Joe Conway
mail@joeconway.com
In reply to: Bruce Momjian (#17)
Re: pgxs: build infrastructure for extensions v4

Bruce Momjian wrote:

FYI, I couldn't find anything in the shell pg_config with this path:

strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH-1);

Did you find a mention of this? I looked in pg_config.sh and
Makefile.global.in.

I see it here:
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/bin/pg_config/Attic/pg_config.sh.diff?r1=1.9;r2=1.10

      --pkglibdir)    show="$show \$val_pkglibdir";;
+    --pgxs)         show="$show \$val_pgxsdir/src/makefiles/pgxs.mk";;
      --configure)    show="$show \$val_configure";;

Joe

#20Joe Conway
mail@joeconway.com
In reply to: Tom Lane (#18)
Re: pgxs: build infrastructure for extensions v4

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

FYI, I couldn't find anything in the shell pg_config with this path:
strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH-1);
Did you find a mention of this? I looked in pg_config.sh and
Makefile.global.in.

The original coding concatenated "src/makefiles/pgxs.mk" to a path value
derived elsewhere (pgxsdir). I was planning to bug Peter about just how
correct this patch is --- it's essentially hardwiring an assumption
about the construction of pgxsdir.

I just added "src/makefiles/pgxs.mk" to the already hardwired path to
pgxs in pg_config.c. But in any case, it looks like pgxsdir is set in
src/Makefile.global.in like like this:
pgxsdir = $(pkglibdir)/pgxs
So it is sort of hardwired already at the moment at least.

Joe

#21Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Joe Conway (#19)
Re: pgxs: build infrastructure for extensions v4

Oh, I see that modification now. Thanks. Sorry I missed it.

---------------------------------------------------------------------------

Joe Conway wrote:

Bruce Momjian wrote:

FYI, I couldn't find anything in the shell pg_config with this path:

strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH-1);

Did you find a mention of this? I looked in pg_config.sh and
Makefile.global.in.

I see it here:
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/bin/pg_config/Attic/pg_config.sh.diff?r1=1.9;r2=1.10

--pkglibdir)    show="$show \$val_pkglibdir";;
+    --pgxs)         show="$show \$val_pgxsdir/src/makefiles/pgxs.mk";;
--configure)    show="$show \$val_configure";;

Joe

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073