1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
# $PostgreSQL: pgsql/contrib/contrib-global.mk,v 1.7 2003/11/29 19:51:18 pgsql 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
|