1 #-------------------------------------------------------------------------
3 # Makefile for the postgres backend
5 # Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
8 # $PostgreSQL: pgsql/src/backend/Makefile,v 1.127 2008/02/26 14:42:27 petere Exp $
10 #-------------------------------------------------------------------------
12 PGFILEDESC = "PostgreSQL Server"
15 include $(top_builddir)/src/Makefile.global
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
21 include $(srcdir)/common.mk
23 ifeq ($(enable_dtrace), yes)
24 LOCALOBJS += utils/probes.o
27 OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
29 # We put libpgport into OBJS, so remove it from LIBS; also add libldap
30 LIBS := $(filter-out -lpgport, $(LIBS)) $(LDAP_LIBS_BE)
32 # The backend doesn't need everything that's in LIBS, however
33 LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
35 ##########################################################################
37 all: submake-libpgport postgres $(POSTGRES_IMP)
39 ifneq ($(PORTNAME), cygwin)
40 ifneq ($(PORTNAME), win32)
41 ifneq ($(PORTNAME), aix)
44 $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o $@
50 ifeq ($(PORTNAME), cygwin)
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)
60 $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
62 libpostgres.a: postgres.def
63 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
67 ifeq ($(PORTNAME), win32)
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)
78 $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
80 libpostgres.a: postgres.def
81 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
85 ifeq ($(PORTNAME), aix)
87 postgres: $(POSTGRES_IMP)
88 $(CC) $(CFLAGS) $(LDFLAGS) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
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 > $@
95 ifneq (,$(findstring aix4.1, $(host_os)))
96 $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
98 $(MKLDEXPORT) SUBSYS.o . > $@
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
109 # The postgres.o target is needed by the rule in Makefile.global that
110 # creates the exports file when MAKE_EXPORTS = true.
112 $(CC) $(LDREL) $(LDFLAGS) $(call expand_subsys,$^) $(LIBS) -o $@
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!
119 $(srcdir)/parser/parse.h: parser/gram.y
120 $(MAKE) -C parser parse.h
122 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
123 $(MAKE) -C utils fmgroids.h
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.
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 $<)" .
134 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
135 cd $(dir $@) && rm -f $(notdir $@) && \
136 $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
139 utils/probes.o: utils/probes.d $(SUBDIROBJS)
140 $(DTRACE) $(DTRACEFLAGS) -G -s $(call expand_subsys,$^) -o $@
143 ##########################################################################
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
151 ##########################################################################
153 install: all installdirs install-bin
154 ifeq ($(PORTNAME), cygwin)
155 ifeq ($(MAKE_DLL), true)
156 $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
159 ifeq ($(PORTNAME), win32)
160 ifeq ($(MAKE_DLL), true)
161 $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
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'
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)'
177 $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
179 ifeq ($(MAKE_EXPORTS), true)
180 $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
186 $(mkinstalldirs) '$(DESTDIR)$(bindir)' '$(DESTDIR)$(datadir)'
187 ifeq ($(PORTNAME), cygwin)
188 ifeq ($(MAKE_DLL), true)
189 $(mkinstalldirs) '$(DESTDIR)$(libdir)'
192 ifeq ($(PORTNAME), win32)
193 ifeq ($(MAKE_DLL), true)
194 $(mkinstalldirs) '$(DESTDIR)$(libdir)'
197 ifeq ($(MAKE_EXPORTS), true)
198 $(mkinstalldirs) '$(DESTDIR)$(pkglibdir)'
202 ##########################################################################
205 rm -f '$(DESTDIR)$(bindir)/postgres$(X)' '$(DESTDIR)$(bindir)/postmaster'
206 ifeq ($(MAKE_EXPORTS), true)
207 rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
209 ifeq ($(PORTNAME), cygwin)
210 ifeq ($(MAKE_DLL), true)
211 rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
214 ifeq ($(PORTNAME), win32)
215 ifeq ($(MAKE_DLL), true)
216 rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
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'
227 ##########################################################################
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
236 ifeq ($(PORTNAME), win32)
237 rm -f postgres.dll postgres.def libpostgres.a $(WIN32RES)
241 rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
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
253 ##########################################################################
255 # Support for code development.
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.
261 $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o postgres