]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
Pgindent run for 8.0.
[postgresql] / src / backend / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for the postgres backend
4 #
5 # Copyright (c) 1994, Regents of the University of California
6 #
7 # $PostgreSQL: pgsql/src/backend/Makefile,v 1.104 2004/08/01 18:07:42 tgl Exp $
8 #
9 #-------------------------------------------------------------------------
10
11 subdir = src/backend
12 top_builddir = ../..
13 include $(top_builddir)/src/Makefile.global
14
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
18
19 OBJS := $(DIRS:%=%/SUBSYS.o)
20
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
27 endif
28
29
30 ##########################################################################
31
32 all: submake-libpgport postgres $(POSTGRES_IMP)
33
34 ifneq ($(PORTNAME), cygwin)
35 ifneq ($(PORTNAME), win32)
36
37 postgres: $(OBJS)
38         $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
39
40 endif
41 endif
42
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)
49         rm -f $@.exp $@.base
50
51 postgres.def: $(OBJS)
52         $(DLLTOOL) --export-all --output-def $@ $^
53
54 libpostgres.a: postgres.def
55         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
56
57 endif # cygwin
58
59 ifeq ($(PORTNAME), win32)
60
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)
66         rm -f $@.exp $@.base
67
68 postgres.def: $(OBJS)
69         $(DLLTOOL) --export-all --output-def $@ $^ $(top_builddir)/src/port/libpgport.a
70
71 libpostgres.a: postgres.def
72         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
73
74 endif # win32
75
76
77 ifeq ($(PORTNAME), aix)
78
79 postgres: $(POSTGRES_IMP)
80         $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
81
82 $(POSTGRES_IMP): $(OBJS)
83         $(LD) $(LDREL) $(LDOUT) SUBSYS.o $^
84 ifeq ($(host_os), aix3.2.5)
85         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
86 else
87 ifneq (,$(findstring aix4.1, $(host_os)))
88         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
89 else
90         $(MKLDEXPORT) SUBSYS.o . > $@
91 endif
92 endif
93         @rm -f SUBSYS.o
94
95 endif # aix
96
97 # Parallel make trickery
98 $(OBJS): $(DIRS:%=%-recursive) ;
99
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
104
105
106 $(DLLINIT): $(DLLINIT:%.o=%.c)
107         $(MAKE) -C $(@D) $(@F)
108
109 # The postgres.o target is needed by the rule in Makefile.global that
110 # creates the exports file when MAKE_EXPORTS = true.
111 postgres.o: $(OBJS)
112         $(CC) $(LDREL) $(LDFLAGS) $^ $(LIBS) -o $@
113
114
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!
118
119 $(srcdir)/parser/parse.h: parser/gram.y
120         $(MAKE) -C parser parse.h
121
122 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
123         $(MAKE) -C utils fmgroids.h
124
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.
128
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 $<)" .
133
134 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
135         cd $(dir $@) && rm -f $(notdir $@) && \
136             $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
137
138
139 ##########################################################################
140
141 distprep:
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
145
146
147 ##########################################################################
148
149 install: all installdirs install-bin
150 ifeq ($(PORTNAME), cygwin)
151 ifeq ($(MAKE_DLL), true)
152         $(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
153 endif
154 endif
155 ifeq ($(PORTNAME), win32)
156 ifeq ($(MAKE_DLL), true)
157         $(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
158 endif
159 endif
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
165
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)
171 else
172         $(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postmaster$(X)
173 endif
174 ifeq ($(MAKE_EXPORTS), true)
175         $(INSTALL_DATA) $(POSTGRES_IMP) $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
176 endif
177
178 .PHONY: install-bin
179
180 installdirs:
181         $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(datadir)
182 ifeq ($(PORTNAME), cygwin)
183 ifeq ($(MAKE_DLL), true)
184         $(mkinstalldirs) $(DESTDIR)$(libdir)
185 endif
186 endif
187 ifeq ($(PORTNAME), win32)
188 ifeq ($(MAKE_DLL), true)
189         $(mkinstalldirs) $(DESTDIR)$(libdir)
190 endif
191 endif
192 ifeq ($(MAKE_EXPORTS), true)
193         $(mkinstalldirs) $(DESTDIR)$(pkglibdir)
194 endif
195
196
197 ##########################################################################
198
199 uninstall:
200         rm -f $(DESTDIR)$(bindir)/postgres$(X) $(DESTDIR)$(bindir)/postmaster
201 ifeq ($(MAKE_EXPORTS), true)
202         rm -f $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
203 endif
204 ifeq ($(PORTNAME), cygwin)
205 ifeq ($(MAKE_DLL), true)
206         rm -f $(DESTDIR)$(libdir)/libpostgres.a
207 endif
208 endif
209 ifeq ($(PORTNAME), win32)
210 ifeq ($(MAKE_DLL), true)
211         rm -f $(DESTDIR)$(libdir)/libpostgres.a
212 endif
213 endif
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
219
220
221 ##########################################################################
222
223 clean:
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
229 endif
230 ifeq ($(PORTNAME), win32)
231         rm -f postgres.dll postgres.def libpostgres.a
232 endif
233         for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
234
235 distclean: clean
236         rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
237
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
246
247
248 ##########################################################################
249 #
250 # Support for code development.
251 #
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.
254 .PHONY: quick
255 quick: $(OBJS)
256         $(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postgres
257
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