1 #-------------------------------------------------------------------------
4 # Makefile for the postgres backend (and the postmaster)
6 # Copyright (c) 1994, Regents of the University of California
12 # This make file is set up so that you can do a parallel make (with
13 # the --jobs option of make) and make multiple subdirectories at
16 # However, the subdirectory make files are not so careful.
17 # Normally, the --jobs option would get passed down to those
18 # subdirectory makes, like any other make option, and they would
19 # fail. But there's a trick: Put a value (max number of
20 # processes) on the --jobs option, e.g. --jobs=4. Now, due to a
21 # special feature of make, the --jobs option will not get passed
22 # to the subdirectory makes. (make does this because if you only
23 # want 4 tasks running, then splitting the subdirectory makes into
24 # multiple tasks would violate your wishes).
28 # Implementation notes:
30 # We don't use $(LD) for linking. We use $(CC) instead. This is because
31 # the $(CC) program apparently can do linking too, and it has certain
32 # things like default options and search paths for libraries set up for
33 # it that the more primitive $(LD) doesn't have.
37 # $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.50 2000/05/29 20:51:35 tgl Exp $
39 #-------------------------------------------------------------------------
42 include $(SRCDIR)/Makefile.global
44 DIRS = access bootstrap catalog commands executor lib libpq \
45 main parser nodes optimizer port postmaster regex rewrite \
52 OBJS = $(DIRS:%=%/SUBSYS.o)
54 ifeq ($(PORTNAME), qnx4)
55 # This file crashes qnx4's wlink and is therefore not in bootstrap/SUBSYS.o
56 # on that platform. (Wotta hack ... is it still necessary?)
57 OBJS+= bootstrap/bootstrap.o
60 VERSIONOBJ = $(SRCDIR)/utils/version.o
69 ifeq ($(MAKE_DLL), true)
70 DLLOBJS= $(OBJS) $(VERSIONOBJ)
71 DLLLIBS= -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32
73 postgres.def: $(DLLOBJS)
74 $(DLLTOOL) --export-all --output-def $@ $(DLLOBJS)
76 libpostgres.a: $(DLLOBJS) $(SRCDIR)/utils/dllinit.o postgres.def
77 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
80 all: prebuildheaders postgres $(POSTGRES_IMP) \
81 global1.bki.source local1_template1.bki.source \
82 global1.description local1_template1.description
84 ifneq ($(PORTNAME), win)
86 postgres: $(OBJS) $(VERSIONOBJ)
87 $(CC) $(CFLAGS) -o postgres $(OBJS) $(VERSIONOBJ) $(LDFLAGS)
91 postgres: $(DLLOBJS) $(SRCDIR)/utils/dllinit.o postgres.def libpostgres.a
92 dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def
93 gcc -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(DLLOBJS) $(DLLLIBS)
94 dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
95 gcc -g -o $@$(X) $@.exp $(DLLOBJS) $(DLLLIBS)
100 $(OBJS): $(DIRS:%=%.dir)
103 $(MAKE) -C $(subst .dir,,$@) all
105 $(VERSIONOBJ): $(SRCDIR)/utils/version.c $(SRCDIR)/include/version.h
106 $(MAKE) -C $(SRCDIR)/utils version.o
108 $(SRCDIR)/utils/dllinit.o: $(SRCDIR)/utils/dllinit.c
109 $(MAKE) -C $(SRCDIR)/utils dllinit.o
111 global1.bki.source local1_template1.bki.source \
112 global1.description local1_template1.description: catalog/$@
115 catalog/global1.bki.source catalog/local1_template1.bki.source \
116 catalog/global1.description catalog/local1_template1.description:
117 $(MAKE) -C catalog $@
119 # The postgres.o target is needed by the rule in Makefile.global that
120 # creates the exports file when MAKE_EXPORTS = true.
122 $(CC) $(LDREL) $(LDOUT) postgres.o $(OBJS) $(LDFLAGS)
124 # These header files should be up-to-date before we do much else...
125 .PHONY: prebuildheaders
127 prebuildheaders: $(SRCDIR)/include/parser/parse.h \
128 $(SRCDIR)/include/utils/fmgroids.h
130 ############################################################################
131 # The following targets are specified in make commands that appear in the
132 # make files in our subdirectories. Note that it's important we match the
133 # dependencies shown in the subdirectory makefiles!
135 $(SRCDIR)/include/parser/parse.h: parser/parse.h
136 cp parser/parse.h $(SRCDIR)/include/parser
138 parser/parse.h: parser/gram.y
139 $(MAKE) -C parser parse.h
141 $(SRCDIR)/include/utils/fmgroids.h: utils/fmgroids.h
142 cp utils/fmgroids.h $(SRCDIR)/include/utils
144 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h
145 $(MAKE) -C utils fmgroids.h
147 #############################################################################
149 rm -f postgres$(X) $(POSTGRES_IMP) \
150 $(SRCDIR)/include/parser/parse.h \
151 $(SRCDIR)/include/utils/fmgroids.h \
152 global1.bki.source local1_template1.bki.source \
153 global1.description local1_template1.description
154 ifeq ($(PORTNAME), win)
155 ifeq ($(MAKE_DLL), true)
156 rm -f postgres.dll postgres.def libpostgres.a
159 for i in $(DIRS); do $(MAKE) -C $$i clean; done
161 depend dep: prebuildheaders
162 for i in $(DIRS); do $(MAKE) -C $$i $@; done
165 for i in $(DIRS); do $(MAKE) -C $$i $@; done
167 #############################################################################
171 # Install the backend program (postgres) to the binary directory and
172 # make a link as "postmaster". Install the bki files, templates, and sample
173 # files to the library directory. Install exported headers to the include
174 # directory (these headers are the minimal ones needed to build loadable
175 # backend extensions).
177 # (History: Before Release 2, make install generated a bki.source file
178 # and then used build parameters to convert it to a bki file, then installed
179 # that bki file in the /files subdirectory of the default data directory.
180 # Initdb then used the bki file to generate the database catalog classes.
181 # That had to change because (1) there can be more than one database system,
182 # and (2) the parameters of a database system should be set at initdb time,
183 # not at postgres build time.
185 .PHONY: install install-bin install-templates install-headers
187 install: $(LIBDIR) $(BINDIR) $(HEADERDIR) $(TEMPLATEDIR) \
188 postgres $(POSTGRES_IMP) \
189 install-bin install-templates install-headers
191 install-bin: $(BINDIR) postgres$(X) $(POSTGRES_IMP)
192 $(INSTALL) $(INSTL_EXE_OPTS) postgres$(X) $(BINDIR)/postgres$(X)
193 @rm -f $(BINDIR)/postmaster
194 ln -s postgres$(X) $(BINDIR)/postmaster
195 ifeq ($(MAKE_EXPORTS), true)
196 $(INSTALL) $(INSTLOPTS) $(POSTGRES_IMP) $(LIBDIR)/$(POSTGRES_IMP)
198 ifeq ($(PORTNAME), win)
199 ifeq ($(MAKE_DLL), true)
200 # $(INSTALL) $(INSTLOPTS) postgres.dll $(BINDIR)/postgres.dll
201 $(INSTALL) $(INSTLOPTS) libpostgres.a $(LIBDIR)/libpostgres.a
205 install-templates: $(TEMPLATEDIR) \
206 global1.bki.source local1_template1.bki.source \
207 global1.description local1_template1.description \
208 libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample \
210 $(INSTALL) $(INSTLOPTS) global1.bki.source \
211 $(TEMPLATEDIR)/global1.bki.source
212 $(INSTALL) $(INSTLOPTS) global1.description \
213 $(TEMPLATEDIR)/global1.description
214 $(INSTALL) $(INSTLOPTS) local1_template1.bki.source \
215 $(TEMPLATEDIR)/local1_template1.bki.source
216 $(INSTALL) $(INSTLOPTS) local1_template1.description \
217 $(TEMPLATEDIR)/local1_template1.description
218 $(INSTALL) $(INSTLOPTS) libpq/pg_hba.conf.sample \
219 $(TEMPLATEDIR)/pg_hba.conf.sample
220 $(INSTALL) $(INSTLOPTS) optimizer/geqo/pg_geqo.sample \
221 $(TEMPLATEDIR)/pg_geqo.sample
222 $(INSTALL) $(INSTLOPTS) pg_options.sample \
223 $(TEMPLATEDIR)/pg_options.sample
225 install-headers: prebuildheaders $(SRCDIR)/include/config.h
226 -@if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi
227 -@if [ ! -d $(HEADERDIR)/port ]; then mkdir $(HEADERDIR)/port; fi
228 -@if [ ! -d $(HEADERDIR)/port/$(PORTNAME) ]; \
229 then mkdir $(HEADERDIR)/port/$(PORTNAME); fi
230 -@if [ ! -d $(HEADERDIR)/lib ]; \
231 then mkdir $(HEADERDIR)/lib; fi
232 -@if [ ! -d $(HEADERDIR)/libpq ]; \
233 then mkdir $(HEADERDIR)/libpq; fi
234 -@if [ ! -d $(HEADERDIR)/utils ]; \
235 then mkdir $(HEADERDIR)/utils; fi
236 -@if [ ! -d $(HEADERDIR)/access ]; \
237 then mkdir $(HEADERDIR)/access; fi
238 -@if [ ! -d $(HEADERDIR)/executor ]; \
239 then mkdir $(HEADERDIR)/executor; fi
240 -@if [ ! -d $(HEADERDIR)/commands ]; \
241 then mkdir $(HEADERDIR)/commands; fi
242 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/os.h \
244 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/config.h \
245 $(HEADERDIR)/config.h
246 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/c.h \
248 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/postgres.h \
249 $(HEADERDIR)/postgres.h
250 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/postgres_ext.h \
251 $(HEADERDIR)/postgres_ext.h
252 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/fmgr.h \
254 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/libpq/pqcomm.h \
255 $(HEADERDIR)/libpq/pqcomm.h
256 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/libpq/libpq-fs.h \
257 $(HEADERDIR)/libpq/libpq-fs.h
258 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/lib/dllist.h \
259 $(HEADERDIR)/lib/dllist.h
260 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/utils/geo_decls.h \
261 $(HEADERDIR)/utils/geo_decls.h
262 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/utils/elog.h \
263 $(HEADERDIR)/utils/elog.h
264 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/utils/fmgroids.h \
265 $(HEADERDIR)/utils/fmgroids.h
266 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/utils/palloc.h \
267 $(HEADERDIR)/utils/palloc.h
268 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/utils/mcxt.h \
269 $(HEADERDIR)/utils/mcxt.h
270 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/access/attnum.h \
271 $(HEADERDIR)/access/attnum.h
272 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/executor/spi.h \
273 $(HEADERDIR)/executor/spi.h
274 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/commands/trigger.h \
275 $(HEADERDIR)/commands/trigger.h
276 ifeq ($(PORTNAME), hpux)
277 # is this still necessary?
278 $(INSTALL) $(INSTLOPTS) $(SRCDIR)/backend/port/hpux/fixade.h \
279 $(HEADERDIR)/port/hpux/fixade.h
291 # TEMPLATEDIR is commonly the same as LIBDIR, but it might be different.
292 # We don't want duplicate rules if they are the same.
293 ifneq ($(TEMPLATEDIR),$(LIBDIR))
301 #############################################################################
303 # Support for code development.
305 # Use target "quick" to build "postgres" when you know all the subsystems
306 # are up to date. It saves the time of doing all the submakes.
309 $(CC) -o postgres $(OBJS) $(LDFLAGS)
312 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
320 # Special rule to generate cpp'd version of a .c file. This is
321 # especially useful given all the hellish macro processing going on.
322 # The cpp'd version has a .C suffix. To create foo.C from foo.c, just
327 $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \