PostgreSQL extension makefile framework ("pgxs"), by Fabien Coelho, with

some massaging by Peter Eisentraut.  This is basically a simple
generalization of the existing contrib makefiles.
This commit is contained in:
Peter Eisentraut 2004-07-30 12:26:40 +00:00
parent f82d99be7e
commit adf57cd7e2
11 changed files with 546 additions and 242 deletions

View File

@ -1,7 +1,7 @@
#
# PostgreSQL top level makefile
#
# $PostgreSQL: pgsql/GNUmakefile.in,v 1.39 2004/06/13 21:51:36 petere Exp $
# $PostgreSQL: pgsql/GNUmakefile.in,v 1.40 2004/07/30 12:26:39 petere Exp $
#
subdir =
@ -11,16 +11,19 @@ include $(top_builddir)/src/Makefile.global
all:
$(MAKE) -C doc all
$(MAKE) -C src all
$(MAKE) -C config all
@echo "All of PostgreSQL successfully made. Ready to install."
install:
$(MAKE) -C doc install
$(MAKE) -C src install
$(MAKE) -C config install
@echo "PostgreSQL installation complete."
installdirs uninstall distprep:
$(MAKE) -C doc $@
$(MAKE) -C src $@
$(MAKE) -C config $@
install-all-headers:
$(MAKE) -C src $@
@ -31,6 +34,7 @@ clean:
$(MAKE) -C doc $@
$(MAKE) -C contrib $@
$(MAKE) -C src $@
$(MAKE) -C config $@
# Garbage from autoconf:
@rm -rf autom4te.cache/
@ -39,6 +43,7 @@ clean:
distclean maintainer-clean:
-$(MAKE) -C doc $@
-$(MAKE) -C contrib $@
-$(MAKE) -C config $@
-$(MAKE) -C src $@
-rm -f config.cache config.log config.status GNUmakefile
# Garbage from autoconf:

16
config/Makefile Normal file
View File

@ -0,0 +1,16 @@
# $PostgreSQL: pgsql/config/Makefile,v 1.1 2004/07/30 12:26:39 petere Exp $
subdir = config
top_builddir = ..
include $(top_builddir)/src/Makefile.global
install: all installdirs
$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(pgxsdir)/config/install-sh
$(INSTALL_SCRIPT) $(srcdir)/mkinstalldirs $(DESTDIR)$(pgxsdir)/config/mkinstalldirs
installdirs:
$(mkinstalldirs) $(DESTDIR)$(pgxsdir)/config
uninstall:
rm -f $(DESTDIR)$(pgxsdir)/config/install-sh $(DESTDIR)$(pgxsdir)/config/mkinstalldirs

View File

@ -1,234 +1,4 @@
# $PostgreSQL: pgsql/contrib/contrib-global.mk,v 1.7 2003/11/29 19:51:18 pgsql Exp $
# $PostgreSQL: pgsql/contrib/contrib-global.mk,v 1.8 2004/07/30 12:26:39 petere Exp $
# 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.
#
# Use the following layout for your Makefile:
#
# subdir = contrib/xxx
# top_builddir = ../..
# include $(top_builddir)/src/Makefile.global
#
# [variable assignments, see below]
# [custom rules, rarely necessary]
#
# include $(top_srcdir)/contrib/contrib-global.mk
#
# The following variables can be set:
#
# 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...
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
NO_PGXS = 1
include $(top_srcdir)/src/makefiles/pgxs.mk

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.84 2004/05/16 23:22:07 neilc Exp $
$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.85 2004/07/30 12:26:39 petere Exp $
-->
<sect1 id="xfunc">
@ -1610,6 +1610,199 @@ concat_text(PG_FUNCTION_ARGS)
&dfunc;
<sect2 id="xfunc-c-pgxs">
<title>Extension build infrastructure</title>
<indexterm zone="xfunc-c-pgxs">
<primary>pgxs</primary>
</indexterm>
<para>
If you are thinking about distributing your PostgreSQL extension
modules, setting up a portable build system for them can be fairly
difficult. Therefore the PostgreSQL installation provides a build
infrastructure for extensions, called <acronym>PGXS</acronym>, so
that simple extension modules can be built simply against an
already installed server. Note that this infrastructure is not
intended to be a universal build system framework that can be used
to build all software interfacing to PostgreSQL; it simply
automates common build rules for simple server extension modules.
For more complicated packages, you need to write your own build
system.
</para>
<para>
To use the infrastructure for your extension, you must write a
simple makefile. In that makefile, you need to set some variables
and finally include the global <acronym>PGXS</acronym> makefile.
Here is an example that builds an extension module named
<literal>isbn_issn</literal> consisting of a shared library, an
SQL script, and a documentation text file:
<programlisting>
MODULES = isbn_issn
DATA_built = isbn_issn.sql
DOCS = README.isbn_issn
PGXS := $(shell pg_config --pgxs)
include $(PGXS)
</programlisting>
The last two lines should always be the same. Earlier in the
file, you assign variables or add custom
<application>make</application> rules.
</para>
<para>
The following variables can be set:
<variablelist>
<varlistentry>
<term><varname>MODULES</varname></term>
<listitem>
<para>
list of shared objects to be build from source file with same
stem (do not include suffix in this list)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>DATA</varname></term>
<listitem>
<para>
random files to install into <literal><replaceable>prefix</replaceable>/share/contrib</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>DATA_built</varname></term>
<listitem>
<para>
random files to install into
<literal><replaceable>prefix</replaceable>/share/contrib</literal>,
which need to be built first
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>DOCS</varname></term>
<listitem>
<para>
random files to install under
<literal><replaceable>prefix</replaceable>/doc/contrib</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>SCRIPTS</varname></term>
<listitem>
<para>
script files (not binaries) to install into
<literal><replaceable>prefix</replaceable>/bin</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>SCRIPTS_built</varname></term>
<listitem>
<para>
script files (not binaries) to install into
<literal><replaceable>prefix</replaceable>/bin</literal>,
which need to be built first
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>REGRESS</varname></term>
<listitem>
<para>
list of regression test cases (without suffix)
</para>
</listitem>
</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>
<term><varname>EXTRA_CLEAN</varname></term>
<listitem>
<para>
extra files to remove in <literal>make clean</literal>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>PG_CPPFLAGS</varname></term>
<listitem>
<para>
will be added to <varname>CPPFLAGS</varname>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>PG_LIBS</varname></term>
<listitem>
<para>
will be added to <varname>PROGRAM</varname> link line
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>SHLIB_LINK</varname></term>
<listitem>
<para>
will be added to <varname>MODULE_big</varname> link line
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
Put this makefile as <literal>Makefile</literal> in the directory
which holds your extension. Then you can do
<literal>make</literal> to compile, and later <literal>make
install</literal> to install your module. The extension is
compiled and installed for the
<productname>PostgreSQL</productname> installation that
corresponds to the first <command>pg_config</command> command
found in your path.
</para>
</sect2>
<sect2>
<title>Composite-Type Arguments in C-Language Functions</title>

