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 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 maintainer-check
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 # Set top_srcdir, srcdir, and VPATH.
45 top_srcdir = $(top_builddir)
47 # If VPATH is set or Makefile is not in current directory we are building
48 # the extension with VPATH so we set the variable here.
52 ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST))))
56 srcdir = $(dir $(firstword $(MAKEFILE_LIST)))
61 vpath_build = @vpath_build@
62 abs_top_builddir = @abs_top_builddir@
63 abs_top_srcdir = @abs_top_srcdir@
65 ifneq ($(vpath_build),yes)
66 top_srcdir = $(top_builddir)
68 else # vpath_build = yes
69 top_srcdir = $(abs_top_srcdir)
70 srcdir = $(top_srcdir)/$(subdir)
75 vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done`
77 # Saved arguments from configure
78 configure_args = @configure_args@
81 ##########################################################################
83 # Installation directories
85 # These are set by the equivalent --xxxdir configure options. We
86 # append "postgresql" to some of them, if the string does not already
87 # contain "pgsql" or "postgres", in order to avoid directory clutter.
89 # In a PGXS build, we cannot use the values inserted into Makefile.global
90 # by configure, since the installation tree may have been relocated.
91 # Instead get the path values from pg_config.
95 # Note that prefix, exec_prefix, and datarootdir aren't defined in a PGXS build;
96 # makefiles may only use the derived variables such as bindir.
99 exec_prefix := @exec_prefix@
100 datarootdir := @datarootdir@
105 ifeq "$(findstring pgsql, $(datadir))" ""
106 ifeq "$(findstring postgres, $(datadir))" ""
107 override datadir := $(datadir)/postgresql
111 sysconfdir := @sysconfdir@
112 ifeq "$(findstring pgsql, $(sysconfdir))" ""
113 ifeq "$(findstring postgres, $(sysconfdir))" ""
114 override sysconfdir := $(sysconfdir)/postgresql
120 pkglibdir = $(libdir)
121 ifeq "$(findstring pgsql, $(pkglibdir))" ""
122 ifeq "$(findstring postgres, $(pkglibdir))" ""
123 override pkglibdir := $(pkglibdir)/postgresql
127 includedir := @includedir@
129 pkgincludedir = $(includedir)
130 ifeq "$(findstring pgsql, $(pkgincludedir))" ""
131 ifeq "$(findstring postgres, $(pkgincludedir))" ""
132 override pkgincludedir := $(pkgincludedir)/postgresql
139 ifeq "$(findstring pgsql, $(docdir))" ""
140 ifeq "$(findstring postgres, $(docdir))" ""
141 override docdir := $(docdir)/postgresql
147 localedir := @localedir@
151 # Extension makefiles should set PG_CONFIG, but older ones might not
153 PG_CONFIG = pg_config
156 bindir := $(shell $(PG_CONFIG) --bindir)
157 datadir := $(shell $(PG_CONFIG) --sharedir)
158 sysconfdir := $(shell $(PG_CONFIG) --sysconfdir)
159 libdir := $(shell $(PG_CONFIG) --libdir)
160 pkglibdir := $(shell $(PG_CONFIG) --pkglibdir)
161 includedir := $(shell $(PG_CONFIG) --includedir)
162 pkgincludedir := $(shell $(PG_CONFIG) --pkgincludedir)
163 mandir := $(shell $(PG_CONFIG) --mandir)
164 docdir := $(shell $(PG_CONFIG) --docdir)
165 localedir := $(shell $(PG_CONFIG) --localedir)
169 # These derived path variables aren't separately configurable.
171 includedir_server = $(pkgincludedir)/server
172 includedir_internal = $(pkgincludedir)/internal
173 pgxsdir = $(pkglibdir)/pgxs
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_openssl = @with_openssl@
187 with_selinux = @with_selinux@
188 with_systemd = @with_systemd@
189 with_libxml = @with_libxml@
190 with_libxslt = @with_libxslt@
191 with_system_tzdata = @with_system_tzdata@
192 with_uuid = @with_uuid@
193 with_zlib = @with_zlib@
194 enable_rpath = @enable_rpath@
195 enable_nls = @enable_nls@
196 enable_debug = @enable_debug@
197 enable_dtrace = @enable_dtrace@
198 enable_coverage = @enable_coverage@
199 enable_tap_tests = @enable_tap_tests@
200 enable_thread_safety = @enable_thread_safety@
201 enable_strong_random = @enable_strong_random@
203 python_includespec = @python_includespec@
204 python_libdir = @python_libdir@
205 python_libspec = @python_libspec@
206 python_additional_libs = @python_additional_libs@
207 python_majorversion = @python_majorversion@
208 python_version = @python_version@
210 krb_srvtab = @krb_srvtab@
212 ICU_CFLAGS = @ICU_CFLAGS@
213 ICU_LIBS = @ICU_LIBS@
216 TCL_LIBS = @TCL_LIBS@
217 TCL_LIB_SPEC = @TCL_LIB_SPEC@
218 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
219 TCL_SHARED_BUILD = @TCL_SHARED_BUILD@
220 TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@
222 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
223 PTHREAD_LIBS = @PTHREAD_LIBS@
226 ##########################################################################
233 CPPFLAGS = @CPPFLAGS@
235 override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS)
238 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
240 override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
242 override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
248 SUN_STUDIO_CC = @SUN_STUDIO_CC@
250 CFLAGS_VECTOR = @CFLAGS_VECTOR@
251 CFLAGS_SSE42 = @CFLAGS_SSE42@
256 BISONFLAGS = @BISONFLAGS@ $(YFLAGS)
258 FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
260 DTRACEFLAGS = @DTRACEFLAGS@
269 LDAP_LIBS_FE = @LDAP_LIBS_FE@
270 LDAP_LIBS_BE = @LDAP_LIBS_BE@
271 UUID_LIBS = @UUID_LIBS@
272 UUID_EXTRA_OBJS = @UUID_EXTRA_OBJS@
274 with_gnu_ld = @with_gnu_ld@
276 # We want -L for libpgport.a and libpgcommon.a to be first in LDFLAGS. We
277 # also need LDFLAGS to be a "recursively expanded" variable, else adjustments
278 # to rpathdir don't work right. So we must NOT do LDFLAGS := something,
279 # meaning this has to be done first and elsewhere we must only do LDFLAGS +=
282 LDFLAGS = -L$(libdir)
284 LDFLAGS = -L$(top_builddir)/src/port -L$(top_builddir)/src/common
288 LDFLAGS_EX = @LDFLAGS_EX@
289 # LDFLAGS_SL might have already been assigned by calling makefile
290 LDFLAGS_SL += @LDFLAGS_SL@
300 # quoted to protect pathname with spaces
303 PERL = $(missing) perl
305 perl_archlibexp = @perl_archlibexp@
306 perl_privlibexp = @perl_privlibexp@
307 perl_embed_ccflags = @perl_embed_ccflags@
308 perl_embed_ldflags = @perl_embed_ldflags@
315 MSGFMT_FLAGS = @MSGFMT_FLAGS@
316 MSGMERGE = @MSGMERGE@
319 XGETTEXT = @XGETTEXT@
330 ifndef NO_TEMP_INSTALL
331 ifneq ($(abs_top_builddir),)
332 ifeq ($(MAKELEVEL),0)
333 rm -rf '$(abs_top_builddir)'/tmp_install
334 $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log
335 $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1
337 $(if $(EXTRA_INSTALL),for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install >>'$(abs_top_builddir)'/tmp_install/log/install.log || exit; done)
342 # There are common routines in src/test/perl, and some test suites have
343 # extra perl modules in their own directory.
344 PG_PROVE_FLAGS = -I $(top_srcdir)/src/test/perl/ -I $(srcdir)
345 # User-supplied prove flags such as --verbose can be provided in PROVE_FLAGS.
348 # prepend to path if already set, else just set it
350 $(1)="$(if $($(1)),$(2):$$$(1),$(2))"
353 # platform-specific environment variable to set shared library path
354 define ld_library_path_var
355 $(if $(filter $(PORTNAME),darwin),DYLD_LIBRARY_PATH,$(if $(filter $(PORTNAME),aix),LIBPATH,$(if $(filter $(PORTNAME),hpux),SHLIB_PATH,LD_LIBRARY_PATH)))
358 define with_temp_install
359 PATH="$(abs_top_builddir)/tmp_install$(bindir):$$PATH" $(call add_to_path,$(ld_library_path_var),$(abs_top_builddir)/tmp_install$(libdir))
362 ifeq ($(enable_tap_tests),yes)
364 define prove_installcheck
365 rm -rf '$(CURDIR)'/tmp_check
366 $(MKDIR_P) '$(CURDIR)'/tmp_check
367 cd $(srcdir) && TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' top_builddir='$(CURDIR)/$(top_builddir)' PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
371 rm -rf '$(CURDIR)'/tmp_check
372 $(MKDIR_P) '$(CURDIR)'/tmp_check
373 cd $(srcdir) && TESTDIR='$(CURDIR)' $(with_temp_install) PGPORT='6$(DEF_PGPORT)' PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl)
377 prove_installcheck = @echo "TAP tests not enabled"
378 prove_check = $(prove_installcheck)
383 install_bin = @install_bin@
384 install_sh = $(SHELL) $(top_srcdir)/config/install-sh -c
385 INSTALL = $(if $(use_install_sh),$(install_sh),$(if $(install_bin),$(install_bin),$(install_sh)))
387 INSTALL_SCRIPT_MODE = 755
388 INSTALL_DATA_MODE = 644
389 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
390 INSTALL_SCRIPT = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
391 INSTALL_DATA = $(INSTALL) -m $(INSTALL_DATA_MODE)
392 INSTALL_STLIB = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
393 INSTALL_SHLIB = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
394 # Override in Makefile.port if necessary
395 INSTALL_SHLIB_OPTS = -m 755
399 missing = $(SHELL) $(top_srcdir)/config/missing
402 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
403 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
407 DBTOEPUB = @DBTOEPUB@
412 XSLTPROC = @XSLTPROC@
420 ifeq ($(enable_coverage),yes)
421 # ccache loses .gcno files
422 export CCACHE_DISABLE = 1
427 DEF_PGPORT = @default_port@
428 WANTED_LANGUAGES = @WANTED_LANGUAGES@
431 ##########################################################################
433 # Additional platform-specific settings
436 # Name of the "template"
439 build_os = @build_os@
443 host_cpu = @host_cpu@
445 # Make HAVE_IPV6 available for initdb script creation
446 HAVE_IPV6= @HAVE_IPV6@
448 # This is mainly for use on FreeBSD, where we have both a.out and elf
449 # systems now. May be applicable to other systems to?
450 ELF_SYSTEM= @ELF_SYS@
452 # Backend stack size limit has to be hard-wired on Windows (it's in bytes)
453 WIN32_STACK_RLIMIT=4194304
455 # Set if we have a working win32 crashdump header
456 have_win32_dbghelp = @have_win32_dbghelp@
458 # Pull in platform-specific magic
459 include $(top_builddir)/src/Makefile.port
461 # Set up rpath if enabled. By default it will point to our libdir,
462 # but individual Makefiles can force other rpath paths if needed.
465 ifeq ($(enable_rpath), yes)
470 ##########################################################################
472 # Some variables needed to find some client interfaces
475 # some contribs assumes headers and libs are in the source tree...
476 libpq_srcdir = $(includedir)
477 libpq_builddir = $(libdir)
479 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
480 libpq_builddir = $(top_builddir)/src/interfaces/libpq
483 # This macro is for use by libraries linking to libpq. (Because libpgport
484 # isn't created with the same link flags as libpq, it can't be used.)
485 libpq = -L$(libpq_builddir) -lpq
487 # This macro is for use by client executables (not libraries) that use libpq.
488 # We force clients to pull symbols from the non-shared libraries libpgport
489 # and libpgcommon rather than pulling some libpgport symbols from libpq just
490 # because libpq uses those functions too. This makes applications less
491 # dependent on changes in libpq's usage of pgport. To do this we link to
492 # pgport before libpq. This does cause duplicate -lpgport's to appear
493 # on client link lines.
495 libpq_pgport = -L$(libdir) -lpgcommon -lpgport $(libpq)
497 libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq)
500 # Cygwin seems to need ldap libraries to be mentioned here, too
501 ifeq ($(PORTNAME),cygwin)
502 libpq_pgport += $(LDAP_LIBS_FE)
506 ##########################################################################
508 # Commonly used submake targets
511 $(MAKE) -C $(libpq_builddir) all
514 $(MAKE) -C $(top_builddir)/src/port all
515 $(MAKE) -C $(top_builddir)/src/common all
517 submake-libpgfeutils:
518 $(MAKE) -C $(top_builddir)/src/port all
519 $(MAKE) -C $(top_builddir)/src/common all
520 $(MAKE) -C $(top_builddir)/src/fe_utils all
522 submake-generated-headers:
523 $(MAKE) -C $(top_builddir)/src/backend generated-headers
525 .PHONY: submake-libpq submake-libpgport submake-libpgfeutils submake-generated-headers
528 ##########################################################################
532 PL_TESTDB = pl_regression
533 CONTRIB_TESTDB = contrib_regression
534 ifneq ($(MODULE_big),)
535 CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULE_big)
538 CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULES)
540 CONTRIB_TESTDB_MODULE = contrib_regression
545 NOLOCALE += --no-locale
548 # file with extra config for temp build
551 TEMP_CONF += --temp-config=$(TEMP_CONFIG)
554 pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
555 pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/
558 $(with_temp_install) \
559 $(top_builddir)/src/test/regress/pg_regress \
560 --temp-instance=./tmp_check \
561 --inputdir=$(srcdir) \
564 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
565 pg_regress_installcheck = \
566 $(top_builddir)/src/test/regress/pg_regress \
567 --inputdir=$(srcdir) \
568 --bindir='$(bindir)' \
569 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
571 pg_isolation_regress_check = \
572 $(with_temp_install) \
573 $(top_builddir)/src/test/isolation/pg_isolation_regress \
574 --temp-instance=./tmp_check_iso \
575 --inputdir=$(srcdir) --outputdir=output_iso \
578 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
579 pg_isolation_regress_installcheck = \
580 $(top_builddir)/src/test/isolation/pg_isolation_regress \
581 --inputdir=$(srcdir) --outputdir=output_iso \
582 --bindir='$(bindir)' \
583 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS)
585 ##########################################################################
589 # This includes your local customizations if Makefile.custom exists
590 # in the source directory. This file doesn't exist in the original
591 # distribution so that it doesn't get overwritten when you upgrade.
593 # NOTE: Makefile.custom is from the pre-Autoconf days of PostgreSQL.
594 # You are liable to shoot yourself in the foot if you use it without
595 # knowing exactly what you're doing. The preferred (and more
596 # reliable) method is to communicate what you want to do to the
597 # configure script, and leave the makefiles alone.
599 -include $(top_srcdir)/src/Makefile.custom
601 ifneq ($(CUSTOM_INSTALL),)
602 INSTALL= $(CUSTOM_INSTALL)
605 ifneq ($(CUSTOM_CC),)
609 ifneq ($(CUSTOM_COPT),)
614 # These variables are meant to be set in the environment of "make"
615 # to add flags to whatever configure picked. Unlike the ones above,
616 # they are documented.
625 LDFLAGS += $(PROFILE)
629 ##########################################################################
631 # substitute implementations of C library routines (see src/port/)
632 # note we already included -L.../src/port in LDFLAGS above
636 # files needed for the chosen CRC-32C implementation
637 PG_CRC32C_OBJS = @PG_CRC32C_OBJS@
639 LIBS := -lpgcommon -lpgport $(LIBS)
641 # to make ws2_32.lib the last library
642 ifeq ($(PORTNAME),win32)
646 # Not really standard libc functions, used by the backend.
650 ##########################################################################
652 # Global targets and rules
656 $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
657 @$(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)
658 $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@')
660 @$(missing) flex $< '$@'
664 $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
666 $(BISON) $(BISONFLAGS) -o $@ $<
668 @$(missing) bison $< $@
672 $(CPP) $(CPPFLAGS) -o $@ $<
675 $(GZIP) --best -c $< >$@
680 # Direct builds of foo.c -> foo are disabled to avoid generating
681 # *.dSYM junk on Macs. All builds should normally go through the
682 # foo.c -> foo.o -> foo steps. This also ensures that dependency
683 # tracking (see below) is used.
688 # Remake Makefile.global from Makefile.global.in if the latter
689 # changed. In order to trigger this rule, the including file must
690 # write `include $(top_builddir)/src/Makefile.global', not some
692 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
693 cd $(top_builddir) && ./config.status src/Makefile.global
695 # Remake pg_config.h from pg_config.h.in if the latter changed.
696 # config.status will not change the timestamp on pg_config.h if it
697 # doesn't change, so as to avoid recompiling the entire tree
698 # unnecessarily. Therefore we make config.status update a timestamp file
699 # stamp-h every time it runs, so that we don't trigger this rule every time.
700 # (We do trigger the null rule for stamp-h to pg_config.h every time; so it's
701 # important for that rule to be empty!)
703 # Of course you need to turn on dependency tracking to get any
704 # dependencies on pg_config.h.
705 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
707 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
708 cd $(top_builddir) && ./config.status src/include/pg_config.h
710 # Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above.
711 $(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ;
713 $(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status
714 cd $(top_builddir) && ./config.status src/include/pg_config_ext.h
716 # Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
718 $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
720 $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
721 cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
723 # When configure changes, rerun configure with the same options as
724 # last time. To change configure, you need to run autoconf manually.
725 $(top_builddir)/config.status: $(top_srcdir)/configure
726 cd $(top_builddir) && ./config.status --recheck
732 # install-strip always uses install-sh, so that strip options can be
734 $(MAKE) use_install_sh=yes \
735 INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
736 INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
737 INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
738 INSTALL_STRIP_FLAG=-s \
742 ##########################################################################
744 # Recursive make support
745 # ----------------------
746 # Instead of recursing through subdirectories with a for loop or
747 # repeated $(MAKE) -C whatever calls, this is a little smarter: it
748 # allows parallel make across directories and lets make -k and -q work
751 # We need the $(eval) function and order-only prerequisites, which are
752 # available in GNU make 3.80. That also happens to be the version
753 # where the .VARIABLES variable was introduced, so this is a simple check.
755 $(error GNU make 3.80 or newer is required. You are using version $(MAKE_VERSION))
758 # This function is only for internal use below. It should be called
759 # using $(eval). It will set up a target so that it recurses into
760 # a given subdirectory. Note that to avoid a nasty bug in make 3.80,
761 # this function has to avoid using any complicated constructs (like
762 # multiple targets on a line) and also not contain any lines that expand
763 # to more than about 200 bytes. This is why we make it apply to just one
764 # subdirectory at a time, rather than to a list of subdirectories.
765 # $1: target name, e.g., all
767 # $3: target to run in subdir, usually same as $1
768 define _create_recursive_target
769 .PHONY: $(1)-$(2)-recurse
770 $(1): $(1)-$(2)-recurse
771 $(1)-$(2)-recurse: $(if $(filter check, $(3)), temp-install)
772 $$(MAKE) -C $(2) $(3)
774 # Note that the use of $$ on the last line above is important; we want
775 # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
776 # to create the rule. This is necessary to get make -q working.
778 # Call this function in a makefile that needs to recurse into subdirectories.
779 # In the normal case all arguments can be defaulted.
780 # $1: targets to make recursive (defaults to list of standard targets)
781 # $2: list of subdirs (defaults to SUBDIRS variable)
782 # $3: target to run in subdir (defaults to current element of $1)
783 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))))))
785 # If a makefile's list of SUBDIRS varies depending on configuration, then
786 # any subdirectories excluded from SUBDIRS should instead be added to
787 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
788 # This ensures that distprep, distclean, etc will apply to all subdirectories.
789 # In the normal case all arguments will be defaulted.
790 # $1: targets to make recursive (defaults to standard_always_targets)
791 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
792 # $3: target to run in subdir (defaults to current element of $1)
793 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))))))
796 ##########################################################################
798 # Automatic dependency generation
799 # -------------------------------
800 # When we configure with --enable-depend then we override the default
801 # compilation rule with the magic below. While or after creating the
802 # actual output file we also create a dependency list for the .c file.
803 # Next time we invoke make we will have top-notch information about
804 # whether this file needs to be updated. The dependency files are kept
805 # in the .deps subdirectory of each directory.
807 autodepend = @autodepend@
809 ifeq ($(autodepend), yes)
812 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
819 # GCC allows us to create object and dependency file in one invocation.
821 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
822 $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
826 # Include all the dependency files generated for the current
827 # directory. Note that make would complain if include was called with
829 Po_files := $(wildcard $(DEPDIR)/*.Po)
835 clean distclean maintainer-clean: clean-deps
844 ##########################################################################
846 # Native language support
848 ifeq ($(enable_nls), yes)
849 ifneq (,$(wildcard $(srcdir)/nls.mk))
851 include $(top_srcdir)/src/nls-global.mk
857 ##########################################################################
861 # Explanation of involved files:
864 # foo.gcno gcov graph (a.k.a. "notes") file, created at compile time
865 # (by gcc -ftest-coverage)
866 # foo.gcda gcov data file, created when the program is run (for
867 # programs compiled with gcc -fprofile-arcs)
868 # foo.c.gcov gcov output file with coverage information, created by
869 # gcov from foo.gcda (by "make coverage")
870 # foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly
873 # lcov tracefile, built from gcda files in one directory,
874 # later collected by "make coverage-html"
876 # tracefile for zero counters for every file, so that
877 # even files that are not touched by tests are counted
878 # for the overall coverage rate
880 ifeq ($(enable_coverage), yes)
882 # make coverage -- text output
884 local_gcda_files = $(wildcard *.gcda)
886 coverage: $(local_gcda_files:.gcda=.c.gcov)
889 $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
891 # make coverage-html -- HTML output via lcov
893 .PHONY: coverage-html
894 coverage-html: coverage-html-stamp
896 GENHTML_FLAGS = -q --legend
897 GENHTML_TITLE = PostgreSQL $(VERSION)
899 coverage-html-stamp: lcov_base.info lcov_test.info
901 $(GENHTML) $(GENHTML_FLAGS) -o coverage --title='$(GENHTML_TITLE)' --num-spaces=4 $(if $(filter no,$(vpath_build)),--prefix='$(abs_top_srcdir)') $^
904 LCOV += --gcov-tool $(GCOV)
905 LCOVFLAGS = -q --no-external
907 all_gcno_files = $(shell find . -name '*.gcno' -print)
909 lcov_base.info: $(all_gcno_files)
910 $(LCOV) $(LCOVFLAGS) -c -i -d . -d $(srcdir) -o $@
912 all_gcda_files = $(shell find . -name '*.gcda' -print)
914 lcov_test.info: $(all_gcda_files)
915 $(LCOV) $(LCOVFLAGS) -c -d . -d $(srcdir) -o $@
919 clean distclean maintainer-clean: clean-coverage
921 .PHONY: clean-coverage
923 rm -rf coverage coverage-html-stamp
924 rm -f *.gcda *.gcno lcov*.info *.gcov .*.gcov *.gcov.out
927 # User-callable target to reset counts between test runs
929 rm -f `find . -name '*.gcda' -print`
931 endif # enable_coverage