2003-11-30 03:52:15 +08:00
|
|
|
# $PostgreSQL: pgsql/contrib/contrib-global.mk,v 1.7 2003/11/29 19:51:18 pgsql Exp $
|
2001-09-06 18:49:30 +08:00
|
|
|
|
|
|
|
# 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
|
2002-11-02 07:45:37 +08:00
|
|
|
# SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin,
|
|
|
|
# which need to be built first
|
2001-09-06 18:49:30 +08:00
|
|
|
# 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)
|
2002-09-06 02:28:46 +08:00
|
|
|
SHLIB_LINK += $(BE_DLLLIBS)
|
2001-09-06 18:49:30 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef PG_CPPFLAGS
|
|
|
|
override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
|
|
|
|
endif
|
|
|
|
|
2002-11-02 07:45:37 +08:00
|
|
|
all: $(PROGRAM) $(DATA_built) $(SCRIPTS_built) $(addsuffix $(DLSUFFIX), $(MODULES))
|
2001-09-06 18:49:30 +08:00
|
|
|
|
|
|
|
ifdef MODULE_big
|
|
|
|
# shared library parameters
|
|
|
|
NAME = $(MODULE_big)
|
|
|
|
SO_MAJOR_VERSION= 0
|
|
|
|
SO_MINOR_VERSION= 0
|
|
|
|
rpath =
|
|
|
|
|
2002-09-06 02:28:46 +08:00
|
|
|
SHLIB_LINK += $(BE_DLLLIBS)
|
2001-09-06 18:49:30 +08:00
|
|
|
|
|
|
|
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 \
|
2001-09-17 00:11:11 +08:00
|
|
|
echo "$(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir)"; \
|
|
|
|
$(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir); \
|
2001-09-06 18:49:30 +08:00
|
|
|
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
|
2001-09-17 00:11:11 +08:00
|
|
|
$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
|
2001-09-06 18:49:30 +08:00
|
|
|
endif # MODULE_big
|
|
|
|
ifdef SCRIPTS
|
|
|
|
@for file in $(addprefix $(srcdir)/, $(SCRIPTS)); do \
|
|
|
|
echo "$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir)"; \
|
2001-09-17 00:11:11 +08:00
|
|
|
$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir); \
|
2001-09-06 18:49:30 +08:00
|
|
|
done
|
|
|
|
endif # SCRIPTS
|
2002-11-02 07:45:37 +08:00
|
|
|
ifdef SCRIPTS_built
|
|
|
|
@for file in $(SCRIPTS_built); do \
|
|
|
|
echo "$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir)"; \
|
|
|
|
$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir); \
|
|
|
|
done
|
|
|
|
endif # SCRIPTS_built
|
2001-09-06 18:49:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
installdirs:
|
|
|
|
ifneq (,$(DATA)$(DATA_built))
|
|
|
|
$(mkinstalldirs) $(DESTDIR)$(datadir)/contrib
|
|
|
|
endif
|
|
|
|
ifneq (,$(MODULES)$(MODULE_big))
|
2001-09-17 00:11:11 +08:00
|
|
|
$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
|
2001-09-06 18:49:30 +08:00
|
|
|
endif
|
|
|
|
ifdef DOCS
|
|
|
|
$(mkinstalldirs) $(DESTDIR)$(docdir)/contrib
|
|
|
|
endif
|
2002-11-02 07:45:37 +08:00
|
|
|
ifneq (,$(PROGRAM)$(SCRIPTS)$(SCRIPTS_built))
|
2001-09-06 18:49:30 +08:00
|
|
|
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
ifneq (,$(DATA)$(DATA_built))
|
2003-08-23 12:23:38 +08:00
|
|
|
rm -f $(addprefix $(DESTDIR)$(datadir)/contrib/, $(notdir $(DATA) $(DATA_built)))
|
2001-09-06 18:49:30 +08:00
|
|
|
endif
|
|
|
|
ifdef MODULES
|
2001-09-17 00:11:11 +08:00
|
|
|
rm -f $(addprefix $(DESTDIR)$(pkglibdir)/, $(addsuffix $(DLSUFFIX), $(MODULES)))
|
2001-09-06 18:49:30 +08:00
|
|
|
endif
|
|
|
|
ifdef DOCS
|
|
|
|
rm -f $(addprefix $(DESTDIR)$(docdir)/contrib/, $(DOCS))
|
|
|
|
endif
|
|
|
|
ifdef PROGRAM
|
|
|
|
rm -f $(DESTDIR)$(bindir)/$(PROGRAM)$(X)
|
|
|
|
endif
|
|
|
|
ifdef MODULE_big
|
2001-09-17 00:11:11 +08:00
|
|
|
rm -f $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
|
2001-09-06 18:49:30 +08:00
|
|
|
endif
|
|
|
|
ifdef SCRIPTS
|
|
|
|
rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
|
|
|
|
endif
|
2002-11-02 07:45:37 +08:00
|
|
|
ifdef SCRIPTS_built
|
|
|
|
rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS_built))
|
|
|
|
endif
|
2001-09-06 18:49:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
ifdef MODULES
|
|
|
|
rm -f $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .o, $(MODULES))
|
|
|
|
endif
|
|
|
|
ifdef DATA_built
|
|
|
|
rm -f $(DATA_built)
|
|
|
|
endif
|
2002-11-02 07:45:37 +08:00
|
|
|
ifdef SCRIPTS_built
|
|
|
|
rm -f $(SCRIPTS_built)
|
|
|
|
endif
|
2001-09-06 18:49:30 +08:00
|
|
|
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
|
2002-11-02 08:16:21 +08:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2001-09-06 18:49:30 +08:00
|
|
|
.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
|
2001-09-17 00:11:11 +08:00
|
|
|
sed 's,MODULE_PATHNAME,$$libdir/$*,g' $< >$@
|
2001-09-06 18:49:30 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef PROGRAM
|
|
|
|
$(PROGRAM): $(OBJS)
|
|
|
|
$(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LIBS) -o $@
|
|
|
|
endif
|