]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
Here's a patch that I discussed recently on pg95-dev that changes the
[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 #
9 # IDENTIFICATION
10 #    $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.7 1996/09/23 08:21:52 scrappy Exp $
11 #
12 #-------------------------------------------------------------------------
13
14 #
15 # The following turns on intermediate linking of partial objects to speed
16 # the link cycle during development. (To turn this off, put "BIGOBJS=false"
17 # in your custom makefile, ../Makefile.custom.)
18 BIGOBJS= true
19
20 PROG=   postgres global1.bki.source local1_template1.bki.source
21
22 MKDIR=  ../mk
23 include $(MKDIR)/postgres.mk
24
25 include $(CURDIR)/access/Makefile.inc
26 include $(CURDIR)/bootstrap/Makefile.inc
27 include $(CURDIR)/catalog/Makefile.inc
28 include $(CURDIR)/commands/Makefile.inc
29 include $(CURDIR)/executor/Makefile.inc
30 include $(CURDIR)/include/Makefile.inc
31 include $(CURDIR)/lib/Makefile.inc
32 include $(CURDIR)/libpq/Makefile.inc
33 include $(CURDIR)/main/Makefile.inc
34 include $(CURDIR)/nodes/Makefile.inc
35 include $(CURDIR)/optimizer/Makefile.inc
36 include $(CURDIR)/parser/Makefile.inc
37 include $(CURDIR)/port/Makefile.inc
38 include $(CURDIR)/postmaster/Makefile.inc
39 include $(CURDIR)/regex/Makefile.inc
40 include $(CURDIR)/rewrite/Makefile.inc
41 include $(CURDIR)/storage/Makefile.inc
42 include $(CURDIR)/tcop/Makefile.inc
43 include $(CURDIR)/tioga/Makefile.inc
44 include $(CURDIR)/utils/Makefile.inc
45
46 SRCS:=  ${SRCS_ACCESS} ${SRCS_BOOTSTRAP} $(SRCS_CATALOG) ${SRCS_COMMANDS} \
47         ${SRCS_EXECUTOR} $(SRCS_LIB) $(SRCS_LIBPQ) ${SRCS_MAIN} \
48         ${SRCS_NODES} ${SRCS_OPTIMIZER} ${SRCS_PARSER} ${SRCS_PORT} \
49         $(SRCS_POSTMASTER) ${SRCS_REGEX} ${SRCS_REWRITE} ${SRCS_STORAGE} \
50         ${SRCS_TCOP} ${SRCS_UTILS} 
51
52 ifeq ($(BIGOBJS), true)
53 OBJS= ACCESS.o BOOTSTRAP.o COMMANDS.o EXECUTOR.o MAIN.o MISC.o NODES.o \
54         PARSER.o OPTIMIZER.o REGEX.o REWRITE.o STORAGE.o TCOP.o UTILS.o
55 CLEANFILES+= $(subst .s,.o,$(SRCS:.c=.o)) $(OBJS)
56 else
57 OBJS:= $(subst .s,.o,$(SRCS:%.c=$(objdir)/%.o))
58 CLEANFILES+= $(notdir $(OBJS))
59 endif
60
61
62 #############################################################################
63 #
64 # TIOGA stuff
65 #
66 ifdef TIOGA
67 SRCS+= $(SRCS_TIOGA) 
68    ifeq ($(BIGOBJS), true)
69 TIOGA.o:        $(SRCS_TIOGA:%.c=$(objdir)/%.o)
70         $(make_partial)
71 OBJS+= TIOGA.o
72 CLEANFILES+= $(SRCS_TIOGA:%.c=%.o) TIOGA.o
73    else
74 OBJS+= $(SRCS_TIOGA:%.c=$(objdir)/%.o)
75    endif
76 endif
77
78
79 #############################################################################
80 #
81 # Compiling the postgres backend.
82 #
83 CFLAGS+=  -DPOSTGRESDIR='"$(POSTGRESDIR)"' \
84         -DPGDATADIR='"$(DATADIR)"' \
85         -I$(CURDIR)/$(objdir) \
86         -I$(CURDIR)/include \
87         -I$(CURDIR)/port/$(PORTNAME) \
88         -I../include
89
90 # turn this on if you prefer European style dates instead of American
91 # style dates
92 ifdef EUROPEAN_DATES
93 CFLAGS += -DEUROPEAN_STYLE
94 endif
95
96 # host based access flags
97 ifdef HBA
98 CFLAGS+= $(HBAFLAGS)
99 endif
100  
101 #
102 # All systems except NEXTSTEP require the math library.
103 # Loader flags for system-dependent libraries are appended in
104 #       src/backend/port/$(PORTNAME)/Makefile.inc
105 #
106 ifneq ($(PORTNAME), next)
107 LDADD+= -lm
108 endif
109
110 # kerberos flags
111 ifdef KRBVERS
112 CFLAGS+= $(KRBFLAGS)
113 LDADD+= $(KRBLIBS)
114 endif
115
116 # statically link in libc for linux
117 ifeq ($(PORTNAME), linux)
118 LDADD+= -lc
119 endif
120
121 # the following is special for Reliant UNIX SVR4 (formerly SINIX)
122 ifeq ($(PORTNAME), svr4)
123 LDFLAGS+= -LD-Blargedynsym
124 endif
125
126 postgres: $(POSTGRES_DEPEND) $(OBJS) $(EXPORTS)
127         $(CC) $(LDFLAGS) -o $(objdir)/$(@F) $(addprefix $(objdir)/,$(notdir $(OBJS))) $(LDADD)
128
129 # Make this target first if you are doing a parallel make.
130 # The targets in 'first' need to be made sequentially because of dependencies.
131 # Then, you can make 'all' with parallelism turned on.
132 first: $(POSTGRES_DEPEND)
133
134
135 #############################################################################
136 #
137 # Partial objects for platforms with slow linkers.
138 #
139 ifeq ($(BIGOBJS), true)
140
141 OBJS_ACCESS:=      $(SRCS_ACCESS:%.c=$(objdir)/%.o)
142 OBJS_BOOTSTRAP:=   $(SRCS_BOOTSTRAP:%.c=$(objdir)/%.o)
143 OBJS_CATALOG:=     $(SRCS_CATALOG:%.c=$(objdir)/%.o)
144 OBJS_COMMANDS:=    $(SRCS_COMMANDS:%.c=$(objdir)/%.o)
145 OBJS_EXECUTOR:=    $(SRCS_EXECUTOR:%.c=$(objdir)/%.o)
146 OBJS_MAIN:=        $(SRCS_MAIN:%.c=$(objdir)/%.o)
147 OBJS_POSTMASTER:=  $(SRCS_POSTMASTER:%.c=$(objdir)/%.o)
148 OBJS_LIB:=         $(SRCS_LIB:%.c=$(objdir)/%.o)
149 OBJS_LIBPQ:=       $(SRCS_LIBPQ:%.c=$(objdir)/%.o)
150 OBJS_PORT:=        $(addprefix $(objdir)/,$(subst .s,.o,$(SRCS_PORT:.c=.o)))
151 OBJS_NODES:=       $(SRCS_NODES:%.c=$(objdir)/%.o)
152 OBJS_PARSER:=      $(SRCS_PARSER:%.c=$(objdir)/%.o)
153 OBJS_OPTIMIZER:=   $(SRCS_OPTIMIZER:%.c=$(objdir)/%.o)
154 OBJS_REGEX:=       $(SRCS_REGEX:%.c=$(objdir)/%.o)
155 OBJS_REWRITE:=     $(SRCS_REWRITE:%.c=$(objdir)/%.o)
156 OBJS_STORAGE:=     $(SRCS_STORAGE:%.c=$(objdir)/%.o)
157 OBJS_TCOP:=        $(SRCS_TCOP:%.c=$(objdir)/%.o)
158 OBJS_UTILS:=       $(SRCS_UTILS:%.c=$(objdir)/%.o)
159
160 ACCESS.o:       $(OBJS_ACCESS)
161         $(make_partial)
162 BOOTSTRAP.o:    $(OBJS_BOOTSTRAP)
163         $(make_partial)
164 COMMANDS.o:     $(OBJS_COMMANDS)
165         $(make_partial)
166 EXECUTOR.o:     $(OBJS_EXECUTOR)
167         $(make_partial)
168 MAIN.o:         $(OBJS_MAIN) $(OBJS_POSTMASTER)
169         $(make_partial)
170 MISC.o:         $(OBJS_CATALOG) $(OBJS_LIB) $(OBJS_LIBPQ) $(OBJS_PORT)
171         $(make_partial)
172 NODES.o:        $(OBJS_NODES)
173         $(make_partial)
174 PARSER.o:       $(OBJS_PARSER)
175         $(make_partial)
176 OPTIMIZER.o:    $(OBJS_OPTIMIZER)
177         $(make_partial)
178 REGEX.o:        $(OBJS_REGEX)
179         $(make_partial)
180 REWRITE.o:      $(OBJS_REWRITE)
181         $(make_partial)
182 STORAGE.o:      $(OBJS_STORAGE)
183         $(make_partial)
184 TCOP.o:         $(OBJS_TCOP)
185         $(make_partial)
186 UTILS.o:        $(OBJS_UTILS)
187         $(make_partial)
188 endif
189
190 #############################################################################
191 #
192 # Installation.
193 #
194 # Install the backend program (postgres) to the binary directory and 
195 # make a link as "postmaster".  Install the bki files templates and sample 
196 # files to the library directory.
197 #
198 # (History:  Before Release 2, make install generated a bki.source file
199 # and then used build parameters to convert it to a bki file, then installed
200 # that bki file in the /files subdirectory of the default data directory.
201 # Initdb then used the bki file to generate the database catalog classes.
202 # That had to change because (1) there can be more than one database system,
203 # and (2) the parameters of a database system should be set at initdb time,
204 # not at postgres build time.
205
206 install: beforeinstall postgres fmgr.h\
207          global1.bki.source local1_template1.bki.source \
208          libpq/pg_hba.sample
209         
210         $(INSTALL) $(INSTL_EXE_OPTS) $(objdir)/postgres \
211           $(DESTDIR)$(BINDIR)/postgres
212         @rm -f $(DESTDIR)$(BINDIR)/postmaster
213         cd $(DESTDIR)$(BINDIR); ln -s postgres postmaster
214         $(INSTALL) $(INSTLOPTS) $(objdir)/fmgr.h $(HEADERDIR)/fmgr.h
215         $(INSTALL) $(INSTLOPTS) $(objdir)/global1.bki.source \
216           $(DESTDIR)$(LIBDIR)/global1.bki.source
217         $(INSTALL) $(INSTLOPTS) $(objdir)/local1_template1.bki.source \
218           $(DESTDIR)$(LIBDIR)/local1_template1.bki.source
219         $(INSTALL) $(INSTLOPTS) libpq/pg_hba.sample \
220           $(DESTDIR)$(LIBDIR)/pg_hba.sample
221
222 # so we can get the UID of the postgres owner (w/o moving pg_id to
223 # src/tools). We just want the vanilla LDFLAGS for pg_id
224 IDLDFLAGS:= $(LDFLAGS)
225 ifeq ($(PORTNAME), hpux)
226 ifeq ($(CC), cc)
227 IDLDFLAGS+= -Aa -D_HPUX_SOURCE
228 endif
229 endif
230
231 CLEANFILES+= postgres
232
233
234 #############################################################################
235 #
236 # Support for code development.
237 #
238
239 #
240 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
241 #
242 IDFILE= ID
243 .PHONY: $(IDFILE)
244 $(IDFILE):
245         $(CURDIR)/makeID $(PORTNAME)
246
247 #
248 # Special rule to generate cpp'd version of a .c file.  This is
249 # especially useful given all the hellish macro processing going on.
250 # The cpp'd version has a .C suffix.  To create foo.C from foo.c, just
251 # type
252 #       bmake foo.C
253 #
254 %.cpp:  %.c
255         $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' > $(objdir)/$(@F)
256
257 cppall: $(SRCS:.c=.cpp)
258
259 #
260 # To use Purify (SunOS only), define PURIFY to be the path (and
261 # options) with which to invoke the Purify loader.  Only the executable
262 # needs to be loaded with Purify.
263 #
264 # PURIFY = /usr/sww/bin/purify -cache-dir=/usr/local/postgres/src/backend/purify-cache
265 #.if defined(PURIFY)
266 #${PROG}: $(POSTGRES_DEPEND) $(OBJS) $(EXPORTS)
267 #       ${PURIFY} ${CC} ${LDFLAGS} -o $(objdir)/$(@F) $(addprefix $(objdir)/,$(notdir $(OBJS))) $(LDADD)
268 #
269 #CLEANFILES+= .purify* .pure .lock.*.o *_pure_*.o *.pure_*link*
270 #.endif
271