aboutsummaryrefslogtreecommitdiff
path: root/src/backend/Makefile
blob: 5fe2088a90b603d402de4045825479a75f7fde00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#-------------------------------------------------------------------------
#
# Makefile--
#   Makefile for the postgres backend (and the postmaster)
#
# Copyright (c) 1994, Regents of the University of California
#
# Functional notes:
#
#   Parallel make:  
#
#     This make file is set up so that you can do a parallel make (with 
#     the --jobs option of make) and make multiple subdirectories at 
#     once.  
#
#     However, the subdirectory make files are not so careful.
#     Normally, the --jobs option would get passed down to those
#     subdirectory makes, like any other make option, and they would
#     fail.  But there's a trick: Put a value (max number of
#     processes) on the --jobs option, e.g. --jobs=4.  Now, due to a
#     special feature of make, the --jobs option will not get passed
#     to the subdirectory makes.  (make does this because if you only
#     want 4 tasks running, then splitting the subdirectory makes into
#     multiple tasks would violate your wishes).
#
#
#
# Implementation notes:
#
#   We don't use $(LD) for linking.  We use $(CC) instead.  This is because
#   the $(CC) program apparently can do linking too, and it has certain
#   thinks like default options and search paths for libraries set up for 
#   it that the more primitive $(LD) doesn't have.
#
#
# IDENTIFICATION
#    $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.14 1996/11/03 09:05:30 bryanh Exp $
#
#-------------------------------------------------------------------------

SRCDIR = ..
include ../Makefile.global


##########################################################################
# Determine linker flags for this platform (mainly, the libraries with
# which to link).
##########################################################################

# All systems except NEXTSTEP require the math library.
# Loader flags for system-dependent libraries are appended in
#	src/backend/port/$(PORTNAME)/Makefile.inc
#
ifneq ($(PORTNAME), next)
LDADD+=	-lm
endif

ifeq ($(PORTNAME), aix)
LDADD+= -ll -lld
endif

ifeq ($(PORTNAME), alpha)
LDADD+= -lln
endif

ifeq ($(PORTNAME), bsdi)
  ifeq ($(PRE_BSDI_2_1), false)
    LDADD+= -ldl -lipc
  else
    LDADD+= -ldld -lipc
  endif
endif

ifeq ($(PORTNAME), hpux)
# HP-UX needs:
# -W l,-E	export symbols for linking with the shared libraries 
#		dynamic loader
# -W p,-H400000	expand cpp #define table size so the Nodes files don't 
#		break it
#
# -W p,-H400000
ifeq ($(CC), cc)
CFLAGS+= -W l,-E 
LDFLAGS+= -W l,-E
LDADD+= -ll -ldld
else
ifeq ($(CC), gcc)
LDADD+= -ll /usr/lib/libdld.sl
endif
endif
endif

ifeq ($(PORTNAME), i386_solaris)
LDADD+= -ll -ldl
endif

ifeq ($(PORTNAME), irix5)
LDADD+= -ll
endif

ifeq ($(PORTNAME), linux)
ifdef LINUX_ELF
LDADD+= -ldl
else
LDADD+= -ldld
endif
endif

ifeq ($(PORTNAME), sparc)
LDADD+= -lln -ldl
endif

ifeq ($(PORTNAME), sparc_solaris)
LDADD+= -ll -ldl
endif

ifeq ($(PORTNAME), svr4)
LDADD+= -ll -ldl
# the following is special for Reliant UNIX SVR4 (formerly SINIX)
LDFLAGS+= -LD-Blargedynsym
endif

ifeq ($(PORTNAME), ultrix4)
LDADD+= -ldl -lln
endif

#############################################################################

OBJS = access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o  \
       commands/SUBSYS.o executor/SUBSYS.o  \
       lib/SUBSYS.o libpq/SUBSYS.o main/SUBSYS.o nodes/SUBSYS.o \
       optimizer/SUBSYS.o parser/SUBSYS.o port/SUBSYS.o \
       postmaster/SUBSYS.o regex/SUBSYS.o rewrite/SUBSYS.o \
       storage/SUBSYS.o tcop/SUBSYS.o utils/SUBSYS.o

ifdef TIOGA
OBJS += tioga/SUBSYS.o
endif

all: postgres global1.bki.source local1_template1.bki.source

postgres: postgres_group1 postgres_group2 postgres_group3 postgres_group4
	$(CC) $(LDFLAGS) -o postgres $(OBJS) $(LDADD)

postgres_group1:
	$(MAKE) -C access     all   
	$(MAKE) -C bootstrap  all   
	$(MAKE) -C catalog    SUBSYS.o
	$(MAKE) -C commands   all   
postgres_group2:
	$(MAKE) -C executor   all   
	$(MAKE) -C lib        all   
	$(MAKE) -C libpq      all   
	$(MAKE) -C main       all   
	$(MAKE) -C nodes      all   
postgres_group3:
	$(MAKE) -C optimizer  all   
	$(MAKE) -C parser     all   
	$(MAKE) -C port       all   PORTNAME=$(PORTNAME)
	$(MAKE) -C postmaster all   
	$(MAKE) -C regex      all   
