]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
Remove trailing slashes from directories in find command
[postgresql] / src / backend / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for the postgres backend
4 #
5 # Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
7 #
8 # src/backend/Makefile
9 #
10 #-------------------------------------------------------------------------
11
12 PGFILEDESC = "PostgreSQL Server"
13 # This is a daemon process, which is why it is not labeled as an executable
14 #PGAPPICON=win32
15
16 subdir = src/backend
17 top_builddir = ../..
18 include $(top_builddir)/src/Makefile.global
19
20 SUBDIRS = access bootstrap catalog parser commands executor foreign lib libpq \
21         main nodes optimizer port postmaster regex replication rewrite \
22         storage tcop tsearch utils $(top_builddir)/src/timezone
23
24 include $(srcdir)/common.mk
25
26 # As of 1/2010:
27 # The probes.o file is necessary for dtrace support on Solaris, and on recent
28 # versions of systemtap.  (Older systemtap releases just produce an empty
29 # file, but that's okay.)  However, OS X's dtrace doesn't use it and doesn't
30 # even recognize the -G option.  So, build probes.o except on Darwin.
31 # This might need adjustment as other platforms add dtrace support.
32 ifneq ($(PORTNAME), darwin)
33 ifeq ($(enable_dtrace), yes)
34 LOCALOBJS += utils/probes.o
35 endif
36 endif
37
38 OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a \
39        $(top_builddir)/src/common/libpgcommon_srv.a
40
41 # We put libpgport and libpgcommon into OBJS, so remove it from LIBS; also add
42 # libldap
43 LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE)
44
45 # The backend doesn't need everything that's in LIBS, however
46 LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
47
48 ##########################################################################
49
50 all: submake-libpgport submake-schemapg postgres $(POSTGRES_IMP)
51
52 ifneq ($(PORTNAME), cygwin)
53 ifneq ($(PORTNAME), win32)
54 ifneq ($(PORTNAME), aix)
55
56 postgres: $(OBJS)
57         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o $@
58
59 endif
60 endif
61 endif
62
63 ifeq ($(PORTNAME), cygwin)
64
65 postgres: $(OBJS)
66         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) -Wl,--stack,$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(call expand_subsys,$^) $(LIBS) -o $@
67
68 # There is no correct way to write a rule that generates two files.
69 # Rules with two targets don't have that meaning, they are merely
70 # shorthand for two otherwise separate rules.  To be safe for parallel
71 # make, we must chain the dependencies like this.  The semicolon is
72 # important, otherwise make will choose some built-in rule.
73
74 libpostgres.a: postgres ;
75
76 endif # cygwin
77
78 ifeq ($(PORTNAME), win32)
79 LIBS += -lsecur32
80
81 postgres: $(OBJS) $(WIN32RES)
82         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS) -o $@$(X)
83
84 libpostgres.a: postgres ;
85
86 endif # win32
87
88 ifeq ($(PORTNAME), aix)
89
90 postgres: $(POSTGRES_IMP)
91         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$(OBJS)) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@
92
93 $(POSTGRES_IMP): $(OBJS)
94         $(LD) $(LDREL) $(LDOUT) SUBSYS.o $(call expand_subsys,$^)
95 ifeq ($(host_os), aix3.2.5)
96         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
97 else
98 ifneq (,$(findstring aix4.1, $(host_os)))
99         $(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
100 else
101         $(MKLDEXPORT) SUBSYS.o . > $@
102 endif
103 endif
104         @rm -f SUBSYS.o
105
106 endif # aix
107
108 # Update the commonly used headers before building the subdirectories
109 $(SUBDIRS:%=%-recursive): $(top_builddir)/src/include/parser/gram.h $(top_builddir)/src/include/catalog/schemapg.h $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/fmgroids.h $(top_builddir)/src/include/utils/errcodes.h $(top_builddir)/src/include/utils/probes.h
110
111 # run this unconditionally to avoid needing to know its dependencies here:
112 submake-schemapg:
113         $(MAKE) -C catalog schemapg.h
114
115 # src/port needs a convenient way to force errcodes.h to get built
116 submake-errcodes: $(top_builddir)/src/include/utils/errcodes.h
117
118 .PHONY: submake-schemapg submake-errcodes
119
120 catalog/schemapg.h: | submake-schemapg
121
122 $(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
123
124
125 # The postgres.o target is needed by the rule in Makefile.global that
126 # creates the exports file when MAKE_EXPORTS = true.
127 postgres.o: $(OBJS)
128         $(CC) $(LDREL) $(LDFLAGS) $(LDFLAGS_EX) $(call expand_subsys,$^) $(LIBS) -o $@
129
130
131 # The following targets are specified in make commands that appear in
132 # the make files in our subdirectories. Note that it's important we
133 # match the dependencies shown in the subdirectory makefiles!
134
135 parser/gram.h: parser/gram.y
136         $(MAKE) -C parser gram.h
137
138 storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl storage/lmgr/lwlocknames.txt
139         $(MAKE) -C storage/lmgr lwlocknames.h
140
141 utils/fmgroids.h: utils/Gen_fmgrtab.pl catalog/Catalog.pm $(top_srcdir)/src/include/catalog/pg_proc.h
142         $(MAKE) -C utils fmgroids.h
143
144 utils/errcodes.h: utils/generate-errcodes.pl utils/errcodes.txt
145         $(MAKE) -C utils errcodes.h
146
147 utils/probes.h: utils/probes.d
148         $(MAKE) -C utils probes.h
149
150 # Make symlinks for these headers in the include directory. That way
151 # we can cut down on the -I options. Also, a symlink is automatically
152 # up to date when we update the base file.
153 #
154 # The point of the prereqdir incantation in some of the rules below is to
155 # force the symlink to use an absolute path rather than a relative path.
156 # For headers which are generated by make distprep, the actual header within
157 # src/backend will be in the source tree, while the symlink in src/include
158 # will be in the build tree, so a simple ../.. reference won't work.
159 # For headers generated during regular builds, we prefer a relative symlink.
160
161 $(top_builddir)/src/include/parser/gram.h: parser/gram.h
162         prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
163           cd '$(dir $@)' && rm -f $(notdir $@) && \
164           $(LN_S) "$$prereqdir/$(notdir $<)" .
165
166 $(top_builddir)/src/include/catalog/schemapg.h: catalog/schemapg.h
167         prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
168           cd '$(dir $@)' && rm -f $(notdir $@) && \
169           $(LN_S) "$$prereqdir/$(notdir $<)" .
170
171 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
172         prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
173           cd '$(dir $@)' && rm -f $(notdir $@) && \
174           $(LN_S) "$$prereqdir/$(notdir $<)" .
175
176 $(top_builddir)/src/include/utils/errcodes.h: utils/errcodes.h
177         prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
178           cd '$(dir $@)' && rm -f $(notdir $@) && \
179           $(LN_S) "$$prereqdir/$(notdir $<)" .
180
181 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
182         prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
183           cd '$(dir $@)' && rm -f $(notdir $@) && \
184           $(LN_S) "$$prereqdir/$(notdir $<)" .
185
186 $(top_builddir)/src/include/utils/probes.h: utils/probes.h
187         cd '$(dir $@)' && rm -f $(notdir $@) && \
188             $(LN_S) "../../../$(subdir)/utils/probes.h" .
189
190
191 utils/probes.o: utils/probes.d $(SUBDIROBJS)
192         $(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
193
194
195 ##########################################################################
196
197 # Be sure that these files get removed by the maintainer-clean target
198 distprep:
199         $(MAKE) -C parser       gram.c gram.h scan.c
200         $(MAKE) -C bootstrap    bootparse.c bootscanner.c
201         $(MAKE) -C catalog      schemapg.h postgres.bki postgres.description postgres.shdescription
202         $(MAKE) -C replication  repl_gram.c repl_scanner.c
203         $(MAKE) -C storage/lmgr lwlocknames.h
204         $(MAKE) -C utils        fmgrtab.c fmgroids.h errcodes.h
205         $(MAKE) -C utils/misc   guc-file.c
206         $(MAKE) -C utils/sort   qsort_tuple.c
207
208
209 ##########################################################################
210
211 install: all installdirs install-bin
212 ifeq ($(PORTNAME), cygwin)
213 ifeq ($(MAKE_DLL), true)
214         $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
215 endif
216 endif
217 ifeq ($(PORTNAME), win32)
218 ifeq ($(MAKE_DLL), true)
219         $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
220 endif
221 endif
222         $(MAKE) -C catalog install-data
223         $(MAKE) -C tsearch install-data
224         $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
225         $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
226         $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
227         $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample'
228
229 install-bin: postgres $(POSTGRES_IMP) installdirs
230         $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
231 ifneq ($(PORTNAME), win32)
232         @rm -f '$(DESTDIR)$(bindir)/postmaster$(X)'
233         ln -s postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
234 else
235         $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postmaster$(X)'
236 endif
237 ifeq ($(MAKE_EXPORTS), true)
238         $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
239         $(INSTALL_PROGRAM) $(MKLDEXPORT) '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh'
240 endif
241
242 .PHONY: install-bin
243
244 installdirs:
245         $(MKDIR_P) '$(DESTDIR)$(bindir)' '$(DESTDIR)$(datadir)'
246 ifeq ($(PORTNAME), cygwin)
247 ifeq ($(MAKE_DLL), true)
248         $(MKDIR_P) '$(DESTDIR)$(libdir)'
249 endif
250 endif
251 ifeq ($(PORTNAME), win32)
252 ifeq ($(MAKE_DLL), true)
253         $(MKDIR_P) '$(DESTDIR)$(libdir)'
254 endif
255 endif
256 ifeq ($(MAKE_EXPORTS), true)
257         $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
258         $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)'
259 endif
260
261
262 ##########################################################################
263
264 uninstall:
265         rm -f '$(DESTDIR)$(bindir)/postgres$(X)' '$(DESTDIR)$(bindir)/postmaster'
266 ifeq ($(MAKE_EXPORTS), true)
267         rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
268         rm -f '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh'
269 endif
270 ifeq ($(PORTNAME), cygwin)
271 ifeq ($(MAKE_DLL), true)
272         rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
273 endif
274 endif
275 ifeq ($(PORTNAME), win32)
276 ifeq ($(MAKE_DLL), true)
277         rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
278 endif
279 endif
280         $(MAKE) -C catalog uninstall-data
281         $(MAKE) -C tsearch uninstall-data
282         rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \
283               '$(DESTDIR)$(datadir)/pg_ident.conf.sample' \
284               '$(DESTDIR)$(datadir)/postgresql.conf.sample' \
285               '$(DESTDIR)$(datadir)/recovery.conf.sample'
286
287
288 ##########################################################################
289
290 clean:
291         rm -f $(LOCALOBJS) postgres$(X) $(POSTGRES_IMP) \
292                 $(top_builddir)/src/include/parser/gram.h \
293                 $(top_builddir)/src/include/catalog/schemapg.h \
294                 $(top_builddir)/src/include/storage/lwlocknames.h \
295                 $(top_builddir)/src/include/utils/fmgroids.h \
296                 $(top_builddir)/src/include/utils/probes.h
297 ifeq ($(PORTNAME), cygwin)
298         rm -f postgres.dll libpostgres.a
299 endif
300 ifeq ($(PORTNAME), win32)
301         rm -f postgres.dll libpostgres.a $(WIN32RES)
302 endif
303
304 distclean: clean
305         rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c \
306               port/pg_latch.c
307
308 maintainer-clean: distclean
309         rm -f bootstrap/bootparse.c \
310               bootstrap/bootscanner.c \
311               parser/gram.c \
312               parser/gram.h \
313               parser/scan.c \
314               catalog/schemapg.h \
315               catalog/postgres.bki \
316               catalog/postgres.description \
317               catalog/postgres.shdescription \
318               replication/repl_gram.c \
319               replication/repl_scanner.c \
320               storage/lmgr/lwlocknames.c \
321               storage/lmgr/lwlocknames.h \
322               utils/fmgroids.h \
323               utils/fmgrtab.c \
324               utils/errcodes.h \
325               utils/misc/guc-file.c \
326               utils/sort/qsort_tuple.c
327
328
329 ##########################################################################
330 #
331 # Support for code development.
332 #
333 # Use target "quick" to build "postgres" when you know all the subsystems
334 # are up to date.  It saves the time of doing all the submakes.
335 .PHONY: quick
336 quick: $(OBJS)
337         $(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(call expand_subsys,$^) $(LIBS) -o postgres