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