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]
|
|
|
|
#
|
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)
|
|
|
|
#
|
2014-11-20 04:21:54 +01:00
|
|
|
# [custom rules, rarely necessary]
|
|
|
|
#
|
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
|
|
|
#
|
2011-02-08 22:08:41 +01:00
|
|
|
# MODULES -- list of shared-library objects to be built from source files
|
|
|
|
# with same stem (do not include library suffixes in this list)
|
|
|
|
# MODULE_big -- a shared library to build from multiple source files
|
2010-01-04 17:34:11 +01:00
|
|
|
# (list object files in OBJS)
|
2011-02-08 22:08:41 +01:00
|
|
|
# PROGRAM -- an executable program to build (list object files in OBJS)
|
2010-01-04 17:34:11 +01:00
|
|
|
#
|
|
|
|
# The following variables can also be set:
|
|
|
|
#
|
2011-02-08 22:08:41 +01:00
|
|
|
# EXTENSION -- name of extension (there must be a $EXTENSION.control file)
|
2011-02-12 04:53:43 +01:00
|
|
|
# MODULEDIR -- subdirectory of $PREFIX/share into which DATA and DOCS files
|
|
|
|
# should be installed (if not set, default is "extension" if EXTENSION
|
|
|
|
# is set, or "contrib" if not)
|
2010-01-04 17:34:11 +01:00
|
|
|
# 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)
|
2011-08-24 21:16:17 +02:00
|
|
|
# REGRESS_OPTS -- additional switches to pass to pg_regress
|
2004-07-30 14:26:40 +02:00
|
|
|
# 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)
|
2014-11-20 03:51:30 +01:00
|
|
|
# If VPATH is set or Makefile is not in current directory we are building
|
|
|
|
# the extension with VPATH so we set the variable here.
|
|
|
|
ifdef VPATH
|
|
|
|
srcdir = $(VPATH)
|
2013-07-01 18:53:05 +02:00
|
|
|
else
|
|
|
|
ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
|
2004-07-30 14:26:40 +02:00
|
|
|
srcdir = .
|
|
|
|
VPATH =
|
2013-07-01 18:53:05 +02:00
|
|
|
else
|
|
|
|
srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
|
|
|
|
VPATH = $(srcdir)
|
|
|
|
endif
|
|
|
|
endif
|
2012-03-30 19:36:49 +02:00
|
|
|
|
|
|
|
# These might be set in Makefile.global, but if they were not found
|
|
|
|
# during the build of PostgreSQL, supply default values so that users
|
|
|
|
# of pgxs can use the variables.
|
|
|
|
ifeq ($(BISON),)
|
|
|
|
BISON = bison
|
|
|
|
endif
|
|
|
|
ifeq ($(FLEX),)
|
|
|
|
FLEX = flex
|
|
|
|
endif
|
2004-07-30 14:26:40 +02:00
|
|
|
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
|
2011-02-12 04:53:43 +01:00
|
|
|
datamoduledir := $(MODULEDIR)
|
|
|
|
docmoduledir := $(MODULEDIR)
|
2010-01-04 17:34:11 +01:00
|
|
|
else
|
2011-02-12 04:53:43 +01:00
|
|
|
ifdef EXTENSION
|
|
|
|
datamoduledir := extension
|
|
|
|
docmoduledir := extension
|
|
|
|
else
|
|
|
|
datamoduledir := contrib
|
|
|
|
docmoduledir := contrib
|
|
|
|
endif
|
2010-01-04 17:34:11 +01:00
|
|
|
endif
|
|
|
|
|
2004-07-30 14:26:40 +02:00
|
|
|
ifdef PG_CPPFLAGS
|
|
|
|
override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
|
|
|
|
endif
|
|
|
|
|
2011-02-08 22:08:41 +01:00
|
|
|
all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .control, $(EXTENSION))
|
2004-07-30 14:26:40 +02:00
|
|
|
|
|
|
|
ifdef MODULE_big
|
|
|
|
# shared library parameters
|
|
|
|
NAME = $(MODULE_big)
|
|
|
|
|
|
|
|
include $(top_srcdir)/src/Makefile.shlib
|
|
|
|
|
|
|
|
all: all-lib
|
|
|
|
endif # MODULE_big
|
|
|
|
|
|
|
|
|
2014-11-20 04:26:32 +01:00
|
|
|
install: all installdirs
|
2013-07-01 18:53:05 +02:00
|
|
|
ifneq (,$(EXTENSION))
|
2014-11-20 04:26:32 +01:00
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(addsuffix .control, $(EXTENSION))) '$(DESTDIR)$(datadir)/extension/'
|
|
|
|
endif # EXTENSION
|
2013-07-01 18:53:05 +02:00
|
|
|
ifneq (,$(DATA)$(DATA_built))
|
2014-11-20 04:26:32 +01:00
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA)) $(DATA_built) '$(DESTDIR)$(datadir)/$(datamoduledir)/'
|
|
|
|
endif # DATA
|
2013-07-01 18:53:05 +02:00
|
|
|
ifneq (,$(DATA_TSEARCH))
|
2014-11-20 04:26:32 +01:00
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DATA_TSEARCH)) '$(DESTDIR)$(datadir)/tsearch_data/'
|
|
|
|
endif # DATA_TSEARCH
|
|
|
|
ifdef MODULES
|
|
|
|
$(INSTALL_SHLIB) $(addsuffix $(DLSUFFIX), $(MODULES)) '$(DESTDIR)$(pkglibdir)/'
|
|
|
|
endif # MODULES
|
2004-07-30 14:26:40 +02:00
|
|
|
ifdef DOCS
|
2005-08-12 23:02:25 +02:00
|
|
|
ifdef docdir
|
2014-11-20 04:26:32 +01:00
|
|
|
$(INSTALL_DATA) $(addprefix $(srcdir)/, $(DOCS)) '$(DESTDIR)$(docdir)/$(docmoduledir)/'
|
2005-08-12 23:02:25 +02:00
|
|
|
endif # docdir
|
2004-07-30 14:26:40 +02:00
|
|
|
endif # DOCS
|
2014-11-20 04:26:32 +01:00
|
|
|
ifdef PROGRAM
|
|
|
|
$(INSTALL_PROGRAM) $(PROGRAM)$(X) '$(DESTDIR)$(bindir)'
|
|
|
|
endif # PROGRAM
|
2004-07-30 14:26:40 +02:00
|
|
|
ifdef SCRIPTS
|
2014-11-20 04:26:32 +01:00
|
|
|
$(INSTALL_SCRIPT) $(addprefix $(srcdir)/, $(SCRIPTS)) '$(DESTDIR)$(bindir)/'
|
2004-07-30 14:26:40 +02:00
|
|
|
endif # SCRIPTS
|
2014-11-20 04:26:32 +01:00
|
|
|
ifdef SCRIPTS_built
|
|
|
|
$(INSTALL_SCRIPT) $(SCRIPTS_built) '$(DESTDIR)$(bindir)/'
|
|
|
|
endif # SCRIPTS_built
|
2004-07-30 14:26:40 +02:00
|
|
|
|
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:
|
2012-12-01 22:04:39 +01:00
|
|
|
ifneq (,$(EXTENSION))
|
|
|
|
$(MKDIR_P) '$(DESTDIR)$(datadir)/extension'
|
|
|
|
endif
|
2004-07-30 14:26:40 +02:00
|
|
|
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:
|
2011-02-12 04:53:43 +01:00
|
|
|
ifneq (,$(EXTENSION))
|
|
|
|
rm -f $(addprefix '$(DESTDIR)$(datadir)/extension'/, $(notdir $(addsuffix .control, $(EXTENSION))))
|
|
|
|
endif
|
|
|
|
ifneq (,$(DATA)$(DATA_built))
|
|
|
|
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
|
2014-07-14 20:07:52 +02:00
|
|
|
rm -f $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .o, $(MODULES)) $(WIN32RES)
|
2004-07-30 14:26:40 +02:00
|
|
|
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
|
2011-11-27 21:42:32 +01:00
|
|
|
rm -rf $(EXTRA_CLEAN)
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|
|
|
|
ifdef REGRESS
|
|
|
|
# things created by various check targets
|
2011-02-14 20:52:32 +01:00
|
|
|
rm -rf $(pg_regress_clean_files)
|
2004-07-30 14:26:40 +02:00
|
|
|
ifeq ($(PORTNAME), win)
|
|
|
|
rm -f regress.def
|
|
|
|
endif
|
|
|
|
endif # REGRESS
|
|
|
|
|
|
|
|
ifdef MODULE_big
|
|
|
|
clean: clean-lib
|
|
|
|
endif
|
|
|
|
|
|
|
|
distclean maintainer-clean: clean
|
|
|
|
|
|
|
|
|
|
|
|
ifdef REGRESS
|
|
|
|
|
2011-08-24 21:16:17 +02:00
|
|
|
# Select database to use for running the tests
|
2012-12-11 17:52:45 +01:00
|
|
|
ifneq ($(USE_MODULE_DB),)
|
|
|
|
REGRESS_OPTS += --dbname=$(CONTRIB_TESTDB_MODULE)
|
|
|
|
else
|
|
|
|
REGRESS_OPTS += --dbname=$(CONTRIB_TESTDB)
|
|
|
|
endif
|
2005-09-27 19:43:31 +02:00
|
|
|
|
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)/%
|
2013-07-01 18:53:05 +02:00
|
|
|
$(MKDIR_P) $(dir $@)
|
2008-10-03 10:00:16 +02:00
|
|
|
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
|
2011-07-25 16:51:02 +02:00
|
|
|
installcheck: submake $(REGRESS_PREP)
|
2011-02-14 20:52:32 +01:00
|
|
|
$(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
|
2004-07-30 14:26:40 +02:00
|
|
|
|
2011-04-25 21:21:37 +02:00
|
|
|
ifdef PGXS
|
2004-07-30 14:26:40 +02:00
|
|
|
check:
|
2011-04-25 21:21:37 +02:00
|
|
|
@echo '"$(MAKE) check" is not supported.'
|
|
|
|
@echo 'Do "$(MAKE) install", then "$(MAKE) installcheck" instead.'
|
|
|
|
else
|
2011-07-25 16:51:02 +02:00
|
|
|
check: all submake $(REGRESS_PREP)
|
2015-04-23 14:59:52 +02:00
|
|
|
$(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
|
|
|
|
|
|
|
|
temp-install: EXTRA_INSTALL=$(subdir)
|
2011-04-25 21:21:37 +02:00
|
|
|
endif
|
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)
|
2013-01-19 20:54:29 +01:00
|
|
|
$(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
|
2004-07-30 14:26:40 +02:00
|
|
|
endif
|