]> granicus.if.org Git - postgresql/blob - contrib/contrib-global.mk
Avoid PQisBusy/PQconsumeInput busy loop in case of PQisBusy returning
[postgresql] / contrib / contrib-global.mk
1 # $Header: /cvsroot/pgsql/contrib/contrib-global.mk,v 1.3 2002/09/05 18:28:45 petere Exp $
2
3 # This file contains generic rules to build many kinds of simple
4 # contrib modules.  You only need to set a few variables and include
5 # this file, the rest will be done here.
6 #
7 # Use the following layout for your Makefile:
8 #
9 #   subdir = contrib/xxx
10 #   top_builddir = ../..
11 #   include $(top_builddir)/src/Makefile.global
12 #
13 #   [variable assignments, see below]
14 #   [custom rules, rarely necessary]
15 #
16 #   include $(top_srcdir)/contrib/contrib-global.mk
17 #
18 # The following variables can be set:
19 #
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 #   DOCS -- random files to install under $PREFIX/doc/contrib
26 #   SCRIPTS -- script files (not binaries) to install into $PREFIX/bin
27 #   REGRESS -- list of regression test cases (without suffix)
28 #
29 # or at most one of these two:
30 #
31 #   PROGRAM -- a binary program to build (list objects files in OBJS)
32 #   MODULE_big -- a shared object to build (list object files in OBJS)
33 #
34 # The following can also be set:
35 #
36 #   EXTRA_CLEAN -- extra files to remove in 'make clean'
37 #   PG_CPPFLAGS -- will be added to CPPFLAGS
38 #   PG_LIBS -- will be added to PROGRAM link line
39 #   SHLIB_LINK -- will be added to MODULE_big link line
40 #
41 # Better look at some of the existing uses for examples...
42
43
44 override CPPFLAGS := -I$(srcdir) $(CPPFLAGS)
45
46 ifdef MODULES
47 override CFLAGS += $(CFLAGS_SL)
48 SHLIB_LINK += $(BE_DLLLIBS)
49 endif
50
51 ifdef PG_CPPFLAGS
52 override CPPFLAGS := $(PG_CPPFLAGS) $(CPPFLAGS)
53 endif
54
55 all: $(PROGRAM) $(DATA_built) $(addsuffix $(DLSUFFIX), $(MODULES))
56
57 ifdef MODULE_big
58 # shared library parameters
59 NAME = $(MODULE_big)
60 SO_MAJOR_VERSION= 0
61 SO_MINOR_VERSION= 0
62 rpath =
63
64 SHLIB_LINK += $(BE_DLLLIBS)
65
66 include $(top_srcdir)/src/Makefile.shlib
67
68 all: all-lib
69 endif # MODULE_big
70
71
72 install: all installdirs
73 ifneq (,$(DATA)$(DATA_built))
74         @for file in $(addprefix $(srcdir)/, $(DATA)) $(DATA_built); do \
75           echo "$(INSTALL_DATA) $$file $(DESTDIR)$(datadir)/contrib"; \
76           $(INSTALL_DATA) $$file $(DESTDIR)$(datadir)/contrib; \
77         done
78 endif # DATA
79 ifdef MODULES
80         @for file in $(addsuffix $(DLSUFFIX), $(MODULES)); do \
81           echo "$(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir)"; \
82           $(INSTALL_SHLIB) $$file $(DESTDIR)$(pkglibdir); \
83         done
84 endif # MODULES
85 ifdef DOCS
86         @for file in $(addprefix $(srcdir)/, $(DOCS)); do \
87           echo "$(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/contrib"; \
88           $(INSTALL_DATA) $$file $(DESTDIR)$(docdir)/contrib; \
89         done
90 endif # DOCS
91 ifdef PROGRAM
92         $(INSTALL_PROGRAM) $(PROGRAM)$(X) $(DESTDIR)$(bindir)
93 endif # PROGRAM
94 ifdef MODULE_big
95         $(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
96 endif # MODULE_big
97 ifdef SCRIPTS
98         @for file in $(addprefix $(srcdir)/, $(SCRIPTS)); do \
99           echo "$(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir)"; \
100           $(INSTALL_SCRIPT) $$file $(DESTDIR)$(bindir); \
101         done
102 endif # SCRIPTS
103
104
105 installdirs:
106 ifneq (,$(DATA)$(DATA_built))
107         $(mkinstalldirs) $(DESTDIR)$(datadir)/contrib
108 endif
109 ifneq (,$(MODULES)$(MODULE_big))
110         $(mkinstalldirs) $(DESTDIR)$(pkglibdir)
111 endif
112 ifdef DOCS
113         $(mkinstalldirs) $(DESTDIR)$(docdir)/contrib
114 endif
115 ifneq (,$(PROGRAM)$(SCRIPTS))
116         $(mkinstalldirs) $(DESTDIR)$(bindir)
117 endif
118
119
120 uninstall:
121 ifneq (,$(DATA)$(DATA_built))
122         rm -f $(addprefix $(DESTDIR)$(datadir)/contrib/, $(DATA) $(DATA_built))
123 endif
124 ifdef MODULES
125         rm -f $(addprefix $(DESTDIR)$(pkglibdir)/, $(addsuffix $(DLSUFFIX), $(MODULES)))
126 endif
127 ifdef DOCS
128         rm -f $(addprefix $(DESTDIR)$(docdir)/contrib/, $(DOCS))
129 endif
130 ifdef PROGRAM
131         rm -f $(DESTDIR)$(bindir)/$(PROGRAM)$(X)
132 endif
133 ifdef MODULE_big
134         rm -f $(DESTDIR)$(pkglibdir)/$(MODULE_big)$(DLSUFFIX)
135 endif
136 ifdef SCRIPTS
137         rm -f $(addprefix $(DESTDIR)$(bindir)/, $(SCRIPTS))
138 endif
139
140
141 clean:
142 ifdef MODULES
143         rm -f $(addsuffix $(DLSUFFIX), $(MODULES)) $(addsuffix .o, $(MODULES))
144 endif
145 ifdef DATA_built
146         rm -f $(DATA_built)
147 endif
148 ifdef PROGRAM
149         rm -f $(PROGRAM)$(X)
150 endif
151 ifdef OBJS
152         rm -f $(OBJS)
153 endif
154 ifdef EXTRA_CLEAN
155         rm -f $(EXTRA_CLEAN)
156 endif
157 ifdef REGRESS
158 # things created by various check targets
159         rm -rf results tmp_check log
160         rm -f regression.diffs regression.out regress.out run_check.out
161 ifeq ($(PORTNAME), win)
162         rm -f regress.def
163 endif
164 endif # REGRESS
165
166 ifdef MODULE_big
167 clean: clean-lib
168 endif
169
170 distclean maintainer-clean: clean
171
172
173 ifdef REGRESS
174 .PHONY: submake
175 submake:
176         $(MAKE) -C $(top_builddir)/src/test/regress pg_regress
177
178 # against installed postmaster
179 installcheck: submake
180         $(top_builddir)/src/test/regress/pg_regress $(REGRESS)
181
182 # in-tree test doesn't work yet (no way to install my shared library)
183 #check: all submake
184 #       $(top_builddir)/src/test/regress/pg_regress --temp-install \
185 #         --top-builddir=$(top_builddir) $(REGRESS)
186 check:
187         @echo "'make check' is not supported."
188         @echo "Do 'make install', then 'make installcheck' instead."
189 endif # REGRESS
190
191
192 # STANDARD RULES
193
194 ifneq (,$(MODULES)$(MODULE_big))
195 %.sql: %.sql.in
196         sed 's,MODULE_PATHNAME,$$libdir/$*,g' $< >$@
197 endif
198
199 ifdef PROGRAM
200 $(PROGRAM): $(OBJS)
201         $(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LIBS) -o $@
202 endif