1# -*-makefile-*- 2# src/Makefile.global.in 3# @configure_input@ 4 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 9# bug. 10# 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#------------------------------------------------------------------------------ 16 17 18########################################################################## 19# 20# Meta configuration 21 22standard_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: 24standard_always_targets = distprep clean distclean maintainer-clean 25 26.PHONY: $(standard_targets) install-strip html man installcheck-parallel maintainer-check 27 28# make `all' the default target 29all: 30 31# Delete target files if the command fails after it has 32# started to update the file. 33.DELETE_ON_ERROR: 34 35# Never delete any intermediate files automatically. 36.SECONDARY: 37 38# PostgreSQL version number 39VERSION = @PACKAGE_VERSION@ 40MAJORVERSION = @PG_MAJORVERSION@ 41VERSION_NUM = @PG_VERSION_NUM@ 42 43# Set top_srcdir, srcdir, and VPATH. 44ifdef PGXS 45top_srcdir = $(top_builddir) 46 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. 49ifdef VPATH 50srcdir = $(VPATH) 51else 52ifeq ($(CURDIR),$(dir $(firstword $(MAKEFILE_LIST)))) 53srcdir = . 54VPATH = 55else 56srcdir = $(dir $(firstword $(MAKEFILE_LIST))) 57VPATH = $(srcdir) 58endif 59endif 60else # not PGXS 61vpath_build = @vpath_build@ 62abs_top_builddir = @abs_top_builddir@ 63abs_top_srcdir = @abs_top_srcdir@ 64 65ifneq ($(vpath_build),yes) 66top_srcdir = $(top_builddir) 67srcdir = . 68else # vpath_build = yes 69top_srcdir = $(abs_top_srcdir) 70srcdir = $(top_srcdir)/$(subdir) 71VPATH = $(srcdir) 72endif 73endif # not PGXS 74 75vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done` 76 77# Saved arguments from configure 78configure_args = @configure_args@ 79 80 81########################################################################## 82# 83# Installation directories 84# 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. 88# 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. 92 93ifndef PGXS 94 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. 97 98prefix := @prefix@ 99exec_prefix := @exec_prefix@ 100datarootdir := @datarootdir@ 101 102bindir := @bindir@ 103 104datadir := @datadir@ 105ifeq "$(findstring pgsql, $(datadir))" "" 106ifeq "$(findstring postgres, $(datadir))" "" 107override datadir := $(datadir)/postgresql 108endif 109endif 110 111sysconfdir := @sysconfdir@ 112ifeq "$(findstring pgsql, $(sysconfdir))" "" 113ifeq "$(findstring postgres, $(sysconfdir))" "" 114override sysconfdir := $(sysconfdir)/postgresql 115endif 116endif 117 118libdir := @libdir@ 119 120pkglibdir = $(libdir) 121ifeq "$(findstring pgsql, $(pkglibdir))" "" 122ifeq "$(findstring postgres, $(pkglibdir))" "" 123override pkglibdir := $(pkglibdir)/postgresql 124endif 125endif 126 127includedir := @includedir@ 128 129pkgincludedir = $(includedir) 130ifeq "$(findstring pgsql, $(pkgincludedir))" "" 131ifeq "$(findstring postgres, $(pkgincludedir))" "" 132override pkgincludedir := $(pkgincludedir)/postgresql 133endif 134endif 135 136mandir := @mandir@ 137 138docdir := @docdir@ 139ifeq "$(findstring pgsql, $(docdir))" "" 140ifeq "$(findstring postgres, $(docdir))" "" 141override docdir := $(docdir)/postgresql 142endif 143endif 144 145htmldir := @htmldir@ 146 147localedir := @localedir@ 148 149else # PGXS case 150 151# Extension makefiles should set PG_CONFIG, but older ones might not 152ifndef PG_CONFIG 153PG_CONFIG = pg_config 154endif 155 156bindir := $(shell $(PG_CONFIG) --bindir) 157datadir := $(shell $(PG_CONFIG) --sharedir) 158sysconfdir := $(shell $(PG_CONFIG) --sysconfdir) 159libdir := $(shell $(PG_CONFIG) --libdir) 160pkglibdir := $(shell $(PG_CONFIG) --pkglibdir) 161includedir := $(shell $(PG_CONFIG) --includedir) 162pkgincludedir := $(shell $(PG_CONFIG) --pkgincludedir) 163mandir := $(shell $(PG_CONFIG) --mandir) 164docdir := $(shell $(PG_CONFIG) --docdir) 165localedir := $(shell $(PG_CONFIG) --localedir) 166 167endif # PGXS 168 169# These derived path variables aren't separately configurable. 170 171includedir_server = $(pkgincludedir)/server 172includedir_internal = $(pkgincludedir)/internal 173pgxsdir = $(pkglibdir)/pgxs 174 175 176########################################################################## 177# 178# Features 179# 180# Records the choice of the various --enable-xxx and --with-xxx options. 181 182with_icu = @with_icu@ 183with_perl = @with_perl@ 184with_python = @with_python@ 185with_tcl = @with_tcl@ 186with_openssl = @with_openssl@ 187with_selinux = @with_selinux@ 188with_systemd = @with_systemd@ 189with_libxml = @with_libxml@ 190with_libxslt = @with_libxslt@ 191with_system_tzdata = @with_system_tzdata@ 192with_uuid = @with_uuid@ 193with_zlib = @with_zlib@ 194enable_rpath = @enable_rpath@ 195enable_nls = @enable_nls@ 196enable_debug = @enable_debug@ 197enable_dtrace = @enable_dtrace@ 198enable_coverage = @enable_coverage@ 199enable_tap_tests = @enable_tap_tests@ 200enable_thread_safety = @enable_thread_safety@ 201enable_strong_random = @enable_strong_random@ 202 203python_includespec = @python_includespec@ 204python_libdir = @python_libdir@ 205python_libspec = @python_libspec@ 206python_additional_libs = @python_additional_libs@ 207python_majorversion = @python_majorversion@ 208python_version = @python_version@ 209 210krb_srvtab = @krb_srvtab@ 211 212ICU_CFLAGS = @ICU_CFLAGS@ 213ICU_LIBS = @ICU_LIBS@ 214 215TCLSH = @TCLSH@ 216TCL_LIBS = @TCL_LIBS@ 217TCL_LIB_SPEC = @TCL_LIB_SPEC@ 218TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@ 219TCL_SHARED_BUILD = @TCL_SHARED_BUILD@ 220TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@ 221 222PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ 223PTHREAD_LIBS = @PTHREAD_LIBS@ 224 225 226########################################################################## 227# 228# Programs and flags 229 230# Compilers 231 232CPP = @CPP@ 233CPPFLAGS = @CPPFLAGS@ 234PG_SYSROOT = @PG_SYSROOT@ 235 236override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS) 237 238ifdef PGXS 239override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS) 240else # not PGXS 241override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS) 242ifdef VPATH 243override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS) 244endif 245endif # not PGXS 246 247CC = @CC@ 248GCC = @GCC@ 249SUN_STUDIO_CC = @SUN_STUDIO_CC@ 250CFLAGS = @CFLAGS@ 251CFLAGS_SL = @CFLAGS_SL@ 252CFLAGS_VECTOR = @CFLAGS_VECTOR@ 253CFLAGS_SSE42 = @CFLAGS_SSE42@ 254 255# Kind-of compilers 256 257BISON = @BISON@ 258BISONFLAGS = @BISONFLAGS@ $(YFLAGS) 259FLEX = @FLEX@ 260FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS) 261DTRACE = @DTRACE@ 262DTRACEFLAGS = @DTRACEFLAGS@ 263ZIC = @ZIC@ 264 265# Linking 266 267AR = @AR@ 268DLLTOOL = @DLLTOOL@ 269DLLWRAP = @DLLWRAP@ 270LIBS = @LIBS@ 271LDAP_LIBS_FE = @LDAP_LIBS_FE@ 272LDAP_LIBS_BE = @LDAP_LIBS_BE@ 273UUID_LIBS = @UUID_LIBS@ 274UUID_EXTRA_OBJS = @UUID_EXTRA_OBJS@ 275LD = @LD@ 276with_gnu_ld = @with_gnu_ld@ 277 278# It's critical that within LDFLAGS, all -L switches pointing to build-tree 279# directories come before any -L switches pointing to external directories. 280# Otherwise it's possible for, e.g., a platform-provided copy of libpq.so 281# to get linked in place of the one we've built. Therefore we adopt the 282# convention that the first component of LDFLAGS is an extra variable 283# LDFLAGS_INTERNAL, and -L and -l switches for PG's own libraries must be 284# put into LDFLAGS_INTERNAL, so they will appear ahead of those for external 285# libraries. 286# 287# We need LDFLAGS and LDFLAGS_INTERNAL to be "recursively expanded" variables, 288# else adjustments to, e.g., rpathdir don't work right. So we must NOT do 289# "LDFLAGS := something" anywhere, ditto for LDFLAGS_INTERNAL. 290# These initial assignments must be "=" type, and elsewhere we must only do 291# "LDFLAGS += something" or "LDFLAGS_INTERNAL += something". 292ifdef PGXS 293 LDFLAGS_INTERNAL = -L$(libdir) 294else 295 LDFLAGS_INTERNAL = -L$(top_builddir)/src/port -L$(top_builddir)/src/common 296endif 297LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@ 298 299LDFLAGS_EX = @LDFLAGS_EX@ 300# LDFLAGS_SL might have already been assigned by calling makefile 301LDFLAGS_SL += @LDFLAGS_SL@ 302LDREL = -r 303LDOUT = -o 304RANLIB = @RANLIB@ 305WINDRES = @WINDRES@ 306X = @EXEEXT@ 307 308# Perl 309 310ifneq (@PERL@,) 311 # quoted to protect pathname with spaces 312 PERL = '@PERL@' 313else 314 PERL = $(missing) perl 315endif 316perl_archlibexp = @perl_archlibexp@ 317perl_privlibexp = @perl_privlibexp@ 318perl_includespec = @perl_includespec@ 319perl_embed_ccflags = @perl_embed_ccflags@ 320perl_embed_ldflags = @perl_embed_ldflags@ 321 322# Miscellaneous 323 324AWK = @AWK@ 325LN_S = @LN_S@ 326MSGFMT = @MSGFMT@ 327MSGFMT_FLAGS = @MSGFMT_FLAGS@ 328MSGMERGE = @MSGMERGE@ 329PYTHON = @PYTHON@ 330TAR = @TAR@ 331XGETTEXT = @XGETTEXT@ 332 333GZIP = gzip 334BZIP2 = bzip2 335 336# Testing 337 338check: temp-install 339 340.PHONY: temp-install 341temp-install: 342ifndef NO_TEMP_INSTALL 343ifneq ($(abs_top_builddir),) 344ifeq ($(MAKELEVEL),0) 345 rm -rf '$(abs_top_builddir)'/tmp_install 346 $(MKDIR_P) '$(abs_top_builddir)'/tmp_install/log 347 $(MAKE) -C '$(top_builddir)' DESTDIR='$(abs_top_builddir)'/tmp_install install >'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1 348 $(MAKE) -j1 $(if $(CHECKPREP_TOP),-C $(CHECKPREP_TOP),) checkprep >>'$(abs_top_builddir)'/tmp_install/log/install.log 2>&1 349endif 350endif 351endif 352 353# Tasks to run serially at the end of temp-install. Some EXTRA_INSTALL 354# entries appear more than once in the tree, and parallel installs of the same 355# file can fail with EEXIST. 356checkprep: 357 $(if $(EXTRA_INSTALL),for extra in $(EXTRA_INSTALL); do $(MAKE) -C '$(top_builddir)'/$$extra DESTDIR='$(abs_top_builddir)'/tmp_install install || exit; done) 358 359PROVE = @PROVE@ 360# There are common routines in src/test/perl, and some test suites have 361# extra perl modules in their own directory. 362PG_PROVE_FLAGS = -I $(top_srcdir)/src/test/perl/ -I $(srcdir) 363# User-supplied prove flags such as --verbose can be provided in PROVE_FLAGS. 364PROVE_FLAGS = 365 366# prepend to path if already set, else just set it 367define add_to_path 368$(1)="$(if $($(1)),$(2):$$$(1),$(2))" 369endef 370 371# platform-specific environment variable to set shared library path 372# individual ports can override this later, this is the default name 373ld_library_path_var = LD_LIBRARY_PATH 374 375# with_temp_install_extra is for individual ports to define if they 376# need something more here. If not defined then the expansion does 377# nothing. 378with_temp_install = \ 379 PATH="$(abs_top_builddir)/tmp_install$(bindir):$$PATH" \ 380 $(call add_to_path,$(strip $(ld_library_path_var)),$(abs_top_builddir)/tmp_install$(libdir)) \ 381 $(with_temp_install_extra) 382 383ifeq ($(enable_tap_tests),yes) 384 385ifndef PGXS 386define prove_installcheck 387rm -rf $(CURDIR)/tmp_check/log 388cd $(srcdir) && \ 389 TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' \ 390 top_builddir='$(CURDIR)/$(top_builddir)' \ 391 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \ 392 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl) 393endef 394else # PGXS case 395define prove_installcheck 396rm -rf $(CURDIR)/tmp_check/log 397cd $(srcdir) && \ 398 TESTDIR='$(CURDIR)' PATH="$(bindir):$$PATH" PGPORT='6$(DEF_PGPORT)' \ 399 top_builddir='$(top_builddir)' \ 400 PG_REGRESS='$(top_builddir)/src/test/regress/pg_regress' \ 401 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl) 402endef 403endif # PGXS 404 405define prove_check 406rm -rf $(CURDIR)/tmp_check/log 407cd $(srcdir) && \ 408 TESTDIR='$(CURDIR)' $(with_temp_install) PGPORT='6$(DEF_PGPORT)' \ 409 PG_REGRESS='$(CURDIR)/$(top_builddir)/src/test/regress/pg_regress' \ 410 $(PROVE) $(PG_PROVE_FLAGS) $(PROVE_FLAGS) $(if $(PROVE_TESTS),$(PROVE_TESTS),t/*.pl) 411endef 412 413else 414prove_installcheck = @echo "TAP tests not enabled" 415prove_check = $(prove_installcheck) 416endif 417 418# Installation. 419 420install_bin = @install_bin@ 421install_sh = $(SHELL) $(top_srcdir)/config/install-sh -c 422INSTALL = $(if $(use_install_sh),$(install_sh),$(if $(install_bin),$(install_bin),$(install_sh))) 423 424INSTALL_SCRIPT_MODE = 755 425INSTALL_DATA_MODE = 644 426INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG) 427INSTALL_SCRIPT = $(INSTALL) -m $(INSTALL_SCRIPT_MODE) 428INSTALL_DATA = $(INSTALL) -m $(INSTALL_DATA_MODE) 429INSTALL_STLIB = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG) 430INSTALL_SHLIB = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG) 431# Override in Makefile.port if necessary 432INSTALL_SHLIB_OPTS = -m 755 433 434MKDIR_P = @MKDIR_P@ 435 436missing = $(SHELL) $(top_srcdir)/config/missing 437 438STRIP = @STRIP@ 439STRIP_STATIC_LIB = @STRIP_STATIC_LIB@ 440STRIP_SHARED_LIB = @STRIP_SHARED_LIB@ 441 442# Documentation 443 444DBTOEPUB = @DBTOEPUB@ 445FOP = @FOP@ 446NSGMLS = @NSGMLS@ 447OSX = @OSX@ 448XMLLINT = @XMLLINT@ 449XSLTPROC = @XSLTPROC@ 450 451# Code coverage 452 453GCOV = @GCOV@ 454LCOV = @LCOV@ 455GENHTML = @GENHTML@ 456 457ifeq ($(enable_coverage),yes) 458# ccache loses .gcno files 459export CCACHE_DISABLE = 1 460endif 461 462# Feature settings 463 464DEF_PGPORT = @default_port@ 465WANTED_LANGUAGES = @WANTED_LANGUAGES@ 466 467 468########################################################################## 469# 470# Additional platform-specific settings 471# 472 473# Name of the "template" 474PORTNAME= @PORTNAME@ 475 476build_os = @build_os@ 477 478host_tuple = @host@ 479host_os = @host_os@ 480host_cpu = @host_cpu@ 481 482# Make HAVE_IPV6 available for initdb script creation 483HAVE_IPV6= @HAVE_IPV6@ 484 485# This is mainly for use on FreeBSD, where we have both a.out and elf 486# systems now. May be applicable to other systems to? 487ELF_SYSTEM= @ELF_SYS@ 488 489# Backend stack size limit has to be hard-wired on Windows (it's in bytes) 490WIN32_STACK_RLIMIT=4194304 491 492# Set if we have a working win32 crashdump header 493have_win32_dbghelp = @have_win32_dbghelp@ 494 495# Pull in platform-specific magic 496include $(top_builddir)/src/Makefile.port 497 498# Set up rpath if enabled. By default it will point to our libdir, 499# but individual Makefiles can force other rpath paths if needed. 500rpathdir = $(libdir) 501 502ifeq ($(enable_rpath), yes) 503LDFLAGS += $(rpath) 504endif 505 506# Show the DLSUFFIX to build scripts (e.g. buildfarm) 507.PHONY: show_dl_suffix 508show_dl_suffix: 509 @echo $(DLSUFFIX) 510 511 512########################################################################## 513# 514# Some variables needed to find some client interfaces 515 516ifdef PGXS 517# some contribs assumes headers and libs are in the source tree... 518libpq_srcdir = $(includedir) 519libpq_builddir = $(libdir) 520else 521libpq_srcdir = $(top_srcdir)/src/interfaces/libpq 522libpq_builddir = $(top_builddir)/src/interfaces/libpq 523endif 524 525# This macro is for use by libraries linking to libpq. (Because libpgport 526# isn't created with the same link flags as libpq, it can't be used.) 527libpq = -L$(libpq_builddir) -lpq 528 529# This macro is for use by client executables (not libraries) that use libpq. 530# We force clients to pull symbols from the non-shared libraries libpgport 531# and libpgcommon rather than pulling some libpgport symbols from libpq just 532# because libpq uses those functions too. This makes applications less 533# dependent on changes in libpq's usage of pgport. To do this we link to 534# pgport before libpq. This does cause duplicate -lpgport's to appear 535# on client link lines. 536ifdef PGXS 537libpq_pgport = -L$(libdir) -lpgcommon -lpgport $(libpq) 538else 539libpq_pgport = -L$(top_builddir)/src/common -lpgcommon -L$(top_builddir)/src/port -lpgport $(libpq) 540endif 541 542# Cygwin seems to need ldap libraries to be mentioned here, too 543ifeq ($(PORTNAME),cygwin) 544libpq_pgport += $(LDAP_LIBS_FE) 545endif 546 547 548########################################################################## 549# 550# Commonly used submake targets 551 552submake-libpq: 553 $(MAKE) -C $(libpq_builddir) all 554 555submake-libpgport: 556 $(MAKE) -C $(top_builddir)/src/port all 557 $(MAKE) -C $(top_builddir)/src/common all 558 559submake-libpgfeutils: 560 $(MAKE) -C $(top_builddir)/src/port all 561 $(MAKE) -C $(top_builddir)/src/common all 562 $(MAKE) -C $(top_builddir)/src/fe_utils all 563 564submake-generated-headers: 565 $(MAKE) -C $(top_builddir)/src/backend generated-headers 566 567.PHONY: submake-libpq submake-libpgport submake-libpgfeutils submake-generated-headers 568 569 570########################################################################## 571# 572# Testing support 573 574ifneq ($(USE_MODULE_DB),) 575 PL_TESTDB = pl_regression_$(NAME) 576 # Replace this with $(or ...) if we ever require GNU make 3.81. 577 ifneq ($(MODULE_big),) 578 CONTRIB_TESTDB=contrib_regression_$(MODULE_big) 579 else 580 ifneq ($(MODULES),) 581 CONTRIB_TESTDB=contrib_regression_$(word 1,$(MODULES)) 582 else 583 CONTRIB_TESTDB=contrib_regression_$(word 1,$(REGRESS)) 584 endif 585 endif 586else 587 PL_TESTDB = pl_regression 588 CONTRIB_TESTDB = contrib_regression 589endif 590 591ifdef NO_LOCALE 592NOLOCALE += --no-locale 593endif 594 595# file with extra config for temp build 596TEMP_CONF = 597ifdef TEMP_CONFIG 598TEMP_CONF += --temp-config=$(TEMP_CONFIG) 599endif 600 601pg_regress_locale_flags = $(if $(ENCODING),--encoding=$(ENCODING)) $(NOLOCALE) 602pg_regress_clean_files = results/ regression.diffs regression.out tmp_check/ tmp_check_iso/ log/ output_iso/ 603 604pg_regress_check = \ 605 $(with_temp_install) \ 606 $(top_builddir)/src/test/regress/pg_regress \ 607 --temp-instance=./tmp_check \ 608 --inputdir=$(srcdir) \ 609 --bindir= \ 610 $(TEMP_CONF) \ 611 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS) 612pg_regress_installcheck = \ 613 $(top_builddir)/src/test/regress/pg_regress \ 614 --inputdir=$(srcdir) \ 615 --bindir='$(bindir)' \ 616 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS) 617 618pg_isolation_regress_check = \ 619 $(with_temp_install) \ 620 $(top_builddir)/src/test/isolation/pg_isolation_regress \ 621 --temp-instance=./tmp_check_iso \ 622 --inputdir=$(srcdir) --outputdir=output_iso \ 623 --bindir= \ 624 $(TEMP_CONF) \ 625 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS) 626pg_isolation_regress_installcheck = \ 627 $(top_builddir)/src/test/isolation/pg_isolation_regress \ 628 --inputdir=$(srcdir) --outputdir=output_iso \ 629 --bindir='$(bindir)' \ 630 $(pg_regress_locale_flags) $(EXTRA_REGRESS_OPTS) 631 632########################################################################## 633# 634# Customization 635# 636# This includes your local customizations if Makefile.custom exists 637# in the source directory. This file doesn't exist in the original 638# distribution so that it doesn't get overwritten when you upgrade. 639# 640# NOTE: Makefile.custom is from the pre-Autoconf days of PostgreSQL. 641# You are liable to shoot yourself in the foot if you use it without 642# knowing exactly what you're doing. The preferred (and more 643# reliable) method is to communicate what you want to do to the 644# configure script, and leave the makefiles alone. 645 646-include $(top_srcdir)/src/Makefile.custom 647 648ifneq ($(CUSTOM_INSTALL),) 649INSTALL= $(CUSTOM_INSTALL) 650endif 651 652ifneq ($(CUSTOM_CC),) 653 CC= $(CUSTOM_CC) 654endif 655 656ifneq ($(CUSTOM_COPT),) 657 COPT= $(CUSTOM_COPT) 658endif 659 660# 661# These variables are meant to be set in the environment of "make" 662# to add flags to whatever configure picked. Unlike the ones above, 663# they are documented. 664# 665ifdef COPT 666 CFLAGS += $(COPT) 667 LDFLAGS += $(COPT) 668endif 669 670ifdef PROFILE 671 CFLAGS += $(PROFILE) 672 LDFLAGS += $(PROFILE) 673endif 674 675 676########################################################################## 677# 678# substitute implementations of C library routines (see src/port/) 679# note we already included -L.../src/port in LDFLAGS above 680 681LIBOBJS = @LIBOBJS@ 682 683# files needed for the chosen CRC-32C implementation 684PG_CRC32C_OBJS = @PG_CRC32C_OBJS@ 685 686LIBS := -lpgcommon -lpgport $(LIBS) 687 688# to make ws2_32.lib the last library 689ifeq ($(PORTNAME),win32) 690LIBS += -lws2_32 691endif 692 693# Not really standard libc functions, used by the backend. 694TAS = @TAS@ 695 696 697########################################################################## 698# 699# Global targets and rules 700 701%.c: %.l 702ifdef FLEX 703 $(FLEX) $(if $(FLEX_NO_BACKUP),-b) $(FLEXFLAGS) -o'$@' $< 704 @$(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) 705 $(if $(FLEX_FIX_WARNING),$(PERL) $(top_srcdir)/src/tools/fix-old-flex-code.pl '$@') 706else 707 @$(missing) flex $< '$@' 708endif 709 710%.c: %.y 711 $(if $(BISON_CHECK_CMD),$(BISON_CHECK_CMD)) 712ifdef BISON 713 $(BISON) $(BISONFLAGS) -o $@ $< 714else 715 @$(missing) bison $< $@ 716endif 717 718%.i: %.c 719 $(CPP) $(CPPFLAGS) -o $@ $< 720 721%.gz: % 722 $(GZIP) --best -c $< >$@ 723 724%.bz2: % 725 $(BZIP2) -c $< >$@ 726 727# Direct builds of foo.c -> foo are disabled to avoid generating 728# *.dSYM junk on Macs. All builds should normally go through the 729# foo.c -> foo.o -> foo steps. This also ensures that dependency 730# tracking (see below) is used. 731%: %.c 732 733ifndef PGXS 734 735# Remake Makefile.global from Makefile.global.in if the latter 736# changed. In order to trigger this rule, the including file must 737# write `include $(top_builddir)/src/Makefile.global', not some 738# shortcut thereof. 739$(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status 740 cd $(top_builddir) && ./config.status src/Makefile.global 741 742# Remake pg_config.h from pg_config.h.in if the latter changed. 743# config.status will not change the timestamp on pg_config.h if it 744# doesn't change, so as to avoid recompiling the entire tree 745# unnecessarily. Therefore we make config.status update a timestamp file 746# stamp-h every time it runs, so that we don't trigger this rule every time. 747# (We do trigger the null rule for stamp-h to pg_config.h every time; so it's 748# important for that rule to be empty!) 749# 750# Of course you need to turn on dependency tracking to get any 751# dependencies on pg_config.h. 752$(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ; 753 754$(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status 755 cd $(top_builddir) && ./config.status src/include/pg_config.h 756 757# Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above. 758$(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ; 759 760$(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status 761 cd $(top_builddir) && ./config.status src/include/pg_config_ext.h 762 763# Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same 764# logic as above. 765$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ; 766 767 $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status 768 cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h 769 770# When configure changes, rerun configure with the same options as 771# last time. To change configure, you need to run autoconf manually. 772$(top_builddir)/config.status: $(top_srcdir)/configure 773 cd $(top_builddir) && ./config.status --recheck 774 775endif # not PGXS 776 777 778install-strip: 779# install-strip always uses install-sh, so that strip options can be 780# passed. 781 $(MAKE) use_install_sh=yes \ 782 INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \ 783 INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \ 784 INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \ 785 INSTALL_STRIP_FLAG=-s \ 786 install 787 788 789########################################################################## 790# 791# Recursive make support 792# ---------------------- 793# Instead of recursing through subdirectories with a for loop or 794# repeated $(MAKE) -C whatever calls, this is a little smarter: it 795# allows parallel make across directories and lets make -k and -q work 796# correctly. 797 798# We need the $(eval) function and order-only prerequisites, which are 799# available in GNU make 3.80. That also happens to be the version 800# where the .VARIABLES variable was introduced, so this is a simple check. 801ifndef .VARIABLES 802$(error GNU make 3.80 or newer is required. You are using version $(MAKE_VERSION)) 803endif 804 805# This function is only for internal use below. It should be called 806# using $(eval). It will set up a target so that it recurses into 807# a given subdirectory. Note that to avoid a nasty bug in make 3.80, 808# this function has to avoid using any complicated constructs (like 809# multiple targets on a line) and also not contain any lines that expand 810# to more than about 200 bytes. This is why we make it apply to just one 811# subdirectory at a time, rather than to a list of subdirectories. 812# $1: target name, e.g., all 813# $2: subdir name 814# $3: target to run in subdir, usually same as $1 815define _create_recursive_target 816.PHONY: $(1)-$(2)-recurse 817$(1): $(1)-$(2)-recurse 818$(1)-$(2)-recurse: $(if $(filter check, $(3)), temp-install) 819 $$(MAKE) -C $(2) $(3) 820endef 821# Note that the use of $$ on the last line above is important; we want 822# $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run 823# to create the rule. This is necessary to get make -q working. 824 825# Call this function in a makefile that needs to recurse into subdirectories. 826# In the normal case all arguments can be defaulted. 827# $1: targets to make recursive (defaults to list of standard targets) 828# $2: list of subdirs (defaults to SUBDIRS variable) 829# $3: target to run in subdir (defaults to current element of $1) 830recurse = $(foreach target,$(if $1,$1,$(standard_targets)),$(foreach subdir,$(if $2,$2,$(SUBDIRS)),$(eval $(call _create_recursive_target,$(target),$(subdir),$(if $3,$3,$(target)))))) 831 832# If a makefile's list of SUBDIRS varies depending on configuration, then 833# any subdirectories excluded from SUBDIRS should instead be added to 834# ALWAYS_SUBDIRS, and then it must call recurse_always as well as recurse. 835# This ensures that distprep, distclean, etc will apply to all subdirectories. 836# In the normal case all arguments will be defaulted. 837# $1: targets to make recursive (defaults to standard_always_targets) 838# $2: list of subdirs (defaults to ALWAYS_SUBDIRS variable) 839# $3: target to run in subdir (defaults to current element of $1) 840recurse_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)))))) 841 842 843########################################################################## 844# 845# Automatic dependency generation 846# ------------------------------- 847# When we configure with --enable-depend then we override the default 848# compilation rule with the magic below. While or after creating the 849# actual output file we also create a dependency list for the .c file. 850# Next time we invoke make we will have top-notch information about 851# whether this file needs to be updated. The dependency files are kept 852# in the .deps subdirectory of each directory. 853 854autodepend = @autodepend@ 855 856ifeq ($(autodepend), yes) 857 858ifndef COMPILE.c 859COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c 860endif 861 862DEPDIR = .deps 863 864ifeq ($(GCC), yes) 865 866# GCC allows us to create object and dependency file in one invocation. 867%.o : %.c 868 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi 869 $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po 870 871endif # GCC 872 873# Include all the dependency files generated for the current 874# directory. Note that make would complain if include was called with 875# no arguments. 876Po_files := $(wildcard $(DEPDIR)/*.Po) 877ifneq (,$(Po_files)) 878include $(Po_files) 879endif 880 881# hook for clean-up 882clean distclean maintainer-clean: clean-deps 883 884.PHONY: clean-deps 885clean-deps: 886 @rm -rf $(DEPDIR) 887 888endif # autodepend 889 890 891########################################################################## 892# 893# Native language support 894 895ifeq ($(enable_nls), yes) 896ifneq (,$(wildcard $(srcdir)/nls.mk)) 897 898include $(top_srcdir)/src/nls-global.mk 899 900endif # nls.mk 901endif # enable_nls 902 903 904########################################################################## 905# 906# Coverage 907 908# Explanation of involved files: 909# foo.c source file 910# foo.o object file 911# foo.gcno gcov graph (a.k.a. "notes") file, created at compile time 912# (by gcc -ftest-coverage) 913# foo.gcda gcov data file, created when the program is run (for 914# programs compiled with gcc -fprofile-arcs) 915# foo.c.gcov gcov output file with coverage information, created by 916# gcov from foo.gcda (by "make coverage") 917# foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly 918# interesting 919# lcov.info lcov tracefile, built from gcda files in one directory, 920# later collected by "make coverage-html" 921 922ifeq ($(enable_coverage), yes) 923 924# There is a strange interaction between lcov and existing .gcov 925# output files. Hence the rm command and the ordering dependency. 926 927gcda_files := $(wildcard *.gcda) 928 929lcov.info: $(gcda_files) 930 rm -f *.gcov .*.gcov 931 $(if $^,$(LCOV) -d . -c -o $@ $(LCOVFLAGS) --gcov-tool $(GCOV)) 932 933%.c.gcov: %.gcda | lcov.info 934 $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out 935 936coverage: $(gcda_files:.gcda=.c.gcov) lcov.info 937 938.PHONY: coverage-html 939coverage-html: coverage 940 rm -rf coverage 941 mkdir coverage 942 $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) `find . -name lcov.info -print` 943 944 945# hook for clean-up 946clean distclean maintainer-clean: clean-coverage 947 948.PHONY: clean-coverage 949clean-coverage: 950 rm -rf coverage 951 rm -f *.gcda *.gcno lcov.info *.gcov .*.gcov *.gcov.out 952 953 954# User-callable target to reset counts between test runs 955coverage-clean: 956 rm -f `find . -name '*.gcda' -print` 957 958endif # enable_coverage 959