]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
First pass at getting shared libraries on AIX properly built.
[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.17 1996/11/23 09:51:57 bryanh Exp $
38 #
39 #-------------------------------------------------------------------------
40
41 SRCDIR = ..
42 include ../Makefile.global
43
44 OBJS = access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o  \
45        commands/SUBSYS.o executor/SUBSYS.o  \
46        lib/SUBSYS.o libpq/SUBSYS.o main/SUBSYS.o nodes/SUBSYS.o \
47        optimizer/SUBSYS.o parser/SUBSYS.o port/SUBSYS.o \
48        postmaster/SUBSYS.o regex/SUBSYS.o rewrite/SUBSYS.o \
49        storage/SUBSYS.o tcop/SUBSYS.o utils/SUBSYS.o \
50        ../utils/version.o
51
52 ifdef TIOGA
53 OBJS += tioga/SUBSYS.o
54 endif
55
56 ifeq ($(MAKE_EXPORTS), true)
57 EXP = postgres$(EXPSUFF)
58 else
59 EXP =
60 endif
61
62 all: postgres $(EXP) global1.bki.source local1_template1.bki.source
63
64 postgres: postgres_group1 postgres_group2 postgres_group3 postgres_group4 
65         $(CC) $(LDFLAGS) -o postgres $(OBJS) $(LDADD)
66
67 postgres_group1:
68         $(MAKE) -C access     all   
69         $(MAKE) -C bootstrap  all   
70         $(MAKE) -C catalog    SUBSYS.o
71         $(MAKE) -C commands   all   
72 postgres_group2:
73         $(MAKE) -C executor   all   
74         $(MAKE) -C lib        all   
75         $(MAKE) -C libpq      all   
76         $(MAKE) -C main       all   
77         $(MAKE) -C nodes      all   
78 postgres_group3:
79         $(MAKE) -C optimizer  all   
80         $(MAKE) -C parser     all   
81         $(MAKE) -C port       all   PORTNAME=$(PORTNAME)
82         $(MAKE) -C postmaster all   
83         $(MAKE) -C regex      all   
84 postgres_group4:
85         $(MAKE) -C rewrite    all   
86         $(MAKE) -C storage    all   
87         $(MAKE) -C tcop       all   
88         $(MAKE) -C utils      all   
89 ifdef TIOGA
90         $(MAKE) -C tioga      all   
91 endif
92         $(MAKE) -C ../utils version.o        
93
94 global1.bki.source local1_template1.bki.source: 
95         $(MAKE) -C catalog $@
96         cp catalog/$@ .
97
98 # The postgres.o target is needed by the rule in Makefile.global that
99 # creates the exports file when MAKE_EXPORTS = true.
100 postgres.o: $(OBJS)
101         $(CC) $(LDFLAGS) -r -o postgres.o $(OBJS) $(LDADD)
102
103
104 ############################################################################
105 # The following targets are specified in make commands that appear in the
106 # make files in our subdirectories.
107
108 parse.h: 
109         $(MAKE) -C parser parse.h
110         cp parser/parse.h .
111
112 fmgr.h:
113         $(MAKE) -C utils fmgr.h
114         cp utils/fmgr.h .
115
116 #############################################################################
117 clean:
118         rm -f postgres fmgr.h parse.h \
119             global1.bki.source local1_template1.bki.source
120         $(MAKE) -C access     clean
121         $(MAKE) -C bootstrap  clean
122         $(MAKE) -C catalog    clean
123         $(MAKE) -C commands   clean
124         $(MAKE) -C executor   clean
125         $(MAKE) -C lib        clean
126         $(MAKE) -C libpq      clean
127         $(MAKE) -C main       clean
128         $(MAKE) -C nodes      clean
129         $(MAKE) -C optimizer  clean
130         $(MAKE) -C parser     clean
131         $(MAKE) -C port       clean   PORTNAME=$(PORTNAME)
132         $(MAKE) -C postmaster clean
133         $(MAKE) -C regex      clean
134         $(MAKE) -C rewrite    clean
135         $(MAKE) -C storage    clean
136         $(MAKE) -C tcop       clean
137         $(MAKE) -C utils      clean
138 ifdef TIOGA
139         $(MAKE) -C tioga      clean
140 endif
141
142 .DEFAULT:
143         $(MAKE) -C access     $@
144         $(MAKE) -C bootstrap  $@
145         $(MAKE) -C catalog    $@
146         $(MAKE) -C commands   $@
147         $(MAKE) -C executor   $@
148         $(MAKE) -C lib        $@
149         $(MAKE) -C libpq      $@
150         $(MAKE) -C main       $@
151         $(MAKE) -C nodes      $@
152         $(MAKE) -C optimizer  $@
153         $(MAKE) -C parser     $@
154         $(MAKE) -C port       $@  PORTNAME=$(PORTNAME)
155         $(MAKE) -C postmaster $@
156         $(MAKE) -C regex      $@
157         $(MAKE) -C rewrite    $@
158         $(MAKE) -C storage    $@
159         $(MAKE) -C tcop       $@
160         $(MAKE) -C utils      $@
161 ifdef TIOGA
162         $(MAKE) -C tioga      $@
163 endif
164
165
166 #############################################################################
167 #
168 # Installation.
169 #
170 # Install the backend program (postgres) to the binary directory and 
171 # make a link as "postmaster".  Install the bki files templates and sample 
172 # files to the library directory.
173 #
174 # (History:  Before Release 2, make install generated a bki.source file
175 # and then used build parameters to convert it to a bki file, then installed
176 # that bki file in the /files subdirectory of the default data directory.
177 # Initdb then used the bki file to generate the database catalog classes.
178 # That had to change because (1) there can be more than one database system,
179 # and (2) the parameters of a database system should be set at initdb time,
180 # not at postgres build time.
181
182 install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(EXP) fmgr.h\
183          global1.bki.source local1_template1.bki.source \
184          libpq/pg_hba.conf.sample 
185         
186         $(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
187 ifeq ($(MAKE_EXPORTS), true)
188         $(INSTALL) $(INSTLOPTS) postgres$(EXPSUFF) $(LIBDIR)/postgres$(EXPSUFF)
189 endif
190         @rm -f $(BINDIR)/postmaster
191         cd $(BINDIR); ln -s postgres postmaster
192         $(INSTALL) $(INSTLOPTS) fmgr.h $(HEADERDIR)/fmgr.h
193         $(INSTALL) $(INSTLOPTS) global1.bki.source \
194           $(LIBDIR)/global1.bki.source
195         $(INSTALL) $(INSTLOPTS) local1_template1.bki.source \
196           $(LIBDIR)/local1_template1.bki.source
197         $(INSTALL) $(INSTLOPTS) libpq/pg_hba.conf.sample \
198           $(LIBDIR)/pg_hba.conf.sample
199
200 $(BINDIR) $(LIBDIR) $(HEADERDIR): 
201         mkdir $@
202
203 #############################################################################
204 #
205 # Support for code development.
206 #
207 # Use target "quick" to build "postgres" when you know all the subsystems 
208 # are up to date.  It saves the time of doing all the submakes.
209 .PHONY: quick
210 quick: $(OBJS)
211         $(CC) $(LDFLAGS) -o postgres $(OBJS) $(LDADD)
212
213 #
214 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
215 #
216 IDFILE= ID
217 .PHONY: $(IDFILE)
218 $(IDFILE):
219         ./makeID $(PORTNAME)
220
221 #
222 # Special rule to generate cpp'd version of a .c file.  This is
223 # especially useful given all the hellish macro processing going on.
224 # The cpp'd version has a .C suffix.  To create foo.C from foo.c, just
225 # type
226 #       make foo.C
227 #
228 %.cpp:  %.c
229         $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \
230             > $(@F)