View File

@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/Makefile,v 1.32 2004/04/30 04:31:52 momjian Exp $
# $PostgreSQL: pgsql/src/Makefile,v 1.33 2004/07/30 12:26:40 petere Exp $
#
#-------------------------------------------------------------------------
@ -22,10 +22,30 @@ all install installdirs uninstall dep depend distprep:
$(MAKE) -C interfaces $@
$(MAKE) -C bin $@
$(MAKE) -C pl $@
$(MAKE) -C makefiles $@
$(MAKE) -C utils $@
install: install-local
install-local: installdirs-local
$(INSTALL_DATA) Makefile.global $(DESTDIR)$(pgxsdir)/$(subdir)/Makefile.global
$(INSTALL_DATA) Makefile.port $(DESTDIR)$(pgxsdir)/$(subdir)/Makefile.port
$(INSTALL_DATA) $(srcdir)/Makefile.shlib $(DESTDIR)$(pgxsdir)/$(subdir)/Makefile.shlib
$(INSTALL_DATA) $(srcdir)/nls-global.mk $(DESTDIR)$(pgxsdir)/$(subdir)/nls-global.mk
install-all-headers:
$(MAKE) -C include $@
installdirs: installdirs-local
installdirs-local:
$(mkinstalldirs) $(DESTDIR)$(pgxsdir)/$(subdir)
uninstall: uninstall-local
uninstall-local:
rm -f $(addprefix $(DESTDIR)$(pgxsdir)/$(subdir), Makefile.global Makefile.port Makefile.shlib nls-global.mk)
clean:
$(MAKE) -C port $@
$(MAKE) -C timezone $@
@ -34,6 +54,7 @@ clean:
$(MAKE) -C interfaces $@
$(MAKE) -C bin $@
$(MAKE) -C pl $@
$(MAKE) -C makefiles $@
$(MAKE) -C test $@
$(MAKE) -C tutorial $@
$(MAKE) -C utils $@
@ -47,8 +68,12 @@ distclean maintainer-clean:
-$(MAKE) -C interfaces $@
-$(MAKE) -C bin $@
-$(MAKE) -C pl $@
-$(MAKE) -C makefiles $@
-$(MAKE) -C test $@
-$(MAKE) -C tutorial $@
-$(MAKE) -C utils $@
-$(MAKE) -C tools/thread $@
rm -f Makefile.port Makefile.global
.PHONY: install-local installdirs-local uninstall-local

View File

