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
23 .PHONY: $(standard_targets) install-strip maintainer-check html man installcheck-parallel
25 # make `all' the default target
28 # Delete target files if the command fails after it has
29 # started to update the file.
32 # PostgreSQL version number
33 VERSION = @PACKAGE_VERSION@
34 MAJORVERSION = @PG_MAJORVERSION@
36 # Support for VPATH builds
37 vpath_build = @vpath_build@
38 abs_top_srcdir = @abs_top_srcdir@
40 ifneq ($(vpath_build),yes)
41 top_srcdir = $(top_builddir)
43 else # vpath_build = yes
44 top_srcdir = $(abs_top_srcdir)
45 srcdir = $(top_srcdir)/$(subdir)
49 vpathsearch = `for f in $(addsuffix /$(1),$(subst :, ,. $(VPATH))); do test -r $$f && echo $$f && break; done`
51 # Saved arguments from configure
52 configure_args = @configure_args@
55 ##########################################################################
57 # Installation directories
59 # These are set by the equivalent --xxxdir configure options. We
60 # append "postgresql" to some of them, if the string does not already
61 # contain "pgsql" or "postgres", in order to avoid directory clutter.
63 # In a PGXS build, we cannot use the values inserted into Makefile.global
64 # by configure, since the installation tree may have been relocated.
65 # Instead get the path values from pg_config.
69 # Note that prefix, exec_prefix, and datarootdir aren't defined in a PGXS build;
70 # makefiles may only use the derived variables such as bindir.
73 exec_prefix := @exec_prefix@
74 datarootdir := @datarootdir@
79 ifeq "$(findstring pgsql, $(datadir))" ""
80 ifeq "$(findstring postgres, $(datadir))" ""
81 override datadir := $(datadir)/postgresql
85 sysconfdir := @sysconfdir@
86 ifeq "$(findstring pgsql, $(sysconfdir))" ""
87 ifeq "$(findstring postgres, $(sysconfdir))" ""
88 override sysconfdir := $(sysconfdir)/postgresql
95 ifeq "$(findstring pgsql, $(pkglibdir))" ""
96 ifeq "$(findstring postgres, $(pkglibdir))" ""
97 override pkglibdir := $(pkglibdir)/postgresql
101 includedir := @includedir@
103 pkgincludedir = $(includedir)
104 ifeq "$(findstring pgsql, $(pkgincludedir))" ""
105 ifeq "$(findstring postgres, $(pkgincludedir))" ""
106 override pkgincludedir := $(pkgincludedir)/postgresql
113 ifeq "$(findstring pgsql, $(docdir))" ""
114 ifeq "$(findstring postgres, $(docdir))" ""
115 override docdir := $(docdir)/postgresql
121 localedir := @localedir@
125 # Extension makefiles should set PG_CONFIG, but older ones might not
127 PG_CONFIG = pg_config
130 bindir := $(shell $(PG_CONFIG) --bindir)
131 datadir := $(shell $(PG_CONFIG) --sharedir)
132 sysconfdir := $(shell $(PG_CONFIG) --sysconfdir)
133 libdir := $(shell $(PG_CONFIG) --libdir)
134 pkglibdir := $(shell $(PG_CONFIG) --pkglibdir)
135 includedir := $(shell $(PG_CONFIG) --includedir)
136 pkgincludedir := $(shell $(PG_CONFIG) --pkgincludedir)
137 mandir := $(shell $(PG_CONFIG) --mandir)
138 docdir := $(shell $(PG_CONFIG) --docdir)
139 localedir := $(shell $(PG_CONFIG) --localedir)
143 # These derived path variables aren't separately configurable.
145 includedir_server = $(pkgincludedir)/server
146 includedir_internal = $(pkgincludedir)/internal
147 pgxsdir = $(pkglibdir)/pgxs
150 ##########################################################################
154 # Records the choice of the various --enable-xxx and --with-xxx options.
156 with_perl = @with_perl@
157 with_python = @with_python@
158 with_tcl = @with_tcl@
159 with_openssl = @with_openssl@
160 with_ossp_uuid = @with_ossp_uuid@
161 with_selinux = @with_selinux@
162 with_libxml = @with_libxml@
163 with_libxslt = @with_libxslt@
164 with_system_tzdata = @with_system_tzdata@
165 with_zlib = @with_zlib@
166 enable_shared = @enable_shared@
167 enable_rpath = @enable_rpath@
168 enable_nls = @enable_nls@
169 enable_debug = @enable_debug@
170 enable_dtrace = @enable_dtrace@
171 enable_coverage = @enable_coverage@
172 enable_thread_safety = @enable_thread_safety@
174 python_includespec = @python_includespec@
175 python_libdir = @python_libdir@
176 python_libspec = @python_libspec@
177 python_additional_libs = @python_additional_libs@
178 python_configdir = @python_configdir@
179 python_majorversion = @python_majorversion@
180 python_version = @python_version@
182 krb_srvtab = @krb_srvtab@
185 TCL_LIB_FILE = @TCL_LIB_FILE@
186 TCL_LIBS = @TCL_LIBS@
187 TCL_LIB_SPEC = @TCL_LIB_SPEC@
188 TCL_INCLUDE_SPEC = @TCL_INCLUDE_SPEC@
189 TCL_SHARED_BUILD = @TCL_SHARED_BUILD@
190 TCL_SHLIB_LD_LIBS = @TCL_SHLIB_LD_LIBS@
192 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
193 PTHREAD_LIBS = @PTHREAD_LIBS@
196 ##########################################################################
203 CPPFLAGS = @CPPFLAGS@
206 override CPPFLAGS := -I$(includedir_server) -I$(includedir_internal) $(CPPFLAGS)
208 override CPPFLAGS := -I$(top_srcdir)/src/include $(CPPFLAGS)
210 override CPPFLAGS := -I$(top_builddir)/src/include $(CPPFLAGS)
216 SUN_STUDIO_CC = @SUN_STUDIO_CC@
222 BISONFLAGS = @BISONFLAGS@ $(YFLAGS)
224 FLEXFLAGS = @FLEXFLAGS@ $(LFLAGS)
226 DTRACEFLAGS = @DTRACEFLAGS@
235 LDAP_LIBS_FE = @LDAP_LIBS_FE@
236 LDAP_LIBS_BE = @LDAP_LIBS_BE@
237 OSSP_UUID_LIBS = @OSSP_UUID_LIBS@
239 with_gnu_ld = @with_gnu_ld@
240 ld_R_works = @ld_R_works@
242 # We want -L for libpgport.a to be first in LDFLAGS. We also need LDFLAGS
243 # to be a "recursively expanded" variable, else adjustments to rpathdir
244 # don't work right. So we must NOT do LDFLAGS := something, meaning this has
245 # to be done first and elsewhere we must only do LDFLAGS += something.
247 LDFLAGS = -L$(libdir)
249 LDFLAGS = -L$(top_builddir)/src/port
253 LDFLAGS_EX = @LDFLAGS_EX@
254 # LDFLAGS_SL might have already been assigned by calling makefile
255 LDFLAGS_SL += @LDFLAGS_SL@
265 # quoted to protect pathname with spaces
268 PERL = $(missing) perl
270 perl_archlibexp = @perl_archlibexp@
271 perl_privlibexp = @perl_privlibexp@
272 perl_useshrplib = @perl_useshrplib@
273 perl_embed_ldflags = @perl_embed_ldflags@
280 MSGMERGE = @MSGMERGE@
283 XGETTEXT = @XGETTEXT@
288 PL_TESTDB = pl_regression
289 CONTRIB_TESTDB = contrib_regression
293 INSTALL = $(SHELL) $(top_srcdir)/config/install-sh -c
295 INSTALL_SCRIPT_MODE = 755
296 INSTALL_DATA_MODE = 644
297 INSTALL_PROGRAM = $(INSTALL_PROGRAM_ENV) $(INSTALL) $(INSTALL_STRIP_FLAG)
298 INSTALL_SCRIPT = $(INSTALL) -m $(INSTALL_SCRIPT_MODE)
299 INSTALL_DATA = $(INSTALL) -m $(INSTALL_DATA_MODE)
300 INSTALL_STLIB = $(INSTALL_STLIB_ENV) $(INSTALL_DATA) $(INSTALL_STRIP_FLAG)
301 INSTALL_SHLIB = $(INSTALL_SHLIB_ENV) $(INSTALL) $(INSTALL_SHLIB_OPTS) $(INSTALL_STRIP_FLAG)
302 # Override in Makefile.port if necessary
303 INSTALL_SHLIB_OPTS = -m 755
307 missing = $(SHELL) $(top_srcdir)/config/missing
310 STRIP_STATIC_LIB = @STRIP_STATIC_LIB@
311 STRIP_SHARED_LIB = @STRIP_SHARED_LIB@
315 have_docbook = @have_docbook@
316 COLLATEINDEX = @COLLATEINDEX@
317 DOCBOOKSTYLE = @DOCBOOKSTYLE@
321 XSLTPROC = @XSLTPROC@
329 ifeq ($(enable_coverage),yes)
330 # ccache loses .gcno files
331 export CCACHE_DISABLE = 1
336 DEF_PGPORT = @default_port@
337 WANTED_LANGUAGES = @WANTED_LANGUAGES@
340 ##########################################################################
342 # Additional platform-specific settings
345 # Name of the "template"
348 build_os = @build_os@
352 host_cpu = @host_cpu@
354 # Make HAVE_IPV6 available for initdb script creation
355 HAVE_IPV6= @HAVE_IPV6@
357 # The HP-UX port makefile, for one, needs access to this symbol
358 HAVE_POSIX_SIGNALS= @HAVE_POSIX_SIGNALS@
360 # This is mainly for use on FreeBSD, where we have both a.out and elf
361 # systems now. May be applicable to other systems to?
362 ELF_SYSTEM= @ELF_SYS@
364 # Backend stack size limit has to be hard-wired on Windows (it's in bytes)
365 WIN32_STACK_RLIMIT=4194304
367 # Set if we have a working win32 crashdump header
368 have_win32_dbghelp = @have_win32_dbghelp@
370 # Pull in platform-specific magic
371 include $(top_builddir)/src/Makefile.port
373 # Set up rpath if enabled. By default it will point to our libdir,
374 # but individual Makefiles can force other rpath paths if needed.
377 ifeq ($(enable_rpath), yes)
382 ##########################################################################
384 # Some variables needed to find some client interfaces
387 # some contribs assumes headers and libs are in the source tree...
388 libpq_srcdir = $(includedir)
389 libpq_builddir = $(libdir)
391 libpq_srcdir = $(top_srcdir)/src/interfaces/libpq
392 libpq_builddir = $(top_builddir)/src/interfaces/libpq
395 # This macro is for use by libraries linking to libpq. (Because libpgport
396 # isn't created with the same link flags as libpq, it can't be used.)
397 libpq = -L$(libpq_builddir) -lpq
399 # If doing static linking, shared library dependency info isn't available,
400 # so add in the libraries that libpq depends on.
401 ifeq ($(enable_shared), no)
402 libpq += $(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt, $(LIBS)) \
403 $(LDAP_LIBS_FE) $(PTHREAD_LIBS)
406 # This macro is for use by client executables (not libraries) that use libpq.
407 # We force clients to pull symbols from the non-shared library libpgport
408 # rather than pulling some libpgport symbols from libpq just because
409 # libpq uses those functions too. This makes applications less
410 # dependent on changes in libpq's usage of pgport. To do this we link to
411 # pgport before libpq. This does cause duplicate -lpgport's to appear
412 # on client link lines.
414 libpq_pgport = -L$(libdir) -lpgport $(libpq)
416 libpq_pgport = -L$(top_builddir)/src/port -lpgport $(libpq)
421 $(MAKE) -C $(libpq_builddir) all
424 $(MAKE) -C $(top_builddir)/src/port all
426 .PHONY: submake-libpq submake-libpgport
429 ##########################################################################
433 # This includes your local customizations if Makefile.custom exists
434 # in the source directory. This file doesn't exist in the original
435 # distribution so that it doesn't get overwritten when you upgrade.
437 # NOTE: Makefile.custom is from the pre-Autoconf days of PostgreSQL.
438 # You are liable to shoot yourself in the foot if you use it without
439 # knowing exactly what you're doing. The preferred (and more
440 # reliable) method is to communicate what you want to do to the
441 # configure script, and leave the makefiles alone.
443 -include $(top_srcdir)/src/Makefile.custom
445 ifneq ($(CUSTOM_INSTALL),)
446 INSTALL= $(CUSTOM_INSTALL)
449 ifneq ($(CUSTOM_CC),)
453 ifneq ($(CUSTOM_COPT),)
464 LDFLAGS += $(PROFILE)
468 ##########################################################################
470 # substitute implementations of C library routines (see src/port/)
471 # note we already included -L.../src/port in LDFLAGS above
475 LIBS := -lpgport $(LIBS)
477 # to make ws2_32.lib the last library, and always link with shfolder,
478 # so SHGetFolderName isn't picked up from shell32.dll
479 ifeq ($(PORTNAME),win32)
480 LIBS += -lws2_32 -lshfolder
483 # Not really standard libc functions, used by the backend.
487 ##########################################################################
489 # Global targets and rules
492 $(CPP) $(CPPFLAGS) -o $@ $<
495 $(GZIP) --best -c $< >$@
502 # Remake Makefile.global from Makefile.global.in if the latter
503 # changed. In order to trigger this rule, the including file must
504 # write `include $(top_builddir)/src/Makefile.global', not some
506 $(top_builddir)/src/Makefile.global: $(top_srcdir)/src/Makefile.global.in $(top_builddir)/config.status
507 cd $(top_builddir) && ./config.status src/Makefile.global
509 # Remake pg_config.h from pg_config.h.in if the latter changed.
510 # config.status will not change the timestamp on pg_config.h if it
511 # doesn't change, so as to avoid recompiling the entire tree
512 # unnecessarily. Therefore we make config.status update a timestamp file
513 # stamp-h everytime it runs, so that we don't trigger this rule everytime.
514 # (We do trigger the null rule for stamp-h to pg_config.h everytime; so it's
515 # important for that rule to be null!)
517 # Of course you need to turn on dependency tracking to get any
518 # dependencies on pg_config.h.
519 $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h
521 $(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
522 cd $(top_builddir) && ./config.status src/include/pg_config.h
524 # Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
526 $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h
528 $(top_builddir)/src/interfaces/ecpg/include/stamp-h: $(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h.in $(top_builddir)/config.status
529 cd $(top_builddir) && ./config.status src/interfaces/ecpg/include/ecpg_config.h
531 # When configure changes, rerun configure with the same options as
532 # last time. To change configure, you need to run autoconf manually.
533 $(top_builddir)/config.status: $(top_srcdir)/configure
534 cd $(top_builddir) && ./config.status --recheck
540 @$(MAKE) INSTALL_PROGRAM_ENV="STRIPPROG='$(STRIP)'" \
541 INSTALL_STLIB_ENV="STRIPPROG='$(STRIP_STATIC_LIB)'" \
542 INSTALL_SHLIB_ENV="STRIPPROG='$(STRIP_SHARED_LIB)'" \
543 INSTALL_STRIP_FLAG=-s \
547 ##########################################################################
549 # Recursive make support
550 # ----------------------
551 # Instead of recursing through subdirectories with a for loop or
552 # repeated $(MAKE) -C whatever calls, this is a little smarter: it
553 # allows parallel make across directories and lets make -k and -q work
556 # We need the $(eval) function and order-only prerequisites, which are
557 # available in GNU make 3.80. That also happens to be the version
558 # where the .VARIABLES variable was introduced, so this is a simple check.
560 $(error GNU make 3.80 or newer is required. You are using version $(MAKE_VERSION))
563 # This function is only for internal use below. It should be called
564 # using $(eval). It will set up a target so that it recurses into
565 # a given subdirectory. Note that to avoid a nasty bug in make 3.80,
566 # this function has to avoid using any complicated constructs (like
567 # multiple targets on a line) and also not contain any lines that expand
568 # to more than about 200 bytes. This is why we make it apply to just one
569 # subdirectory at a time, rather than to a list of subdirectories.
570 # $1: target name, e.g., all
572 # $3: target to run in subdir, usually same as $1
573 define _create_recursive_target
574 .PHONY: $(1)-$(2)-recurse
575 $(1): $(1)-$(2)-recurse
577 $$(MAKE) -C $(2) $(3)
579 # Note that the use of $$ on the last line above is important; we want
580 # $(MAKE) to be evaluated when the rule is run, not when the $(eval) is run
581 # to create the rule. This is necessary to get make -q working.
583 # Call this function in a makefile that needs to recurse into subdirectories.
584 # In the normal case all arguments can be defaulted.
585 # $1: targets to make recursive (defaults to list of standard targets)
586 # $2: list of subdirs (defaults to SUBDIRS variable)
587 # $3: target to run in subdir (defaults to current element of $1)
588 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))))))
591 ##########################################################################
593 # Automatic dependency generation
594 # -------------------------------
595 # When we configure with --enable-depend then we override the default
596 # compilation rule with the magic below. While or after creating the
597 # actual output file we also create a dependency list for the .c file.
598 # Next time we invoke make we will have top-notch information about
599 # whether this file needs to be updated. The dependency files are kept
600 # in the .deps subdirectory of each directory.
602 autodepend = @autodepend@
604 ifeq ($(autodepend), yes)
607 COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
614 # GCC allows us to create object and dependency file in one invocation.
616 @if test ! -d $(DEPDIR); then mkdir -p $(DEPDIR); fi
617 $(COMPILE.c) -o $@ $< -MMD -MP -MF $(DEPDIR)/$(*F).Po
621 # Include all the dependency files generated for the current
622 # directory. List /dev/null as dummy because if the wildcard expands
623 # to nothing then make would complain.
624 -include $(wildcard $(DEPDIR)/*.Po) /dev/null
627 clean distclean maintainer-clean: clean-deps
633 # When in automatic dependency mode, never delete any intermediate
634 # files automatically. Otherwise, the following could happen: When
635 # starting from a clean source tree, the first build would delete the
636 # intermediate file, but also create the dependency file, which
637 # mentions the intermediate file, thus making it non-intermediate.
638 # The second build will then need to rebuild the now non-intermediate
639 # missing file. So the second build will do work even though nothing
640 # had changed. One place where this happens is the .c -> .o -> .so
641 # chain for some contrib modules.
647 ##########################################################################
649 # Native language support
651 ifeq ($(enable_nls), yes)
652 ifneq (,$(wildcard $(srcdir)/nls.mk))
654 include $(top_srcdir)/src/nls-global.mk
660 ##########################################################################
664 # Explanation of involved files:
667 # foo.gcno gcov graph (a.k.a. "notes") file, created at compile time
668 # (by gcc -ftest-coverage)
669 # foo.gcda gcov data file, created when the program is run (for
670 # programs compiled with gcc -fprofile-arcs)
671 # foo.c.gcov gcov output file with coverage information, created by
672 # gcov from foo.gcda (by "make coverage")
673 # foo.c.gcov.out stdout captured when foo.c.gcov is created, mildly
675 # lcov.info lcov tracefile, built from gcda files in one directory,
676 # later collected by "make coverage-html"
678 ifeq ($(enable_coverage), yes)
680 # There is a strange interaction between lcov and existing .gcov
681 # output files. Hence the rm command and the ordering dependency.
683 gcda_files := $(wildcard *.gcda)
685 lcov.info: $(gcda_files)
687 $(if $^,$(LCOV) -d . -c -o $@ $(LCOVFLAGS))
689 %.c.gcov: %.gcda | lcov.info
690 $(GCOV) -b -f -p -o . $(GCOVFLAGS) $*.c >$*.c.gcov.out
692 coverage: $(gcda_files:.gcda=.c.gcov) lcov.info
694 .PHONY: coverage-html
695 coverage-html: coverage
698 $(GENHTML) --show-details --legend --output-directory=coverage --title=PostgreSQL --num-spaces=4 --prefix=$(abs_top_srcdir) `find . -name lcov.info -print`
702 clean distclean maintainer-clean: clean-coverage
704 .PHONY: clean-coverage
707 rm -f *.gcda *.gcno lcov.info *.gcov *.gcov.out
710 # User-callable target to reset counts between test runs
712 rm -f `find . -name '*.gcda' -print`
714 endif # enable_coverage