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.107.4.1 2005-01-26 21:57:32 tgl Exp $
9
#-------------------------------------------------------------------------
11
PGFILEDESC = "PostgreSQL Database Backend"
14
include $(top_builddir)/src/Makefile.global
16
DIRS := access bootstrap catalog parser commands executor lib libpq \
17
main nodes optimizer port postmaster regex rewrite \
18
storage tcop utils $(top_builddir)/src/timezone
20
OBJS := $(DIRS:%=%/SUBSYS.o)
22
ifeq ($(PORTNAME), qnx4)
23
# This file crashes qnx4's wlink and is therefore not in
24
# bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
25
# necessary?) [ Yes, until the Watcom compiler goes open source it's
26
# effectively unsupported ]
27
OBJS+= bootstrap/bootstrap.o
30
# Use server version of port library
31
LIBS := $(patsubst -lpgport,-lpgport_srv, $(LIBS))
33
##########################################################################
35
all: submake-libpgport postgres $(POSTGRES_IMP)
37
ifneq ($(PORTNAME), cygwin)
38
ifneq ($(PORTNAME), win32)
41
$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
46
ifeq ($(PORTNAME), cygwin)
47
postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
48
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
49
$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(LIBS)
50
$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
51
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack,4194304 -o $@$(X) $@.exp $(OBJS) $(LIBS)
55
$(DLLTOOL) --export-all --output-def $@ $^
57
libpostgres.a: postgres.def
58
$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
62
ifeq ($(PORTNAME), win32)
64
postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a $(WIN32RES)
65
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
66
$(CC) $(CFLAGS) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(WIN32RES) $(LIBS)
67
$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
68
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--stack=4194304 -o $@$(X) $@.exp $(OBJS) $(WIN32RES) $(LIBS)
72
$(DLLTOOL) --export-all --output-def $@ $^ $(top_builddir)/src/port/libpgport.a
74
libpostgres.a: postgres.def
75
$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
80
ifeq ($(PORTNAME), aix)
82
postgres: $(POSTGRES_IMP)
83
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
85
$(POSTGRES_IMP): $(OBJS)
86
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $^
87
ifeq ($(host_os), aix3.2.5)
88
$(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
90
ifneq (,$(findstring aix4.1, $(host_os)))
91
$(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
93
$(MKLDEXPORT) SUBSYS.o . > $@
100
# Parallel make trickery
101
$(OBJS): $(DIRS:%=%-recursive) ;
103
.PHONY: $(DIRS:%=%-recursive)
104
# Update the commonly used headers before building the subdirectories
105
$(DIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
106
$(MAKE) -C $(subst -recursive,,$@) all
109
$(DLLINIT): $(DLLINIT:%.o=%.c)
110
$(MAKE) -C $(@D) $(@F)
112
# The postgres.o target is needed by the rule in Makefile.global that
113
# creates the exports file when MAKE_EXPORTS = true.
115
$(CC) $(LDREL) $(LDFLAGS) $^ $(LIBS) -o $@
118
# The following targets are specified in make commands that appear in
119
# the make files in our subdirectories. Note that it's important we
120
# match the dependencies shown in the subdirectory makefiles!
122
$(srcdir)/parser/parse.h: parser/gram.y
123
$(MAKE) -C parser parse.h
125
utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
126
$(MAKE) -C utils fmgroids.h
128
# Make symlinks for these headers in the include directory. That way
129
# we can cut down on the -I options. Also, a symlink is automatically
130
# up to date when we update the base file.
132
$(top_builddir)/src/include/parser/parse.h: $(srcdir)/parser/parse.h
133
prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
134
cd $(dir $@) && rm -f $(notdir $@) && \
135
$(LN_S) "$$prereqdir/$(notdir $<)" .
137
$(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
138
cd $(dir $@) && rm -f $(notdir $@) && \
139
$(LN_S) ../../../$(subdir)/utils/fmgroids.h .
142
##########################################################################
145
$(MAKE) -C parser gram.c parse.h scan.c
146
$(MAKE) -C bootstrap bootparse.c bootstrap_tokens.h bootscanner.c
147
$(MAKE) -C utils/misc guc-file.c
150
##########################################################################
152
install: all installdirs install-bin
153
ifeq ($(PORTNAME), cygwin)
154
ifeq ($(MAKE_DLL), true)
155
$(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
158
ifeq ($(PORTNAME), win32)
159
ifeq ($(MAKE_DLL), true)
160
$(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
163
$(MAKE) -C catalog install-data
164
$(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample $(DESTDIR)$(datadir)/pg_hba.conf.sample
165
$(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample $(DESTDIR)$(datadir)/pg_ident.conf.sample
166
$(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample $(DESTDIR)$(datadir)/postgresql.conf.sample
167
$(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample $(DESTDIR)$(datadir)/recovery.conf.sample
169
install-bin: postgres $(POSTGRES_IMP) installdirs
170
$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
171
ifneq ($(PORTNAME), win32)
172
@rm -f $(DESTDIR)$(bindir)/postmaster$(X)
173
ln -s postgres$(X) $(DESTDIR)$(bindir)/postmaster$(X)
175
$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postmaster$(X)
177
ifeq ($(MAKE_EXPORTS), true)
178
$(INSTALL_DATA) $(POSTGRES_IMP) $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
184
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(datadir)
185
ifeq ($(PORTNAME), cygwin)
186
ifeq ($(MAKE_DLL), true)
187
$(mkinstalldirs) $(DESTDIR)$(libdir)
190
ifeq ($(PORTNAME), win32)
191
ifeq ($(MAKE_DLL), true)
192
$(mkinstalldirs) $(DESTDIR)$(libdir)
195
ifeq ($(MAKE_EXPORTS), true)
196
$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
200
##########################################################################
203
rm -f $(DESTDIR)$(bindir)/postgres$(X) $(DESTDIR)$(bindir)/postmaster
204
ifeq ($(MAKE_EXPORTS), true)
205
rm -f $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
207
ifeq ($(PORTNAME), cygwin)
208
ifeq ($(MAKE_DLL), true)
209
rm -f $(DESTDIR)$(libdir)/libpostgres.a
212
ifeq ($(PORTNAME), win32)
213
ifeq ($(MAKE_DLL), true)
214
rm -f $(DESTDIR)$(libdir)/libpostgres.a
217
$(MAKE) -C catalog uninstall-data
218
rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
219
$(DESTDIR)$(datadir)/pg_service.conf.sample \
220
$(DESTDIR)$(datadir)/pg_ident.conf.sample \
221
$(DESTDIR)$(datadir)/postgresql.conf.sample
224
##########################################################################
227
rm -f postgres$(X) $(POSTGRES_IMP) \
228
$(top_srcdir)/src/include/parser/parse.h \
229
$(top_builddir)/src/include/utils/fmgroids.h
230
ifeq ($(PORTNAME), cygwin)
231
rm -f postgres.dll postgres.def libpostgres.a
233
ifeq ($(PORTNAME), win32)
234
rm -f postgres.dll postgres.def libpostgres.a $(WIN32RES)
236
for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
239
rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
241
maintainer-clean: distclean
242
rm -f $(srcdir)/bootstrap/bootparse.c \
243
$(srcdir)/bootstrap/bootscanner.c \
244
$(srcdir)/bootstrap/bootstrap_tokens.h \
245
$(srcdir)/parser/gram.c \
246
$(srcdir)/parser/scan.c \
247
$(srcdir)/parser/parse.h \
248
$(srcdir)/utils/misc/guc-file.c
251
##########################################################################
253
# Support for code development.
255
# Use target "quick" to build "postgres" when you know all the subsystems
256
# are up to date. It saves the time of doing all the submakes.
259
$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postgres
261
depend dep: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
262
for i in $(DIRS); do $(MAKE) -C $$i $@; done