Improve PGXS makefile system to allow the module's makefile to specify

where to install DATA and DOCS files.  This is mainly intended to allow
versioned installation, eg, install into contrib/fooM.N/ rather than
directly into contrib/.

Mark Cave-Ayland
This commit is contained in:
Tom Lane 2010-01-04 16:34:11 +00:00
parent 06f82b2961
commit 4c5b4c8bd0
2 changed files with 81 additions and 56 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.143 2009/12/10 06:32:28 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.144 2010/01/04 16:34:11 tgl Exp $ -->
<sect1 id="xfunc"> <sect1 id="xfunc">
<title>User-Defined Functions</title> <title>User-Defined Functions</title>
@ -2414,24 +2414,58 @@ include $(PGXS)
</para> </para>
<para> <para>
The following variables can be set: Set one of these three variables to specify what is built:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><varname>MODULES</varname></term> <term><varname>MODULES</varname></term>
<listitem> <listitem>
<para> <para>
list of shared objects to be built from source file with same list of shared objects to be built from source files with same
stem (do not include suffix in this list) stem (do not include suffix in this list)
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>MODULE_big</varname></term>
<listitem>
<para>
a shared object to build from multiple source files
(list object files in <varname>OBJS</varname>)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>PROGRAM</varname></term>
<listitem>
<para>
a binary program to build
(list object files in <varname>OBJS</varname>)
</para>
</listitem>
</varlistentry>
</variablelist>
The following variables can also be set:
<variablelist>
<varlistentry>
<term><varname>MODULEDIR</varname></term>
<listitem>
<para>
subdirectory into which DATA and DOCS files should be
installed (if not set, default is <literal>contrib</literal>)
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>DATA</varname></term> <term><varname>DATA</varname></term>
<listitem> <listitem>
<para> <para>
random files to install into <literal><replaceable>prefix</replaceable>/share/contrib</literal> random files to install into <literal><replaceable>prefix</replaceable>/share/$MODULEDIR</literal>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -2441,18 +2475,28 @@ include $(PGXS)
<listitem> <listitem>
<para> <para>
random files to install into random files to install into
<literal><replaceable>prefix</replaceable>/share/contrib</literal>, <literal><replaceable>prefix</replaceable>/share/$MODULEDIR</literal>,
which need to be built first which need to be built first
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>DATA_TSEARCH</varname></term>
<listitem>
<para>
random files to install under
<literal><replaceable>prefix</replaceable>/share/tsearch_data</literal>
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>DOCS</varname></term> <term><varname>DOCS</varname></term>
<listitem> <listitem>
<para> <para>
random files to install under random files to install under
<literal><replaceable>prefix</replaceable>/doc/contrib</literal> <literal><replaceable>prefix</replaceable>/doc/$MODULEDIR</literal>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -2486,33 +2530,6 @@ include $(PGXS)
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist>
or at most one of these two:
<variablelist>
<varlistentry>
<term><varname>PROGRAM</varname></term>
<listitem>
<para>
a binary program to build (list objects files in <varname>OBJS</varname>)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>MODULE_big</varname></term>
<listitem>
<para>
a shared object to build (list object files in <varname>OBJS</varname>)
</para>
</listitem>
</varlistentry>
</variablelist>
The following can also be set:
<variablelist>
<varlistentry> <varlistentry>
<term><varname>EXTRA_CLEAN</varname></term> <term><varname>EXTRA_CLEAN</varname></term>

View File

@ -1,6 +1,6 @@
# PGXS: PostgreSQL extensions makefile # PGXS: PostgreSQL extensions makefile
# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.17 2009/08/26 22:24:43 petere Exp $ # $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.18 2010/01/04 16:34:11 tgl Exp $
# This file contains generic rules to build many kinds of simple # This file contains generic rules to build many kinds of simple
# extension modules. You only need to set a few variables and include # extension modules. You only need to set a few variables and include
@ -15,27 +15,27 @@
# PGXS := $(shell $(PG_CONFIG) --pgxs) # PGXS := $(shell $(PG_CONFIG) --pgxs)
# include $(PGXS) # include $(PGXS)
# #
# The following variables can be set: # Set one of these three variables to specify what is built:
# #
# MODULES -- list of shared objects to be build from source file with # MODULES -- list of shared objects to be built from source files with
# same stem (do not include suffix in this list) # same stem (do not include suffix in this list)
# DATA -- random files to install into $PREFIX/share/contrib # MODULE_big -- a shared object to build from multiple source files
# DATA_built -- random files to install into $PREFIX/share/contrib, # (list object files in OBJS)
# PROGRAM -- a binary program to build (list object files in OBJS)
#
# The following variables can also be set:
#
# MODULEDIR -- subdirectory into which DATA and DOCS files should be
# installed (if not set, default is "contrib")
# DATA -- random files to install into $PREFIX/share/$MODULEDIR
# DATA_built -- random files to install into $PREFIX/share/$MODULEDIR,
# which need to be built first # which need to be built first
# DATA_TSEARCH -- random files to install into $PREFIX/share/tsearch_data # DATA_TSEARCH -- random files to install into $PREFIX/share/tsearch_data
# DOCS -- random files to install under $PREFIX/doc/contrib # DOCS -- random files to install under $PREFIX/doc/$MODULEDIR
# SCRIPTS -- script files (not binaries) to install into $PREFIX/bin # SCRIPTS -- script files (not binaries) to install into $PREFIX/bin
# SCRIPTS_built -- 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 # which need to be built first
# REGRESS -- list of regression test cases (without suffix) # 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' # EXTRA_CLEAN -- extra files to remove in 'make clean'
# PG_CPPFLAGS -- will be added to CPPFLAGS # PG_CPPFLAGS -- will be added to CPPFLAGS
# PG_LIBS -- will be added to PROGRAM link line # PG_LIBS -- will be added to PROGRAM link line
@ -71,6 +71,14 @@ override CFLAGS += $(CFLAGS_SL)
SHLIB_LINK += $(BE_DLLLIBS) SHLIB_LINK += $(BE_DLLLIBS)
endif endif
ifdef MODULEDIR
datamoduledir = $(MODULEDIR)
docmoduledir = $(MODULEDIR)
else
datamoduledir = contrib
docmoduledir = contrib
endif
ifdef PG_CPPFLAGS ifdef PG_CPPFLAGS
override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS) override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
endif endif
@ -90,8 +98,8 @@ endif # MODULE_big
install: all installdirs install: all installdirs
ifneq (,$(DATA)$(DATA_built)) ifneq (,$(DATA)$(DATA_built))
@for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \ @for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \
echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'"; \ echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'"; \
$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'; \ $(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'; \
done done
endif # DATA endif # DATA
ifneq (,$(DATA_TSEARCH)) ifneq (,$(DATA_TSEARCH))
@ -109,8 +117,8 @@ endif # MODULES
ifdef DOCS ifdef DOCS
ifdef docdir ifdef docdir
@for file in $(addprefix $(srcdir)/, $(DOCS)); do \ @for file in $(addprefix $(srcdir)/, $(DOCS)); do \
echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'"; \ echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'"; \
$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'; \ $(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'; \
done done
endif # docdir endif # docdir
endif # DOCS endif # DOCS
@ -137,7 +145,7 @@ endif # MODULE_big
installdirs: installdirs:
ifneq (,$(DATA)$(DATA_built)) ifneq (,$(DATA)$(DATA_built))
$(MKDIR_P) '$(DESTDIR)$(datadir)/contrib' $(MKDIR_P) '$(DESTDIR)$(datadir)/$(datamoduledir)'
endif endif
ifneq (,$(DATA_TSEARCH)) ifneq (,$(DATA_TSEARCH))
$(MKDIR_P) '$(DESTDIR)$(datadir)/tsearch_data' $(MKDIR_P) '$(DESTDIR)$(datadir)/tsearch_data'
@ -147,7 +155,7 @@ ifneq (,$(MODULES))
endif endif
ifdef DOCS ifdef DOCS
ifdef docdir ifdef docdir
$(MKDIR_P) '$(DESTDIR)$(docdir)/contrib' $(MKDIR_P) '$(DESTDIR)$(docdir)/$(docmoduledir)'
endif # docdir endif # docdir
endif # DOCS endif # DOCS
ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built)) ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built))
@ -161,16 +169,16 @@ endif # MODULE_big
uninstall: uninstall:
ifneq (,$(DATA)$(DATA_built)) ifneq (,$(DATA)$(DATA_built))
rm -f $(addprefix '$(DESTDIR)$(datadir)'/contrib/, $(notdir $(DATA) $(DATA_built))) rm -f $(addprefix '$(DESTDIR)$(datadir)/$(datamoduledir)'/, $(notdir $(DATA) $(DATA_built)))
endif endif
ifneq (,$(DATA_TSEARCH)) ifneq (,$(DATA_TSEARCH))
rm -f $(addprefix '$(DESTDIR)$(datadir)'/tsearch_data/, $(notdir $(DATA_TSEARCH))) rm -f $(addprefix '$(DESTDIR)$(datadir)/tsearch_data'/, $(notdir $(DATA_TSEARCH)))
endif endif
ifdef MODULES ifdef MODULES
rm -f $(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX), $(MODULES))) rm -f $(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX), $(MODULES)))
endif endif
ifdef DOCS ifdef DOCS
rm -f $(addprefix '$(DESTDIR)$(docdir)'/contrib/, $(DOCS)) rm -f $(addprefix '$(DESTDIR)$(docdir)/$(docmoduledir)'/, $(DOCS))
endif endif
ifdef PROGRAM ifdef PROGRAM
rm -f '$(DESTDIR)$(bindir)/$(PROGRAM)$(X)' rm -f '$(DESTDIR)$(bindir)/$(PROGRAM)$(X)'