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@
206 python_includespec = @python_includespec@
207 python_libdir = @python_libdir@
208 python_libspec = @python_libspec@
209 python_additional_libs = @python_additional_libs@
210 python_majorversion = @python_majorversion@
211 python_version = @python_version@
213 krb_srvtab = @krb_srvtab@
215 ICU_CFLAGS = @ICU_CFLAGS@
216 ICU_LIBS = @ICU_LIBS@
219 TCL_LIBS = @TCL_LIBS@
220 TCL_LIB_SPEC = @TCL_LIB_SPEC@
221 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
222 TCL_SHARED_BUILD = @TCL_SHARED_BUILD@
224 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
225 PTHREAD_LIBS = @PTHREAD_LIBS@
227 LLVM_BINPATH = @LLVM_BINPATH@
229 BITCODE_CFLAGS = @BITCODE_CFLAGS@
230 BITCODE_CXXFLAGS = @BITCODE_CXXFLAGS@
232 ##########################################################################
239 CPPFLAGS = @CPPFLAGS@
240 PG_SYSROOT = @PG_SYSROOT@
242 override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS)
245 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
247 override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
249 override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
255 SUN_STUDIO_CC = @SUN_STUDIO_CC@
258 CFLAGS_SL = @CFLAGS_SL@
259 # *_MODULE are for flags applied to extension libraries
260 CFLAGS_SL_MODULE = @CFLAGS_SL_MODULE@
261 CXXFLAGS_SL_MODULE = @CXXFLAGS_SL_MODULE@
262 CFLAGS_UNROLL_LOOPS = @CFLAGS_UNROLL_LOOPS@
263 CFLAGS_VECTORIZE = @CFLAGS_VECTORIZE@
264 CFLAGS_CRC = @CFLAGS_CRC@
265 PERMIT_DECLARATION_AFTER_STATEMENT = @PERMIT_DECLARATION_AFTER_STATEMENT@
266 CXXFLAGS = @CXXFLAGS@
268 LLVM_CPPFLAGS = @LLVM_CPPFLAGS@
269 LLVM_CFLAGS = @LLVM_CFLAGS@
270 LLVM_CXXFLAGS = @LLVM_CXXFLAGS@
275 BISONFLAGS = @BISONFLAGS@ $(YFLAGS)
277 FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
279 DTRACEFLAGS = @DTRACEFLAGS@
287 LDAP_LIBS_FE = @LDAP_LIBS_FE@
288 LDAP_LIBS_BE = @LDAP_LIBS_BE@
289 UUID_LIBS = @UUID_LIBS@
290 LLVM_LIBS=@LLVM_LIBS@
292 # It's critical that within LDFLAGS, all -L switches pointing to build-tree
293 # directories come before any -L switches pointing to external directories.
294 # Otherwise it's possible for, e.g., a platform-provided copy of libpq.so
295 # to get linked in place of the one we've built. Therefore we adopt the
296 # convention that the first component of LDFLAGS is an extra variable
297 # LDFLAGS_INTERNAL, and -L and -l switches for PG's own libraries must be
298 # put into LDFLAGS_INTERNAL, so they will appear ahead of those for external
301 # We need LDFLAGS and LDFLAGS_INTERNAL to be "recursively expanded" variables,
302 # else adjustments to, e.g., rpathdir don't work right. So we must NOT do
303 # "LDFLAGS := something" anywhere, ditto for LDFLAGS_INTERNAL.
304 # These initial assignments must be "=" type, and elsewhere we must only do
305 # "LDFLAGS += something" or "LDFLAGS_INTERNAL += something".
307 LDFLAGS_INTERNAL = -L$(libdir)
309 LDFLAGS_INTERNAL = -L$(top_builddir)/src/port -L$(top_builddir)/src/common
311 LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@
313 LDFLAGS_EX = @LDFLAGS_EX@
314 LDFLAGS_EX_BE = @LDFLAGS_EX_BE@
315 # LDFLAGS_SL might have already been assigned by calling makefile
316 LDFLAGS_SL += @LDFLAGS_SL@
323 # quoted to protect pathname with spaces
326 PERL = $(missing) perl
328 perl_archlibexp = @perl_archlibexp@
329 perl_privlibexp = @perl_privlibexp@
330 perl_includespec = @perl_includespec@
331 perl_embed_ccflags = @perl_embed_ccflags@
332 perl_embed_ldflags = @perl_embed_ldflags@
339 MSGFMT_FLAGS = @MSGFMT_FLAGS@
340 MSGMERGE = @MSGMERGE@
344 XGETTEXT = @XGETTEXT@
351 DOWNLOAD = wget -O $@ --no-use-server-timestamps
352 #DOWNLOAD = curl -o $@
355 # Unicode data information
357 # Before each major release, update these and run make update-unicode.
359 # Pick a release from here: <https://www.unicode.org/Public/>. Note
360 # that the most recent release listed there is often a pre-release;
361 # don't pick that one, except for testing.
362 UNICODE_VERSION = 15.0.0
364 # Pick a release from here: <http://cldr.unicode.org/index/downloads>
368 # Tree-wide build support
370 # Just about every code subdirectory wants to have the generated headers
371 # available before building, but we don't want parallel makes all trying
372 # to build the same headers. These rules, together with the recursion rules
373 # below, ensure that we update the generated headers once, if needed,
374 # at the top level of any "make all/install/check/installcheck" request.
375 # If a particular subdirectory knows this isn't needed in itself or its
376 # children, it can set NO_GENERATED_HEADERS.
378 all install check installcheck: submake-generated-headers
380 .PHONY: submake-generated-headers
382 submake-generated-headers:
383 ifndef NO_GENERATED_HEADERS
384 ifeq ($(MAKELEVEL),0)
385 $(MAKE) -C $(top_builddir)/src/backend generated-headers
392 # In much the same way as above, these rules ensure that we build a temp
393 # install tree just once in any recursive "make check". The additional test
394 # on abs_top_builddir prevents doing anything foolish to the root directory.
400 temp-install: | submake-generated-headers
401 ifndef NO_TEMP_INSTALL
402 ifneq ($(abs_top_builddir),)
403 ifeq ($(MAKELEVEL),0)
404 rm -rf '$(abs_top_builddir)'/tmp_install
405 $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log
406 $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
407 $(MAKE) -j1 $(if $(CHECKPREP_TOP),-C $(CHECKPREP_TOP),) checkprep >>'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
412 # Tasks to run serially at the end of temp-install. Some EXTRA_INSTALL
413 # entries appear more than once in the tree, and parallel installs of the same
414 # file can fail with EEXIST.
416 $(if $(EXTRA_INSTALL),for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install || exit; done)
419 # There are common routines in src/test/perl, and some test suites have
420 # extra perl modules in their own directory.
421 PG_PROVE_FLAGS = -I $(top_srcdir)/src/test/perl/ -I $(srcdir)
422 # User-supplied prove flags such as --verbose can be provided in PROVE_FLAGS.
425 # prepend to path if already set, else just set it
427 $(1)="$(if $($(1)),$(2):$$$(1),$(2))"
430 # platform-specific environment variable to set shared library path
431 # individual ports can override this later, this is the default name
432 ld_library_path_var = LD_LIBRARY_PATH
434 # with_temp_install_extra is for individual ports to define if they
435 # need something more here. If not defined then the expansion does
437 with_temp_install = \
438 PATH="$(abs_top_builddir)/tmp_install$(bindir):$(CURDIR):$$PATH" \
439 $(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \
440 $(with_temp_install_extra)
442 ifeq ($(enable_tap_tests),yes)
445 define prove_installcheck
446 echo "# +++ tap install-check in $(subdir) +++" && \
447 rm -rf '$(CURDIR)'/tmp_check && \
448 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
450 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
451 TESTDATADIR='$(CURDIR)/tmp_check' \
452 PATH="$(bindir):$(CURDIR):$$PATH" \
453 PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
454 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
455 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
458 define prove_installcheck
459 echo "# +++ tap install-check in $(subdir) +++" && \
460 rm -rf '$(CURDIR)'/tmp_check && \
461 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
463 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
464 TESTDATADIR='$(CURDIR)/tmp_check' \
465 PATH="$(bindir):$(CURDIR):$$PATH" \
466 PGPORT='6$(DEF_PGPORT)' \
467 PG_REGRESS='$(top_builddir)/src/test/regress/pg_regress' \
468 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
473 echo "# +++ tap check in $(subdir) +++" && \
474 rm -rf '$(CURDIR)'/tmp_check && \
475 $(MKDIR_P) '$(CURDIR)'/tmp_check && \
477 TESTLOGDIR='$(CURDIR)/tmp_check/log' \
478 TESTDATADIR='$(CURDIR)/tmp_check' \
479 $(with_temp_install) \
480 PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' \
481 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \
482 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
486 prove_installcheck = @echo "TAP tests not enabled. Try configuring with --enable-tap-tests"
487 prove_check = $(prove_installcheck)
492 install_bin = @install_bin@
493 install_sh = $(SHELL) $(top_srcdir)/config/install-sh -c
494 INSTALL = $(if $(use_install_sh),$(install_sh),$(if $(install_bin),$(install_bin),$(install_sh)))
496 INSTALL_SCRIPT_MODE = 755
497 INSTALL_DATA_MODE = 644
498 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
499 INSTALL_SCRIPT = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
500 INSTALL_DATA = $(INSTALL) -m $(INSTALL_DATA_MODE)
501 INSTALL_STLIB = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
502 INSTALL_SHLIB = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
503 # Override in Makefile.port if necessary
504 INSTALL_SHLIB_OPTS = -m 755
508 missing = $(SHELL) $(top_srcdir)/config/missing
511 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
512 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
516 DBTOEPUB = @DBTOEPUB@
519 XSLTPROC = @XSLTPROC@
529 DEF_PGPORT = @default_port@
530 WANTED_LANGUAGES = @WANTED_LANGUAGES@
533 ##########################################################################
535 # Additional platform-specific settings
538 # Name of the "template"
541 build_os = @build_os@
545 host_cpu = @host_cpu@
547 # Backend stack size limit has to be hard-wired on Windows (it's in bytes)
548 WIN32_STACK_RLIMIT=4194304
550 DLSUFFIX = @DLSUFFIX@
552 # Pull in platform-specific magic
553 include $(top_builddir)/src/Makefile.port
555 # Set up rpath if enabled. By default it will point to our libdir,
556 # but individual Makefiles can force other rpath paths if needed.
559 ifeq ($(enable_rpath), yes)
563 # Show the DLSUFFIX to build scripts (e.g. buildfarm)
564 .PHONY: show_dl_suffix
569 ##########################################################################
571 # Some variables needed to find some client interfaces
574 # some contribs assumes headers and libs are in the source tree...
575 libpq_srcdir = $(includedir)
576 libpq_builddir = $(libdir)
578 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
579 libpq_builddir = $(top_builddir)/src/interfaces/libpq
582 # How to link to libpq. (This macro may be used as-is by backend extensions.
583 # Client-side code should go through libpq_pgport or libpq_pgport_shlib,
585 libpq = -L$(libpq_builddir) -lpq
587 # libpq_pgport is for use by client executables (not libraries) that use libpq.
588 # We force clients to pull symbols from the non-shared libraries libpgport
589 # and libpgcommon rather than pulling some libpgport symbols from libpq just
590 # because libpq uses those functions too. This makes applications less
591 # dependent on changes in libpq's usage of pgport (on platforms where we
592 # don't have symbol export control for libpq). To do this we link to
593 # pgport before libpq. This does cause duplicate -lpgport's to appear
594 # on client link lines, since that also appears in $(LIBS).
595 # libpq_pgport_shlib is the same idea, but for use in client shared libraries.
597 libpq_pgport = -L$(libdir) -lpgcommon -lpgport $(libpq)
598 libpq_pgport_shlib = -L$(libdir) -lpgcommon_shlib -lpgport_shlib $(libpq)
600 libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq)
601 libpq_pgport_shlib = -L$(top_builddir)/src/common -lpgcommon_shlib -L$(top_builddir)/src/port -lpgport_shlib $(libpq)
604 # Cygwin seems to need ldap libraries to be mentioned here, too
605 ifeq ($(PORTNAME),cygwin)
606 libpq_pgport += $(LDAP_LIBS_FE)
610 ##########################################################################
612 # Commonly used submake targets
614 submake-libpq: | submake-generated-headers
615 $(MAKE) -C $(libpq_builddir) all
617 submake-libpgport: | submake-generated-headers
618 $(MAKE) -C $(top_builddir)/src/port all
619 $(MAKE) -C $(top_builddir)/src/common all
621 submake-libpgfeutils: | submake-generated-headers
622 $(MAKE) -C $(top_builddir)/src/port all
623 $(MAKE) -C $(top_builddir)/src/common all
624 $(MAKE) -C $(top_builddir)/src/fe_utils all
626 .PHONY: submake-libpq submake-libpgport submake-libpgfeutils
629 ##########################################################################
633 ifneq ($(USE_MODULE_DB),)
634 PL_TESTDB = pl_regression_$(NAME)
635 ifneq ($(MODULE_big),)
636 CONTRIB_TESTDB=contrib_regression_$(MODULE_big)
637 ISOLATION_TESTDB=isolation_regression_$(MODULE_big)
640 CONTRIB_TESTDB=contrib_regression_$(word 1,$(MODULES))
641 ISOLATION_TESTDB=isolation_regression_$(word 1,$(MODULES))
643 CONTRIB_TESTDB=contrib_regression_$(word 1,$(REGRESS))
644 ISOLATION_TESTDB=isolation_regression_$(word 1,$(ISOLATION))
648 PL_TESTDB = pl_regression
649 CONTRIB_TESTDB = contrib_regression
650 ISOLATION_TESTDB = isolation_regression
654 NOLOCALE += --no-locale
657 # file with extra config for temp build
660 TEMP_CONF += --temp-config=$(TEMP_CONFIG)
663 pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
664 pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/
667 echo "\# +++ regress check in $(subdir) +++" && \
668 $(with_temp_install) \
669 $(top_builddir)/src/test/regress/pg_regress \
670 --temp-instance=./tmp_check \
671 --inputdir=$(srcdir) \
674 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
675 pg_regress_installcheck = \
676 echo "\# +++ regress install-check in $(subdir) +++" && \
677 $(top_builddir)/src/test/regress/pg_regress \
678 --inputdir=$(srcdir) \
679 --bindir='$(bindir)' \
680 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
682 pg_isolation_regress_check = \
683 echo "\# +++ isolation check in $(subdir) +++" && \
684 $(with_temp_install) \
685 $(top_builddir)/src/test/isolation/pg_isolation_regress \
686 --temp-instance=./tmp_check_iso \
687 --inputdir=$(srcdir) --outputdir=output_iso \
690 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
691 pg_isolation_regress_installcheck = \
692 echo "\# +++ isolation install-check in $(subdir) +++" && \
693 $(top_builddir)/src/test/isolation/pg_isolation_regress \
694 --inputdir=$(srcdir) --outputdir=output_iso \
695 --bindir='$(bindir)' \
696 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
698 ##########################################################################
702 # This includes your local customizations if Makefile.custom exists
703 # in the source directory. This file doesn't exist in the original
704 # distribution so that it doesn't get overwritten when you upgrade.
706 # NOTE: Makefile.custom is from the pre-Autoconf days of PostgreSQL.
707 # You are liable to shoot yourself in the foot if you use it without
708 # knowing exactly what you're doing. The preferred (and more
709 # reliable) method is to communicate what you want to do to the
710 # configure script, and leave the makefiles alone.
712 -include $(top_srcdir)/src/Makefile.custom
714 ifneq ($(CUSTOM_INSTALL),)
715 INSTALL= $(CUSTOM_INSTALL)
718 ifneq ($(CUSTOM_CC),)
722 ifneq ($(CUSTOM_COPT),)
727 # These variables are meant to be set in the environment of "make"
728 # to add flags to whatever configure picked. Unlike the ones above,
729 # they are documented.
738 LDFLAGS += $(PROFILE)
742 ##########################################################################
744 # substitute implementations of C library routines (see src/port/)
745 # note we already included -L.../src/port in LDFLAGS above
749 # files needed for the chosen CRC-32C implementation
750 PG_CRC32C_OBJS = @PG_CRC32C_OBJS@
752 LIBS := -lpgcommon -lpgport $(LIBS)
754 # to make ws2_32.lib the last library
755 ifeq ($(PORTNAME),win32)
759 # Not really standard libc functions, used by the backend.
763 ##########################################################################
765 # Global targets and rules
769 $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
770 @$(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)
771 $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
773 @$(missing) flex $< '$@'
777 $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
779 $(BISON) $(BISONFLAGS) -o $@ $<
781 @$(missing) bison $< $@
785 $(CPP) $(CPPFLAGS) -o $@ $<
788 $(GZIP) --best -c $< >$@
793 # Direct builds of foo.c -> foo are disabled to avoid generating
794 # *.dSYM junk on Macs. All builds should normally go through the
795 # foo.c -> foo.o -> foo steps. This also ensures that dependency
796 # tracking (see below) is used.
799 # Replace gmake's default rule for linking a single .o file to produce an
800 # executable. The main point here is to put LDFLAGS after the .o file,
801 # since we put -l switches into LDFLAGS and those are order-sensitive.
802 # In addition, include CFLAGS and LDFLAGS_EX per project conventions.
804 $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
808 # Remake Makefile.global from Makefile.global.in if the latter
809 # changed. In order to trigger this rule, the including file must
810 # write `include $(top_builddir)/src/Makefile.global', not some
812 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
813 cd $(top_builddir) && ./config.status src/Makefile.global
815 # Remake pg_config.h from pg_config.h.in if the latter changed.
816 # config.status will not change the timestamp on pg_config.h if it
817 # doesn't change, so as to avoid recompiling the entire tree
818 # unnecessarily. Therefore we make config.status update a timestamp file
819 # stamp-h every time it runs, so that we don't trigger this rule every time.
820 # (We do trigger the null rule for stamp-h to pg_config.h every time; so it's
821 # important for that rule to be empty!)
823 # Of course you need to turn on dependency tracking to get any
824 # dependencies on pg_config.h.
825 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
827 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
828 cd $(top_builddir) && ./config.status src/include/pg_config.h
830 # Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above.
831 $(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ;
833 $(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status
834 cd $(top_builddir) && ./config.status src/include/pg_config_ext.h
836 # Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
838 $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
840 $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
841 cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
843 # When configure changes, rerun configure with the same options as
844 # last time. To change configure, you need to run autoconf manually.
845 $(top_builddir)/config.status: $(top_srcdir)/configure
846 cd $(top_builddir) && ./config.status --recheck
852 # install-strip always uses install-sh, so that strip options can be
854 $(MAKE) use_install_sh=yes \
855 INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
856 INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
857 INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
858 INSTALL_STRIP_FLAG=-s \
862 ##########################################################################
864 # Recursive make support
865 # ----------------------
866 # Instead of recursing through subdirectories with a for loop or
867 # repeated $(MAKE) -C whatever calls, this is a little smarter: it
868 # allows parallel make across directories and lets make -k and -q work
871 # We need the ability to export target-specific variables, which was
872 # added in GNU make 3.81. That also happens to be the version
873 # where the .FEATURES variable was introduced, so this is a simple check.
875 $(error GNU make 3.81 or newer is required. You are using version $(MAKE_VERSION))
878 # This function is only for internal use below. It should be called
879 # using $(eval). It will set up a target so that it recurses into a
880 # given subdirectory. For the tree-wide all/install/check/installcheck cases,
881 # ensure we do our one-time tasks before recursing (see targets above).
882 # Note that to avoid a nasty bug in make 3.80,
883 # this function was written to not use any complicated constructs (like
884 # multiple targets on a line) and also not contain any lines that expand
885 # to more than about 200 bytes. This is why we make it apply to just one
886 # subdirectory at a time, rather than to a list of subdirectories.
887 # $1: target name, e.g., all
889 # $3: target to run in subdir, usually same as $1
890 define _create_recursive_target
891 .PHONY: $(1)-$(2)-recurse
892 $(1): $(1)-$(2)-recurse
893 $(1)-$(2)-recurse: $(if $(filter all install check installcheck, $(3)), submake-generated-headers) $(if $(filter check, $(3)), temp-install)
894 $$(MAKE) -C $(2) $(3)
896 # Note that the use of $$ on the last line above is important; we want
897 # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
898 # to create the rule. This is necessary to get make -q working.
900 # Call this function in a makefile that needs to recurse into subdirectories.
901 # In the normal case all arguments can be defaulted.
902 # $1: targets to make recursive (defaults to list of standard targets)
903 # $2: list of subdirs (defaults to SUBDIRS variable)
904 # $3: target to run in subdir (defaults to current element of $1)
905 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))))))
907 # If a makefile's list of SUBDIRS varies depending on configuration, then
908 # any subdirectories excluded from SUBDIRS should instead be added to
909 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
910 # This ensures that distprep, distclean, etc will apply to all subdirectories.
911 # In the normal case all arguments will be defaulted.
912 # $1: targets to make recursive (defaults to standard_always_targets)
913 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
914 # $3: target to run in subdir (defaults to current element of $1)
915 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))))))
918 ##########################################################################
920 # Automatic dependency generation
921 # -------------------------------
922 # When we configure with --enable-depend then we override the default
923 # compilation rule with the magic below. While or after creating the
924 # actual output file we also create a dependency list for the .c file.
925 # Next time we invoke make we will have top-notch information about
926 # whether this file needs to be updated. The dependency files are kept
927 # in the .deps subdirectory of each directory.
929 autodepend = @autodepend@
931 ifeq ($(autodepend), yes)
934 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
938 COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
945 # GCC allows us to create object and dependency file in one invocation.
947 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
948 $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
951 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
952 $(COMPILE.cc) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
956 # Include all the dependency files generated for the current
957 # directory. Note that make would complain if include was called with
959 Po_files := $(wildcard $(DEPDIR)/*.Po)
965 clean distclean maintainer-clean: clean-deps
974 ##########################################################################
976 # Native language support
978 ifeq ($(enable_nls), yes)
979 ifneq (,$(wildcard $(srcdir)/nls.mk))
981 include $(top_srcdir)/src/nls-global.mk
987 ##########################################################################
991 # Explanation of involved files:
994 # foo.gcno gcov graph (a.k.a. "notes") file, created at compile time
995 # (by gcc -ftest-coverage)
996 # foo.gcda gcov data file, created when the program is run (for
997 # programs compiled with gcc -fprofile-arcs)
998 # foo.c.gcov gcov output file with coverage information, created by
999 # gcov from foo.gcda (by "make coverage")
1000 # foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly
1003 # lcov tracefile, built from gcda files in one directory,
1004 # later collected by "make coverage-html"
1006 # tracefile for zero counters for every file, so that
1007 # even files that are not touched by tests are counted
1008 # for the overall coverage rate
1010 ifeq ($(enable_coverage), yes)
1012 # make coverage -- text output
1014 local_gcda_files = $(wildcard *.gcda)
1016 coverage: $(local_gcda_files:.gcda=.c.gcov)
1019 $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
1021 # make coverage-html -- HTML output via lcov
1023 .PHONY: coverage-html
1024 coverage-html: coverage-html-stamp
1026 GENHTML_FLAGS = -q --legend
1027 GENHTML_TITLE = PostgreSQL $(VERSION)
1029 coverage-html-stamp: lcov_base.info lcov_test.info
1031 $(GENHTML) $(GENHTML_FLAGS) -o coverage --title='$(GENHTML_TITLE)' --num-spaces=4 $(if $(filter no,$(vpath_build)),--prefix='$(abs_top_srcdir)') $^
1034 LCOV += --gcov-tool $(GCOV)
1035 LCOVFLAGS = -q --no-external
1037 all_gcno_files = $(shell find . -name '*.gcno' -print)
1039 lcov_base.info: $(all_gcno_files)
1040 $(LCOV) $(LCOVFLAGS) -c -i -d . -d $(srcdir) -o $@
1042 all_gcda_files = $(shell find . -name '*.gcda' -print)
1044 lcov_test.info: $(all_gcda_files)
1045 $(LCOV) $(LCOVFLAGS) -c -d . -d $(srcdir) -o $@
1049 clean distclean maintainer-clean: clean-coverage
1051 .PHONY: clean-coverage
1053 rm -rf coverage coverage-html-stamp
1054 rm -f *.gcda *.gcno lcov*.info *.gcov .*.gcov *.gcov.out
1057 # User-callable target to reset counts between test runs
1059 rm -f `find . -name '*.gcda' -print`
1061 endif # enable_coverage
1063 ##########################################################################
1069 # -Wno-ignored-attributes added so gnu_printf doesn't trigger
1070 # warnings, when the main binary is compiled with C.
1071 COMPILE.c.bc = $(CLANG) -Wno-ignored-attributes $(BITCODE_CFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
1074 ifndef COMPILE.cxx.bc
1075 COMPILE.cxx.bc = $(CLANG) -xc++ -Wno-ignored-attributes $(BITCODE_CXXFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
1079 $(COMPILE.c.bc) -o $@ $<
1082 $(COMPILE.cxx.bc) -o $@ $<
1084 # Install LLVM bitcode module (for JITing).
1086 # The arguments are:
1087 # $(1) name of the module (e.g. an extension's name or postgres for core code)
1088 # $(2) source objects, with .o suffix
1090 # The many INSTALL_DATA invocations aren't particularly fast, it'd be
1091 # good if we could coalesce them, but I didn't find a good way.
1093 # Note: blank line at end of macro is necessary to let it be used in foreach
1094 define install_llvm_module
1095 $(MKDIR_P) '$(DESTDIR)${bitcodedir}/$(1)'
1096 $(MKDIR_P) $(sort $(dir $(addprefix '$(DESTDIR)${bitcodedir}'/$(1)/, $(2))))
1097 $(foreach obj, ${2}, $(INSTALL_DATA) $(patsubst %.o,%.bc, $(obj)) '$(DESTDIR)${bitcodedir}'/$(1)/$(dir $(obj))
1099 cd '$(DESTDIR)${bitcodedir}' && $(LLVM_BINPATH)/llvm-lto -thinlto -thinlto-action=thinlink -o $(1).index.bc $(addprefix $(1)/,$(patsubst %.o,%.bc, $(2)))
1103 # Uninstall LLVM bitcode module.
1105 # The arguments are:
1106 # $(1) name of the module (e.g. an extension's name or postgres for core code)
1108 # This intentionally doesn't use the explicit installed file list,
1109 # seems too likely to change regularly.
1110 define uninstall_llvm_module
1111 rm -rf '$(DESTDIR)${bitcodedir}/$(1)/'
1112 rm -f '$(DESTDIR)${bitcodedir}/$(1).index.bc'