2004-07-30 14:26:40 +02:00
|
|
|
# PGXS: PostgreSQL extensions makefile
|
|
|
|
|
2010-11-23 21:27:50 +01:00
|
|
|
# src/makefiles/pgxs.mk
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
# 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]
|
|
|
|
#
|
2007-06-27 00:05:04 +02:00
|
|
|
# PG_CONFIG = pg_config
|
|
|
|
# PGXS := $(shell $(PG_CONFIG) --pgxs)
|
2004-07-30 14:26:40 +02:00
|
|
|
# include $(PGXS)
|
|
|
|
#
|
2010-01-04 17:34:11 +01:00
|
|
|
# Set one of these three variables to specify what is built:
|
2004-07-30 14:26:40 +02:00
|
|
|
#
|
2010-01-04 17:34:11 +01:00
|
|
|
# MODULES -- list of shared objects to be built from source files with
|
2004-07-30 14:26:40 +02:00
|
|
|
# same stem (do not include suffix in this list)
|
2010-01-04 17:34:11 +01:00
|
|
|
# MODULE_big -- a shared object to build from multiple source files
|
|
|
|
# (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,
|
2004-07-30 14:26:40 +02:00
|
|
|
# which need to be built first
|
2007-10-16 18:00:00 +02:00
|
|
|
# DATA_TSEARCH -- random files to install into $PREFIX/share/tsearch_data
|
2010-01-04 17:34:11 +01:00
|
|
|
# DOCS -- random files to install under $PREFIX/doc/$MODULEDIR
|
2004-07-30 14:26:40 +02:00
|
|
|
# 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)
|
|
|
|
# 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
|
2007-06-27 00:05:04 +02:00
|
|
|
# PG_CONFIG -- path to pg_config program for the PostgreSQL installation
|
|
|
|
# to build against (typically just "pg_config" to use the first one in
|
|
|
|
# your PATH)
|
2004-07-30 14:26:40 +02:00
|
|
|
#
|
|
|
|
# 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 ...
|
2004-10-06 10:50:02 +02:00
|
|
|
top_builddir := $(dir $(PGXS))../..
|
2004-07-30 14:26:40 +02:00
|
|
|
include $(top_builddir)/src/Makefile.global
|
|
|
|
|
|
|
|
top_srcdir = $(top_builddir)
|
|
|
|
srcdir = .
|
|
|
|
VPATH =
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2010-01-05 04:56:52 +01:00
|
|
|
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
ifdef MODULES
|
|
|
|
override CFLAGS += $(CFLAGS_SL)
|
|
|
|
endif
|
|
|
|
|
2010-01-04 17:34:11 +01:00
|
|
|
ifdef MODULEDIR
|
|
|
|
datamoduledir = $(MODULEDIR)
|
|
|
|
docmoduledir = $(MODULEDIR)
|
|
|
|
else
|
|
|
|
datamoduledir = contrib
|
|
|
|
docmoduledir = contrib
|
|
|
|
endif
|
|
|
|
|
2004-07-30 14:26:40 +02:00
|
|
|
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)
|
|
|
|
|
|
|
|
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 \
|
2010-01-04 17:34:11 +01:00
|
|
|
echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'"; \
|
|
|
|
$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/$(datamoduledir)'; \
|
2004-07-30 14:26:40 +02:00
|
|
|
done
|
|
|
|
endif # DATA
|
2007-10-16 18:00:00 +02:00
|
|
|
ifneq (,$(DATA_TSEARCH))
|
|
|
|
@for file in $(addprefix $(srcdir)/, $(DATA_TSEARCH)); do \
|
|
|
|
echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/tsearch_data'"; \
|
|
|
|
$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/tsearch_data'; \
|
|
|
|
done
|
|
|
|
endif # DATA_TSEARCH
|
2004-07-30 14:26:40 +02:00
|
|
|
ifdef MODULES
|
|
|
|
@for file in $(addsuffix $(DLSUFFIX), $(MODULES)); do \
|
2005-12-09 22:19:36 +01:00
|
|
|
echo "$(INSTALL_SHLIB) $$file '$(DESTDIR)$(pkglibdir)'"; \
|
|
|
|
$(INSTALL_SHLIB) $$file '$(DESTDIR)$(pkglibdir)'; \
|
2004-07-30 14:26:40 +02:00
|
|
|
done
|
|
|
|
endif # MODULES
|
|
|
|
ifdef DOCS
|
2005-08-12 23:02:25 +02:00
|
|
|
ifdef docdir
|
2004-07-30 14:26:40 +02:00
|
|
|
@for file in $(addprefix $(srcdir)/, $(DOCS)); do \
|
2010-01-04 17:34:11 +01:00
|
|
|
echo "$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'"; \
|
|
|
|
$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/$(docmoduledir)'; \
|
2004-07-30 14:26:40 +02:00
|
|
|
done
|
2005-08-12 23:02:25 +02:00
|
|
|
endif # docdir
|
2004-07-30 14:26:40 +02:00
|
|
|
endif # DOCS
|
|
|
|
ifdef PROGRAM
|
2005-12-09 22:19:36 +01:00
|
|
|
$(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)'
|
2004-07-30 14:26:40 +02:00
|
|
|
endif # PROGRAM
|
|
|
|
ifdef SCRIPTS
|
|
|
|
@for file in $(addprefix $(srcdir)/, $(SCRIPTS)); do \
|
2005-12-09 22:19:36 +01:00
|
|
|
echo "$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'"; \
|
|
|
|
$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'; \
|
2004-07-30 14:26:40 +02:00
|
|
|
done
|
|
|
|
endif # SCRIPTS
|
|
|
|
ifdef SCRIPTS_built
|
|
|
|
@for file in $(SCRIPTS_built); do \
|
2005-12-09 22:19:36 +01:00
|
|
|
echo "$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'"; \
|
|
|
|
$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'; \
|
2004-07-30 14:26:40 +02:00
|
|
|
done
|
|
|
|
endif # SCRIPTS_built
|
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef MODULE_big
|
|
|
|
install: install-lib
|
|
|
|
endif # MODULE_big
|
|
|
|
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
installdirs:
|
|
|
|
ifneq (,$(DATA)$(DATA_built))
|
2010-01-04 17:34:11 +01:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(datadir)/$(datamoduledir)'
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
2007-10-16 18:00:00 +02:00
|
|
|
ifneq (,$(DATA_TSEARCH))
|
2009-08-27 00:24:44 +02:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(datadir)/tsearch_data'
|
2007-10-16 18:00:00 +02:00
|
|
|
endif
|
2008-04-07 16:15:58 +02:00
|
|
|
ifneq (,$(MODULES))
|
2009-08-27 00:24:44 +02:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
ifdef DOCS
|
2005-08-12 23:02:25 +02:00
|
|
|
ifdef docdir
|
2010-01-04 17:34:11 +01:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(docdir)/$(docmoduledir)'
|
2005-08-12 23:02:25 +02:00
|
|
|
endif # docdir
|
|
|
|
endif # DOCS
|
2004-07-30 14:26:40 +02:00
|
|
|
ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built))
|
2009-08-27 00:24:44 +02:00
|
|
|
$(MKDIR_P) '$(DESTDIR)$(bindir)'
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef MODULE_big
|
|
|
|
installdirs: installdirs-lib
|
|
|
|
endif # MODULE_big
|
|
|
|
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
ifneq (,$(DATA)$(DATA_built))
|
2010-01-04 17:34:11 +01:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(datadir)/$(datamoduledir)'/, $(notdir $(DATA) $(DATA_built)))
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
2007-10-16 18:00:00 +02:00
|
|
|
ifneq (,$(DATA_TSEARCH))
|
2010-01-04 17:34:11 +01:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(datadir)/tsearch_data'/, $(notdir $(DATA_TSEARCH)))
|
2007-10-16 18:00:00 +02:00
|
|
|
endif
|
2004-07-30 14:26:40 +02:00
|
|
|
ifdef MODULES
|
2005-12-09 22:19:36 +01:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX), $(MODULES)))
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
ifdef DOCS
|
2010-01-04 17:34:11 +01:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(docdir)/$(docmoduledir)'/, $(DOCS))
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
ifdef PROGRAM
|
2005-12-09 22:19:36 +01:00
|
|
|
rm -f '$(DESTDIR)$(bindir)/$(PROGRAM)$(X)'
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
ifdef SCRIPTS
|
2005-12-09 22:19:36 +01:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(SCRIPTS))
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
ifdef SCRIPTS_built
|
2005-12-09 22:19:36 +01:00
|
|
|
rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(SCRIPTS_built))
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
|
2008-04-07 16:15:58 +02:00
|
|
|
ifdef MODULE_big
|
|
|
|
uninstall: uninstall-lib
|
|
|
|
endif # MODULE_big
|
|
|
|
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2005-09-27 19:43:31 +02:00
|
|
|
# Calling makefile can set REGRESS_OPTS, but this is the default:
|
|
|
|
ifndef REGRESS_OPTS
|
|
|
|
REGRESS_OPTS = --dbname=$(CONTRIB_TESTDB)
|
|
|
|
endif
|
|
|
|
|
2006-07-21 02:24:04 +02:00
|
|
|
# where to find psql for running the tests
|
|
|
|
PSQLDIR = $(bindir)
|
|
|
|
|
2008-10-03 10:00:16 +02:00
|
|
|
# When doing a VPATH build, must copy over the data 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)/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
|
|
|
|
|
2004-07-30 14:26:40 +02:00
|
|
|
.PHONY: submake
|
|
|
|
submake:
|
2005-09-27 19:43:31 +02:00
|
|
|
ifndef PGXS
|
2006-07-19 04:37:00 +02:00
|
|
|
$(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
|
2005-09-27 19:43:31 +02:00
|
|
|
endif
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
# against installed postmaster
|
|
|
|
installcheck: submake
|
2008-10-02 14:25:25 +02:00
|
|
|
$(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir=$(PSQLDIR) $(REGRESS_OPTS) $(REGRESS)
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
# in-tree test doesn't work yet (no way to install my shared library)
|
|
|
|
#check: all submake
|
2006-07-19 04:37:00 +02:00
|
|
|
# $(top_builddir)/src/test/regress/pg_regress --temp-install \
|
2005-05-17 20:26:23 +02:00
|
|
|
# --top-builddir=$(top_builddir) $(REGRESS_OPTS) $(REGRESS)
|
2004-07-30 14:26:40 +02:00
|
|
|
check:
|
|
|
|
@echo "'make check' is not supported."
|
|
|
|
@echo "Do 'make install', then 'make installcheck' instead."
|
2009-07-08 15:47:29 +02:00
|
|
|
@exit 1
|
2004-07-30 14:26:40 +02:00
|
|
|
endif # REGRESS
|
|
|
|
|
|
|
|
|
|
|
|
# STANDARD RULES
|
|
|
|
|
|
|
|
ifneq (,$(MODULES)$(MODULE_big))
|
|
|
|
%.sql: %.sql.in
|
|
|
|
sed 's,MODULE_PATHNAME,$$libdir/$*,g' $< >$@
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef PROGRAM
|
|
|
|
$(PROGRAM): $(OBJS)
|
2010-07-06 01:40:13 +02:00
|
|
|
$(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|