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