1 #-------------------------------------------------------------------------
3 # Makefile for the postgres backend
5 # Copyright (c) 1994, Regents of the University of California
7 # $PostgreSQL: pgsql/src/backend/Makefile,v 1.104 2004/08/01 18:07:42 tgl Exp $
9 #-------------------------------------------------------------------------
13 include $(top_builddir)/src/Makefile.global
15 DIRS := access bootstrap catalog parser commands executor lib libpq \
16 main nodes optimizer port postmaster regex rewrite \
17 storage tcop utils $(top_builddir)/src/timezone
19 OBJS := $(DIRS:%=%/SUBSYS.o)
21 ifeq ($(PORTNAME), qnx4)
22 # This file crashes qnx4's wlink and is therefore not in
23 # bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
24 # necessary?) [ Yes, until the Watcom compiler goes open source it's
25 # effectively unsupported ]
26 OBJS+= bootstrap/bootstrap.o
30 ##########################################################################
32 all: submake-libpgport postgres $(POSTGRES_IMP)
34 ifneq ($(PORTNAME), cygwin)
35 ifneq ($(PORTNAME), win32)
38 $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
43 ifeq ($(PORTNAME), cygwin)
44 postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
45 $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
46 $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
47 $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
48 $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(LIBS)
52 $(DLLTOOL) --export-all --output-def $@ $^
54 libpostgres.a: postgres.def
55 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
59 ifeq ($(PORTNAME), win32)
61 postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
62 $(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
63 $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
64 $(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
65 $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(LIBS)
69 $(DLLTOOL) --export-all --output-def $@ $^ $(top_builddir)/src/port/libpgport.a
71 libpostgres.a: postgres.def
72 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
77 ifeq ($(PORTNAME), aix)
79 postgres: $(POSTGRES_IMP)
80 $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
82 $(POSTGRES_IMP): $(OBJS)
83 $(LD) $(LDREL) $(LDOUT) SUBSYS.o $^
84 ifeq ($(host_os), aix3.2.5)
85 $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
87 ifneq (,$(findstring aix4.1, $(host_os)))
88 $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
90 $(MKLDEXPORT) SUBSYS.o . > $@
97 # Parallel make trickery
98 $(OBJS): $(DIRS:%=%-recursive) ;
100 .PHONY: $(DIRS:%=%-recursive)
101 # Update the commonly used headers before building the subdirectories
102 $(DIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
103 $(MAKE) -C $(subst -recursive,,$@) all
106 $(DLLINIT): $(DLLINIT:%.o=%.c)
107 $(MAKE) -C $(@D) $(@F)
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) $^ $(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 ##########################################################################
142 $(MAKE) -C parser gram.c parse.h scan.c
143 $(MAKE) -C bootstrap bootparse.c bootstrap_tokens.h bootscanner.c
144 $(MAKE) -C utils/misc guc-file.c
147 ##########################################################################
149 install: all installdirs install-bin
150 ifeq ($(PORTNAME), cygwin)
151 ifeq ($(MAKE_DLL), true)
152 $(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
155 ifeq ($(PORTNAME), win32)
156 ifeq ($(MAKE_DLL), true)
157 $(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
160 $(MAKE) -C catalog install-data
161 $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample $(DESTDIR)$(datadir)/pg_hba.conf.sample
162 $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample $(DESTDIR)$(datadir)/pg_ident.conf.sample
163 $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample $(DESTDIR)$(datadir)/postgresql.conf.sample
164 $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample $(DESTDIR)$(datadir)/recovery.conf.sample
166 install-bin: postgres $(POSTGRES_IMP) installdirs
167 $(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
168 ifneq ($(PORTNAME), win32)
169 @rm -f $(DESTDIR)$(bindir)/postmaster$(X)
170 ln -s postgres$(X) $(DESTDIR)$(bindir)/postmaster$(X)
172 $(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postmaster$(X)
174 ifeq ($(MAKE_EXPORTS), true)
175 $(INSTALL_DATA) $(POSTGRES_IMP) $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
181 $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(datadir)
182 ifeq ($(PORTNAME), cygwin)
183 ifeq ($(MAKE_DLL), true)
184 $(mkinstalldirs) $(DESTDIR)$(libdir)
187 ifeq ($(PORTNAME), win32)
188 ifeq ($(MAKE_DLL), true)
189 $(mkinstalldirs) $(DESTDIR)$(libdir)
192 ifeq ($(MAKE_EXPORTS), true)
193 $(mkinstalldirs) $(DESTDIR)$(pkglibdir)
197 ##########################################################################
200 rm -f $(DESTDIR)$(bindir)/postgres$(X) $(DESTDIR)$(bindir)/postmaster
201 ifeq ($(MAKE_EXPORTS), true)
202 rm -f $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
204 ifeq ($(PORTNAME), cygwin)
205 ifeq ($(MAKE_DLL), true)
206 rm -f $(DESTDIR)$(libdir)/libpostgres.a
209 ifeq ($(PORTNAME), win32)
210 ifeq ($(MAKE_DLL), true)
211 rm -f $(DESTDIR)$(libdir)/libpostgres.a
214 $(MAKE) -C catalog uninstall-data
215 rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
216 $(DESTDIR)$(datadir)/pg_service.conf.sample \
217 $(DESTDIR)$(datadir)/pg_ident.conf.sample \
218 $(DESTDIR)$(datadir)/postgresql.conf.sample
221 ##########################################################################
224 rm -f postgres$(X) $(POSTGRES_IMP) \
225 $(top_srcdir)/src/include/parser/parse.h \
226 $(top_builddir)/src/include/utils/fmgroids.h
227 ifeq ($(PORTNAME), cygwin)
228 rm -f postgres.dll postgres.def libpostgres.a
230 ifeq ($(PORTNAME), win32)
231 rm -f postgres.dll postgres.def libpostgres.a
233 for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
236 rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
238 maintainer-clean: distclean
239 rm -f $(srcdir)/bootstrap/bootparse.c \
240 $(srcdir)/bootstrap/bootscanner.c \
241 $(srcdir)/bootstrap/bootstrap_tokens.h \
242 $(srcdir)/parser/gram.c \
243 $(srcdir)/parser/scan.c \
244 $(srcdir)/parser/parse.h \
245 $(srcdir)/utils/misc/guc-file.c
248 ##########################################################################
250 # Support for code development.
252 # Use target "quick" to build "postgres" when you know all the subsystems
253 # are up to date. It saves the time of doing all the submakes.
256 $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postgres
258 depend dep: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
259 for i in $(DIRS); do $(MAKE) -C $$i $@; done