postgres_group4:
	$(MAKE) -C rewrite    all   
	$(MAKE) -C storage    all   
	$(MAKE) -C tcop       all   
	$(MAKE) -C utils      all   
ifdef TIOGA
	$(MAKE) -C tioga      all   
endif

global1.bki.source local1_template1.bki.source: 
	$(MAKE) -C catalog $@
	cp catalog/$@ .


############################################################################
# The following targets are specified in make commands that appear in the
# make files in our subdirectories.

parse.h: 
	$(MAKE) -C parser parse.h
	cp parser/parse.h .

fmgr.h:
	$(MAKE) -C utils fmgr.h
	cp utils/fmgr.h .

#############################################################################
clean:
	rm -f postgres fmgr.h parse.h \
	    global1.bki.source local1_template1.bki.source
	$(MAKE) -C access     clean
	$(MAKE) -C bootstrap  clean
	$(MAKE) -C catalog    clean
	$(MAKE) -C commands   clean
	$(MAKE) -C executor   clean
	$(MAKE) -C lib        clean
	$(MAKE) -C libpq      clean
	$(MAKE) -C main       clean
	$(MAKE) -C nodes      clean
	$(MAKE) -C optimizer  clean
	$(MAKE) -C parser     clean
	$(MAKE) -C port       clean   PORTNAME=$(PORTNAME)
	$(MAKE) -C postmaster clean
	$(MAKE) -C regex      clean
	$(MAKE) -C rewrite    clean
	$(MAKE) -C storage    clean
	$(MAKE) -C tcop       clean
	$(MAKE) -C utils      clean
ifdef TIOGA
	$(MAKE) -C tioga      clean
endif

.DEFAULT:
	$(MAKE) -C access     $@
	$(MAKE) -C bootstrap  $@
	$(MAKE) -C catalog    $@
	$(MAKE) -C commands   $@
	$(MAKE) -C executor   $@
	$(MAKE) -C lib        $@
	$(MAKE) -C libpq      $@
	$(MAKE) -C main       $@
	$(MAKE) -C nodes      $@
	$(MAKE) -C optimizer  $@
	$(MAKE) -C parser     $@
	$(MAKE) -C port       $@  PORTNAME=$(PORTNAME)
	$(MAKE) -C postmaster $@
	$(MAKE) -C regex      $@
	$(MAKE) -C rewrite    $@
	$(MAKE) -C storage    $@
	$(MAKE) -C tcop       $@
	$(MAKE) -C utils      $@
ifdef TIOGA
	$(MAKE) -C tioga      $@
endif


#############################################################################
#
# Installation.
#
# Install the backend program (postgres) to the binary directory and 
# make a link as "postmaster".  Install the bki files templates and sample 
# files to the library directory.
#
# (History:  Before Release 2, make install generated a bki.source file
# and then used build parameters to convert it to a bki file, then installed
# that bki file in the /files subdirectory of the default data directory.
# Initdb then used the bki file to generate the database catalog classes.
# That had to change because (1) there can be more than one database system,
# and (2) the parameters of a database system should be set at initdb time,
# not at postgres build time.

D_LIBDIR = $(DESTDIR)$(LIBDIR)
D_BINDIR = $(DESTDIR)$(BINDIR)

install: $(D_LIBDIR) $(D_BINDIR) $(HEADERDIR) postgres fmgr.h\
         global1.bki.source local1_template1.bki.source \
         libpq/pg_hba.conf.sample
	
	$(INSTALL) $(INSTL_EXE_OPTS) postgres $(D_BINDIR)/postgres
	@rm -f $(D_BINDIR)/postmaster
	cd $(D_BINDIR); ln -s postgres postmaster
	$(INSTALL) $(INSTLOPTS) fmgr.h $(HEADERDIR)/fmgr.h
	$(INSTALL) $(INSTLOPTS) global1.bki.source \
	  $(D_LIBDIR)/global1.bki.source
	$(INSTALL) $(INSTLOPTS) local1_template1.bki.source \
	  $(D_LIBDIR)/local1_template1.bki.source
	$(INSTALL) $(INSTLOPTS) libpq/pg_hba.conf.sample \
	  $(D_LIBDIR)/pg_hba.conf.sample

$(D_BINDIR) $(D_LIBDIR) $(HEADERDIR): 
	mkdir $@

#############################################################################
#
# Support for code development.
#
# Use target "quick" to build "postgres" when you know all the subsystems 
# are up to date.  It saves the time of doing all the submakes.
.PHONY: quick
quick: $(OBJS)
	$(CC) $(LDFLAGS) -o postgres $(OBJS) $(LDADD)

#
# Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
#
IDFILE=	ID
.PHONY: $(IDFILE)
$(IDFILE):
	./makeID $(PORTNAME)

#
# Special rule to generate cpp'd version of a .c file.  This is
# especially useful given all the hellish macro processing going on.
# The cpp'd version has a .C suffix.  To create foo.C from foo.c, just
# type
#	make foo.C
#
%.cpp:	%.c
	$(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \
	    > $(@F)