nbtree: fix read page recheck typo.
[pgsql.git] / src / backend / Makefile
blob84302cc6dab7b12d8452705ec2916696a8b5d4b3
1 #-------------------------------------------------------------------------
3 # Makefile for the postgres backend
5 # Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
8 # src/backend/Makefile
10 #-------------------------------------------------------------------------
12 PGFILEDESC = "PostgreSQL Server"
13 PGAPPICON=win32
15 subdir = src/backend
16 top_builddir = ../..
17 include $(top_builddir)/src/Makefile.global
19 SUBDIRS = access archive backup bootstrap catalog parser commands executor \
20 foreign lib libpq \
21 main nodes optimizer partitioning port postmaster \
22 regex replication rewrite \
23 statistics storage tcop tsearch utils $(top_builddir)/src/timezone \
24 jit
26 include $(srcdir)/common.mk
28 # As of 1/2010:
29 # The probes.o file is necessary for dtrace support on Solaris, and on recent
30 # versions of systemtap. (Older systemtap releases just produce an empty
31 # file, but that's okay.) However, macOS's dtrace doesn't use it and doesn't
32 # even recognize the -G option. So, build probes.o except on macOS.
33 # This might need adjustment as other platforms add dtrace support.
34 ifneq ($(PORTNAME), darwin)
35 ifeq ($(enable_dtrace), yes)
36 LOCALOBJS += utils/probes.o
37 endif
38 endif
40 OBJS = \
41 $(LOCALOBJS) \
42 $(SUBDIROBJS) \
43 $(top_builddir)/src/common/libpgcommon_srv.a \
44 $(top_builddir)/src/port/libpgport_srv.a
46 # We put libpgport and libpgcommon into OBJS, so remove it from LIBS; also add
47 # libldap and ICU
48 LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS)
50 # The backend doesn't need everything that's in LIBS, however
51 LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
53 ifeq ($(with_systemd),yes)
54 LIBS += -lsystemd
55 endif
57 override LDFLAGS := $(LDFLAGS) $(LDFLAGS_EX) $(LDFLAGS_EX_BE)
59 ##########################################################################
61 all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
63 ifneq ($(PORTNAME), cygwin)
64 ifneq ($(PORTNAME), win32)
66 postgres: $(OBJS)
67 $(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
69 endif
70 endif
72 ifeq ($(PORTNAME), cygwin)
74 postgres: $(OBJS)
75 $(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) -Wl,--stack,$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(LIBS) -o $@
77 # libpostgres.a is actually built in the preceding rule, but we need this to
78 # ensure it's newer than postgres; see notes in src/backend/parser/Makefile
79 libpostgres.a: postgres
80 touch $@
82 endif # cygwin
84 ifeq ($(PORTNAME), win32)
85 LIBS += -lsecur32
87 postgres: $(OBJS) $(WIN32RES)
88 $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LDFLAGS) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(LIBS) -o $@$(X)
90 # libpostgres.a is actually built in the preceding rule, but we need this to
91 # ensure it's newer than postgres; see notes in src/backend/parser/Makefile
92 libpostgres.a: postgres
93 touch $@
95 endif # win32
97 $(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
100 # The following targets are specified in make commands that appear in
101 # the make files in our subdirectories. Note that it's important we
102 # match the dependencies shown in the subdirectory makefiles!
103 # Also, in cases where a subdirectory makefile generates two files in
104 # what's really one step, such as bison producing both gram.h and gram.c,
105 # we must request making the one that is shown as the secondary (dependent)
106 # output, else the timestamp on it might be wrong. By project convention,
107 # the .h file is the dependent one for bison output, so we need only request
108 # that; but in other cases, request both for safety.
110 parser/gram.h: parser/gram.y
111 $(MAKE) -C parser gram.h
113 storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl ../include/storage/lwlocklist.h utils/activity/wait_event_names.txt
114 $(MAKE) -C storage/lmgr lwlocknames.h
116 utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl utils/activity/wait_event_names.txt
117 $(MAKE) -C utils/activity wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
119 # run this unconditionally to avoid needing to know its dependencies here:
120 submake-catalog-headers:
121 $(MAKE) -C ../include/catalog generated-headers
123 # run this unconditionally to avoid needing to know its dependencies here:
124 submake-nodes-headers:
125 $(MAKE) -C nodes generated-header-symlinks
127 # run this unconditionally to avoid needing to know its dependencies here:
128 submake-utils-headers:
129 $(MAKE) -C utils generated-header-symlinks
131 .PHONY: submake-catalog-headers submake-nodes-headers submake-utils-headers
133 # Make symlinks for these headers in the include directory. That way
134 # we can cut down on the -I options. Also, a symlink is automatically
135 # up to date when we update the base file.
137 # The point of the prereqdir incantation in some of the rules below is to
138 # force the symlink to use an absolute path rather than a relative path.
139 # This is needed to support platforms without ln -s.
141 .PHONY: generated-headers
143 generated-headers: $(top_builddir)/src/include/storage/lwlocknames.h $(top_builddir)/src/include/utils/wait_event_types.h submake-catalog-headers submake-nodes-headers submake-utils-headers parser/gram.h
145 $(top_builddir)/src/include/storage/lwlocknames.h: storage/lmgr/lwlocknames.h
146 prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
147 cd '$(dir $@)' && rm -f $(notdir $@) && \
148 $(LN_S) "$$prereqdir/$(notdir $<)" .
150 $(top_builddir)/src/include/utils/wait_event_types.h: utils/activity/wait_event_types.h
151 prereqdir=`cd '$(dir $<)' >/dev/null && pwd` && \
152 cd '$(dir $@)' && rm -f $(notdir $@) && \
153 $(LN_S) "$$prereqdir/$(notdir $<)" .
155 utils/probes.o: utils/probes.d $(SUBDIROBJS)
156 $(DTRACE) $(DTRACEFLAGS) -C -G -s $(call expand_subsys,$^) -o $@
159 ##########################################################################
161 # This target is only needed by nls.mk.
162 .PHONY: generated-parser-sources
163 generated-parser-sources:
164 $(MAKE) -C parser gram.c gram.h scan.c
165 $(MAKE) -C bootstrap bootparse.c bootparse.h bootscanner.c
166 $(MAKE) -C replication repl_gram.c repl_gram.h repl_scanner.c syncrep_gram.c syncrep_gram.h syncrep_scanner.c
167 $(MAKE) -C utils/adt jsonpath_gram.c jsonpath_gram.h jsonpath_scan.c
168 $(MAKE) -C utils/misc guc-file.c
171 ##########################################################################
173 install: all installdirs install-bin
174 ifeq ($(PORTNAME), cygwin)
175 ifeq ($(MAKE_DLL), true)
176 $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
177 endif
178 endif
179 ifeq ($(PORTNAME), win32)
180 ifeq ($(MAKE_DLL), true)
181 $(INSTALL_DATA) libpostgres.a '$(DESTDIR)$(libdir)/libpostgres.a'
182 endif
183 endif
184 $(MAKE) -C catalog install-data
185 $(MAKE) -C tsearch install-data
186 $(MAKE) -C utils install-data
187 $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample'
188 $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample'
189 $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample'
191 ifeq ($(with_llvm), yes)
192 install-bin: install-postgres-bitcode
194 install-postgres-bitcode: $(OBJS) all
195 $(call install_llvm_module,postgres,$(call expand_subsys, $(filter-out $(top_builddir)/src/timezone/objfiles.txt, $(SUBDIROBJS))))
196 endif
198 install-bin: postgres $(POSTGRES_IMP) installdirs
199 $(INSTALL_PROGRAM) postgres$(X) '$(DESTDIR)$(bindir)/postgres$(X)'
200 ifeq ($(MAKE_EXPORTS), true)
201 $(INSTALL_DATA) $(POSTGRES_IMP) '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
202 $(INSTALL_PROGRAM) $(MKLDEXPORT) '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh'
203 endif
205 .PHONY: install-bin
207 installdirs:
208 $(MKDIR_P) '$(DESTDIR)$(bindir)' '$(DESTDIR)$(datadir)'
209 ifeq ($(PORTNAME), cygwin)
210 ifeq ($(MAKE_DLL), true)
211 $(MKDIR_P) '$(DESTDIR)$(libdir)'
212 endif
213 endif
214 ifeq ($(PORTNAME), win32)
215 ifeq ($(MAKE_DLL), true)
216 $(MKDIR_P) '$(DESTDIR)$(libdir)'
217 endif
218 endif
219 ifeq ($(MAKE_EXPORTS), true)
220 $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'
221 $(MKDIR_P) '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)'
222 endif
225 ##########################################################################
227 uninstall:
228 rm -f '$(DESTDIR)$(bindir)/postgres$(X)'
229 ifeq ($(MAKE_EXPORTS), true)
230 rm -f '$(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)'
231 rm -f '$(DESTDIR)$(pgxsdir)/$(MKLDEXPORT_DIR)/mkldexport.sh'
232 endif
233 ifeq ($(PORTNAME), cygwin)
234 ifeq ($(MAKE_DLL), true)
235 rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
236 endif
237 endif
238 ifeq ($(PORTNAME), win32)
239 ifeq ($(MAKE_DLL), true)
240 rm -f '$(DESTDIR)$(libdir)/libpostgres.a'
241 endif
242 endif
243 $(MAKE) -C catalog uninstall-data
244 $(MAKE) -C tsearch uninstall-data
245 $(MAKE) -C utils uninstall-data
246 rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \
247 '$(DESTDIR)$(datadir)/pg_ident.conf.sample' \
248 '$(DESTDIR)$(datadir)/postgresql.conf.sample'
249 ifeq ($(with_llvm), yes)
250 $(call uninstall_llvm_module,postgres)
251 endif
254 ##########################################################################
256 clean:
257 rm -f $(LOCALOBJS) postgres$(X) $(POSTGRES_IMP)
258 ifeq ($(PORTNAME), cygwin)
259 rm -f postgres.dll libpostgres.a
260 endif
261 ifeq ($(PORTNAME), win32)
262 rm -f postgres.dll libpostgres.a $(WIN32RES)
263 endif
265 distclean: clean
266 # generated by configure
267 rm -f port/tas.s port/pg_sema.c port/pg_shmem.c
270 ##########################################################################
272 # Support for code development.
274 # Use target "quick" to build "postgres" when you know all the subsystems
275 # are up to date. It saves the time of doing all the submakes.
276 .PHONY: quick
277 quick: $(OBJS)
278 $(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o postgres