]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
Even compile generated .h files should be in ${SRCDIR}/include...
[postgresql] / 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 #   thinks 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.11 1996/10/31 07:25:15 scrappy Exp $
38 #
39 #-------------------------------------------------------------------------
40
41 SRCDIR = ..
42 include ../Makefile.global
43
44
45 ##########################################################################
46 # Determine linker flags for this platform (mainly, the libraries with
47 # which to link).
48 ##########################################################################
49
50 # All systems except NEXTSTEP require the math library.
51 # Loader flags for system-dependent libraries are appended in
52 #       src/backend/port/$(PORTNAME)/Makefile.inc
53 #
54 ifneq ($(PORTNAME), next)
55 LDADD+= -lm
56 endif
57
58 ifeq ($(PORTNAME), aix)
59 LDADD+= -ll -lld
60 endif
61
62 ifeq ($(PORTNAME), alpha)
63 LDADD+= -lln
64 endif
65
66 ifeq ($(PORTNAME), bsdi)
67 LDADD+= -ldld -lipc
68 endif
69
70 ifeq ($(PORTNAME), bsdi_2_1)
71 LDADD+= -ldl -lipc
72 endif
73
74 ifeq ($(PORTNAME), hpux)
75 # HP-UX needs:
76 # -W l,-E       export symbols for linking with the shared libraries 
77 #               dynamic loader
78 # -W p,-H400000 expand cpp #define table size so the Nodes files don't 
79 #               break it
80 #
81 # -W p,-H400000
82 ifeq ($(CC), cc)
83 CFLAGS+= -W l,-E 
84 LDFLAGS+= -W l,-E
85 LDADD+= -ll -ldld
86 else
87 ifeq ($(CC), gcc)
88 LDADD+= -ll /usr/lib/libdld.sl
89 endif
90 endif
91 endif
92
93 ifeq ($(PORTNAME), i386_solaris)
94 LDADD+= -ll -ldl
95 endif
96
97 ifeq ($(PORTNAME), irix5)
98 LDADD+= -ll
99 endif
100
101 ifeq ($(PORTNAME), linux)
102 ifdef LINUX_ELF
103 LDADD+= -ldl
104 else
105 LDADD+= -ldld
106 endif
107 endif
108
109 ifeq ($(PORTNAME), sparc)
110 LDADD+= -lln -ldl
111 endif
112
113 ifeq ($(PORTNAME), sparc_solaris)
114 LDADD+= -ll -ldl
115 endif
116
117 ifeq ($(PORTNAME), svr4)
118 LDADD+= -ll -ldl
119 # the following is special for Reliant UNIX SVR4 (formerly SINIX)
120 LDFLAGS+= -LD-Blargedynsym
121 endif
122
123 ifeq ($(PORTNAME), ultrix4)
124 LDADD+= -ldl -lln
125 endif
126
127 #############################################################################
128
129 OBJS = access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o  \
130        commands/SUBSYS.o executor/SUBSYS.o  \
131        lib/SUBSYS.o libpq/SUBSYS.o main/SUBSYS.o nodes/SUBSYS.o \
132        optimizer/SUBSYS.o parser/SUBSYS.o port/SUBSYS.o \
133        postmaster/SUBSYS.o regex/SUBSYS.o rewrite/SUBSYS.o \
134        storage/SUBSYS.o tcop/SUBSYS.o utils/SUBSYS.o
135
136 ifdef TIOGA
137 OBJS += tioga/SUBSYS.o
138 endif
139
140 all: postgres global1.bki.source local1_template1.bki.source
141
142 postgres: postgres_group1 postgres_group2 postgres_group3 postgres_group4
143         $(CC) $(LDFLAGS) -o postgres $(OBJS) $(LDADD)
144
145 postgres_group1:
146         $(MAKE) -C access     SUBSYS.o   
147         $(MAKE) -C bootstrap  SUBSYS.o   
148         $(MAKE) -C catalog    SUBSYS.o   
149         $(MAKE) -C commands   SUBSYS.o   
150 postgres_group2:
151         $(MAKE) -C executor   SUBSYS.o   
152         $(MAKE) -C lib        SUBSYS.o   
153         $(MAKE) -C libpq      SUBSYS.o   
154         $(MAKE) -C main       SUBSYS.o   
155         $(MAKE) -C nodes      SUBSYS.o   
156 postgres_group3:
157         $(MAKE) -C optimizer  SUBSYS.o   
158         $(MAKE) -C parser     SUBSYS.o   
159         $(MAKE) -C port       SUBSYS.o   PORTNAME=$(PORTNAME)
160         $(MAKE) -C postmaster SUBSYS.o   
161         $(MAKE) -C regex      SUBSYS.o   
162 postgres_group4:
163         $(MAKE) -C rewrite    SUBSYS.o   
164         $(MAKE) -C storage    SUBSYS.o   
165         $(MAKE) -C tcop       SUBSYS.o   
166         $(MAKE) -C utils      SUBSYS.o   
167 ifdef TIOGA
168         $(MAKE) -C tioga      SUBSYS.o   
169 endif
170
171 global1.bki.source local1_template1.bki.source: 
172         $(MAKE) -C catalog $@
173         cp catalog/$@ ../include
174
175
176 ############################################################################
177 # The following targets are specified in make commands that appear in the
178 # make files in our subdirectories.
179
180 parse.h: 
181         $(MAKE) -C parser parse.h
182         cp parser/parse.h ../include
183
184 fmgr.h:
185         $(MAKE) -C utils fmgr.h
186         cp utils/fmgr.h ../include
187
188 #############################################################################
189 clean:
190         rm -f postgres fmgr.h parse.h \
191             global1.bki.source local1_template1.bki.source
192         $(MAKE) -C access     clean
193         $(MAKE) -C bootstrap  clean
194         $(MAKE) -C catalog    clean
195         $(MAKE) -C commands   clean
196         $(MAKE) -C executor   clean
197         $(MAKE) -C lib        clean
198         $(MAKE) -C libpq      clean
199         $(MAKE) -C main       clean
200         $(MAKE) -C nodes      clean
201         $(MAKE) -C optimizer  clean
202         $(MAKE) -C parser     clean
203         $(MAKE) -C port       clean   PORTNAME=$(PORTNAME)
204         $(MAKE) -C postmaster clean
205         $(MAKE) -C regex      clean
206         $(MAKE) -C rewrite    clean
207         $(MAKE) -C storage    clean
208         $(MAKE) -C tcop       clean
209         $(MAKE) -C utils      clean
210 ifdef TIOGA
211         $(MAKE) -C tioga      clean
212 endif
213
214 .DEFAULT:
215         $(MAKE) -C access     $@
216         $(MAKE) -C bootstrap  $@
217         $(MAKE) -C catalog    $@
218         $(MAKE) -C commands   $@
219         $(MAKE) -C executor   $@
220         $(MAKE) -C lib        $@
221         $(MAKE) -C libpq      $@
222         $(MAKE) -C main       $@
223         $(MAKE) -C nodes      $@
224         $(MAKE) -C optimizer  $@
225         $(MAKE) -C parser     $@
226         $(MAKE) -C port       $@  PORTNAME=$(PORTNAME)
227         $(MAKE) -C postmaster $@
228         $(MAKE) -C regex      $@
229         $(MAKE) -C rewrite    $@
230         $(MAKE) -C storage    $@
231         $(MAKE) -C tcop       $@
232         $(MAKE) -C utils      $@
233 ifdef TIOGA
234         $(MAKE) -C tioga      $@
235 endif
236
237
238 #############################################################################
239 #
240 # Installation.
241 #
242 # Install the backend program (postgres) to the binary directory and 
243 # make a link as "postmaster".  Install the bki files templates and sample 
244 # files to the library directory.
245 #
246 # (History:  Before Release 2, make install generated a bki.source file
247 # and then used build parameters to convert it to a bki file, then installed
248 # that bki file in the /files subdirectory of the default data directory.
249 # Initdb then used the bki file to generate the database catalog classes.
250 # That had to change because (1) there can be more than one database system,
251 # and (2) the parameters of a database system should be set at initdb time,
252 # not at postgres build time.
253
254 D_LIBDIR = $(DESTDIR)$(LIBDIR)
255 D_BINDIR = $(DESTDIR)$(BINDIR)
256
257 install: $(D_LIBDIR) $(D_BINDIR) $(HEADERDIR) postgres fmgr.h\
258          global1.bki.source local1_template1.bki.source \
259          libpq/pg_hba.conf.sample
260         
261         $(INSTALL) $(INSTL_EXE_OPTS) postgres $(D_BINDIR)/postgres
262         @rm -f $(D_BINDIR)/postmaster
263         cd $(D_BINDIR); ln -s postgres postmaster
264         $(INSTALL) $(INSTLOPTS) fmgr.h $(HEADERDIR)/fmgr.h
265         $(INSTALL) $(INSTLOPTS) global1.bki.source \
266           $(D_LIBDIR)/global1.bki.source
267         $(INSTALL) $(INSTLOPTS) local1_template1.bki.source \
268           $(D_LIBDIR)/local1_template1.bki.source
269         $(INSTALL) $(INSTLOPTS) libpq/pg_hba.conf.sample \
270           $(D_LIBDIR)/pg_hba.conf.sample
271
272 $(D_BINDIR) $(D_LIBDIR) $(HEADERDIR): 
273         mkdir $@
274
275 #############################################################################
276 #
277 # Support for code development.
278 #
279
280 #
281 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
282 #
283 IDFILE= ID
284 .PHONY: $(IDFILE)
285 $(IDFILE):
286         ./makeID $(PORTNAME)
287
288 #
289 # Special rule to generate cpp'd version of a .c file.  This is
290 # especially useful given all the hellish macro processing going on.
291 # The cpp'd version has a .C suffix.  To create foo.C from foo.c, just
292 # type
293 #       make foo.C
294 #
295 %.cpp:  %.c
296         $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \
297             > $(@F)