You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1088 lines
34KB

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