2 # src/Makefile.global.in
4 #------------------------------------------------------------------------------
5 # All PostgreSQL makefiles include this file and use the variables it sets,
6 # which in turn are put here by the configure script. There is no need for
7 # users to edit this file -- if it turns out to be necessary then that's a
10 # A makefile that includes this file needs to set the variable `subdir' to
11 # the relative path from the top to itself and `top_builddir' to the relative
12 # path from itself to the top before including this file. (The "top" is the
13 # parent directory of the directory this file is in.)
14 #------------------------------------------------------------------------------
17 ##########################################################################
21 standard_targets = all install installdirs uninstall distprep clean distclean maintainer-clean coverage check installcheck maintainer-check init-po update-po
22 # these targets should recurse even into subdirectories not being built:
23 standard_always_targets = distprep clean distclean maintainer-clean
25 .PHONY: $(standard_targets) install-strip html man installcheck-parallel
27 # make `all' the default target
30 # Delete target files if the command fails after it has
31 # started to update the file.
34 # Never delete any intermediate files automatically.
37 # PostgreSQL version number
38 VERSION = @PACKAGE_VERSION@
39 MAJORVERSION = @PG_MAJORVERSION@
41 # Support for VPATH builds
42 vpath_build = @vpath_build@
43 abs_top_srcdir = @abs_top_srcdir@
45 ifneq ($(vpath_build),yes)
46 top_srcdir = $(top_builddir)
48 else # vpath_build = yes
49 top_srcdir = $(abs_top_srcdir)
50 srcdir = $(top_srcdir)/$(subdir)
54 vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done`
56 # Saved arguments from configure
57 configure_args = @configure_args@
60 ##########################################################################
62 # Installation directories
64 # These are set by the equivalent --xxxdir configure options. We
65 # append "postgresql" to some of them, if the string does not already
66 # contain "pgsql" or "postgres", in order to avoid directory clutter.
68 # In a PGXS build, we cannot use the values inserted into Makefile.global
69 # by configure, since the installation tree may have been relocated.
70 # Instead get the path values from pg_config.
74 # Note that prefix, exec_prefix, and datarootdir aren't defined in a PGXS build;
75 # makefiles may only use the derived variables such as bindir.
78 exec_prefix := @exec_prefix@
79 datarootdir := @datarootdir@
84 ifeq "$(findstring pgsql, $(datadir))" ""
85 ifeq "$(findstring postgres, $(datadir))" ""
86 override datadir := $(datadir)/postgresql
90 sysconfdir := @sysconfdir@
91 ifeq "$(findstring pgsql, $(sysconfdir))" ""
92 ifeq "$(findstring postgres, $(sysconfdir))" ""
93 override sysconfdir := $(sysconfdir)/postgresql
100 ifeq "$(findstring pgsql, $(pkglibdir))" ""
101 ifeq "$(findstring postgres, $(pkglibdir))" ""
102 override pkglibdir := $(pkglibdir)/postgresql
106 includedir := @includedir@
108 pkgincludedir = $(includedir)
109 ifeq "$(findstring pgsql, $(pkgincludedir))" ""
110 ifeq "$(findstring postgres, $(pkgincludedir))" ""
111 override pkgincludedir := $(pkgincludedir)/postgresql
118 ifeq "$(findstring pgsql, $(docdir))" ""
119 ifeq "$(findstring postgres, $(docdir))" ""
120 override docdir := $(docdir)/postgresql
126 localedir := @localedir@
130 # Extension makefiles should set PG_CONFIG, but older ones might not
132 PG_CONFIG = pg_config
135 bindir := $(shell $(PG_CONFIG) --bindir)
136 datadir := $(shell $(PG_CONFIG) --sharedir)
137 sysconfdir := $(shell $(PG_CONFIG) --sysconfdir)
138 libdir := $(shell $(PG_CONFIG) --libdir)
139 pkglibdir := $(shell $(PG_CONFIG) --pkglibdir)
140 includedir := $(shell $(PG_CONFIG) --includedir)
141 pkgincludedir := $(shell $(PG_CONFIG) --pkgincludedir)
142 mandir := $(shell $(PG_CONFIG) --mandir)
143 docdir := $(shell $(PG_CONFIG) --docdir)
144 localedir := $(shell $(PG_CONFIG) --localedir)
148 # These derived path variables aren't separately configurable.
150 includedir_server = $(pkgincludedir)/server
151 includedir_internal = $(pkgincludedir)/internal
152 pgxsdir = $(pkglibdir)/pgxs
155 ##########################################################################
159 # Records the choice of the various --enable-xxx and --with-xxx options.
161 with_perl = @with_perl@
162 with_python = @with_python@
163 with_tcl = @with_tcl@
164 with_openssl = @with_openssl@
165 with_ossp_uuid = @with_ossp_uuid@
166 with_selinux = @with_selinux@
167 with_libxml = @with_libxml@
168 with_libxslt = @with_libxslt@
169 with_system_tzdata = @with_system_tzdata@
170 with_zlib = @with_zlib@
171 enable_rpath = @enable_rpath@
172 enable_nls = @enable_nls@
173 enable_debug = @enable_debug@
174 enable_dtrace = @enable_dtrace@
175 enable_coverage = @enable_coverage@
176 enable_thread_safety = @enable_thread_safety@
178 python_enable_shared = @python_enable_shared@
179 python_includespec = @python_includespec@
180 python_libdir = @python_libdir@
181 python_libspec = @python_libspec@
182 python_additional_libs = @python_additional_libs@
183 python_majorversion = @python_majorversion@
184 python_version = @python_version@
186 krb_srvtab = @krb_srvtab@
189 TCL_LIB_FILE = @TCL_LIB_FILE@
190 TCL_LIBS = @TCL_LIBS@
191 TCL_LIB_SPEC = @TCL_LIB_SPEC@
192 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
193 TCL_SHARED_BUILD = @TCL_SHARED_BUILD@
194 TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@
196 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
197 PTHREAD_LIBS = @PTHREAD_LIBS@
200 ##########################################################################
207 CPPFLAGS = @CPPFLAGS@
210 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
212 override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
214 override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
220 SUN_STUDIO_CC = @SUN_STUDIO_CC@
226 BISONFLAGS = @BISONFLAGS@ $(YFLAGS)
228 FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
230 DTRACEFLAGS = @DTRACEFLAGS@
239 LDAP_LIBS_FE = @LDAP_LIBS_FE@
240 LDAP_LIBS_BE = @LDAP_LIBS_BE@
241 OSSP_UUID_LIBS = @OSSP_UUID_LIBS@
243 with_gnu_ld = @with_gnu_ld@
244 ld_R_works = @ld_R_works@
246 # We want -L for libpgport.a and libpgcommon.a to be first in LDFLAGS. We
247 # also need LDFLAGS to be a "recursively expanded" variable, else adjustments
248 # to rpathdir don't work right. So we must NOT do LDFLAGS := something,
249 # meaning this has to be done first and elsewhere we must only do LDFLAGS +=
252 LDFLAGS = -L$(libdir)
254 LDFLAGS = -L$(top_builddir)/src/port -L$(top_builddir)/src/common
258 LDFLAGS_EX = @LDFLAGS_EX@
259 # LDFLAGS_SL might have already been assigned by calling makefile
260 LDFLAGS_SL += @LDFLAGS_SL@
270 # quoted to protect pathname with spaces
273 PERL = $(missing) perl
275 perl_archlibexp = @perl_archlibexp@
276 perl_privlibexp = @perl_privlibexp@
277 perl_useshrplib = @perl_useshrplib@
278 perl_embed_ldflags = @perl_embed_ldflags@
285 MSGMERGE = @MSGMERGE@
288 XGETTEXT = @XGETTEXT@
295 install_bin = @install_bin@
296 install_sh = $(SHELL) $(top_srcdir)/config/install-sh -c
297 INSTALL = $(if $(use_install_sh),$(install_sh),$(if $(install_bin),$(install_bin),$(install_sh)))
299 INSTALL_SCRIPT_MODE = 755
300 INSTALL_DATA_MODE = 644
301 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
302 INSTALL_SCRIPT = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
303 INSTALL_DATA = $(INSTALL) -m $(INSTALL_DATA_MODE)
304 INSTALL_STLIB = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
305 INSTALL_SHLIB = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
306 # Override in Makefile.port if necessary
307 INSTALL_SHLIB_OPTS = -m 755
311 missing = $(SHELL) $(top_srcdir)/config/missing
314 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
315 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
319 have_docbook = @have_docbook@
320 COLLATEINDEX = @COLLATEINDEX@
321 DOCBOOKSTYLE = @DOCBOOKSTYLE@
325 XSLTPROC = @XSLTPROC@
333 ifeq ($(enable_coverage),yes)
334 # ccache loses .gcno files
335 export CCACHE_DISABLE = 1
340 DEF_PGPORT = @default_port@
341 WANTED_LANGUAGES = @WANTED_LANGUAGES@
344 ##########################################################################
346 # Additional platform-specific settings
349 # Name of the "template"
352 build_os = @build_os@
356 host_cpu = @host_cpu@
358 # Make HAVE_IPV6 available for initdb script creation
359 HAVE_IPV6= @HAVE_IPV6@
361 # The HP-UX port makefile, for one, needs access to this symbol
362 HAVE_POSIX_SIGNALS= @HAVE_POSIX_SIGNALS@
364 # This is mainly for use on FreeBSD, where we have both a.out and elf
365 # systems now. May be applicable to other systems to?
366 ELF_SYSTEM= @ELF_SYS@
368 # Backend stack size limit has to be hard-wired on Windows (it's in bytes)
369 WIN32_STACK_RLIMIT=4194304
371 # Set if we have a working win32 crashdump header
372 have_win32_dbghelp = @have_win32_dbghelp@
374 # Pull in platform-specific magic
375 include $(top_builddir)/src/Makefile.port
377 # Set up rpath if enabled. By default it will point to our libdir,
378 # but individual Makefiles can force other rpath paths if needed.
381 ifeq ($(enable_rpath), yes)
386 ##########################################################################
388 # Some variables needed to find some client interfaces
391 # some contribs assumes headers and libs are in the source tree...
392 libpq_srcdir = $(includedir)
393 libpq_builddir = $(libdir)
395 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
396 libpq_builddir = $(top_builddir)/src/interfaces/libpq
399 # This macro is for use by libraries linking to libpq. (Because libpgport
400 # isn't created with the same link flags as libpq, it can't be used.)
401 libpq = -L$(libpq_builddir) -lpq
403 # This macro is for use by client executables (not libraries) that use libpq.
404 # We force clients to pull symbols from the non-shared libraries libpgport
405 # and libpgcommon rather than pulling some libpgport symbols from libpq just
406 # because libpq uses those functions too. This makes applications less
407 # dependent on changes in libpq's usage of pgport. To do this we link to
408 # pgport before libpq. This does cause duplicate -lpgport's to appear
409 # on client link lines.
411 libpq_pgport = -L$(libdir) -lpgport -lpgcommon $(libpq)
413 libpq_pgport = -L$(top_builddir)/src/port -lpgport \
414 -L$(top_builddir)/src/common -lpgcommon $(libpq)
419 $(MAKE) -C $(libpq_builddir) all
422 $(MAKE) -C $(top_builddir)/src/port all
423 $(MAKE) -C $(top_builddir)/src/common all
425 .PHONY: submake-libpq submake-libpgport
428 ##########################################################################
432 PL_TESTDB = pl_regression
433 CONTRIB_TESTDB = contrib_regression
434 ifneq ($(MODULE_big),)
435 CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULE_big)
438 CONTRIB_TESTDB_MODULE = contrib_regression_$(MODULES)
440 CONTRIB_TESTDB_MODULE = contrib_regression
445 NOLOCALE += --no-locale
448 pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE)
450 pg_regress_check = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --temp-install=./tmp_check --top-builddir=$(top_builddir) $(pg_regress_locale_flags)
451 pg_regress_installcheck = $(top_builddir)/src/test/regress/pg_regress --inputdir=$(srcdir) --psqldir='$(PSQLDIR)' $(pg_regress_locale_flags)
453 pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ log/
456 ##########################################################################
460 # This includes your local customizations if Makefile.custom exists
461 # in the source directory. This file doesn't exist in the original
462 # distribution so that it doesn't get overwritten when you upgrade.
464 # NOTE: Makefile.custom is from the pre-Autoconf days of PostgreSQL.
465 # You are liable to shoot yourself in the foot if you use it without
466 # knowing exactly what you're doing. The preferred (and more
467 # reliable) method is to communicate what you want to do to the
468 # configure script, and leave the makefiles alone.
470 -include $(top_srcdir)/src/Makefile.custom
472 ifneq ($(CUSTOM_INSTALL),)
473 INSTALL= $(CUSTOM_INSTALL)
476 ifneq ($(CUSTOM_CC),)
480 ifneq ($(CUSTOM_COPT),)
491 LDFLAGS += $(PROFILE)
495 ##########################################################################
497 # substitute implementations of C library routines (see src/port/)
498 # note we already included -L.../src/port in LDFLAGS above
502 LIBS := -lpgport -lpgcommon $(LIBS)
504 # to make ws2_32.lib the last library, and always link with shfolder,
505 # so SHGetFolderName isn't picked up from shell32.dll
506 ifeq ($(PORTNAME),win32)
507 LIBS += -lws2_32 -lshfolder
510 # Not really standard libc functions, used by the backend.
514 ##########################################################################
516 # Global targets and rules
520 $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $<
521 @$(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)
523 @$(missing) flex $< '$@'
527 $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD))
529 $(BISON) $(BISONFLAGS) -o $@ $<
531 @$(missing) bison $< $@
535 $(CPP) $(CPPFLAGS) -o $@ $<
538 $(GZIP) --best -c $< >$@
543 # Direct builds of foo.c -> foo are disabled to avoid generating
544 # *.dSYM junk on Macs. All builds should normally go through the
545 # foo.c -> foo.o -> foo steps. This also ensures that dependency
546 # tracking (see below) is used.
551 # Remake Makefile.global from Makefile.global.in if the latter
552 # changed. In order to trigger this rule, the including file must
553 # write `include $(top_builddir)/src/Makefile.global', not some
555 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
556 cd $(top_builddir) && ./config.status src/Makefile.global
558 # Remake pg_config.h from pg_config.h.in if the latter changed.
559 # config.status will not change the timestamp on pg_config.h if it
560 # doesn't change, so as to avoid recompiling the entire tree
561 # unnecessarily. Therefore we make config.status update a timestamp file
562 # stamp-h every time it runs, so that we don't trigger this rule every time.
563 # (We do trigger the null rule for stamp-h to pg_config.h every time; so it's
564 # important for that rule to be empty!)
566 # Of course you need to turn on dependency tracking to get any
567 # dependencies on pg_config.h.
568 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
570 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
571 cd $(top_builddir) && ./config.status src/include/pg_config.h
573 # Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above.
574 $(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ;
576 $(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status
577 cd $(top_builddir) && ./config.status src/include/pg_config_ext.h
579 # Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
581 $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
583 $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
584 cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
586 # When configure changes, rerun configure with the same options as
587 # last time. To change configure, you need to run autoconf manually.
588 $(top_builddir)/config.status: $(top_srcdir)/configure
589 cd $(top_builddir) && ./config.status --recheck
595 # install-strip always uses install-sh, so that strip options can be
597 $(MAKE) use_install_sh=yes \
598 INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
599 INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
600 INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
601 INSTALL_STRIP_FLAG=-s \
605 ##########################################################################
607 # Recursive make support
608 # ----------------------
609 # Instead of recursing through subdirectories with a for loop or
610 # repeated $(MAKE) -C whatever calls, this is a little smarter: it
611 # allows parallel make across directories and lets make -k and -q work
614 # We need the $(eval) function and order-only prerequisites, which are
615 # available in GNU make 3.80. That also happens to be the version
616 # where the .VARIABLES variable was introduced, so this is a simple check.
618 $(error GNU make 3.80 or newer is required. You are using version $(MAKE_VERSION))
621 # This function is only for internal use below. It should be called
622 # using $(eval). It will set up a target so that it recurses into
623 # a given subdirectory. Note that to avoid a nasty bug in make 3.80,
624 # this function has to avoid using any complicated constructs (like
625 # multiple targets on a line) and also not contain any lines that expand
626 # to more than about 200 bytes. This is why we make it apply to just one
627 # subdirectory at a time, rather than to a list of subdirectories.
628 # $1: target name, e.g., all
630 # $3: target to run in subdir, usually same as $1
631 define _create_recursive_target
632 .PHONY: $(1)-$(2)-recurse
633 $(1): $(1)-$(2)-recurse
635 $$(MAKE) -C $(2) $(3)
637 # Note that the use of $$ on the last line above is important; we want
638 # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
639 # to create the rule. This is necessary to get make -q working.
641 # Call this function in a makefile that needs to recurse into subdirectories.
642 # In the normal case all arguments can be defaulted.
643 # $1: targets to make recursive (defaults to list of standard targets)
644 # $2: list of subdirs (defaults to SUBDIRS variable)
645 # $3: target to run in subdir (defaults to current element of $1)
646 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))))))
648 # If a makefile's list of SUBDIRS varies depending on configuration, then
649 # any subdirectories excluded from SUBDIRS should instead be added to
650 # ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse.
651 # This ensures that distprep, distclean, etc will apply to all subdirectories.
652 # In the normal case all arguments will be defaulted.
653 # $1: targets to make recursive (defaults to standard_always_targets)
654 # $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable)
655 # $3: target to run in subdir (defaults to current element of $1)
656 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))))))
659 ##########################################################################
661 # Automatic dependency generation
662 # -------------------------------
663 # When we configure with --enable-depend then we override the default
664 # compilation rule with the magic below. While or after creating the
665 # actual output file we also create a dependency list for the .c file.
666 # Next time we invoke make we will have top-notch information about
667 # whether this file needs to be updated. The dependency files are kept
668 # in the .deps subdirectory of each directory.
670 autodepend = @autodepend@
672 ifeq ($(autodepend), yes)
675 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
682 # GCC allows us to create object and dependency file in one invocation.
684 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
685 $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
689 # Include all the dependency files generated for the current
690 # directory. Note that make would complain if include was called with
692 Po_files := $(wildcard $(DEPDIR)/*.Po)
698 clean distclean maintainer-clean: clean-deps
707 ##########################################################################
709 # Native language support
711 ifeq ($(enable_nls), yes)
712 ifneq (,$(wildcard $(srcdir)/nls.mk))
714 include $(top_srcdir)/src/nls-global.mk
720 ##########################################################################
724 # Explanation of involved files:
727 # foo.gcno gcov graph (a.k.a. "notes") file, created at compile time
728 # (by gcc -ftest-coverage)
729 # foo.gcda gcov data file, created when the program is run (for
730 # programs compiled with gcc -fprofile-arcs)
731 # foo.c.gcov gcov output file with coverage information, created by
732 # gcov from foo.gcda (by "make coverage")
733 # foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly
735 # lcov.info lcov tracefile, built from gcda files in one directory,
736 # later collected by "make coverage-html"
738 ifeq ($(enable_coverage), yes)
740 # There is a strange interaction between lcov and existing .gcov
741 # output files. Hence the rm command and the ordering dependency.
743 gcda_files := $(wildcard *.gcda)
745 lcov.info: $(gcda_files)
747 $(if $^,$(LCOV) -d . -c -o $@ $(LCOVFLAGS))
749 %.c.gcov: %.gcda | lcov.info
750 $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
752 coverage: $(gcda_files:.gcda=.c.gcov) lcov.info
754 .PHONY: coverage-html
755 coverage-html: coverage
758 $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) `find . -name lcov.info -print`
762 clean distclean maintainer-clean: clean-coverage
764 .PHONY: clean-coverage
767 rm -f *.gcda *.gcno lcov.info *.gcov *.gcov.out
770 # User-callable target to reset counts between test runs
772 rm -f `find . -name '*.gcda' -print`
774 endif # enable_coverage