1 # PGXS: PostgreSQL extensions makefile
5 # This file contains generic rules to build many kinds of simple
6 # extension modules. You only need to set a few variables and include
7 # this file, the rest will be done here.
9 # Use the following layout for your Makefile:
11 # [variable assignments, see below]
12 # [custom rules, rarely necessary]
14 # PG_CONFIG = pg_config
15 # PGXS := $(shell $(PG_CONFIG) --pgxs)
18 # The following variables can be set:
20 # MODULES -- list of shared objects to be build from source file with
21 # same stem (do not include suffix in this list)
22 # DATA -- random files to install into $PREFIX/share/contrib
23 # DATA_built -- random files to install into $PREFIX/share/contrib,
24 # which need to be built first
25 # DATA_TSEARCH -- random files to install into $PREFIX/share/tsearch_data
26 # DOCS -- random files to install under $PREFIX/doc/contrib
27 # SCRIPTS -- script files (not binaries) to install into $PREFIX/bin
28 # SCRIPTS_built -- script files (not binaries) to install into $PREFIX/bin,
29 # which need to be built first
30 # REGRESS -- list of regression test cases (without suffix)
32 # or at most one of these two:
34 # PROGRAM -- a binary program to build (list objects files in OBJS)
35 # MODULE_big -- a shared object to build (list object files in OBJS)
37 # The following can also be set:
39 # EXTRA_CLEAN -- extra files to remove in 'make clean'
40 # PG_CPPFLAGS -- will be added to CPPFLAGS
41 # PG_LIBS -- will be added to PROGRAM link line
42 # SHLIB_LINK -- will be added to MODULE_big link line
43 # PG_CONFIG -- path to pg_config program for the PostgreSQL installation
44 # to build against (typically just "pg_config" to use the first one in
47 # Better look at some of the existing uses for examples...
51 $(error pgxs error
: makefile variable PGXS or NO_PGXS must be set
)
57 # We assume that we are in src/makefiles/, so top is ...
58 top_builddir
:= $(dir $(PGXS
))..
/..
59 include $(top_builddir
)/src
/Makefile.global
61 top_srcdir
= $(top_builddir
)
67 override CPPFLAGS
:= -I
$(srcdir) $(CPPFLAGS
)
70 override CFLAGS
+= $(CFLAGS_SL
)
71 SHLIB_LINK
+= $(BE_DLLLIBS
)
75 override CPPFLAGS
:= $(PG_CPPFLAGS
) $(CPPFLAGS
)
78 all: $(PROGRAM
) $(DATA_built
) $(SCRIPTS_built
) $(addsuffix $(DLSUFFIX
), $(MODULES
))
81 # shared library parameters
84 include $(top_srcdir
)/src
/Makefile.shlib
90 install: all installdirs
91 ifneq (,$(DATA
)$(DATA_built
))
92 @for file in
$(addprefix $(srcdir)/, $(DATA
)) $(DATA_built
); do \
93 echo
"$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/contrib'"; \
94 $(INSTALL_DATA
) $$file '$(DESTDIR)$(datadir)/contrib'; \
97 ifneq (,$(DATA_TSEARCH
))
98 @for file in
$(addprefix $(srcdir)/, $(DATA_TSEARCH
)); do \
99 echo
"$(INSTALL_DATA) $$file '$(DESTDIR)$(datadir)/tsearch_data'"; \
100 $(INSTALL_DATA
) $$file '$(DESTDIR)$(datadir)/tsearch_data'; \
104 @for file in
$(addsuffix $(DLSUFFIX
), $(MODULES
)); do \
105 echo
"$(INSTALL_SHLIB) $$file '$(DESTDIR)$(pkglibdir)'"; \
106 $(INSTALL_SHLIB
) $$file '$(DESTDIR)$(pkglibdir)'; \
111 @for file in
$(addprefix $(srcdir)/, $(DOCS
)); do \
112 echo
"$(INSTALL_DATA) $$file '$(DESTDIR)$(docdir)/contrib'"; \
113 $(INSTALL_DATA
) $$file '$(DESTDIR)$(docdir)/contrib'; \
118 $(INSTALL_PROGRAM
) $(PROGRAM
)$(X
) '$(DESTDIR)$(bindir)'
121 @for file in
$(addprefix $(srcdir)/, $(SCRIPTS
)); do \
122 echo
"$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'"; \
123 $(INSTALL_SCRIPT
) $$file '$(DESTDIR)$(bindir)'; \
127 @for file in
$(SCRIPTS_built
); do \
128 echo
"$(INSTALL_SCRIPT) $$file '$(DESTDIR)$(bindir)'"; \
129 $(INSTALL_SCRIPT
) $$file '$(DESTDIR)$(bindir)'; \
131 endif # SCRIPTS_built
139 ifneq (,$(DATA
)$(DATA_built
))
140 $(mkinstalldirs
) '$(DESTDIR)$(datadir)/contrib'
142 ifneq (,$(DATA_TSEARCH
))
143 $(mkinstalldirs
) '$(DESTDIR)$(datadir)/tsearch_data'
146 $(mkinstalldirs
) '$(DESTDIR)$(pkglibdir)'
150 $(mkinstalldirs
) '$(DESTDIR)$(docdir)/contrib'
153 ifneq (,$(PROGRAM
)$(SCRIPTS
)$(SCRIPTS_built
))
154 $(mkinstalldirs
) '$(DESTDIR)$(bindir)'
158 installdirs: installdirs-lib
163 ifneq (,$(DATA
)$(DATA_built
))
164 rm -f
$(addprefix '$(DESTDIR)$(datadir)'/contrib
/, $(notdir $(DATA
) $(DATA_built
)))
166 ifneq (,$(DATA_TSEARCH
))
167 rm -f
$(addprefix '$(DESTDIR)$(datadir)'/tsearch_data
/, $(notdir $(DATA_TSEARCH
)))
170 rm -f
$(addprefix '$(DESTDIR)$(pkglibdir)'/, $(addsuffix $(DLSUFFIX
), $(MODULES
)))
173 rm -f
$(addprefix '$(DESTDIR)$(docdir)'/contrib
/, $(DOCS
))
176 rm -f
'$(DESTDIR)$(bindir)/$(PROGRAM)$(X)'
179 rm -f
$(addprefix '$(DESTDIR)$(bindir)'/, $(SCRIPTS
))
182 rm -f
$(addprefix '$(DESTDIR)$(bindir)'/, $(SCRIPTS_built
))
186 uninstall: uninstall-lib
192 rm -f
$(addsuffix $(DLSUFFIX
), $(MODULES
)) $(addsuffix .o
, $(MODULES
))
198 rm -f
$(SCRIPTS_built
)
210 # things created by various check targets
211 rm -rf results tmp_check log
212 rm -f regression.diffs regression.out regress.out run_check.out
213 ifeq ($(PORTNAME
), win
)
222 distclean maintainer-clean
: clean
227 # Calling makefile can set REGRESS_OPTS, but this is the default:
229 REGRESS_OPTS
= --dbname
=$(CONTRIB_TESTDB
)
232 # where to find psql for running the tests
235 # When doing a VPATH build, must copy over the test .sql and .out
236 # files so that the driver script can find them. We have to use an
237 # absolute path for the targets, because otherwise make will try to
238 # locate the missing files using VPATH, and will find them in
239 # $(srcdir), but the point here is that we want to copy them from
240 # $(srcdir) to the build directory.
243 abs_builddir
:= $(shell pwd
)
244 test_files_src
:= $(wildcard $(srcdir)/sql
/*.sql
) $(wildcard $(srcdir)/expected
/*.out
) $(wildcard $(srcdir)/data
/*.data
)
245 test_files_build
:= $(patsubst $(srcdir)/%, $(abs_builddir
)/%, $(test_files_src
))
247 all: $(test_files_build
)
248 $(test_files_build
): $(abs_builddir
)/%: $(srcdir)/%
255 $(MAKE
) -C
$(top_builddir
)/src
/test/regress pg_regress
$(X
)
258 # against installed postmaster
259 installcheck: submake
260 $(top_builddir
)/src
/test/regress
/pg_regress
--psqldir
=$(PSQLDIR
) $(REGRESS_OPTS
) $(REGRESS
)
262 # in-tree test doesn't work yet (no way to install my shared library)
264 # $(top_builddir)/src/test/regress/pg_regress --temp-install \
265 # --top-builddir=$(top_builddir) $(REGRESS_OPTS) $(REGRESS)
267 @echo
"'make check' is not supported."
268 @echo
"Do 'make install', then 'make installcheck' instead."
274 ifneq (,$(MODULES
)$(MODULE_big
))
276 sed
's,MODULE_PATHNAME,$$libdir/$*,g' $< >$@
281 $(CC
) $(CFLAGS
) $(OBJS
) $(PG_LIBS
) $(LDFLAGS
) $(LIBS
) -o
$@