OSDN Git Service

Neglected to add fmgr.h to set of installed headers...
[pg-rex/syncrep.git] / src / backend / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile--
4 #   Makefile for the postgres backend (and the postmaster)
5 #
6 # Copyright (c) 1994, Regents of the University of California
7 #
8 # Functional notes:
9 #
10 #   Parallel make:  
11 #
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 
14 #     once.  
15 #
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).
25 #
26 #
27 #
28 # Implementation notes:
29 #
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.
34 #
35 #
36 # IDENTIFICATION
37 #    $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.50 2000/05/29 20:51:35 tgl Exp $
38 #
39 #-------------------------------------------------------------------------
40
41 SRCDIR = ..
42 include $(SRCDIR)/Makefile.global
43
44 DIRS = access bootstrap catalog commands executor lib libpq \
45         main parser nodes optimizer port postmaster regex rewrite \
46         storage tcop utils
47
48 ifdef TIOGA
49 DIRS += tioga
50 endif
51
52 OBJS = $(DIRS:%=%/SUBSYS.o)
53
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
58 endif
59
60 VERSIONOBJ = $(SRCDIR)/utils/version.o
61
62 # kerberos flags
63
64 ifdef KRBVERS
65 CFLAGS+= $(KRBFLAGS)
66 LDFLAGS+= $(KRBLIBS)
67 endif
68
69 ifeq ($(MAKE_DLL), true)
70 DLLOBJS= $(OBJS) $(VERSIONOBJ)
71 DLLLIBS= -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32
72
73 postgres.def: $(DLLOBJS)
74         $(DLLTOOL) --export-all --output-def $@ $(DLLOBJS)
75
76 libpostgres.a: $(DLLOBJS) $(SRCDIR)/utils/dllinit.o postgres.def
77         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
78 endif
79
80 all: prebuildheaders postgres $(POSTGRES_IMP) \
81                 global1.bki.source local1_template1.bki.source \
82                 global1.description local1_template1.description
83
84 ifneq ($(PORTNAME), win)
85
86 postgres: $(OBJS) $(VERSIONOBJ)
87         $(CC) $(CFLAGS) -o postgres $(OBJS) $(VERSIONOBJ) $(LDFLAGS)
88
89 else
90
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)
96         rm $@.exp $@.base
97
98 endif
99
100 $(OBJS): $(DIRS:%=%.dir)
101
102 $(DIRS:%=%.dir):
103         $(MAKE) -C $(subst .dir,,$@) all 
104
105 $(VERSIONOBJ): $(SRCDIR)/utils/version.c $(SRCDIR)/include/version.h
106         $(MAKE) -C $(SRCDIR)/utils version.o
107
108 $(SRCDIR)/utils/dllinit.o: $(SRCDIR)/utils/dllinit.c
109         $(MAKE) -C $(SRCDIR)/utils dllinit.o
110
111 global1.bki.source local1_template1.bki.source \
112 global1.description local1_template1.description: catalog/$@
113         cp catalog/$@ .
114
115 catalog/global1.bki.source catalog/local1_template1.bki.source \
116 catalog/global1.description catalog/local1_template1.description:
117         $(MAKE) -C catalog $@
118
119 # The postgres.o target is needed by the rule in Makefile.global that
120 # creates the exports file when MAKE_EXPORTS = true.
121 postgres.o: $(OBJS)
122         $(CC) $(LDREL) $(LDOUT) postgres.o $(OBJS) $(LDFLAGS)
123
124 # These header files should be up-to-date before we do much else...
125 .PHONY: prebuildheaders
126
127 prebuildheaders: $(SRCDIR)/include/parser/parse.h \
128                 $(SRCDIR)/include/utils/fmgroids.h
129
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!
134
135 $(SRCDIR)/include/parser/parse.h: parser/parse.h
136         cp parser/parse.h $(SRCDIR)/include/parser
137
138 parser/parse.h: parser/gram.y
139         $(MAKE) -C parser parse.h
140
141 $(SRCDIR)/include/utils/fmgroids.h: utils/fmgroids.h
142         cp utils/fmgroids.h $(SRCDIR)/include/utils
143
144 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(SRCDIR)/include/catalog/pg_proc.h
145         $(MAKE) -C utils fmgroids.h
146
147 #############################################################################
148 clean:
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
157 endif
158 endif
159         for i in $(DIRS); do $(MAKE) -C $$i clean; done
160
161 depend dep: prebuildheaders
162         for i in $(DIRS); do $(MAKE) -C $$i $@; done
163
164 .DEFAULT:
165         for i in $(DIRS); do $(MAKE) -C $$i $@; done
166
167 #############################################################################
168 #
169 # Installation.
170 #
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).
176 #
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.
184
185 .PHONY: install install-bin install-templates install-headers
186
187 install: $(LIBDIR) $(BINDIR) $(HEADERDIR) $(TEMPLATEDIR) \
188          postgres $(POSTGRES_IMP) \
189          install-bin install-templates install-headers
190
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)
197 endif
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
202 endif
203 endif
204
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 \
209          pg_options.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
224
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 \
243           $(HEADERDIR)/os.h
244         $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/config.h \
245           $(HEADERDIR)/config.h
246         $(INSTALL) $(INSTLOPTS) $(SRCDIR)/include/c.h \
247           $(HEADERDIR)/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 \
253           $(HEADERDIR)/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
280 endif
281
282 $(BINDIR):
283         mkdir $@
284
285 $(LIBDIR):
286         mkdir $@
287
288 $(HEADERDIR):
289         mkdir $@
290
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))
294
295 $(TEMPLATEDIR):
296         mkdir $@
297
298 endif
299
300
301 #############################################################################
302 #
303 # Support for code development.
304 #
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.
307 .PHONY: quick
308 quick: $(OBJS)
309         $(CC) -o postgres $(OBJS) $(LDFLAGS)
310
311 #
312 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
313 #
314 IDFILE= ID
315 .PHONY: $(IDFILE)
316 $(IDFILE):
317         ./makeID 
318
319 #
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
323 # type
324 #       make foo.C
325 #
326 %.cpp:  %.c
327         $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \
328             > $(@F)