@ -1,5 +1,5 @@
# -*-makefile-*-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.189 2004/06/02 21:05:52 momjian Exp $
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.190 2004/07/30 12:26:40 petere Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
@ -116,6 +116,8 @@ endif
localedir := @localedir@
pgxsdir = $(pkglibdir)/pgxs
##########################################################################
#
@ -166,10 +168,15 @@ COLLATEINDEX = @COLLATEINDEX@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
ifdef PGXS
override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
else # not PGXS
override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
ifdef VPATH
override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
endif
endif # not PGXS
CC = @CC@
GCC = @GCC@
@ -366,6 +373,9 @@ TAS = @TAS@
%.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,6 +403,8 @@ $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(
$(top_builddir)/config.status: $(top_srcdir)/configure
cd $(top_builddir) && ./config.status --recheck
endif # not PGXS
install-strip:
@$(MAKE) INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \

View File

@ -1,4 +1,4 @@
# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.6 2003/11/29 19:52:04 pgsql Exp $
# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.7 2004/07/30 12:26:40 petere Exp $
subdir = src/bin/pg_config
top_builddir = ../../..
@ -12,6 +12,7 @@ pg_config: pg_config.sh $(top_builddir)/src/Makefile.global Makefile
-e 's,@includedir_server@,$(includedir_server),g' \
-e 's,@libdir@,$(libdir),g' \
-e 's,@pkglibdir@,$(pkglibdir),g' \
-e 's,@pgxsdir@,$(pgxsdir),g' \
-e "s|@configure@|$(configure_args)|g" \
-e 's,@version@,$(VERSION),g' \
$< >$@

View File

@ -7,7 +7,7 @@
# Author: Peter Eisentraut <peter_e@gmx.net>
# Public domain
# $PostgreSQL: pgsql/src/bin/pg_config/pg_config.sh,v 1.9 2003/11/29 19:52:04 pgsql Exp $
# $PostgreSQL: pgsql/src/bin/pg_config/pg_config.sh,v 1.10 2004/07/30 12:26:40 petere Exp $
me=`basename $0`
@ -17,6 +17,7 @@ val_includedir='@includedir@'
val_includedir_server='@includedir_server@'
val_libdir='@libdir@'
val_pkglibdir='@pkglibdir@'
val_pgxsdir='@pgxsdir@'
val_configure="@configure@"
val_version='@version@'
@ -33,6 +34,7 @@ Options:
--includedir-server show location of C header files for the server
--libdir show location of object code libraries
--pkglibdir show location of dynamically loadable modules
--pgxs show location of extension makefile
--configure show options given to 'configure' script when
PostgreSQL was built
--version show the PostgreSQL version, then exit
@ -60,11 +62,12 @@ do
show="$show \$val_includedir_server";;
--libdir) show="$show \$val_libdir";;
--pkglibdir) show="$show \$val_pkglibdir";;
--pgxs) show="$show \$val_pgxsdir/src/makefiles/pgxs.mk";;
--configure) show="$show \$val_configure";;
--version) echo "PostgreSQL $val_version"
--version) echo "PostgreSQL $val_version"
exit 0;;
--help|-\?) echo "$help"
--help|-\?) echo "$help"
exit 0;;
*) echo "$me: invalid argument: $opt" 1>&2
echo "$advice" 1>&2

15
src/makefiles/Makefile Normal file
View File

@ -0,0 +1,15 @@
# $PostgreSQL: pgsql/src/makefiles/Makefile,v 1.1 2004/07/30 12:26:40 petere Exp $
subdir = src/makefiles
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
install: all installdirs
$(INSTALL_DATA) $(srcdir)/pgxs.mk $(DESTDIR)$(pgxsdir)/$(subdir)/
installdirs:
$(mkinstalldirs) $(DESTDIR)$(pgxsdir)/$(subdir)
uninstall:
rm -f $(DESTDIR)$(pgxsdir)/$(subdir)/pgxs.mk

250
src/makefiles/pgxs.mk Normal file
View File

@ -0,0 +1,250 @@
# PGXS: PostgreSQL extensions makefile
# $PostgreSQL: pgsql/src/makefiles/pgxs.mk,v 1.1 2004/07/30 12:26:40 petere Exp $
# This file contains generic rules to build many kinds of simple
# extension modules. You only need to set a few variables and include
# this file, the rest will be done here.
#
# Use the following layout for your Makefile:
#
# [variable assignments, see below]
# [custom rules, rarely necessary]
#
# PGXS := $(shell pg_config --pgxs)
# include $(PGXS)
#
# The following variables can be set:
#
# 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...
ifndef PGXS
ifndef NO_PGXS
$(error pgxs error: makefile variable PGXS or NO_PGXS must be set)
endif
endif
ifdef PGXS
# We assume that we are in src/makefiles/, so top is ...
top_builddir := $(dir $(PGXS))/../..
include $(top_builddir)/src/Makefile.global
top_srcdir = $(top_builddir)
srcdir = .
VPATH =
endif
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

View File

@ -2,7 +2,7 @@
#
# Makefile for utils
#
# $PostgreSQL: pgsql/src/utils/Makefile,v 1.20 2003/11/29 19:52:15 pgsql Exp $
# $PostgreSQL: pgsql/src/utils/Makefile,v 1.21 2004/07/30 12:26:40 petere Exp $
#
# dllinit.o is only built on Win32 platform.
#
@ -12,7 +12,21 @@ subdir = src/utils
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
ifdef DLLINIT
all:
install: all installdirs
$(INSTALL_DATA) dllinit.o $(DESTDIR)$(pgxsdir)/$(subdir)/
installdirs:
$(mkinstalldirs) $(DESTDIR)$(pgxsdir)/$(subdir)
uninstall:
rm -f $(DESTDIR)$(pgxsdir)/$(subdir)/dllinit.o
clean distclean maintainer-clean:
rm -f dllinit.o
endif # not DLLINIT