]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
Document and enforce that the usable range of setseed() arguments is
[postgresql] / src / backend / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for the postgres backend
4 #
5 # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
7 #
8 # $PostgreSQL: pgsql/src/backend/Makefile,v 1.127 2008/02/26 14:42:27 petere Exp $
9 #
10 #-------------------------------------------------------------------------
11
12 PGFILEDESC = "PostgreSQL Server"
13 subdir = src/backend
14 top_builddir = ../..
15 include $(top_builddir)/src/Makefile.global
16
17 SUBDIRS = access bootstrap catalog parser commands executor lib libpq \
18         main nodes optimizer port postmaster regex rewrite \
19         storage tcop tsearch utils $(top_builddir)/src/timezone
20
21 include $(srcdir)/common.mk
22
23 ifeq ($(enable_dtrace), yes)
24 LOCALOBJS += utils/probes.o
25 endif
26
27 OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
28
29 # We put libpgport into OBJS, so remove it from LIBS; also add libldap
30 LIBS := $(filter-out -lpgport, $(LIBS)) $(LDAP_LIBS_BE)
31
32 # The backend doesn't need everything that's in LIBS, however
33 LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
34
35 ##########################################################################
36
37 all: submake-libpgport postgres $(POSTGRES_IMP)
38
39 ifneq ($(PORTNAME), cygwin)
40 ifneq ($(PORTNAME), win32)
41 ifneq ($(PORTNAME), aix)
42
43 postgres: $(OBJS)
44         $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o $@
45
46 endif
47 endif
48 endif
49
50 ifeq ($(PORTNAME), cygwin)
51
52 postgres: $(OBJS) postgres.def libpostgres.a
53         $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
54         $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
55         $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
56         $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack,$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
57         rm -f $@.exp $@.base
58
59 postgres.def: $(OBJS)
60         $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
61
62 libpostgres.a: postgres.def
63         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
64
65 endif # cygwin
66
67 ifeq ($(PORTNAME), win32)
68 LIBS += -lsecur32
69
70 postgres: $(OBJS) postgres.def libpostgres.a $(WIN32RES)
71         $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
72         $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
73         $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
74         $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack=$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
75         rm -f $@.exp $@.base
76
77 postgres.def: $(OBJS)
78         $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
79
80 libpostgres.a: postgres.def
81         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
82
83 endif # win32
84
85 ifeq ($(PORTNAME), aix)
86
87 postgres: $(POSTGRES_IMP)
88         $(CC) $(CFLAGS) $(LDFLAGS) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
89
90 $(POSTGRES_IMP): $(OBJS)
91         $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(call expand_subsys,$^)
92 ifeq ($(host_os), aix3.2.5)
93         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
94 else
95 ifneq (,$(findstring aix4.1, $(host_os)))
96         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
97 else
98         $(MKLDEXPORT) SUBSYS.o . > $@
99 endif
100 endif
101         @rm -f SUBSYS.o
102
103 endif # aix
104
105 # Update the commonly used headers before building the subdirectories
106 $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
107
108
109 # The postgres.o target is needed by the rule in Makefile.global that
110 # creates the exports file when MAKE_EXPORTS = true.
111 postgres.o: $(OBJS)
112         $(CC) $(LDREL) $(LDFLAGS) $(call expand_subsys,$^) $(LIBS) -o $@
113
114
115 # The following targets are specified in make commands that appear in
116 # the make files in our subdirectories. Note that it's important we
117 # match the dependencies shown in the subdirectory makefiles!
118
119 $(srcdir)/parser/parse.h: parser/gram.y
120         $(MAKE) -C parser parse.h
121
122 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
123         $(MAKE) -C utils fmgroids.h
124
125 # Make symlinks for these headers in the include directory. That way
126 # we can cut down on the -I options. Also, a symlink is automatically
127 # up to date when we update the base file.
128
129 $(top_builddir)/src/include/parser/parse.h: $(srcdir)/parser/parse.h
130         prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
131           cd $(dir $@) && rm -f $(notdir $@) && \
132           $(LN_S) "$$prereqdir/$(notdir $<)" .
133
134 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
135         cd $(dir $@) && rm -f $(notdir $@) && \
136             $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
137
138
139 utils/probes.o: utils/probes.d $(SUBDIROBJS)
140         $(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@
141
142
143 ##########################################################################
144
145 distprep:
146         $(MAKE) -C parser       gram.c parse.h scan.c
147         $(MAKE) -C bootstrap    bootparse.c bootstrap_tokens.h bootscanner.c
148         $(MAKE) -C utils/misc   guc-file.c
149
150
151 ##########################################################################
152
153 install: all installdirs install-bin
154 ifeq ($(PORTNAME), cygwin)
155 ifeq ($(MAKE_DLL), true)
156         $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
157 endif
158 endif
159 ifeq ($(PORTNAME), win32)
160 ifeq ($(MAKE_DLL), true)
161         $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
162 endif
163 endif
164         $(MAKE) -C catalog install-data
165         $(MAKE) -C tsearch install-data
166         $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
167         $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
168         $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
169         $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
170
171 install-bin: postgres $(POSTGRES_IMP) installdirs
172         $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
173 ifneq ($(PORTNAME), win32)
174         @rm -f '$(DESTDIR)$(bindir)/postmaster$(X)'
175         ln -s postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
176 else
177         $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
178 endif
179 ifeq ($(MAKE_EXPORTS), true)
180         $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
181 endif
182
183 .PHONY: install-bin
184
185 installdirs:
186         $(mkinstalldirs) '$(DESTDIR)$(bindir)' '$(DESTDIR)$(datadir)'
187 ifeq ($(PORTNAME), cygwin)
188 ifeq ($(MAKE_DLL), true)
189         $(mkinstalldirs) '$(DESTDIR)$(libdir)'
190 endif
191 endif
192 ifeq ($(PORTNAME), win32)
193 ifeq ($(MAKE_DLL), true)
194         $(mkinstalldirs) '$(DESTDIR)$(libdir)'
195 endif
196 endif
197 ifeq ($(MAKE_EXPORTS), true)
198         $(mkinstalldirs) '$(DESTDIR)$(pkglibdir)'
199 endif
200
201
202 ##########################################################################
203
204 uninstall:
205         rm -f '$(DESTDIR)$(bindir)/postgres$(X)' '$(DESTDIR)$(bindir)/postmaster'
206 ifeq ($(MAKE_EXPORTS), true)
207         rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
208 endif
209 ifeq ($(PORTNAME), cygwin)
210 ifeq ($(MAKE_DLL), true)
211         rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
212 endif
213 endif
214 ifeq ($(PORTNAME), win32)
215 ifeq ($(MAKE_DLL), true)
216         rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
217 endif
218 endif
219         $(MAKE) -C catalog uninstall-data
220         $(MAKE) -C tsearch uninstall-data
221         rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \
222               '$(DESTDIR)$(datadir)/pg_ident.conf.sample' \
223               '$(DESTDIR)$(datadir)/postgresql.conf.sample' \
224               '$(DESTDIR)$(datadir)/recovery.conf.sample'
225
226
227 ##########################################################################
228
229 clean:
230         rm -f $(LOCALOBJS) postgres$(X) $(POSTGRES_IMP) \
231                 $(top_srcdir)/src/include/parser/parse.h \
232                 $(top_builddir)/src/include/utils/fmgroids.h
233 ifeq ($(PORTNAME), cygwin)
234         rm -f postgres.dll postgres.def libpostgres.a
235 endif
236 ifeq ($(PORTNAME), win32)
237         rm -f postgres.dll postgres.def libpostgres.a $(WIN32RES)
238 endif
239
240 distclean: clean
241         rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
242
243 maintainer-clean: distclean
244         rm -f $(srcdir)/bootstrap/bootparse.c \
245               $(srcdir)/bootstrap/bootscanner.c \
246               $(srcdir)/bootstrap/bootstrap_tokens.h \
247               $(srcdir)/parser/gram.c \
248               $(srcdir)/parser/scan.c \
249               $(srcdir)/parser/parse.h \
250               $(srcdir)/utils/misc/guc-file.c
251
252
253 ##########################################################################
254 #
255 # Support for code development.
256 #
257 # Use target "quick" to build "postgres" when you know all the subsystems 
258 # are up to date.  It saves the time of doing all the submakes.
259 .PHONY: quick
260 quick: $(OBJS)
261         $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o postgres