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 clean distclean coverage check checkprep installcheck init-po update-po
23 # these targets should recurse even into subdirectories not being built:
24 standard_always_targets = clean distclean
26 .PHONY: $(standard_targets) maintainer-clean 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 maintainer-clean: distclean
40 # PostgreSQL version number
41 VERSION = @PACKAGE_VERSION@
42 MAJORVERSION = @PG_MAJORVERSION@
43 VERSION_NUM = @PG_VERSION_NUM@
45 PACKAGE_URL = @PACKAGE_URL@
47 # Set top_srcdir, srcdir, and VPATH.
49 top_srcdir = $(top_builddir)
51 # If VPATH is set or Makefile is not in current directory we are building
52 # the extension with VPATH so we set the variable here.
56 ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
60 srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
65 vpath_build = @vpath_build@
66 abs_top_builddir = @abs_top_builddir@
67 abs_top_srcdir = @abs_top_srcdir@
69 ifneq ($(vpath_build),yes)
70 top_srcdir = $(top_builddir)
72 else # vpath_build = yes
73 top_srcdir = $(abs_top_srcdir)
74 srcdir = $(top_srcdir)/$(subdir)
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_injection_points = @enable_injection_points@
205 enable_tap_tests = @enable_tap_tests@
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_CRC = @CFLAGS_CRC@
266 PERMIT_DECLARATION_AFTER_STATEMENT = @PERMIT_DECLARATION_AFTER_STATEMENT@
267 PERMIT_MISSING_VARIABLE_DECLARATIONS = @PERMIT_MISSING_VARIABLE_DECLARATIONS@
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@
289 LDAP_LIBS_FE = @LDAP_LIBS_FE@
290 LDAP_LIBS_BE = @LDAP_LIBS_BE@
291 UUID_LIBS = @UUID_LIBS@
292 LLVM_LIBS=@LLVM_LIBS@
294 # It's critical that within LDFLAGS, all -L switches pointing to build-tree
295 # directories come before any -L switches pointing to external directories.
296 # Otherwise it's possible for, e.g., a platform-provided copy of libpq.so
297 # to get linked in place of the one we've built. Therefore we adopt the
298 # convention that the first component of LDFLAGS is an extra variable
299 # LDFLAGS_INTERNAL, and -L and -l switches for PG's own libraries must be
300 # put into LDFLAGS_INTERNAL, so they will appear ahead of those for external
303 # We need LDFLAGS and LDFLAGS_INTERNAL to be "recursively expanded" variables,
304 # else adjustments to, e.g., rpathdir don't work right. So we must NOT do
305 # "LDFLAGS := something" anywhere, ditto for LDFLAGS_INTERNAL.
306 # These initial assignments must be "=" type, and elsewhere we must only do
307 # "LDFLAGS += something" or "LDFLAGS_INTERNAL += something".
309 LDFLAGS_INTERNAL = -L$(libdir)
311 LDFLAGS_INTERNAL = -L$(top_builddir)/src/port -L$(top_builddir)/src/common
313 LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@
315 LDFLAGS_EX = @LDFLAGS_EX@
316 LDFLAGS_EX_BE = @LDFLAGS_EX_BE@
317 # LDFLAGS_SL might have already been assigned by calling makefile
318 LDFLAGS_SL += @LDFLAGS_SL@
324 # quoted to protect pathname with spaces
326 perl_archlibexp = @perl_archlibexp@
327 perl_privlibexp = @perl_privlibexp@
328 perl_includespec = @perl_includespec@
329 perl_embed_ccflags = @perl_embed_ccflags@
330 perl_embed_ldflags = @perl_embed_ldflags@
337 MSGFMT_FLAGS = @MSGFMT_FLAGS@
338 MSGMERGE = @MSGMERGE@
342 XGETTEXT = @XGETTEXT@
349 DOWNLOAD = wget -O $@ --no-use-server-timestamps
350 #DOWNLOAD = curl -o $@
353 # Unicode data information
355 # Before each major release, update these and run make update-unicode.
357 # Pick a release from here: <https://www.unicode.org/Public/>. Note
358 # that the most recent release listed there is often a pre-release;
359 # don't pick that one, except for testing.
360 UNICODE_VERSION = 15.1.0
362 # Pick a release from here: <http://cldr.unicode.org/index/downloads>
366 # Tree-wide build support
368 # Just about every code subdirectory wants to have the generated headers
369 # available before building, but we don't want parallel makes all trying
370 # to build the same headers. These rules, together with the recursion rules
371 # below, ensure that we update the generated headers once, if needed,
372 # at the top level of any "make all/install/check/installcheck" request.
373 # If a particular subdirectory knows this isn't needed in itself or its
374 # children, it can set NO_GENERATED_HEADERS.
376 all install check installcheck: submake-generated-headers
378 .PHONY: submake-generated-headers
380 submake-generated-headers:
381 ifndef NO_GENERATED_HEADERS
382 ifeq ($(MAKELEVEL),0)
383 $(MAKE) -C $(top_builddir)/src/backend generated-headers
390 # In much the same way as above, these rules ensure that we build a temp
391 # install tree just once in any recursive "make check". The additional test
392 # on abs_top_builddir prevents doing anything foolish to the root directory.
399 # prepend to path if already set, else just set it
401 $(1)="$(if $($(1)),$(2):$$$(1),$(2))"
404 # platform-specific environment variable to set shared library path
405 # individual ports can override this later, this is the default name
406 ld_library_path_var = LD_LIBRARY_PATH
408 # with_temp_install_extra is for individual ports to define if they
409 # need something more here. If not defined then the expansion does
411 with_temp_install = \
412 PATH="$(abs_top_builddir)/tmp_install$(bindir):$(CURDIR):$$PATH" \
413 $(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \
414 INITDB_TEMPLATE='$(abs_top_builddir)'/tmp_install/initdb-template \
415 $(with_temp_install_extra)
417 temp-install: | submake-generated-headers
418 ifndef NO_TEMP_INSTALL
419 ifneq ($(abs_top_builddir),)
420 ifeq ($(MAKELEVEL),0)
421 rm -rf '$(abs_top_builddir)'/tmp_install
422 $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log
423 $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
424 $(MAKE) -j1 $(if $(CHECKPREP_TOP),-C $(CHECKPREP_TOP),) checkprep >>'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
426 $(with_temp_install) initdb --auth trust --no-sync --no-instructions --lc-messages=C --no-clean '$(abs_top_builddir)'/tmp_install/initdb-template >>'$(abs_top_builddir)'/tmp_install/log/initdb-template.log 2>&1
431 # Tasks to run serially at the end of temp-install. Some EXTRA_INSTALL
432 # entries appear more than once in the tree, and parallel installs of the same
433 # file can fail with EEXIST.
435 $(if $(EXTRA_INSTALL),for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install || exit; done)
438 # There are common routines in src/test/perl, and some test suites have
439 # extra perl modules in their own directory.
440 PG_PROVE_FLAGS = -I $(top_srcdir)/src/test/perl/ -I $(srcdir)
441 # User-supplied prove flags such as --verbose can be provided in PROVE_FLAGS.
444 ifeq ($(enable_tap_tests),yes)
447 define prove_installcheck
448 echo "# +++ tap install-check in $(subdir) +++" && \
449 rm -rf '$(CURDIR)'/tmp_check && \
450 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
452 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
453 TESTDATADIR='$(CURDIR)/tmp_check' \
454 PATH="$(bindir):$(CURDIR):$$PATH" \
455 PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
456 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
457 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
460 define prove_installcheck
461 echo "# +++ tap install-check in $(subdir) +++" && \
462 rm -rf '$(CURDIR)'/tmp_check && \
463 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
465 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
466 TESTDATADIR='$(CURDIR)/tmp_check' \
467 PATH="$(bindir):$(CURDIR):$$PATH" \
468 PGPORT='6$(DEF_PGPORT)' \
469 PG_REGRESS='$(top_builddir)/src/test/regress/pg_regress' \
470 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
475 echo "# +++ tap check in $(subdir) +++" && \
476 rm -rf '$(CURDIR)'/tmp_check && \
477 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
479 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
480 TESTDATADIR='$(CURDIR)/tmp_check' \
481 $(with_temp_install) \
482 PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
483 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
484 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
488 prove_installcheck = @echo "TAP tests not enabled. Try configuring with --enable-tap-tests"
489 prove_check = $(prove_installcheck)
494 install_bin = @install_bin@
495 install_sh = $(SHELL) $(top_srcdir)/config/install-sh -c
496 INSTALL = $(if $(use_install_sh),$(install_sh),$(if $(install_bin),$(install_bin),$(install_sh)))
498 INSTALL_SCRIPT_MODE = 755
499 INSTALL_DATA_MODE = 644
500 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
501 INSTALL_SCRIPT = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
502 INSTALL_DATA = $(INSTALL) -m $(INSTALL_DATA_MODE)
503 INSTALL_STLIB = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
504 INSTALL_SHLIB = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
505 # Override in Makefile.port if necessary
506 INSTALL_SHLIB_OPTS = -m 755
510 missing = $(SHELL) $(top_srcdir)/config/missing
513 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
514 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
518 DBTOEPUB = @DBTOEPUB@
521 XSLTPROC = @XSLTPROC@
531 DEF_PGPORT = @default_port@
532 WANTED_LANGUAGES = @WANTED_LANGUAGES@
535 ##########################################################################
537 # Additional platform-specific settings
540 # Name of the "template"
543 build_os = @build_os@
547 host_cpu = @host_cpu@
549 # Backend stack size limit has to be hard-wired on Windows (it's in bytes)
550 WIN32_STACK_RLIMIT=4194304
552 DLSUFFIX = @DLSUFFIX@
554 # Pull in platform-specific magic
555 include $(top_builddir)/src/Makefile.port
557 # Set up rpath if enabled. By default it will point to our libdir,
558 # but individual Makefiles can force other rpath paths if needed.
561 ifeq ($(enable_rpath), yes)
565 # Show the DLSUFFIX to build scripts (e.g. buildfarm)
566 .PHONY: show_dl_suffix
571 ##########################################################################
573 # Some variables needed to find some client interfaces
576 # some contribs assumes headers and libs are in the source tree...
577 libpq_srcdir = $(includedir)
578 libpq_builddir = $(libdir)
580 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
581 libpq_builddir = $(top_builddir)/src/interfaces/libpq
584 # How to link to libpq. (This macro may be used as-is by backend extensions.
585 # Client-side code should go through libpq_pgport or libpq_pgport_shlib,
587 libpq = -L$(libpq_builddir) -lpq
589 # libpq_pgport is for use by client executables (not libraries) that use libpq.
590 # We used to use this to force libpgport and libpgcommon to be linked before
591 # libpq, ensuring that clients would pull symbols from those libraries rather
592 # than possibly getting them from libpq (and thereby having an unwanted
593 # dependency on which symbols libpq uses). However, now that we can prevent
594 # libpq from exporting those symbols on all platforms of interest, we don't
595 # worry about that anymore. The previous technique resulted in duplicate
596 # libraries in link commands, since those libraries also appear in $(LIBS).
597 # Some platforms warn about that, so avoiding those warnings is now more
598 # important. Hence, $(libpq_pgport) is now equivalent to $(libpq), but we
599 # still recommend using it for client executables in case some other reason
600 # appears to handle them differently.
601 libpq_pgport = $(libpq)
603 # libpq_pgport_shlib is the same idea, but for use in client shared libraries.
604 # We need those clients to use the shlib variants. (Ideally, users of this
605 # macro would strip libpgport and libpgcommon from $(LIBS), but no harm is
606 # done if they don't, since they will have satisfied all their references
607 # from these libraries.)
609 libpq_pgport_shlib = -L$(libdir) -lpgcommon_shlib -lpgport_shlib $(libpq)
611 libpq_pgport_shlib = -L$(top_builddir)/src/common -lpgcommon_shlib -L$(top_builddir)/src/port -lpgport_shlib $(libpq)
614 # Cygwin seems to need ldap libraries to be mentioned here, too
615 ifeq ($(PORTNAME),cygwin)
616 libpq_pgport += $(LDAP_LIBS_FE)
620 ##########################################################################
622 # Commonly used submake targets
624 submake-libpq: | submake-generated-headers
625 $(MAKE) -C $(libpq_builddir) all
627 submake-libpgport: | submake-generated-headers
628 $(MAKE) -C $(top_builddir)/src/port all
629 $(MAKE) -C $(top_builddir)/src/common all
631 submake-libpgfeutils: | submake-generated-headers
632 $(MAKE) -C $(top_builddir)/src/port all
633 $(MAKE) -C $(top_builddir)/src/common all
634 $(MAKE) -C $(top_builddir)/src/fe_utils all
636 .PHONY: submake-libpq submake-libpgport submake-libpgfeutils
639 ##########################################################################
643 # Store any configure-time setting for PG_TEST_EXTRA, but let environment
644 # variables override it to maintain the historical behavior of the tests.
645 # (Standard `=` assignment would require devs to use a commandline option.)
646 # This is skipped in PGXS mode to keep the setting from escaping into other
649 PG_TEST_EXTRA ?= @PG_TEST_EXTRA@
653 ifneq ($(USE_MODULE_DB),)
654 PL_TESTDB = pl_regression_$(NAME)
655 ifneq ($(MODULE_big),)
656 CONTRIB_TESTDB=contrib_regression_$(MODULE_big)
657 ISOLATION_TESTDB=isolation_regression_$(MODULE_big)
660 CONTRIB_TESTDB=contrib_regression_$(word 1,$(MODULES))
661 ISOLATION_TESTDB=isolation_regression_$(word 1,$(MODULES))
663 CONTRIB_TESTDB=contrib_regression_$(word 1,$(REGRESS))
664 ISOLATION_TESTDB=isolation_regression_$(word 1,$(ISOLATION))
668 PL_TESTDB = pl_regression
669 CONTRIB_TESTDB = contrib_regression
670 ISOLATION_TESTDB = isolation_regression
674 NOLOCALE += --no-locale
677 # file with extra config for temp build
680 TEMP_CONF += --temp-config=$(TEMP_CONFIG)
683 pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
684 pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/
687 echo "\# +++ regress check in $(subdir) +++" && \
688 $(with_temp_install) \
689 $(top_builddir)/src/test/regress/pg_regress \
690 --temp-instance=./tmp_check \
691 --inputdir=$(srcdir) \
694 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
695 pg_regress_installcheck = \
696 echo "\# +++ regress install-check in $(subdir) +++" && \
697 $(top_builddir)/src/test/regress/pg_regress \
698 --inputdir=$(srcdir) \
699 --bindir='$(bindir)' \
700 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
702 pg_isolation_regress_check = \
703 echo "\# +++ isolation check in $(subdir) +++" && \
704 $(with_temp_install) \
705 $(top_builddir)/src/test/isolation/pg_isolation_regress \
706 --temp-instance=./tmp_check_iso \
707 --inputdir=$(srcdir) --outputdir=output_iso \
710 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
711 pg_isolation_regress_installcheck = \
712 echo "\# +++ isolation install-check in $(subdir) +++" && \
713 $(top_builddir)/src/test/isolation/pg_isolation_regress \
714 --inputdir=$(srcdir) --outputdir=output_iso \
715 --bindir='$(bindir)' \
716 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
718 ##########################################################################
722 # This includes your local customizations if Makefile.custom exists
723 # in the source directory. This file doesn't exist in the original
724 # distribution so that it doesn't get overwritten when you upgrade.
726 # NOTE: Makefile.custom is from the pre-Autoconf days of PostgreSQL.
727 # You are liable to shoot yourself in the foot if you use it without
728 # knowing exactly what you're doing. The preferred (and more
729 # reliable) method is to communicate what you want to do to the
730 # configure script, and leave the makefiles alone.
732 -include $(top_srcdir)/src/Makefile.custom
734 ifneq ($(CUSTOM_INSTALL),)
735 INSTALL= $(CUSTOM_INSTALL)
738 ifneq ($(CUSTOM_CC),)
742 ifneq ($(CUSTOM_COPT),)
747 # These variables are meant to be set in the environment of "make"
748 # to add flags to whatever configure picked. Unlike the ones above,
749 # they are documented.
759 LDFLAGS += $(PROFILE)
763 ##########################################################################
765 # substitute implementations of C library routines (see src/port/)
766 # note we already included -L.../src/port in LDFLAGS above
770 # files needed for the chosen CRC-32C implementation
771 PG_CRC32C_OBJS = @PG_CRC32C_OBJS@
773 LIBS := -lpgcommon -lpgport $(LIBS)
775 # to make ws2_32.lib the last library
776 ifeq ($(PORTNAME),win32)
780 # Not really standard libc functions, used by the backend.
784 ##########################################################################
786 # Global targets and rules
789 $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
790 @$(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)
791 $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
794 $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
795 $(BISON) $(BISONFLAGS) -o $@ $<
798 $(CPP) $(CPPFLAGS) -o $@ $<
801 $(GZIP) --best -c $< >$@
806 # Direct builds of foo.c -> foo are disabled to avoid generating
807 # *.dSYM junk on Macs. All builds should normally go through the
808 # foo.c -> foo.o -> foo steps. This also ensures that dependency
809 # tracking (see below) is used.
812 # Replace gmake's default rule for linking a single .o file to produce an
813 # executable. The main point here is to put LDFLAGS after the .o file,
814 # since we put -l switches into LDFLAGS and those are order-sensitive.
815 # In addition, include CFLAGS and LDFLAGS_EX per project conventions.
817 $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
821 # Remake Makefile.global from Makefile.global.in if the latter
822 # changed. In order to trigger this rule, the including file must
823 # write `include $(top_builddir)/src/Makefile.global', not some
825 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
826 cd $(top_builddir) && ./config.status src/Makefile.global
828 # Remake pg_config.h from pg_config.h.in if the latter changed.
829 # config.status will not change the timestamp on pg_config.h if it
830 # doesn't change, so as to avoid recompiling the entire tree
831 # unnecessarily. Therefore we make config.status update a timestamp file
832 # stamp-h every time it runs, so that we don't trigger this rule every time.
833 # (We do trigger the null rule for stamp-h to pg_config.h every time; so it's
834 # important for that rule to be empty!)
836 # Of course you need to turn on dependency tracking to get any
837 # dependencies on pg_config.h.
838 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
840 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
841 cd $(top_builddir) && ./config.status src/include/pg_config.h
843 # Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
845 $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
847 $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
848 cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
850 # When configure changes, rerun configure with the same options as
851 # last time. To change configure, you need to run autoconf manually.
852 $(top_builddir)/config.status: $(top_srcdir)/configure
853 cd $(top_builddir) && ./config.status --recheck
859 # install-strip always uses install-sh, so that strip options can be
861 $(MAKE) use_install_sh=yes \
862 INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
863 INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
864 INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
865 INSTALL_STRIP_FLAG=-s \
869 ##########################################################################
871 # Recursive make support
872 # ----------------------
873 # Instead of recursing through subdirectories with a for loop or
874 # repeated $(MAKE) -C whatever calls, this is a little smarter: it
875 # allows parallel make across directories and lets make -k and -q work
878 # We need the ability to export target-specific variables, which was
879 # added in GNU make 3.81. That also happens to be the version
880 # where the .FEATURES variable was introduced, so this is a simple check.
882 $(error GNU make 3.81 or newer is required. You are using version $(MAKE_VERSION))
885 # This function is only for internal use below. It should be called
886 # using $(eval). It will set up a target so that it recurses into a
887 # given subdirectory. For the tree-wide all/install/check/installcheck cases,
888 # ensure we do our one-time tasks before recursing (see targets above).
889 # Note that to avoid a nasty bug in make 3.80,
890 # this function was written to not use any complicated constructs (like
891 # multiple targets on a line) and also not contain any lines that expand
892 # to more than about 200 bytes. This is why we make it apply to just one
893 # subdirectory at a time, rather than to a list of subdirectories.
894 # $1: target name, e.g., all
896 # $3: target to run in subdir, usually same as $1
897 define _create_recursive_target
898 .PHONY: $(1)-$(2)-recurse
899 $(1): $(1)-$(2)-recurse
900 $(1)-$(2)-recurse: $(if $(filter all install check installcheck, $(3)), submake-generated-headers) $(if $(filter check, $(3)), temp-install)
901 $$(MAKE) -C $(2) $(3)
903 # Note that the use of $$ on the last line above is important; we want
904 # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
905 # to create the rule. This is necessary to get make -q working.
907 # Call this function in a makefile that needs to recurse into subdirectories.
908 # In the normal case all arguments can be defaulted.
909 # $1: targets to make recursive (defaults to list of standard targets)
910 # $2: list of subdirs (defaults to SUBDIRS variable)
911 # $3: target to run in subdir (defaults to current element of $1)
912 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))))))
914 # If a makefile's list of SUBDIRS varies depending on configuration, then
915 # any subdirectories excluded from SUBDIRS should instead be added to
916 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
917 # This ensures that distclean, etc will apply to all subdirectories.
918 # In the normal case all arguments will be defaulted.
919 # $1: targets to make recursive (defaults to standard_always_targets)
920 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
921 # $3: target to run in subdir (defaults to current element of $1)
922 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))))))
925 ##########################################################################
927 # Automatic dependency generation
928 # -------------------------------
929 # When we configure with --enable-depend then we override the default
930 # compilation rule with the magic below. While or after creating the
931 # actual output file we also create a dependency list for the .c file.
932 # Next time we invoke make we will have top-notch information about
933 # whether this file needs to be updated. The dependency files are kept
934 # in the .deps subdirectory of each directory.
936 autodepend = @autodepend@
938 ifeq ($(autodepend), yes)
941 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
945 COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
952 # GCC allows us to create object and dependency file in one invocation.
954 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
955 $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
958 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
959 $(COMPILE.cc) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
963 # Include all the dependency files generated for the current
964 # directory. Note that make would complain if include was called with
966 Po_files := $(wildcard $(DEPDIR)/*.Po)
972 clean distclean: clean-deps
981 ##########################################################################
983 # Native language support
985 ifeq ($(enable_nls), yes)
986 ifneq (,$(wildcard $(srcdir)/nls.mk))
988 include $(top_srcdir)/src/nls-global.mk
994 ##########################################################################
998 # Explanation of involved files:
1001 # foo.gcno gcov graph (a.k.a. "notes") file, created at compile time
1002 # (by gcc -ftest-coverage)
1003 # foo.gcda gcov data file, created when the program is run (for
1004 # programs compiled with gcc -fprofile-arcs)
1005 # foo.c.gcov gcov output file with coverage information, created by
1006 # gcov from foo.gcda (by "make coverage")
1007 # foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly
1010 # lcov tracefile, built from gcda files in one directory,
1011 # later collected by "make coverage-html"
1013 # tracefile for zero counters for every file, so that
1014 # even files that are not touched by tests are counted
1015 # for the overall coverage rate
1017 ifeq ($(enable_coverage), yes)
1019 # make coverage -- text output
1021 local_gcda_files = $(wildcard *.gcda)
1023 coverage: $(local_gcda_files:.gcda=.c.gcov)
1026 $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
1028 # make coverage-html -- HTML output via lcov
1030 .PHONY: coverage-html
1031 coverage-html: coverage-html-stamp
1033 GENHTML_FLAGS = -q --legend
1034 GENHTML_TITLE = PostgreSQL $(VERSION)
1036 coverage-html-stamp: lcov_base.info lcov_test.info
1038 $(GENHTML) $(GENHTML_FLAGS) -o coverage --title='$(GENHTML_TITLE)' --num-spaces=4 $(if $(filter no,$(vpath_build)),--prefix='$(abs_top_srcdir)') $^
1041 LCOV += --gcov-tool $(GCOV)
1042 LCOVFLAGS = -q --no-external
1044 all_gcno_files = $(shell find . -name '*.gcno' -print)
1046 lcov_base.info: $(all_gcno_files)
1047 $(LCOV) $(LCOVFLAGS) -c -i -d . -d $(srcdir) -o $@
1049 all_gcda_files = $(shell find . -name '*.gcda' -print)
1051 lcov_test.info: $(all_gcda_files)
1052 $(LCOV) $(LCOVFLAGS) -c -d . -d $(srcdir) -o $@
1056 clean distclean: clean-coverage
1058 .PHONY: clean-coverage
1060 rm -rf coverage coverage-html-stamp
1061 rm -f *.gcda *.gcno lcov*.info *.gcov .*.gcov *.gcov.out
1064 # User-callable target to reset counts between test runs
1066 rm -f `find . -name '*.gcda' -print`
1068 endif # enable_coverage
1070 ##########################################################################
1076 # -Wno-ignored-attributes added so gnu_printf doesn't trigger
1077 # warnings, when the main binary is compiled with C.
1078 COMPILE.c.bc = $(CLANG) -Wno-ignored-attributes $(BITCODE_CFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
1081 ifndef COMPILE.cxx.bc
1082 COMPILE.cxx.bc = $(CLANG) -xc++ -Wno-ignored-attributes $(BITCODE_CXXFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
1086 $(COMPILE.c.bc) -o $@ $<
1089 $(COMPILE.cxx.bc) -o $@ $<
1091 # Install LLVM bitcode module (for JITing).
1093 # The arguments are:
1094 # $(1) name of the module (e.g. an extension's name or postgres for core code)
1095 # $(2) source objects, with .o suffix
1097 # The many INSTALL_DATA invocations aren't particularly fast, it'd be
1098 # good if we could coalesce them, but I didn't find a good way.
1100 # Note: blank line at end of macro is necessary to let it be used in foreach
1101 define install_llvm_module
1102 $(MKDIR_P) '$(DESTDIR)${bitcodedir}/$(1)'
1103 $(MKDIR_P) $(sort $(dir $(addprefix '$(DESTDIR)${bitcodedir}'/$(1)/, $(2))))
1104 $(foreach obj, ${2}, $(INSTALL_DATA) $(patsubst %.o,%.bc, $(obj)) '$(DESTDIR)${bitcodedir}'/$(1)/$(dir $(obj))
1106 cd '$(DESTDIR)${bitcodedir}' && $(LLVM_BINPATH)/llvm-lto -thinlto -thinlto-action=thinlink -o $(1).index.bc $(addprefix $(1)/,$(patsubst %.o,%.bc, $(2)))
1110 # Uninstall LLVM bitcode module.
1112 # The arguments are:
1113 # $(1) name of the module (e.g. an extension's name or postgres for core code)
1115 # This intentionally doesn't use the explicit installed file list,
1116 # seems too likely to change regularly.
1117 define uninstall_llvm_module
1118 rm -rf '$(DESTDIR)${bitcodedir}/$(1)/'
1119 rm -f '$(DESTDIR)${bitcodedir}/$(1).index.bc'