]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
Support unlogged tables.
[postgresql] / src / backend / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for the postgres backend
4 #
5 # Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
7 #
8 # src/backend/Makefile
9 #
10 #-------------------------------------------------------------------------
11
12 PGFILEDESC = "PostgreSQL Server"
13 # This is a daemon process, which is why it is not labeled as an executable
14 #PGAPPICON=win32
15
16 subdir = src/backend
17 top_builddir = ../..
18 include $(top_builddir)/src/Makefile.global
19
20 SUBDIRS = access bootstrap catalog parser commands executor foreign lib libpq \
21         main nodes optimizer port postmaster regex replication rewrite \
22         storage tcop tsearch utils $(top_builddir)/src/timezone
23
24 include $(srcdir)/common.mk
25
26 # As of 1/2010:
27 # The probes.o file is necessary for dtrace support on Solaris, and on recent
28 # versions of systemtap.  (Older systemtap releases just produce an empty
29 # file, but that's okay.)  However, OS X's dtrace doesn't use it and doesn't
30 # even recognize the -G option.  So, build probes.o except on Darwin.
31 # This might need adjustment as other platforms add dtrace support.
32 ifneq ($(PORTNAME), darwin)
33 ifeq ($(enable_dtrace), yes)
34 LOCALOBJS += utils/probes.o
35 endif
36 endif
37
38 OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
39
40 # We put libpgport into OBJS, so remove it from LIBS; also add libldap
41 LIBS := $(filter-out -lpgport, $(LIBS)) $(LDAP_LIBS_BE)
42
43 # The backend doesn't need everything that's in LIBS, however
44 LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
45
46 ##########################################################################
47
48 all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
49
50 ifneq ($(PORTNAME), cygwin)
51 ifneq ($(PORTNAME), win32)
52 ifneq ($(PORTNAME), aix)
53
54 postgres: $(OBJS)
55         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o $@
56
57 endif
58 endif
59 endif
60
61 ifeq ($(PORTNAME), cygwin)
62
63 postgres: $(OBJS) postgres.def libpostgres.a
64         $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
65         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
66         $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
67         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack,$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(LIBS)
68         rm -f $@.exp $@.base
69
70 postgres.def: $(OBJS)
71         $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
72
73 libpostgres.a: postgres.def
74         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
75
76 endif # cygwin
77
78 ifeq ($(PORTNAME), win32)
79 LIBS += -lsecur32
80
81 postgres: $(OBJS) postgres.def libpostgres.a $(WIN32RES)
82         $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
83         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
84         $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
85         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
86         rm -f $@.exp $@.base
87
88 postgres.def: $(OBJS)
89         $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
90
91 libpostgres.a: postgres.def
92         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
93
94 endif # win32
95
96 ifeq ($(PORTNAME), aix)
97
98 postgres: $(POSTGRES_IMP)
99         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
100
101 $(POSTGRES_IMP): $(OBJS)
102         $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(call expand_subsys,$^)
103 ifeq ($(host_os), aix3.2.5)
104         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
105 else
106 ifneq (,$(findstring aix4.1, $(host_os)))
107         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
108 else
109         $(MKLDEXPORT) SUBSYS.o . > $@
110 endif
111 endif
112         @rm -f SUBSYS.o
113
114 endif # aix
115
116 # Update the commonly used headers before building the subdirectories
117 $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h
118
119 # run this unconditionally to avoid needing to know its dependencies here:
120 submake-schemapg:
121         $(MAKE) -C catalog schemapg.h
122
123 .PHONY: submake-schemapg
124
125 catalog/schemapg.h: | submake-schemapg
126
127 $(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
128
129
130 # The postgres.o target is needed by the rule in Makefile.global that
131 # creates the exports file when MAKE_EXPORTS = true.
132 postgres.o: $(OBJS)
133         $(CC) $(LDREL) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$^) $(LIBS) -o $@
134
135
136 # The following targets are specified in make commands that appear in
137 # the make files in our subdirectories. Note that it's important we
138 # match the dependencies shown in the subdirectory makefiles!
139
140 parser/gram.h: parser/gram.y
141         $(MAKE) -C parser gram.h
142
143 utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
144         $(MAKE) -C utils fmgroids.h
145
146 utils/probes.h: utils/probes.d
147         $(MAKE) -C utils probes.h
148
149 # Make symlinks for these headers in the include directory. That way
150 # we can cut down on the -I options. Also, a symlink is automatically
151 # up to date when we update the base file.
152 #
153 # The point of the prereqdir incantation in some of the rules below is to
154 # force the symlink to use an absolute path rather than a relative path.
155 # For headers which are generated by make distprep, the actual header within
156 # src/backend will be in the source tree, while the symlink in src/include
157 # will be in the build tree, so a simple ../.. reference won't work.
158 # For headers generated during regular builds, we prefer a relative symlink.
159
160 $(top_builddir)/src/include/parser/gram.h: parser/gram.h
161         prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
162           cd $(dir $@) && rm -f $(notdir $@) && \
163           $(LN_S) "$$prereqdir/$(notdir $<)" .
164
165 $(top_builddir)/src/include/catalog/schemapg.h: catalog/schemapg.h
166         prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
167           cd $(dir $@) && rm -f $(notdir $@) && \
168           $(LN_S) "$$prereqdir/$(notdir $<)" .
169
170 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
171         prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
172           cd $(dir $@) && rm -f $(notdir $@) && \
173           $(LN_S) "$$prereqdir/$(notdir $<)" .
174
175 $(top_builddir)/src/include/utils/probes.h: utils/probes.h
176         cd $(dir $@) && rm -f $(notdir $@) && \
177             $(LN_S) ../../../$(subdir)/utils/probes.h .
178
179
180 utils/probes.o: utils/probes.d $(SUBDIROBJS)
181         $(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
182
183
184 ##########################################################################
185
186 distprep:
187         $(MAKE) -C parser       gram.c gram.h scan.c
188         $(MAKE) -C bootstrap    bootparse.c bootscanner.c
189         $(MAKE) -C catalog      schemapg.h postgres.bki postgres.description postgres.shdescription
190         $(MAKE) -C utils        fmgrtab.c fmgroids.h
191         $(MAKE) -C utils/misc   guc-file.c
192
193
194 ##########################################################################
195
196 install: all installdirs install-bin
197 ifeq ($(PORTNAME), cygwin)
198 ifeq ($(MAKE_DLL), true)
199         $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
200 endif
201 endif
202 ifeq ($(PORTNAME), win32)
203 ifeq ($(MAKE_DLL), true)
204         $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
205 endif
206 endif
207         $(MAKE) -C catalog install-data
208         $(MAKE) -C tsearch install-data
209         $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
210         $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
211         $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
212         $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
213
214 install-bin: postgres $(POSTGRES_IMP) installdirs
215         $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
216 ifneq ($(PORTNAME), win32)
217         @rm -f '$(DESTDIR)$(bindir)/postmaster$(X)'
218         ln -s postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
219 else
220         $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
221 endif
222 ifeq ($(MAKE_EXPORTS), true)
223         $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
224 endif
225
226 .PHONY: install-bin
227
228 installdirs:
229         $(MKDIR_P) '$(DESTDIR)$(bindir)' '$(DESTDIR)$(datadir)'
230 ifeq ($(PORTNAME), cygwin)
231 ifeq ($(MAKE_DLL), true)
232         $(MKDIR_P) '$(DESTDIR)$(libdir)'
233 endif
234 endif
235 ifeq ($(PORTNAME), win32)
236 ifeq ($(MAKE_DLL), true)
237         $(MKDIR_P) '$(DESTDIR)$(libdir)'
238 endif
239 endif
240 ifeq ($(MAKE_EXPORTS), true)
241         $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
242 endif
243
244
245 ##########################################################################
246
247 uninstall:
248         rm -f '$(DESTDIR)$(bindir)/postgres$(X)' '$(DESTDIR)$(bindir)/postmaster'
249 ifeq ($(MAKE_EXPORTS), true)
250         rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
251 endif
252 ifeq ($(PORTNAME), cygwin)
253 ifeq ($(MAKE_DLL), true)
254         rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
255 endif
256 endif
257 ifeq ($(PORTNAME), win32)
258 ifeq ($(MAKE_DLL), true)
259         rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
260 endif
261 endif
262         $(MAKE) -C catalog uninstall-data
263         $(MAKE) -C tsearch uninstall-data
264         rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \
265               '$(DESTDIR)$(datadir)/pg_ident.conf.sample' \
266               '$(DESTDIR)$(datadir)/postgresql.conf.sample' \
267               '$(DESTDIR)$(datadir)/recovery.conf.sample'
268
269
270 ##########################################################################
271
272 clean:
273         rm -f $(LOCALOBJS) postgres$(X) $(POSTGRES_IMP) \
274                 $(top_builddir)/src/include/parser/gram.h \
275                 $(top_builddir)/src/include/catalog/schemapg.h \
276                 $(top_builddir)/src/include/utils/fmgroids.h \
277                 $(top_builddir)/src/include/utils/probes.h
278 ifeq ($(PORTNAME), cygwin)
279         rm -f postgres.dll postgres.def libpostgres.a
280 endif
281 ifeq ($(PORTNAME), win32)
282         rm -f postgres.dll postgres.def libpostgres.a $(WIN32RES)
283 endif
284
285 distclean: clean
286         rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c \
287               port/pg_latch.c
288
289 maintainer-clean: distclean
290         rm -f bootstrap/bootparse.c \
291               bootstrap/bootscanner.c \
292               parser/gram.c \
293               parser/scan.c \
294               parser/gram.h \
295               catalog/schemapg.h \
296               catalog/postgres.bki \
297               catalog/postgres.description \
298               catalog/postgres.shdescription \
299               utils/fmgroids.h \
300               utils/fmgrtab.c \
301               utils/misc/guc-file.c
302
303
304 ##########################################################################
305 #
306 # Support for code development.
307 #
308 # Use target "quick" to build "postgres" when you know all the subsystems
309 # are up to date.  It saves the time of doing all the submakes.
310 .PHONY: quick
311 quick: $(OBJS)
312         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o postgres