Fix ancient bug in handling of to_char modifier 'TH', when used with HH.
[PostgreSQL.git] / src / backend / Makefile
bloba9023d4e8d4c5148c5448ed18b0f0c4d38e57bfe
1 #-------------------------------------------------------------------------
3 # Makefile for the postgres backend
5 # Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
8 # $PostgreSQL$
10 #-------------------------------------------------------------------------
12 PGFILEDESC = "PostgreSQL Server"
13 subdir = src/backend
14 top_builddir = ../..
15 include $(top_builddir)/src/Makefile.global
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
21 include $(srcdir)/common.mk
23 ifeq ($(PORTNAME), solaris)
24 ifeq ($(enable_dtrace), yes)
25 LOCALOBJS += utils/probes.o
26 endif
27 endif
29 OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
31 # We put libpgport into OBJS, so remove it from LIBS; also add libldap
32 LIBS := $(filter-out -lpgport, $(LIBS)) $(LDAP_LIBS_BE)
34 # The backend doesn't need everything that's in LIBS, however
35 LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
37 ##########################################################################
39 all: submake-libpgport postgres $(POSTGRES_IMP)
41 ifneq ($(PORTNAME), cygwin)
42 ifneq ($(PORTNAME), win32)
43 ifneq ($(PORTNAME), aix)
45 postgres: $(OBJS)
46 $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o $@
48 endif
49 endif
50 endif
52 ifeq ($(PORTNAME), cygwin)
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
61 postgres.def: $(OBJS)
62 $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
64 libpostgres.a: postgres.def
65 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
67 endif # cygwin
69 ifeq ($(PORTNAME), win32)
70 LIBS += -lsecur32
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
79 postgres.def: $(OBJS)
80 $(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
82 libpostgres.a: postgres.def
83 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
85 endif # win32
87 ifeq ($(PORTNAME), aix)
89 postgres: $(POSTGRES_IMP)
90 $(CC) $(CFLAGS) $(LDFLAGS) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
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
105 endif # aix
107 # Update the commonly used headers before building the subdirectories
108 $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/probes.h
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 $@
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!
121 $(srcdir)/parser/gram.h: parser/gram.y
122 $(MAKE) -C parser gram.h
124 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
125 $(MAKE) -C utils fmgroids.h
127 utils/probes.h: utils/probes.d
128 $(MAKE) -C utils probes.h
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.
134 $(top_builddir)/src/include/parser/gram.h: $(srcdir)/parser/gram.h
135 prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
136 cd $(dir $@) && rm -f $(notdir $@) && \
137 $(LN_S) "$$prereqdir/$(notdir $<)" .
139 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
140 cd $(dir $@) && rm -f $(notdir $@) && \
141 $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
143 $(top_builddir)/src/include/utils/probes.h: utils/probes.h
144 cd $(dir $@) && rm -f $(notdir $@) && \
145 $(LN_S) ../../../$(subdir)/utils/probes.h .
148 ifeq ($(PORTNAME), solaris)
149 utils/probes.o: utils/probes.d $(SUBDIROBJS)
150 $(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
151 endif
154 ##########################################################################
156 distprep:
157 $(MAKE) -C parser gram.c gram.h scan.c
158 $(MAKE) -C bootstrap bootparse.c bootscanner.c
159 $(MAKE) -C utils/misc guc-file.c
162 ##########################################################################
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'
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
194 .PHONY: install-bin
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
213 ##########################################################################
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'
238 ##########################################################################
240 clean:
241 rm -f $(LOCALOBJS) postgres$(X) $(POSTGRES_IMP) \
242 $(top_srcdir)/src/include/parser/gram.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
251 distclean: clean
252 rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
254 maintainer-clean: distclean
255 rm -f $(srcdir)/bootstrap/bootparse.c \
256 $(srcdir)/bootstrap/bootscanner.c \
257 $(srcdir)/parser/gram.c \
258 $(srcdir)/parser/scan.c \
259 $(srcdir)/parser/gram.h \
260 $(srcdir)/utils/misc/guc-file.c
263 ##########################################################################
265 # Support for code development.
267 # Use target "quick" to build "postgres" when you know all the subsystems
268 # are up to date. It saves the time of doing all the submakes.
269 .PHONY: quick
270 quick: $(OBJS)
271 $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o postgres