2 # src/Makefile.global.in
5 #------------------------------------------------------------------------------
6 # All PostgreSQL makefiles include this file and use the variables it sets,
7 # which in turn are put here by the configure script. There is no need for
8 # users to edit this file -- if it turns out to be necessary then that's a
11 # A makefile that includes this file needs to set the variable `subdir' to
12 # the relative path from the top to itself and `top_builddir' to the relative
13 # path from itself to the top before including this file. (The "top" is the
14 # parent directory of the directory this file is in.)
15 #------------------------------------------------------------------------------
18 ##########################################################################
22 standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check checkprep installcheck init-po update-po
23 # these targets should recurse even into subdirectories not being built:
24 standard_always_targets = distprep clean distclean maintainer-clean
26 .PHONY: $(standard_targets) install-strip html man installcheck-parallel update-unicode
28 # make `all' the default target
31 # Delete target files if the command fails after it has
32 # started to update the file.
35 # Never delete any intermediate files automatically.
38 # PostgreSQL version number
39 VERSION = @PACKAGE_VERSION@
40 MAJORVERSION = @PG_MAJORVERSION@
41 VERSION_NUM = @PG_VERSION_NUM@
43 PACKAGE_URL = @PACKAGE_URL@
45 # Set top_srcdir, srcdir, and VPATH.
47 top_srcdir = $(top_builddir)
49 # If VPATH is set or Makefile is not in current directory we are building
50 # the extension with VPATH so we set the variable here.
54 ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
58 srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
63 vpath_build = @vpath_build@
64 abs_top_builddir = @abs_top_builddir@
65 abs_top_srcdir = @abs_top_srcdir@
67 ifneq ($(vpath_build),yes)
68 top_srcdir = $(top_builddir)
70 else # vpath_build = yes
71 top_srcdir = $(abs_top_srcdir)
72 srcdir = $(top_srcdir)/$(subdir)
77 vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done`
80 ##########################################################################
82 # Installation directories
84 # These are set by the equivalent --xxxdir configure options. We
85 # append "postgresql" to some of them, if the string does not already
86 # contain "pgsql" or "postgres", in order to avoid directory clutter.
88 # In a PGXS build, we cannot use the values inserted into Makefile.global
89 # by configure, since the installation tree may have been relocated.
90 # Instead get the path values from pg_config.
94 # Note that prefix, exec_prefix, and datarootdir aren't defined in a PGXS build;
95 # makefiles may only use the derived variables such as bindir.
98 exec_prefix := @exec_prefix@
99 datarootdir := @datarootdir@
104 ifeq "$(findstring pgsql, $(datadir))" ""
105 ifeq "$(findstring postgres, $(datadir))" ""
106 override datadir := $(datadir)/postgresql
110 sysconfdir := @sysconfdir@
111 ifeq "$(findstring pgsql, $(sysconfdir))" ""
112 ifeq "$(findstring postgres, $(sysconfdir))" ""
113 override sysconfdir := $(sysconfdir)/postgresql
119 pkglibdir = $(libdir)
120 ifeq "$(findstring pgsql, $(pkglibdir))" ""
121 ifeq "$(findstring postgres, $(pkglibdir))" ""
122 override pkglibdir := $(pkglibdir)/postgresql
126 includedir := @includedir@
128 pkgincludedir = $(includedir)
129 ifeq "$(findstring pgsql, $(pkgincludedir))" ""
130 ifeq "$(findstring postgres, $(pkgincludedir))" ""
131 override pkgincludedir := $(pkgincludedir)/postgresql
138 ifeq "$(findstring pgsql, $(docdir))" ""
139 ifeq "$(findstring postgres, $(docdir))" ""
140 override docdir := $(docdir)/postgresql
146 localedir := @localedir@
150 # Extension makefiles should set PG_CONFIG, but older ones might not
152 PG_CONFIG = pg_config
155 bindir := $(shell $(PG_CONFIG) --bindir)
156 datadir := $(shell $(PG_CONFIG) --sharedir)
157 sysconfdir := $(shell $(PG_CONFIG) --sysconfdir)
158 libdir := $(shell $(PG_CONFIG) --libdir)
159 pkglibdir := $(shell $(PG_CONFIG) --pkglibdir)
160 includedir := $(shell $(PG_CONFIG) --includedir)
161 pkgincludedir := $(shell $(PG_CONFIG) --pkgincludedir)
162 mandir := $(shell $(PG_CONFIG) --mandir)
163 docdir := $(shell $(PG_CONFIG) --docdir)
164 localedir := $(shell $(PG_CONFIG) --localedir)
168 # These derived path variables aren't separately configurable.
170 includedir_server = $(pkgincludedir)/server
171 includedir_internal = $(pkgincludedir)/internal
172 pgxsdir = $(pkglibdir)/pgxs
173 bitcodedir = $(pkglibdir)/bitcode
176 ##########################################################################
180 # Records the choice of the various --enable-xxx and --with-xxx options.
182 with_icu = @with_icu@
183 with_perl = @with_perl@
184 with_python = @with_python@
185 with_tcl = @with_tcl@
186 with_ssl = @with_ssl@
187 with_readline = @with_readline@
188 with_selinux = @with_selinux@
189 with_systemd = @with_systemd@
190 with_gssapi = @with_gssapi@
191 with_krb_srvnam = @with_krb_srvnam@
192 with_ldap = @with_ldap@
193 with_libxml = @with_libxml@
194 with_libxslt = @with_libxslt@
195 with_llvm = @with_llvm@
196 with_system_tzdata = @with_system_tzdata@
197 with_uuid = @with_uuid@
198 with_zlib = @with_zlib@
199 enable_rpath = @enable_rpath@
200 enable_nls = @enable_nls@
201 enable_debug = @enable_debug@
202 enable_dtrace = @enable_dtrace@
203 enable_coverage = @enable_coverage@
204 enable_tap_tests = @enable_tap_tests@
205 enable_thread_safety = @enable_thread_safety@
207 python_includespec = @python_includespec@
208 python_libdir = @python_libdir@
209 python_libspec = @python_libspec@
210 python_additional_libs = @python_additional_libs@
211 python_majorversion = @python_majorversion@
212 python_version = @python_version@
214 krb_srvtab = @krb_srvtab@
216 ICU_CFLAGS = @ICU_CFLAGS@
217 ICU_LIBS = @ICU_LIBS@
220 TCL_LIBS = @TCL_LIBS@
221 TCL_LIB_SPEC = @TCL_LIB_SPEC@
222 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
223 TCL_SHARED_BUILD = @TCL_SHARED_BUILD@
225 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
226 PTHREAD_LIBS = @PTHREAD_LIBS@
228 LLVM_BINPATH = @LLVM_BINPATH@
230 BITCODE_CFLAGS = @BITCODE_CFLAGS@
231 BITCODE_CXXFLAGS = @BITCODE_CXXFLAGS@
233 ##########################################################################
240 CPPFLAGS = @CPPFLAGS@
241 PG_SYSROOT = @PG_SYSROOT@
243 override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS)
246 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
248 override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
250 override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
256 SUN_STUDIO_CC = @SUN_STUDIO_CC@
259 CFLAGS_SL = @CFLAGS_SL@
260 # *_MODULE are for flags applied to extension libraries
261 CFLAGS_SL_MODULE = @CFLAGS_SL_MODULE@
262 CXXFLAGS_SL_MODULE = @CXXFLAGS_SL_MODULE@
263 CFLAGS_UNROLL_LOOPS = @CFLAGS_UNROLL_LOOPS@
264 CFLAGS_VECTORIZE = @CFLAGS_VECTORIZE@
265 CFLAGS_SSE42 = @CFLAGS_SSE42@
266 CFLAGS_ARMV8_CRC32C = @CFLAGS_ARMV8_CRC32C@
267 PERMIT_DECLARATION_AFTER_STATEMENT = @PERMIT_DECLARATION_AFTER_STATEMENT@
268 CXXFLAGS = @CXXFLAGS@
270 LLVM_CPPFLAGS = @LLVM_CPPFLAGS@
271 LLVM_CFLAGS = @LLVM_CFLAGS@
272 LLVM_CXXFLAGS = @LLVM_CXXFLAGS@
277 BISONFLAGS = @BISONFLAGS@ $(YFLAGS)
279 FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
281 DTRACEFLAGS = @DTRACEFLAGS@
288 LDAP_LIBS_FE = @LDAP_LIBS_FE@
289 LDAP_LIBS_BE = @LDAP_LIBS_BE@
290 UUID_LIBS = @UUID_LIBS@
291 LLVM_LIBS=@LLVM_LIBS@
293 with_gnu_ld = @with_gnu_ld@
295 # It's critical that within LDFLAGS, all -L switches pointing to build-tree
296 # directories come before any -L switches pointing to external directories.
297 # Otherwise it's possible for, e.g., a platform-provided copy of libpq.so
298 # to get linked in place of the one we've built. Therefore we adopt the
299 # convention that the first component of LDFLAGS is an extra variable
300 # LDFLAGS_INTERNAL, and -L and -l switches for PG's own libraries must be
301 # put into LDFLAGS_INTERNAL, so they will appear ahead of those for external
304 # We need LDFLAGS and LDFLAGS_INTERNAL to be "recursively expanded" variables,
305 # else adjustments to, e.g., rpathdir don't work right. So we must NOT do
306 # "LDFLAGS := something" anywhere, ditto for LDFLAGS_INTERNAL.
307 # These initial assignments must be "=" type, and elsewhere we must only do
308 # "LDFLAGS += something" or "LDFLAGS_INTERNAL += something".
310 LDFLAGS_INTERNAL = -L$(libdir)
312 LDFLAGS_INTERNAL = -L$(top_builddir)/src/port -L$(top_builddir)/src/common
314 LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@
316 LDFLAGS_EX = @LDFLAGS_EX@
317 # LDFLAGS_SL might have already been assigned by calling makefile
318 LDFLAGS_SL += @LDFLAGS_SL@
328 # quoted to protect pathname with spaces
331 PERL = $(missing) perl
333 perl_archlibexp = @perl_archlibexp@
334 perl_privlibexp = @perl_privlibexp@
335 perl_includespec = @perl_includespec@
336 perl_embed_ccflags = @perl_embed_ccflags@
337 perl_embed_ldflags = @perl_embed_ldflags@
344 MSGFMT_FLAGS = @MSGFMT_FLAGS@
345 MSGMERGE = @MSGMERGE@
348 XGETTEXT = @XGETTEXT@
355 DOWNLOAD = wget -O $@ --no-use-server-timestamps
356 #DOWNLOAD = curl -o $@
359 # Unicode data information
361 # Before each major release, update these and run make update-unicode.
363 # Pick a release from here: <https://www.unicode.org/Public/>. Note
364 # that the most recent release listed there is often a pre-release;
365 # don't pick that one, except for testing.
366 UNICODE_VERSION = 15.0.0
368 # Pick a release from here: <http://cldr.unicode.org/index/downloads>
372 # Tree-wide build support
374 # Just about every code subdirectory wants to have the generated headers
375 # available before building, but we don't want parallel makes all trying
376 # to build the same headers. These rules, together with the recursion rules
377 # below, ensure that we update the generated headers once, if needed,
378 # at the top level of any "make all/install/check/installcheck" request.
379 # If a particular subdirectory knows this isn't needed in itself or its
380 # children, it can set NO_GENERATED_HEADERS.
382 all install check installcheck: submake-generated-headers
384 .PHONY: submake-generated-headers
386 submake-generated-headers:
387 ifndef NO_GENERATED_HEADERS
388 ifeq ($(MAKELEVEL),0)
389 $(MAKE) -C $(top_builddir)/src/backend generated-headers
396 # In much the same way as above, these rules ensure that we build a temp
397 # install tree just once in any recursive "make check". The additional test
398 # on abs_top_builddir prevents doing anything foolish to the root directory.
404 temp-install: | submake-generated-headers
405 ifndef NO_TEMP_INSTALL
406 ifneq ($(abs_top_builddir),)
407 ifeq ($(MAKELEVEL),0)
408 rm -rf '$(abs_top_builddir)'/tmp_install
409 $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log
410 $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
411 $(MAKE) -j1 $(if $(CHECKPREP_TOP),-C $(CHECKPREP_TOP),) checkprep >>'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
416 # Tasks to run serially at the end of temp-install. Some EXTRA_INSTALL
417 # entries appear more than once in the tree, and parallel installs of the same
418 # file can fail with EEXIST.
420 $(if $(EXTRA_INSTALL),for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install || exit; done)
423 # There are common routines in src/test/perl, and some test suites have
424 # extra perl modules in their own directory.
425 PG_PROVE_FLAGS = -I $(top_srcdir)/src/test/perl/ -I $(srcdir)
426 # User-supplied prove flags such as --verbose can be provided in PROVE_FLAGS.
429 # prepend to path if already set, else just set it
431 $(1)="$(if $($(1)),$(2):$$$(1),$(2))"
434 # platform-specific environment variable to set shared library path
435 # individual ports can override this later, this is the default name
436 ld_library_path_var = LD_LIBRARY_PATH
438 # with_temp_install_extra is for individual ports to define if they
439 # need something more here. If not defined then the expansion does
441 with_temp_install = \
442 PATH="$(abs_top_builddir)/tmp_install$(bindir):$(CURDIR):$$PATH" \
443 $(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \
444 $(with_temp_install_extra)
446 ifeq ($(enable_tap_tests),yes)
449 define prove_installcheck
450 echo "+++ tap install-check in $(subdir) +++" && \
451 rm -rf '$(CURDIR)'/tmp_check && \
452 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
454 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
455 TESTDATADIR='$(CURDIR)/tmp_check' \
456 PATH="$(bindir):$(CURDIR):$$PATH" \
457 PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
458 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
459 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
462 define prove_installcheck
463 echo "+++ tap install-check in $(subdir) +++" && \
464 rm -rf '$(CURDIR)'/tmp_check && \
465 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
467 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
468 TESTDATADIR='$(CURDIR)/tmp_check' \
469 PATH="$(bindir):$(CURDIR):$$PATH" \
470 PGPORT='6$(DEF_PGPORT)' top_builddir='$(top_builddir)' \
471 PG_REGRESS='$(top_builddir)/src/test/regress/pg_regress' \
472 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
477 echo "+++ tap check in $(subdir) +++" && \
478 rm -rf '$(CURDIR)'/tmp_check && \
479 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
481 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
482 TESTDATADIR='$(CURDIR)/tmp_check' \
483 $(with_temp_install) \
484 PGPORT='6$(DEF_PGPORT)' \
485 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
486 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
490 prove_installcheck = @echo "TAP tests not enabled. Try configuring with --enable-tap-tests"
491 prove_check = $(prove_installcheck)
496 install_bin = @install_bin@
497 install_sh = $(SHELL) $(top_srcdir)/config/install-sh -c
498 INSTALL = $(if $(use_install_sh),$(install_sh),$(if $(install_bin),$(install_bin),$(install_sh)))
500 INSTALL_SCRIPT_MODE = 755
501 INSTALL_DATA_MODE = 644
502 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
503 INSTALL_SCRIPT = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
504 INSTALL_DATA = $(INSTALL) -m $(INSTALL_DATA_MODE)
505 INSTALL_STLIB = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
506 INSTALL_SHLIB = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
507 # Override in Makefile.port if necessary
508 INSTALL_SHLIB_OPTS = -m 755
512 missing = $(SHELL) $(top_srcdir)/config/missing
515 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
516 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
520 DBTOEPUB = @DBTOEPUB@
523 XSLTPROC = @XSLTPROC@
533 DEF_PGPORT = @default_port@
534 WANTED_LANGUAGES = @WANTED_LANGUAGES@
537 ##########################################################################
539 # Additional platform-specific settings
542 # Name of the "template"
545 build_os = @build_os@
549 host_cpu = @host_cpu@
551 # Backend stack size limit has to be hard-wired on Windows (it's in bytes)
552 WIN32_STACK_RLIMIT=4194304
554 DLSUFFIX = @DLSUFFIX@
556 # Pull in platform-specific magic
557 include $(top_builddir)/src/Makefile.port
559 # Set up rpath if enabled. By default it will point to our libdir,
560 # but individual Makefiles can force other rpath paths if needed.
563 ifeq ($(enable_rpath), yes)
567 # Show the DLSUFFIX to build scripts (e.g. buildfarm)
568 .PHONY: show_dl_suffix
573 ##########################################################################
575 # Some variables needed to find some client interfaces
578 # some contribs assumes headers and libs are in the source tree...
579 libpq_srcdir = $(includedir)
580 libpq_builddir = $(libdir)
582 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
583 libpq_builddir = $(top_builddir)/src/interfaces/libpq
586 # How to link to libpq. (This macro may be used as-is by backend extensions.
587 # Client-side code should go through libpq_pgport or libpq_pgport_shlib,
589 libpq = -L$(libpq_builddir) -lpq
591 # libpq_pgport is for use by client executables (not libraries) that use libpq.
592 # We force clients to pull symbols from the non-shared libraries libpgport
593 # and libpgcommon rather than pulling some libpgport symbols from libpq just
594 # because libpq uses those functions too. This makes applications less
595 # dependent on changes in libpq's usage of pgport (on platforms where we
596 # don't have symbol export control for libpq). To do this we link to
597 # pgport before libpq. This does cause duplicate -lpgport's to appear
598 # on client link lines, since that also appears in $(LIBS).
599 # libpq_pgport_shlib is the same idea, but for use in client shared libraries.
601 libpq_pgport = -L$(libdir) -lpgcommon -lpgport $(libpq)
602 libpq_pgport_shlib = -L$(libdir) -lpgcommon_shlib -lpgport_shlib $(libpq)
604 libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq)
605 libpq_pgport_shlib = -L$(top_builddir)/src/common -lpgcommon_shlib -L$(top_builddir)/src/port -lpgport_shlib $(libpq)
608 # Cygwin seems to need ldap libraries to be mentioned here, too
609 ifeq ($(PORTNAME),cygwin)
610 libpq_pgport += $(LDAP_LIBS_FE)
614 ##########################################################################
616 # Commonly used submake targets
618 submake-libpq: | submake-generated-headers
619 $(MAKE) -C $(libpq_builddir) all
621 submake-libpgport: | submake-generated-headers
622 $(MAKE) -C $(top_builddir)/src/port all
623 $(MAKE) -C $(top_builddir)/src/common all
625 submake-libpgfeutils: | submake-generated-headers
626 $(MAKE) -C $(top_builddir)/src/port all
627 $(MAKE) -C $(top_builddir)/src/common all
628 $(MAKE) -C $(top_builddir)/src/fe_utils all
630 .PHONY: submake-libpq submake-libpgport submake-libpgfeutils
633 ##########################################################################
637 ifneq ($(USE_MODULE_DB),)
638 PL_TESTDB = pl_regression_$(NAME)
639 ifneq ($(MODULE_big),)
640 CONTRIB_TESTDB=contrib_regression_$(MODULE_big)
641 ISOLATION_TESTDB=isolation_regression_$(MODULE_big)
644 CONTRIB_TESTDB=contrib_regression_$(word 1,$(MODULES))
645 ISOLATION_TESTDB=isolation_regression_$(word 1,$(MODULES))
647 CONTRIB_TESTDB=contrib_regression_$(word 1,$(REGRESS))
648 ISOLATION_TESTDB=isolation_regression_$(word 1,$(ISOLATION))
652 PL_TESTDB = pl_regression
653 CONTRIB_TESTDB = contrib_regression
654 ISOLATION_TESTDB = isolation_regression
658 NOLOCALE += --no-locale
661 # file with extra config for temp build
664 TEMP_CONF += --temp-config=$(TEMP_CONFIG)
667 pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
668 pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/
671 echo "+++ regress check in $(subdir) +++" && \
672 $(with_temp_install) \
673 $(top_builddir)/src/test/regress/pg_regress \
674 --temp-instance=./tmp_check \
675 --inputdir=$(srcdir) \
678 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
679 pg_regress_installcheck = \
680 echo "+++ regress install-check in $(subdir) +++" && \
681 $(top_builddir)/src/test/regress/pg_regress \
682 --inputdir=$(srcdir) \
683 --bindir='$(bindir)' \
684 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
686 pg_isolation_regress_check = \
687 echo "+++ isolation check in $(subdir) +++" && \
688 $(with_temp_install) \
689 $(top_builddir)/src/test/isolation/pg_isolation_regress \
690 --temp-instance=./tmp_check_iso \
691 --inputdir=$(srcdir) --outputdir=output_iso \
694 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
695 pg_isolation_regress_installcheck = \
696 echo "+++ isolation install-check in $(subdir) +++" && \
697 $(top_builddir)/src/test/isolation/pg_isolation_regress \
698 --inputdir=$(srcdir) --outputdir=output_iso \
699 --bindir='$(bindir)' \
700 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
702 ##########################################################################
706 # This includes your local customizations if Makefile.custom exists
707 # in the source directory. This file doesn't exist in the original
708 # distribution so that it doesn't get overwritten when you upgrade.
710 # NOTE: Makefile.custom is from the pre-Autoconf days of PostgreSQL.
711 # You are liable to shoot yourself in the foot if you use it without
712 # knowing exactly what you're doing. The preferred (and more
713 # reliable) method is to communicate what you want to do to the
714 # configure script, and leave the makefiles alone.
716 -include $(top_srcdir)/src/Makefile.custom
718 ifneq ($(CUSTOM_INSTALL),)
719 INSTALL= $(CUSTOM_INSTALL)
722 ifneq ($(CUSTOM_CC),)
726 ifneq ($(CUSTOM_COPT),)
731 # These variables are meant to be set in the environment of "make"
732 # to add flags to whatever configure picked. Unlike the ones above,
733 # they are documented.
742 LDFLAGS += $(PROFILE)
746 ##########################################################################
748 # substitute implementations of C library routines (see src/port/)
749 # note we already included -L.../src/port in LDFLAGS above
753 # files needed for the chosen CRC-32C implementation
754 PG_CRC32C_OBJS = @PG_CRC32C_OBJS@
756 LIBS := -lpgcommon -lpgport $(LIBS)
758 # to make ws2_32.lib the last library
759 ifeq ($(PORTNAME),win32)
763 # Not really standard libc functions, used by the backend.
767 ##########################################################################
769 # Global targets and rules
773 $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
774 @$(if $(FLEX_NO_BACKUP),if [ `wc -l <lex.backup` -eq 1 ]; then rm lex.backup; else echo "Scanner requires backup; see lex.backup." 1>&2; exit 1; fi)
775 $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
777 @$(missing) flex $< '$@'
781 $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
783 $(BISON) $(BISONFLAGS) -o $@ $<
785 @$(missing) bison $< $@
789 $(CPP) $(CPPFLAGS) -o $@ $<
792 $(GZIP) --best -c $< >$@
797 # Direct builds of foo.c -> foo are disabled to avoid generating
798 # *.dSYM junk on Macs. All builds should normally go through the
799 # foo.c -> foo.o -> foo steps. This also ensures that dependency
800 # tracking (see below) is used.
803 # Replace gmake's default rule for linking a single .o file to produce an
804 # executable. The main point here is to put LDFLAGS after the .o file,
805 # since we put -l switches into LDFLAGS and those are order-sensitive.
806 # In addition, include CFLAGS and LDFLAGS_EX per project conventions.
808 $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
812 # Remake Makefile.global from Makefile.global.in if the latter
813 # changed. In order to trigger this rule, the including file must
814 # write `include $(top_builddir)/src/Makefile.global', not some
816 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
817 cd $(top_builddir) && ./config.status src/Makefile.global
819 # Remake pg_config.h from pg_config.h.in if the latter changed.
820 # config.status will not change the timestamp on pg_config.h if it
821 # doesn't change, so as to avoid recompiling the entire tree
822 # unnecessarily. Therefore we make config.status update a timestamp file
823 # stamp-h every time it runs, so that we don't trigger this rule every time.
824 # (We do trigger the null rule for stamp-h to pg_config.h every time; so it's
825 # important for that rule to be empty!)
827 # Of course you need to turn on dependency tracking to get any
828 # dependencies on pg_config.h.
829 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
831 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
832 cd $(top_builddir) && ./config.status src/include/pg_config.h
834 # Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above.
835 $(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ;
837 $(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status
838 cd $(top_builddir) && ./config.status src/include/pg_config_ext.h
840 # Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
842 $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
844 $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
845 cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
847 # When configure changes, rerun configure with the same options as
848 # last time. To change configure, you need to run autoconf manually.
849 $(top_builddir)/config.status: $(top_srcdir)/configure
850 cd $(top_builddir) && ./config.status --recheck
856 # install-strip always uses install-sh, so that strip options can be
858 $(MAKE) use_install_sh=yes \
859 INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
860 INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
861 INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
862 INSTALL_STRIP_FLAG=-s \
866 ##########################################################################
868 # Recursive make support
869 # ----------------------
870 # Instead of recursing through subdirectories with a for loop or
871 # repeated $(MAKE) -C whatever calls, this is a little smarter: it
872 # allows parallel make across directories and lets make -k and -q work
875 # We need the ability to export target-specific variables, which was
876 # added in GNU make 3.81. That also happens to be the version
877 # where the .FEATURES variable was introduced, so this is a simple check.
879 $(error GNU make 3.81 or newer is required. You are using version $(MAKE_VERSION))
882 # This function is only for internal use below. It should be called
883 # using $(eval). It will set up a target so that it recurses into a
884 # given subdirectory. For the tree-wide all/install/check/installcheck cases,
885 # ensure we do our one-time tasks before recursing (see targets above).
886 # Note that to avoid a nasty bug in make 3.80,
887 # this function was written to not use any complicated constructs (like
888 # multiple targets on a line) and also not contain any lines that expand
889 # to more than about 200 bytes. This is why we make it apply to just one
890 # subdirectory at a time, rather than to a list of subdirectories.
891 # $1: target name, e.g., all
893 # $3: target to run in subdir, usually same as $1
894 define _create_recursive_target
895 .PHONY: $(1)-$(2)-recurse
896 $(1): $(1)-$(2)-recurse
897 $(1)-$(2)-recurse: $(if $(filter all install check installcheck, $(3)), submake-generated-headers) $(if $(filter check, $(3)), temp-install)
898 $$(MAKE) -C $(2) $(3)
900 # Note that the use of $$ on the last line above is important; we want
901 # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
902 # to create the rule. This is necessary to get make -q working.
904 # Call this function in a makefile that needs to recurse into subdirectories.
905 # In the normal case all arguments can be defaulted.
906 # $1: targets to make recursive (defaults to list of standard targets)
907 # $2: list of subdirs (defaults to SUBDIRS variable)
908 # $3: target to run in subdir (defaults to current element of $1)
909 recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if $2,$2,$(SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target))))))
911 # If a makefile's list of SUBDIRS varies depending on configuration, then
912 # any subdirectories excluded from SUBDIRS should instead be added to
913 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
914 # This ensures that distprep, distclean, etc will apply to all subdirectories.
915 # In the normal case all arguments will be defaulted.
916 # $1: targets to make recursive (defaults to standard_always_targets)
917 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
918 # $3: target to run in subdir (defaults to current element of $1)
919 recurse_always = $(foreach target,$(if $1,$1,$(standard_always_targets)),$(foreach subdir,$(if $2,$2,$(ALWAYS_SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target))))))
922 ##########################################################################
924 # Automatic dependency generation
925 # -------------------------------
926 # When we configure with --enable-depend then we override the default
927 # compilation rule with the magic below. While or after creating the
928 # actual output file we also create a dependency list for the .c file.
929 # Next time we invoke make we will have top-notch information about
930 # whether this file needs to be updated. The dependency files are kept
931 # in the .deps subdirectory of each directory.
933 autodepend = @autodepend@
935 ifeq ($(autodepend), yes)
938 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
942 COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
949 # GCC allows us to create object and dependency file in one invocation.
951 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
952 $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
955 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
956 $(COMPILE.cc) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
960 # Include all the dependency files generated for the current
961 # directory. Note that make would complain if include was called with
963 Po_files := $(wildcard $(DEPDIR)/*.Po)
969 clean distclean maintainer-clean: clean-deps
978 ##########################################################################
980 # Native language support
982 ifeq ($(enable_nls), yes)
983 ifneq (,$(wildcard $(srcdir)/nls.mk))
985 include $(top_srcdir)/src/nls-global.mk
991 ##########################################################################
995 # Explanation of involved files:
998 # foo.gcno gcov graph (a.k.a. "notes") file, created at compile time
999 # (by gcc -ftest-coverage)
1000 # foo.gcda gcov data file, created when the program is run (for
1001 # programs compiled with gcc -fprofile-arcs)
1002 # foo.c.gcov gcov output file with coverage information, created by
1003 # gcov from foo.gcda (by "make coverage")
1004 # foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly
1007 # lcov tracefile, built from gcda files in one directory,
1008 # later collected by "make coverage-html"
1010 # tracefile for zero counters for every file, so that
1011 # even files that are not touched by tests are counted
1012 # for the overall coverage rate
1014 ifeq ($(enable_coverage), yes)
1016 # make coverage -- text output
1018 local_gcda_files = $(wildcard *.gcda)
1020 coverage: $(local_gcda_files:.gcda=.c.gcov)
1023 $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
1025 # make coverage-html -- HTML output via lcov
1027 .PHONY: coverage-html
1028 coverage-html: coverage-html-stamp
1030 GENHTML_FLAGS = -q --legend
1031 GENHTML_TITLE = PostgreSQL $(VERSION)
1033 coverage-html-stamp: lcov_base.info lcov_test.info
1035 $(GENHTML) $(GENHTML_FLAGS) -o coverage --title='$(GENHTML_TITLE)' --num-spaces=4 $(if $(filter no,$(vpath_build)),--prefix='$(abs_top_srcdir)') $^
1038 LCOV += --gcov-tool $(GCOV)
1039 LCOVFLAGS = -q --no-external
1041 all_gcno_files = $(shell find . -name '*.gcno' -print)
1043 lcov_base.info: $(all_gcno_files)
1044 $(LCOV) $(LCOVFLAGS) -c -i -d . -d $(srcdir) -o $@
1046 all_gcda_files = $(shell find . -name '*.gcda' -print)
1048 lcov_test.info: $(all_gcda_files)
1049 $(LCOV) $(LCOVFLAGS) -c -d . -d $(srcdir) -o $@
1053 clean distclean maintainer-clean: clean-coverage
1055 .PHONY: clean-coverage
1057 rm -rf coverage coverage-html-stamp
1058 rm -f *.gcda *.gcno lcov*.info *.gcov .*.gcov *.gcov.out
1061 # User-callable target to reset counts between test runs
1063 rm -f `find . -name '*.gcda' -print`
1065 endif # enable_coverage
1067 ##########################################################################
1073 # -Wno-ignored-attributes added so gnu_printf doesn't trigger
1074 # warnings, when the main binary is compiled with C.
1075 COMPILE.c.bc = $(CLANG) -Wno-ignored-attributes $(BITCODE_CFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
1078 ifndef COMPILE.cxx.bc
1079 COMPILE.cxx.bc = $(CLANG) -xc++ -Wno-ignored-attributes $(BITCODE_CXXFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
1083 $(COMPILE.c.bc) -o $@ $<
1086 $(COMPILE.cxx.bc) -o $@ $<
1088 # Install LLVM bitcode module (for JITing).
1090 # The arguments are:
1091 # $(1) name of the module (e.g. an extension's name or postgres for core code)
1092 # $(2) source objects, with .o suffix
1094 # The many INSTALL_DATA invocations aren't particularly fast, it'd be
1095 # good if we could coalesce them, but I didn't find a good way.
1097 # Note: blank line at end of macro is necessary to let it be used in foreach
1098 define install_llvm_module
1099 $(MKDIR_P) '$(DESTDIR)${bitcodedir}/$(1)'
1100 $(MKDIR_P) $(sort $(dir $(addprefix '$(DESTDIR)${bitcodedir}'/$(1)/, $(2))))
1101 $(foreach obj, ${2}, $(INSTALL_DATA) $(patsubst %.o,%.bc, $(obj)) '$(DESTDIR)${bitcodedir}'/$(1)/$(dir $(obj))
1103 cd '$(DESTDIR)${bitcodedir}' && $(LLVM_BINPATH)/llvm-lto -thinlto -thinlto-action=thinlink -o $(1).index.bc $(addprefix $(1)/,$(patsubst %.o,%.bc, $(2)))
1107 # Uninstall LLVM bitcode module.
1109 # The arguments are:
1110 # $(1) name of the module (e.g. an extension's name or postgres for core code)
1112 # This intentionally doesn't use the explicit installed file list,
1113 # seems too likely to change regularly.
1114 define uninstall_llvm_module
1115 rm -rf '$(DESTDIR)${bitcodedir}/$(1)/'
1116 rm -f '$(DESTDIR)${bitcodedir}/$(1).index.bc'