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.

Makefile.global.in 33KB

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