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.

configure.in 80KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441
  1. dnl Process this file with autoconf to produce a configure script.
  2. dnl configure.in
  3. dnl
  4. dnl Developers, please strive to achieve this order:
  5. dnl
  6. dnl 0. Initialization and options processing
  7. dnl 1. Programs
  8. dnl 2. Libraries
  9. dnl 3. Header files
  10. dnl 4. Types
  11. dnl 5. Structures
  12. dnl 6. Compiler characteristics
  13. dnl 7. Functions, global variables
  14. dnl 8. System services
  15. dnl
  16. dnl Read the Autoconf manual for details.
  17. dnl
  18. m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
  19. AC_INIT([PostgreSQL], [13devel], [pgsql-bugs@lists.postgresql.org])
  20. m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
  21. Untested combinations of 'autoconf' and PostgreSQL versions are not
  22. recommended. You can remove the check from 'configure.in' but it is then
  23. your responsibility whether the result works or not.])])
  24. AC_COPYRIGHT([Copyright (c) 1996-2019, PostgreSQL Global Development Group])
  25. AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
  26. AC_CONFIG_AUX_DIR(config)
  27. AC_PREFIX_DEFAULT(/usr/local/pgsql)
  28. AC_SUBST(configure_args, [$ac_configure_args])
  29. [PG_MAJORVERSION=`expr "$PACKAGE_VERSION" : '\([0-9][0-9]*\)'`]
  30. AC_SUBST(PG_MAJORVERSION)
  31. AC_DEFINE_UNQUOTED(PG_MAJORVERSION, "$PG_MAJORVERSION", [PostgreSQL major version as a string])
  32. PGAC_ARG_REQ(with, extra-version, [STRING], [append STRING to version],
  33. [PG_VERSION="$PACKAGE_VERSION$withval"],
  34. [PG_VERSION="$PACKAGE_VERSION"])
  35. AC_DEFINE_UNQUOTED(PG_VERSION, "$PG_VERSION", [PostgreSQL version as a string])
  36. AC_CANONICAL_HOST
  37. template=
  38. AC_MSG_CHECKING([which template to use])
  39. PGAC_ARG_REQ(with, template, [NAME], [override operating system template],
  40. [
  41. case $withval in
  42. list) echo; ls "$srcdir/src/template"; exit;;
  43. *) if test -f "$srcdir/src/template/$with_template" ; then
  44. template=$withval
  45. else
  46. AC_MSG_ERROR(['$withval' is not a valid template name. Use 'list' for a list.])
  47. fi;;
  48. esac
  49. ],
  50. [
  51. # --with-template not given
  52. case $host_os in
  53. aix*) template=aix ;;
  54. cygwin*) template=cygwin ;;
  55. darwin*) template=darwin ;;
  56. dragonfly*) template=netbsd ;;
  57. freebsd*) template=freebsd ;;
  58. hpux*) template=hpux ;;
  59. linux*|gnu*|k*bsd*-gnu)
  60. template=linux ;;
  61. mingw*) template=win32 ;;
  62. netbsd*) template=netbsd ;;
  63. openbsd*) template=openbsd ;;
  64. solaris*) template=solaris ;;
  65. esac
  66. if test x"$template" = x"" ; then
  67. AC_MSG_ERROR([[
  68. *******************************************************************
  69. PostgreSQL has apparently not been ported to your platform yet.
  70. To try a manual configuration, look into the src/template directory
  71. for a similar platform and use the '--with-template=' option.
  72. Please also contact <pgsql-bugs@lists.postgresql.org> to see about
  73. rectifying this. Include the above 'checking host system type...'
  74. line.
  75. *******************************************************************
  76. ]])
  77. fi
  78. ])
  79. AC_MSG_RESULT([$template])
  80. PORTNAME=$template
  81. AC_SUBST(PORTNAME)
  82. # Initialize default assumption that we do not need separate assembly code
  83. # for TAS (test-and-set). This can be overridden by the template file
  84. # when it's executed.
  85. need_tas=no
  86. tas_file=dummy.s
  87. ##
  88. ## Command line options
  89. ##
  90. #
  91. # Add non-standard directories to the include path
  92. #
  93. PGAC_ARG_REQ(with, includes, [DIRS], [look for additional header files in DIRS])
  94. #
  95. # Add non-standard directories to the library search path
  96. #
  97. PGAC_ARG_REQ(with, libraries, [DIRS], [look for additional libraries in DIRS],
  98. [LIBRARY_DIRS=$withval])
  99. PGAC_ARG_REQ(with, libs, [DIRS], [alternative spelling of --with-libraries],
  100. [LIBRARY_DIRS=$withval])
  101. #
  102. # 64-bit integer date/time storage is now the only option, but to avoid
  103. # unnecessary breakage of build scripts, continue to accept an explicit
  104. # "--enable-integer-datetimes" switch.
  105. #
  106. PGAC_ARG_BOOL(enable, integer-datetimes, yes, [obsolete option, no longer supported],
  107. [],
  108. [AC_MSG_ERROR([--disable-integer-datetimes is no longer supported])])
  109. #
  110. # NLS
  111. #
  112. AC_MSG_CHECKING([whether NLS is wanted])
  113. PGAC_ARG_OPTARG(enable, nls,
  114. [LANGUAGES], [enable Native Language Support],
  115. [],
  116. [WANTED_LANGUAGES=$enableval],
  117. [AC_DEFINE(ENABLE_NLS, 1,
  118. [Define to 1 if you want National Language Support. (--enable-nls)])])
  119. AC_MSG_RESULT([$enable_nls])
  120. AC_SUBST(enable_nls)
  121. AC_SUBST(WANTED_LANGUAGES)
  122. #
  123. # Default port number (--with-pgport), default 5432
  124. #
  125. AC_MSG_CHECKING([for default port number])
  126. PGAC_ARG_REQ(with, pgport, [PORTNUM], [set default port number [5432]],
  127. [default_port=$withval],
  128. [default_port=5432])
  129. AC_MSG_RESULT([$default_port])
  130. # Need both of these because some places want an integer and some a string
  131. AC_DEFINE_UNQUOTED(DEF_PGPORT, ${default_port},
  132. [Define to the default TCP port number on which the server listens and
  133. to which clients will try to connect. This can be overridden at run-time,
  134. but it's convenient if your clients have the right default compiled in.
  135. (--with-pgport=PORTNUM)])
  136. AC_DEFINE_UNQUOTED(DEF_PGPORT_STR, "${default_port}",
  137. [Define to the default TCP port number as a string constant.])
  138. AC_SUBST(default_port)
  139. # It's worth validating port; you can get very confusing errors otherwise
  140. if test x"$default_port" = x""; then
  141. AC_MSG_ERROR([invalid --with-pgport specification: empty string])
  142. elif test ! x`echo "$default_port" | sed -e 's/[[0-9]]*//'` = x""; then
  143. AC_MSG_ERROR([invalid --with-pgport specification: must be a number])
  144. elif test ! x`echo "$default_port" | sed -e 's/^0.//'` = x"$default_port"; then
  145. AC_MSG_ERROR([invalid --with-pgport specification: must not have leading 0])
  146. elif test "$default_port" -lt "1" -o "$default_port" -gt "65535"; then
  147. AC_MSG_ERROR([invalid --with-pgport specification: must be between 1 and 65535])
  148. fi
  149. #
  150. # '-rpath'-like feature can be disabled
  151. #
  152. PGAC_ARG_BOOL(enable, rpath, yes,
  153. [do not embed shared library search path in executables])
  154. AC_SUBST(enable_rpath)
  155. #
  156. # Spinlocks
  157. #
  158. PGAC_ARG_BOOL(enable, spinlocks, yes,
  159. [do not use spinlocks])
  160. #
  161. # Atomic operations
  162. #
  163. PGAC_ARG_BOOL(enable, atomics, yes,
  164. [do not use atomic operations])
  165. #
  166. # --enable-debug adds -g to compiler flags
  167. #
  168. PGAC_ARG_BOOL(enable, debug, no,
  169. [build with debugging symbols (-g)])
  170. AC_SUBST(enable_debug)
  171. #
  172. # --enable-profiling enables gcc profiling
  173. #
  174. PGAC_ARG_BOOL(enable, profiling, no,
  175. [build with profiling enabled ])
  176. #
  177. # --enable-coverage enables generation of code coverage metrics with gcov
  178. #
  179. PGAC_ARG_BOOL(enable, coverage, no,
  180. [build with coverage testing instrumentation],
  181. [PGAC_PATH_PROGS(GCOV, gcov)
  182. if test -z "$GCOV"; then
  183. AC_MSG_ERROR([gcov not found])
  184. fi
  185. PGAC_PATH_PROGS(LCOV, lcov)
  186. if test -z "$LCOV"; then
  187. AC_MSG_ERROR([lcov not found])
  188. fi
  189. PGAC_PATH_PROGS(GENHTML, genhtml)
  190. if test -z "$GENHTML"; then
  191. AC_MSG_ERROR([genhtml not found])
  192. fi])
  193. AC_SUBST(enable_coverage)
  194. #
  195. # DTrace
  196. #
  197. PGAC_ARG_BOOL(enable, dtrace, no,
  198. [build with DTrace support],
  199. [PGAC_PATH_PROGS(DTRACE, dtrace)
  200. if test -z "$DTRACE"; then
  201. AC_MSG_ERROR([dtrace not found])
  202. fi
  203. AC_SUBST(DTRACEFLAGS)])
  204. AC_SUBST(enable_dtrace)
  205. #
  206. # TAP tests
  207. #
  208. PGAC_ARG_BOOL(enable, tap-tests, no,
  209. [enable TAP tests (requires Perl and IPC::Run)])
  210. AC_SUBST(enable_tap_tests)
  211. #
  212. # Block size
  213. #
  214. AC_MSG_CHECKING([for block size])
  215. PGAC_ARG_REQ(with, blocksize, [BLOCKSIZE], [set table block size in kB [8]],
  216. [blocksize=$withval],
  217. [blocksize=8])
  218. case ${blocksize} in
  219. 1) BLCKSZ=1024;;
  220. 2) BLCKSZ=2048;;
  221. 4) BLCKSZ=4096;;
  222. 8) BLCKSZ=8192;;
  223. 16) BLCKSZ=16384;;
  224. 32) BLCKSZ=32768;;
  225. *) AC_MSG_ERROR([Invalid block size. Allowed values are 1,2,4,8,16,32.])
  226. esac
  227. AC_MSG_RESULT([${blocksize}kB])
  228. AC_DEFINE_UNQUOTED([BLCKSZ], ${BLCKSZ}, [
  229. Size of a disk block --- this also limits the size of a tuple. You
  230. can set it bigger if you need bigger tuples (although TOAST should
  231. reduce the need to have large tuples, since fields can be spread
  232. across multiple tuples).
  233. BLCKSZ must be a power of 2. The maximum possible value of BLCKSZ
  234. is currently 2^15 (32768). This is determined by the 15-bit widths
  235. of the lp_off and lp_len fields in ItemIdData (see
  236. include/storage/itemid.h).
  237. Changing BLCKSZ requires an initdb.
  238. ])
  239. #
  240. # Relation segment size
  241. #
  242. AC_MSG_CHECKING([for segment size])
  243. PGAC_ARG_REQ(with, segsize, [SEGSIZE], [set table segment size in GB [1]],
  244. [segsize=$withval],
  245. [segsize=1])
  246. # this expression is set up to avoid unnecessary integer overflow
  247. # blocksize is already guaranteed to be a factor of 1024
  248. RELSEG_SIZE=`expr '(' 1024 / ${blocksize} ')' '*' ${segsize} '*' 1024`
  249. test $? -eq 0 || exit 1
  250. AC_MSG_RESULT([${segsize}GB])
  251. AC_DEFINE_UNQUOTED([RELSEG_SIZE], ${RELSEG_SIZE}, [
  252. RELSEG_SIZE is the maximum number of blocks allowed in one disk file.
  253. Thus, the maximum size of a single file is RELSEG_SIZE * BLCKSZ;
  254. relations bigger than that are divided into multiple files.
  255. RELSEG_SIZE * BLCKSZ must be less than your OS' limit on file size.
  256. This is often 2 GB or 4GB in a 32-bit operating system, unless you
  257. have large file support enabled. By default, we make the limit 1 GB
  258. to avoid any possible integer-overflow problems within the OS.
  259. A limit smaller than necessary only means we divide a large
  260. relation into more chunks than necessary, so it seems best to err
  261. in the direction of a small limit.
  262. A power-of-2 value is recommended to save a few cycles in md.c,
  263. but is not absolutely required.
  264. Changing RELSEG_SIZE requires an initdb.
  265. ])
  266. #
  267. # WAL block size
  268. #
  269. AC_MSG_CHECKING([for WAL block size])
  270. PGAC_ARG_REQ(with, wal-blocksize, [BLOCKSIZE], [set WAL block size in kB [8]],
  271. [wal_blocksize=$withval],
  272. [wal_blocksize=8])
  273. case ${wal_blocksize} in
  274. 1) XLOG_BLCKSZ=1024;;
  275. 2) XLOG_BLCKSZ=2048;;
  276. 4) XLOG_BLCKSZ=4096;;
  277. 8) XLOG_BLCKSZ=8192;;
  278. 16) XLOG_BLCKSZ=16384;;
  279. 32) XLOG_BLCKSZ=32768;;
  280. 64) XLOG_BLCKSZ=65536;;
  281. *) AC_MSG_ERROR([Invalid WAL block size. Allowed values are 1,2,4,8,16,32,64.])
  282. esac
  283. AC_MSG_RESULT([${wal_blocksize}kB])
  284. AC_DEFINE_UNQUOTED([XLOG_BLCKSZ], ${XLOG_BLCKSZ}, [
  285. Size of a WAL file block. This need have no particular relation to BLCKSZ.
  286. XLOG_BLCKSZ must be a power of 2, and if your system supports O_DIRECT I/O,
  287. XLOG_BLCKSZ must be a multiple of the alignment requirement for direct-I/O
  288. buffers, else direct I/O may fail.
  289. Changing XLOG_BLCKSZ requires an initdb.
  290. ])
  291. #
  292. # C compiler
  293. #
  294. # For historical reasons you can also use --with-CC to specify the C compiler
  295. # to use, although the standard way to do this is to set the CC environment
  296. # variable.
  297. PGAC_ARG_REQ(with, CC, [CMD], [set compiler (deprecated)], [CC=$with_CC])
  298. case $template in
  299. aix) pgac_cc_list="gcc xlc"; pgac_cxx_list="g++ xlC";;
  300. *) pgac_cc_list="gcc cc"; pgac_cxx_list="g++ c++";;
  301. esac
  302. AC_PROG_CC([$pgac_cc_list])
  303. AC_PROG_CC_C99()
  304. # Error out if the compiler does not support C99, as the codebase
  305. # relies on that.
  306. if test "$ac_cv_prog_cc_c99" = no; then
  307. AC_MSG_ERROR([C compiler "$CC" does not support C99])
  308. fi
  309. AC_PROG_CXX([$pgac_cxx_list])
  310. # Check if it's Intel's compiler, which (usually) pretends to be gcc,
  311. # but has idiosyncrasies of its own. We assume icc will define
  312. # __INTEL_COMPILER regardless of CFLAGS.
  313. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifndef __INTEL_COMPILER
  314. choke me
  315. @%:@endif])], [ICC=yes], [ICC=no])
  316. # Check if it's Sun Studio compiler. We assume that
  317. # __SUNPRO_C will be defined for Sun Studio compilers
  318. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifndef __SUNPRO_C
  319. choke me
  320. @%:@endif])], [SUN_STUDIO_CC=yes], [SUN_STUDIO_CC=no])
  321. AC_SUBST(SUN_STUDIO_CC)
  322. #
  323. # LLVM
  324. #
  325. # Checked early because subsequent tests depend on it.
  326. PGAC_ARG_BOOL(with, llvm, no, [build with LLVM based JIT support],
  327. [AC_DEFINE([USE_LLVM], 1, [Define to 1 to build with LLVM based JIT support. (--with-llvm)])])
  328. AC_SUBST(with_llvm)
  329. dnl must use AS_IF here, else AC_REQUIRES inside PGAC_LLVM_SUPPORT malfunctions
  330. AS_IF([test "$with_llvm" = yes], [
  331. PGAC_LLVM_SUPPORT()
  332. ]) # fi
  333. unset CFLAGS
  334. unset CXXFLAGS
  335. #
  336. # Read the template
  337. #
  338. . "$srcdir/src/template/$template" || exit
  339. # C[XX]FLAGS are selected so:
  340. # If the user specifies something in the environment, that is used.
  341. # else: If the template file set something, that is used.
  342. # else: If coverage was enabled, don't set anything.
  343. # else: If the compiler is GCC, then we use -O2.
  344. # else: If the compiler is something else, then we use -O, unless debugging.
  345. if test "$ac_env_CFLAGS_set" = set; then
  346. CFLAGS=$ac_env_CFLAGS_value
  347. elif test "${CFLAGS+set}" = set; then
  348. : # (keep what template set)
  349. elif test "$enable_coverage" = yes; then
  350. : # no optimization by default
  351. elif test "$GCC" = yes; then
  352. CFLAGS="-O2"
  353. else
  354. # if the user selected debug mode, don't use -O
  355. if test "$enable_debug" != yes; then
  356. CFLAGS="-O"
  357. fi
  358. fi
  359. if test "$ac_env_CXXFLAGS_set" = set; then
  360. CXXFLAGS=$ac_env_CXXFLAGS_value
  361. elif test "${CXXFLAGS+set}" = set; then
  362. : # (keep what template set)
  363. elif test "$enable_coverage" = yes; then
  364. : # no optimization by default
  365. elif test "$GCC" = yes; then
  366. CXXFLAGS="-O2"
  367. else
  368. # if the user selected debug mode, don't use -O
  369. if test "$enable_debug" != yes; then
  370. CXXFLAGS="-O"
  371. fi
  372. fi
  373. # When generating bitcode (for inlining) we always want to use -O2
  374. # even when --enable-debug is specified. The bitcode it's not going to
  375. # be used for line-by-line debugging, and JIT inlining doesn't work
  376. # without at least -O1 (otherwise clang will emit 'noinline'
  377. # attributes everywhere), which is bad for testing. Still allow the
  378. # environment to override if done explicitly.
  379. if test "$ac_env_BITCODE_CFLAGS_set" = set; then
  380. BITCODE_CFLAGS=$ac_env_BITCODE_CFLAGS_value
  381. else
  382. BITCODE_CFLAGS="-O2 $BITCODE_CFLAGS"
  383. fi
  384. if test "$ac_env_BITCODE_CXXFLAGS_set" = set; then
  385. BITCODE_CXXFLAGS=$ac_env_BITCODE_CXXFLAGS_value
  386. else
  387. BITCODE_CXXFLAGS="-O2 $BITCODE_CXXFLAGS"
  388. fi
  389. # C[XX]FLAGS we determined above will be added back at the end
  390. user_CFLAGS=$CFLAGS
  391. CFLAGS=""
  392. user_CXXFLAGS=$CXXFLAGS
  393. CXXFLAGS=""
  394. user_BITCODE_CFLAGS=$BITCODE_CFLAGS
  395. BITCODE_CFLAGS=""
  396. user_BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS
  397. BITCODE_CXXFLAGS=""
  398. # set CFLAGS_VECTOR from the environment, if available
  399. if test "$ac_env_CFLAGS_VECTOR_set" = set; then
  400. CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
  401. fi
  402. # Some versions of GCC support some additional useful warning flags.
  403. # Check whether they are supported, and add them to CFLAGS if so.
  404. # ICC pretends to be GCC but it's lying; it doesn't support these flags,
  405. # but has its own. Also check other compiler-specific flags here.
  406. if test "$GCC" = yes -a "$ICC" = no; then
  407. CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
  408. CXXFLAGS="-Wall -Wpointer-arith"
  409. # These work in some but not all gcc versions
  410. save_CFLAGS=$CFLAGS
  411. PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
  412. # -Wdeclaration-after-statement isn't applicable for C++. Specific C files
  413. # disable it, so AC_SUBST the negative form.
  414. PERMIT_DECLARATION_AFTER_STATEMENT=
  415. if test x"$save_CFLAGS" != x"$CFLAGS"; then
  416. PERMIT_DECLARATION_AFTER_STATEMENT=-Wno-declaration-after-statement
  417. fi
  418. AC_SUBST(PERMIT_DECLARATION_AFTER_STATEMENT)
  419. # Really don't want VLAs to be used in our dialect of C
  420. PGAC_PROG_CC_CFLAGS_OPT([-Werror=vla])
  421. # -Wvla is not applicable for C++
  422. PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
  423. PGAC_PROG_CXX_CFLAGS_OPT([-Wendif-labels])
  424. PGAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute])
  425. PGAC_PROG_CXX_CFLAGS_OPT([-Wmissing-format-attribute])
  426. # This was included in -Wall/-Wformat in older GCC versions
  427. PGAC_PROG_CC_CFLAGS_OPT([-Wformat-security])
  428. PGAC_PROG_CXX_CFLAGS_OPT([-Wformat-security])
  429. # Disable strict-aliasing rules; needed for gcc 3.3+
  430. PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
  431. PGAC_PROG_CXX_CFLAGS_OPT([-fno-strict-aliasing])
  432. # Disable optimizations that assume no overflow; needed for gcc 4.3+
  433. PGAC_PROG_CC_CFLAGS_OPT([-fwrapv])
  434. PGAC_PROG_CXX_CFLAGS_OPT([-fwrapv])
  435. # Disable FP optimizations that cause various errors on gcc 4.5+ or maybe 4.6+
  436. PGAC_PROG_CC_CFLAGS_OPT([-fexcess-precision=standard])
  437. PGAC_PROG_CXX_CFLAGS_OPT([-fexcess-precision=standard])
  438. # Optimization flags for specific files that benefit from vectorization
  439. PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-funroll-loops])
  440. PGAC_PROG_CC_VAR_OPT(CFLAGS_VECTOR, [-ftree-vectorize])
  441. # We want to suppress clang's unhelpful unused-command-line-argument warnings
  442. # but gcc won't complain about unrecognized -Wno-foo switches, so we have to
  443. # test for the positive form and if that works, add the negative form
  444. NOT_THE_CFLAGS=""
  445. PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wunused-command-line-argument])
  446. if test -n "$NOT_THE_CFLAGS"; then
  447. CFLAGS="$CFLAGS -Wno-unused-command-line-argument"
  448. fi
  449. # Similarly disable useless truncation warnings from gcc 8+
  450. NOT_THE_CFLAGS=""
  451. PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wformat-truncation])
  452. if test -n "$NOT_THE_CFLAGS"; then
  453. CFLAGS="$CFLAGS -Wno-format-truncation"
  454. fi
  455. NOT_THE_CFLAGS=""
  456. PGAC_PROG_CC_VAR_OPT(NOT_THE_CFLAGS, [-Wstringop-truncation])
  457. if test -n "$NOT_THE_CFLAGS"; then
  458. CFLAGS="$CFLAGS -Wno-stringop-truncation"
  459. fi
  460. elif test "$ICC" = yes; then
  461. # Intel's compiler has a bug/misoptimization in checking for
  462. # division by NAN (NaN == 0), -mp1 fixes it, so add it to the CFLAGS.
  463. PGAC_PROG_CC_CFLAGS_OPT([-mp1])
  464. PGAC_PROG_CXX_CFLAGS_OPT([-mp1])
  465. # Make sure strict aliasing is off (though this is said to be the default)
  466. PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
  467. PGAC_PROG_CXX_CFLAGS_OPT([-fno-strict-aliasing])
  468. elif test "$PORTNAME" = "aix"; then
  469. # AIX's xlc has to have strict aliasing turned off too
  470. PGAC_PROG_CC_CFLAGS_OPT([-qnoansialias])
  471. PGAC_PROG_CXX_CFLAGS_OPT([-qnoansialias])
  472. PGAC_PROG_CC_CFLAGS_OPT([-qlonglong])
  473. PGAC_PROG_CXX_CFLAGS_OPT([-qlonglong])
  474. elif test "$PORTNAME" = "hpux"; then
  475. # On some versions of HP-UX, libm functions do not set errno by default.
  476. # Fix that by using +Olibmerrno if the compiler recognizes it.
  477. PGAC_PROG_CC_CFLAGS_OPT([+Olibmerrno])
  478. PGAC_PROG_CXX_CFLAGS_OPT([+Olibmerrno])
  479. fi
  480. AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
  481. # Determine flags used to emit bitcode for JIT inlining. Need to test
  482. # for behaviour changing compiler flags, to keep compatibility with
  483. # compiler used for normal postgres code.
  484. if test "$with_llvm" = yes ; then
  485. CLANGXX="$CLANG -xc++"
  486. PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fno-strict-aliasing])
  487. PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fno-strict-aliasing])
  488. PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fwrapv])
  489. PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fwrapv])
  490. PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fexcess-precision=standard])
  491. PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fexcess-precision=standard])
  492. fi
  493. # supply -g if --enable-debug
  494. if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
  495. CFLAGS="$CFLAGS -g"
  496. fi
  497. if test "$enable_debug" = yes && test "$ac_cv_prog_cxx_g" = yes; then
  498. CXXFLAGS="$CXXFLAGS -g"
  499. fi
  500. # enable code coverage if --enable-coverage
  501. if test "$enable_coverage" = yes; then
  502. if test "$GCC" = yes; then
  503. CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
  504. CXXFLAGS="$CXXFLAGS -fprofile-arcs -ftest-coverage"
  505. else
  506. AC_MSG_ERROR([--enable-coverage is supported only when using GCC])
  507. fi
  508. fi
  509. # enable profiling if --enable-profiling
  510. if test "$enable_profiling" = yes && test "$ac_cv_prog_cc_g" = yes; then
  511. if test "$GCC" = yes; then
  512. AC_DEFINE([PROFILE_PID_DIR], 1,
  513. [Define to 1 to allow profiling output to be saved separately for each process.])
  514. CFLAGS="$CFLAGS -pg $PLATFORM_PROFILE_FLAGS"
  515. CXXFLAGS="$CXXFLAGS -pg $PLATFORM_PROFILE_FLAGS"
  516. else
  517. AC_MSG_ERROR([--enable-profiling is supported only when using GCC])
  518. fi
  519. fi
  520. # We already have this in Makefile.win32, but configure needs it too
  521. if test "$PORTNAME" = "win32"; then
  522. CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
  523. fi
  524. # Now that we're done automatically adding stuff to C[XX]FLAGS, put back the
  525. # user-specified flags (if any) at the end. This lets users override
  526. # the automatic additions.
  527. CFLAGS="$CFLAGS $user_CFLAGS"
  528. CXXFLAGS="$CXXFLAGS $user_CXXFLAGS"
  529. BITCODE_CFLAGS="$BITCODE_CFLAGS $user_BITCODE_CFLAGS"
  530. BITCODE_CXXFLAGS="$BITCODE_CXXFLAGS $user_BITCODE_CXXFLAGS"
  531. AC_SUBST(BITCODE_CFLAGS, $BITCODE_CFLAGS)
  532. AC_SUBST(BITCODE_CXXFLAGS, $BITCODE_CXXFLAGS)
  533. # Check if the compiler still works with the final flag settings
  534. # (note, we're not checking that for CXX, which is optional)
  535. AC_MSG_CHECKING([whether the C compiler still works])
  536. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])],
  537. [AC_MSG_RESULT(yes)],
  538. [AC_MSG_RESULT(no)
  539. AC_MSG_ERROR([cannot proceed])])
  540. # Defend against gcc -ffast-math
  541. if test "$GCC" = yes; then
  542. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@ifdef __FAST_MATH__
  543. choke me
  544. @%:@endif])], [], [AC_MSG_ERROR([do not put -ffast-math in CFLAGS])])
  545. fi
  546. # Defend against clang being used on x86-32 without SSE2 enabled. As current
  547. # versions of clang do not understand -fexcess-precision=standard, the use of
  548. # x87 floating point operations leads to problems like isinf possibly returning
  549. # false for a value that is infinite when converted from the 80bit register to
  550. # the 8byte memory representation.
  551. #
  552. # Only perform the test if the compiler doesn't understand
  553. # -fexcess-precision=standard, that way a potentially fixed compiler will work
  554. # automatically.
  555. if test "$pgac_cv_prog_CC_cflags__fexcess_precision_standard" = no; then
  556. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  557. @%:@if defined(__clang__) && defined(__i386__) && !defined(__SSE2_MATH__)
  558. choke me
  559. @%:@endif
  560. ])], [],
  561. [AC_MSG_ERROR([Compiling PostgreSQL with clang, on 32bit x86, requires SSE2 support. Use -msse2 or use gcc.])])
  562. fi
  563. AC_PROG_CPP
  564. AC_SUBST(GCC)
  565. #
  566. # Set up TAS assembly code if needed; the template file has now had its
  567. # chance to request this.
  568. #
  569. AC_CONFIG_LINKS([src/backend/port/tas.s:src/backend/port/tas/${tas_file}])
  570. if test "$need_tas" = yes ; then
  571. TAS=tas.o
  572. else
  573. TAS=""
  574. fi
  575. AC_SUBST(TAS)
  576. #
  577. # Automatic dependency tracking
  578. #
  579. PGAC_ARG_BOOL(enable, depend, no, [turn on automatic dependency tracking],
  580. [autodepend=yes])
  581. AC_SUBST(autodepend)
  582. #
  583. # Enable assert checks
  584. #
  585. PGAC_ARG_BOOL(enable, cassert, no, [enable assertion checks (for debugging)],
  586. [AC_DEFINE([USE_ASSERT_CHECKING], 1,
  587. [Define to 1 to build with assertion checks. (--enable-cassert)])])
  588. #
  589. # Include directories
  590. #
  591. ac_save_IFS=$IFS
  592. IFS="${IFS}${PATH_SEPARATOR}"
  593. # SRCH_INC comes from the template file
  594. for dir in $with_includes $SRCH_INC; do
  595. if test -d "$dir"; then
  596. INCLUDES="$INCLUDES -I$dir"
  597. else
  598. AC_MSG_WARN([*** Include directory $dir does not exist.])
  599. fi
  600. done
  601. IFS=$ac_save_IFS
  602. AC_SUBST(INCLUDES)
  603. #
  604. # Library directories
  605. #
  606. ac_save_IFS=$IFS
  607. IFS="${IFS}${PATH_SEPARATOR}"
  608. # LIBRARY_DIRS comes from command line, SRCH_LIB from template file.
  609. for dir in $LIBRARY_DIRS $SRCH_LIB; do
  610. if test -d "$dir"; then
  611. LIBDIRS="$LIBDIRS -L$dir"
  612. else
  613. AC_MSG_WARN([*** Library directory $dir does not exist.])
  614. fi
  615. done
  616. IFS=$ac_save_IFS
  617. #
  618. # Enable thread-safe client libraries
  619. #
  620. AC_MSG_CHECKING([allow thread-safe client libraries])
  621. PGAC_ARG_BOOL(enable, thread-safety, yes, [disable thread-safety in client libraries])
  622. if test "$enable_thread_safety" = yes; then
  623. AC_DEFINE([ENABLE_THREAD_SAFETY], 1,
  624. [Define to 1 to build client libraries as thread-safe code. (--enable-thread-safety)])
  625. fi
  626. AC_MSG_RESULT([$enable_thread_safety])
  627. AC_SUBST(enable_thread_safety)
  628. #
  629. # ICU
  630. #
  631. AC_MSG_CHECKING([whether to build with ICU support])
  632. PGAC_ARG_BOOL(with, icu, no, [build with ICU support],
  633. [AC_DEFINE([USE_ICU], 1, [Define to build with ICU support. (--with-icu)])])
  634. AC_MSG_RESULT([$with_icu])
  635. AC_SUBST(with_icu)
  636. if test "$with_icu" = yes; then
  637. PKG_CHECK_MODULES(ICU, icu-uc icu-i18n)
  638. fi
  639. #
  640. # Optionally build Tcl modules (PL/Tcl)
  641. #
  642. AC_MSG_CHECKING([whether to build with Tcl])
  643. PGAC_ARG_BOOL(with, tcl, no, [build Tcl modules (PL/Tcl)])
  644. AC_MSG_RESULT([$with_tcl])
  645. AC_SUBST([with_tcl])
  646. # We see if the path to the Tcl/Tk configuration scripts is specified.
  647. # This will override the use of tclsh to find the paths to search.
  648. PGAC_ARG_REQ(with, tclconfig, [DIR], [tclConfig.sh is in DIR])
  649. #
  650. # Optionally build Perl modules (PL/Perl)
  651. #
  652. AC_MSG_CHECKING([whether to build Perl modules])
  653. PGAC_ARG_BOOL(with, perl, no, [build Perl modules (PL/Perl)])
  654. AC_MSG_RESULT([$with_perl])
  655. AC_SUBST(with_perl)
  656. #
  657. # Optionally build Python modules (PL/Python)
  658. #
  659. AC_MSG_CHECKING([whether to build Python modules])
  660. PGAC_ARG_BOOL(with, python, no, [build Python modules (PL/Python)])
  661. AC_MSG_RESULT([$with_python])
  662. AC_SUBST(with_python)
  663. #
  664. # GSSAPI
  665. #
  666. AC_MSG_CHECKING([whether to build with GSSAPI support])
  667. PGAC_ARG_BOOL(with, gssapi, no, [build with GSSAPI support],
  668. [
  669. AC_DEFINE(ENABLE_GSS, 1, [Define to build with GSSAPI support. (--with-gssapi)])
  670. krb_srvtab="FILE:\$(sysconfdir)/krb5.keytab"
  671. ])
  672. AC_MSG_RESULT([$with_gssapi])
  673. AC_SUBST(with_gssapi)
  674. AC_SUBST(krb_srvtab)
  675. #
  676. # Kerberos configuration parameters
  677. #
  678. PGAC_ARG_REQ(with, krb-srvnam,
  679. [NAME], [default service principal name in Kerberos (GSSAPI) [postgres]],
  680. [],
  681. [with_krb_srvnam="postgres"])
  682. AC_SUBST(with_krb_srvnam)
  683. AC_DEFINE_UNQUOTED([PG_KRB_SRVNAM], ["$with_krb_srvnam"],
  684. [Define to the name of the default PostgreSQL service principal in Kerberos (GSSAPI). (--with-krb-srvnam=NAME)])
  685. #
  686. # PAM
  687. #
  688. AC_MSG_CHECKING([whether to build with PAM support])
  689. PGAC_ARG_BOOL(with, pam, no,
  690. [build with PAM support],
  691. [AC_DEFINE([USE_PAM], 1, [Define to 1 to build with PAM support. (--with-pam)])])
  692. AC_MSG_RESULT([$with_pam])
  693. #
  694. # BSD AUTH
  695. #
  696. AC_MSG_CHECKING([whether to build with BSD Authentication support])
  697. PGAC_ARG_BOOL(with, bsd-auth, no,
  698. [build with BSD Authentication support],
  699. [AC_DEFINE([USE_BSD_AUTH], 1, [Define to 1 to build with BSD Authentication support. (--with-bsd-auth)])])
  700. AC_MSG_RESULT([$with_bsd_auth])
  701. #
  702. # LDAP
  703. #
  704. AC_MSG_CHECKING([whether to build with LDAP support])
  705. PGAC_ARG_BOOL(with, ldap, no,
  706. [build with LDAP support],
  707. [AC_DEFINE([USE_LDAP], 1, [Define to 1 to build with LDAP support. (--with-ldap)])])
  708. AC_MSG_RESULT([$with_ldap])
  709. AC_SUBST(with_ldap)
  710. #
  711. # Bonjour
  712. #
  713. AC_MSG_CHECKING([whether to build with Bonjour support])
  714. PGAC_ARG_BOOL(with, bonjour, no,
  715. [build with Bonjour support],
  716. [AC_DEFINE([USE_BONJOUR], 1, [Define to 1 to build with Bonjour support. (--with-bonjour)])])
  717. AC_MSG_RESULT([$with_bonjour])
  718. #
  719. # OpenSSL
  720. #
  721. AC_MSG_CHECKING([whether to build with OpenSSL support])
  722. PGAC_ARG_BOOL(with, openssl, no, [build with OpenSSL support],
  723. [AC_DEFINE([USE_OPENSSL], 1, [Define to build with OpenSSL support. (--with-openssl)])])
  724. AC_MSG_RESULT([$with_openssl])
  725. AC_SUBST(with_openssl)
  726. #
  727. # SELinux
  728. #
  729. AC_MSG_CHECKING([whether to build with SELinux support])
  730. PGAC_ARG_BOOL(with, selinux, no, [build with SELinux support])
  731. AC_SUBST(with_selinux)
  732. AC_MSG_RESULT([$with_selinux])
  733. #
  734. # Systemd
  735. #
  736. AC_MSG_CHECKING([whether to build with systemd support])
  737. PGAC_ARG_BOOL(with, systemd, no, [build with systemd support],
  738. [AC_DEFINE([USE_SYSTEMD], 1, [Define to build with systemd support. (--with-systemd)])])
  739. AC_SUBST(with_systemd)
  740. AC_MSG_RESULT([$with_systemd])
  741. #
  742. # Readline
  743. #
  744. PGAC_ARG_BOOL(with, readline, yes,
  745. [do not use GNU Readline nor BSD Libedit for editing])
  746. # readline on MinGW has problems with backslashes in psql and other bugs.
  747. # This is particularly a problem with non-US code pages.
  748. # Therefore disable its use until we understand the cause. 2004-07-20
  749. if test "$PORTNAME" = "win32"; then
  750. if test "$with_readline" = yes; then
  751. AC_MSG_WARN([*** Readline does not work on MinGW --- disabling])
  752. with_readline=no
  753. fi
  754. fi
  755. #
  756. # Prefer libedit
  757. #
  758. PGAC_ARG_BOOL(with, libedit-preferred, no,
  759. [prefer BSD Libedit over GNU Readline])
  760. #
  761. # UUID library
  762. #
  763. # There are at least three UUID libraries in common use: the FreeBSD/NetBSD
  764. # library, the e2fsprogs libuuid (now part of util-linux-ng), and the OSSP
  765. # UUID library. More than one of these might be present on a given platform,
  766. # so we make the user say which one she wants.
  767. #
  768. PGAC_ARG_REQ(with, uuid, [LIB], [build contrib/uuid-ossp using LIB (bsd,e2fs,ossp)])
  769. if test x"$with_uuid" = x"" ; then
  770. with_uuid=no
  771. fi
  772. PGAC_ARG_BOOL(with, ossp-uuid, no, [obsolete spelling of --with-uuid=ossp])
  773. if test "$with_ossp_uuid" = yes ; then
  774. with_uuid=ossp
  775. fi
  776. if test "$with_uuid" = bsd ; then
  777. AC_DEFINE([HAVE_UUID_BSD], 1, [Define to 1 if you have BSD UUID support.])
  778. UUID_EXTRA_OBJS="md5.o sha1.o"
  779. elif test "$with_uuid" = e2fs ; then
  780. AC_DEFINE([HAVE_UUID_E2FS], 1, [Define to 1 if you have E2FS UUID support.])
  781. UUID_EXTRA_OBJS="md5.o sha1.o"
  782. elif test "$with_uuid" = ossp ; then
  783. AC_DEFINE([HAVE_UUID_OSSP], 1, [Define to 1 if you have OSSP UUID support.])
  784. UUID_EXTRA_OBJS=""
  785. elif test "$with_uuid" = no ; then
  786. UUID_EXTRA_OBJS=""
  787. else
  788. AC_MSG_ERROR([--with-uuid must specify one of bsd, e2fs, or ossp])
  789. fi
  790. AC_SUBST(with_uuid)
  791. AC_SUBST(UUID_EXTRA_OBJS)
  792. #
  793. # XML
  794. #
  795. PGAC_ARG_BOOL(with, libxml, no, [build with XML support],
  796. [AC_DEFINE([USE_LIBXML], 1, [Define to 1 to build with XML support. (--with-libxml)])])
  797. if test "$with_libxml" = yes ; then
  798. PGAC_PATH_PROGS(XML2_CONFIG, xml2-config)
  799. AC_ARG_VAR(XML2_CONFIG, [path to xml2-config utility])dnl
  800. if test -n "$XML2_CONFIG"; then
  801. for pgac_option in `$XML2_CONFIG --cflags`; do
  802. case $pgac_option in
  803. -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
  804. esac
  805. done
  806. for pgac_option in `$XML2_CONFIG --libs`; do
  807. case $pgac_option in
  808. -L*) LDFLAGS="$LDFLAGS $pgac_option";;
  809. esac
  810. done
  811. fi
  812. fi
  813. AC_SUBST(with_libxml)
  814. #
  815. # XSLT
  816. #
  817. PGAC_ARG_BOOL(with, libxslt, no, [use XSLT support when building contrib/xml2],
  818. [AC_DEFINE([USE_LIBXSLT], 1, [Define to 1 to use XSLT support when building contrib/xml2. (--with-libxslt)])])
  819. AC_SUBST(with_libxslt)
  820. #
  821. # tzdata
  822. #
  823. PGAC_ARG_REQ(with, system-tzdata,
  824. [DIR], [use system time zone data in DIR])
  825. AC_SUBST(with_system_tzdata)
  826. #
  827. # Zlib
  828. #
  829. PGAC_ARG_BOOL(with, zlib, yes,
  830. [do not use Zlib])
  831. AC_SUBST(with_zlib)
  832. #
  833. # Assignments
  834. #
  835. CPPFLAGS="$CPPFLAGS $INCLUDES"
  836. LDFLAGS="$LDFLAGS $LIBDIRS"
  837. AC_ARG_VAR(LDFLAGS_EX, [extra linker flags for linking executables only])
  838. AC_ARG_VAR(LDFLAGS_SL, [extra linker flags for linking shared libraries only])
  839. PGAC_PROG_LD
  840. AC_SUBST(LD)
  841. AC_SUBST(with_gnu_ld)
  842. AC_PROG_RANLIB
  843. PGAC_CHECK_STRIP
  844. AC_CHECK_TOOL(AR, ar, ar)
  845. if test "$PORTNAME" = "win32"; then
  846. AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool)
  847. AC_CHECK_TOOL(DLLWRAP, dllwrap, dllwrap)
  848. AC_CHECK_TOOL(WINDRES, windres, windres)
  849. fi
  850. AC_PROG_INSTALL
  851. # When Autoconf chooses install-sh as install program it tries to generate
  852. # a relative path to it in each makefile where it substitutes it. This clashes
  853. # with our Makefile.global concept. This workaround helps.
  854. case $INSTALL in
  855. *install-sh*) install_bin='';;
  856. *) install_bin=$INSTALL;;
  857. esac
  858. AC_SUBST(install_bin)
  859. PGAC_PATH_PROGS(TAR, tar)
  860. AC_PROG_LN_S
  861. AC_PROG_MKDIR_P
  862. # When Autoconf chooses install-sh as mkdir -p program it tries to generate
  863. # a relative path to it in each makefile where it substitutes it. This clashes
  864. # with our Makefile.global concept. This workaround helps.
  865. case $MKDIR_P in
  866. *install-sh*) MKDIR_P='\${SHELL} \${top_srcdir}/config/install-sh -c -d';;
  867. esac
  868. PGAC_PATH_BISON
  869. PGAC_PATH_FLEX
  870. PGAC_PATH_PERL
  871. if test "$with_perl" = yes; then
  872. if test -z "$PERL"; then
  873. AC_MSG_ERROR([Perl not found])
  874. fi
  875. PGAC_CHECK_PERL_CONFIGS([archlibexp,privlibexp,useshrplib])
  876. if test "$perl_useshrplib" != yes && test "$perl_useshrplib" != true; then
  877. AC_MSG_ERROR([cannot build PL/Perl because libperl is not a shared library
  878. You might have to rebuild your Perl installation. Refer to the
  879. documentation for details. Use --without-perl to disable building
  880. PL/Perl.])
  881. fi
  882. # On most platforms, archlibexp is also where the Perl include files live ...
  883. perl_includespec="-I$perl_archlibexp/CORE"
  884. # ... but on newer macOS versions, we must use -iwithsysroot to look
  885. # under $PG_SYSROOT
  886. if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
  887. if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
  888. perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
  889. fi
  890. fi
  891. AC_SUBST(perl_includespec)dnl
  892. PGAC_CHECK_PERL_EMBED_CCFLAGS
  893. PGAC_CHECK_PERL_EMBED_LDFLAGS
  894. fi
  895. if test "$with_python" = yes; then
  896. PGAC_PATH_PYTHON
  897. PGAC_CHECK_PYTHON_EMBED_SETUP
  898. fi
  899. if test "$cross_compiling" = yes && test -z "$with_system_tzdata"; then
  900. PGAC_PATH_PROGS(ZIC, zic)
  901. if test -z "$ZIC"; then
  902. AC_MSG_ERROR([
  903. When cross-compiling, either use the option --with-system-tzdata to use
  904. existing time-zone data, or set the environment variable ZIC to a zic
  905. program to use during the build.])
  906. fi
  907. fi
  908. #
  909. # Pthreads
  910. #
  911. # For each platform, we need to know about any special compile and link
  912. # libraries, and whether the normal C function names are thread-safe.
  913. # See the comment at the top of src/port/thread.c for more information.
  914. # WIN32 doesn't need the pthread tests; it always uses threads
  915. #
  916. # These tests are run before the library-tests, because linking with the
  917. # other libraries can pull in the pthread functions as a side-effect. We
  918. # want to use the -pthread or similar flags directly, and not rely on
  919. # the side-effects of linking with some other library.
  920. dnl note: We have to use AS_IF here rather than plain if. The AC_CHECK_HEADER
  921. dnl invocation below is the first one in the script, and autoconf generates
  922. dnl additional code for that, which must not be inside the if-block. AS_IF
  923. dnl knows how to do that.
  924. AS_IF([test "$enable_thread_safety" = yes -a "$PORTNAME" != "win32"],
  925. [ # then
  926. AX_PTHREAD # set thread flags
  927. # Some platforms use these, so just define them. They can't hurt if they
  928. # are not supported. For example, on Solaris -D_POSIX_PTHREAD_SEMANTICS
  929. # enables 5-arg getpwuid_r, among other things.
  930. PTHREAD_CFLAGS="$PTHREAD_CFLAGS -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS"
  931. # Check for *_r functions
  932. _CFLAGS="$CFLAGS"
  933. _LIBS="$LIBS"
  934. CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  935. LIBS="$LIBS $PTHREAD_LIBS"
  936. AC_CHECK_HEADER(pthread.h, [], [AC_MSG_ERROR([
  937. pthread.h not found; use --disable-thread-safety to disable thread safety])])
  938. AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r])
  939. # Do test here with the proper thread flags
  940. PGAC_FUNC_STRERROR_R_INT
  941. CFLAGS="$_CFLAGS"
  942. LIBS="$_LIBS"
  943. ], [ # else
  944. # do not use values from template file
  945. PTHREAD_CFLAGS=
  946. PTHREAD_LIBS=
  947. ]) # fi
  948. AC_SUBST(PTHREAD_CFLAGS)
  949. AC_SUBST(PTHREAD_LIBS)
  950. ##
  951. ## Libraries
  952. ##
  953. ## Most libraries are included only if they demonstrably provide a function
  954. ## we need, but libm is an exception: always include it, because there are
  955. ## too many compilers that play cute optimization games that will break
  956. ## probes for standard functions such as pow().
  957. ##
  958. AC_CHECK_LIB(m, main)
  959. AC_SEARCH_LIBS(setproctitle, util)
  960. AC_SEARCH_LIBS(dlopen, dl)
  961. AC_SEARCH_LIBS(socket, [socket ws2_32])
  962. AC_SEARCH_LIBS(shl_load, dld)
  963. AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
  964. AC_SEARCH_LIBS(shm_open, rt)
  965. AC_SEARCH_LIBS(shm_unlink, rt)
  966. AC_SEARCH_LIBS(clock_gettime, [rt posix4])
  967. # Solaris:
  968. AC_SEARCH_LIBS(fdatasync, [rt posix4])
  969. # Required for thread_test.c on Solaris
  970. AC_SEARCH_LIBS(sched_yield, rt)
  971. # Required for thread_test.c on Solaris 2.5:
  972. # Other ports use it too (HP-UX) so test unconditionally
  973. AC_SEARCH_LIBS(gethostbyname_r, nsl)
  974. # Cygwin:
  975. AC_SEARCH_LIBS(shmget, cygipc)
  976. if test "$with_readline" = yes; then
  977. PGAC_CHECK_READLINE
  978. if test x"$pgac_cv_check_readline" = x"no"; then
  979. AC_MSG_ERROR([readline library not found
  980. If you have readline already installed, see config.log for details on the
  981. failure. It is possible the compiler isn't looking in the proper directory.
  982. Use --without-readline to disable readline support.])
  983. fi
  984. fi
  985. if test "$with_zlib" = yes; then
  986. AC_CHECK_LIB(z, inflate, [],
  987. [AC_MSG_ERROR([zlib library not found
  988. If you have zlib already installed, see config.log for details on the
  989. failure. It is possible the compiler isn't looking in the proper directory.
  990. Use --without-zlib to disable zlib support.])])
  991. fi
  992. if test "$enable_spinlocks" = yes; then
  993. AC_DEFINE(HAVE_SPINLOCKS, 1, [Define to 1 if you have spinlocks.])
  994. else
  995. AC_MSG_WARN([
  996. *** Not using spinlocks will cause poor performance.])
  997. fi
  998. if test "$enable_atomics" = yes; then
  999. AC_DEFINE(HAVE_ATOMICS, 1, [Define to 1 if you want to use atomics if available.])
  1000. else
  1001. AC_MSG_WARN([
  1002. *** Not using atomic operations will cause poor performance.])
  1003. fi
  1004. if test "$with_gssapi" = yes ; then
  1005. if test "$PORTNAME" != "win32"; then
  1006. AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gss 'gssapi -lkrb5 -lcrypto'], [],
  1007. [AC_MSG_ERROR([could not find function 'gss_init_sec_context' required for GSSAPI])])
  1008. else
  1009. LIBS="$LIBS -lgssapi32"
  1010. fi
  1011. fi
  1012. if test "$with_openssl" = yes ; then
  1013. dnl Order matters!
  1014. if test "$PORTNAME" != "win32"; then
  1015. AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
  1016. AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
  1017. else
  1018. AC_SEARCH_LIBS(CRYPTO_new_ex_data, [eay32 crypto], [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
  1019. AC_SEARCH_LIBS(SSL_new, [ssleay32 ssl], [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
  1020. fi
  1021. AC_CHECK_FUNCS([SSL_clear_options SSL_get_current_compression X509_get_signature_nid])
  1022. # Functions introduced in OpenSSL 1.1.0. We used to check for
  1023. # OPENSSL_VERSION_NUMBER, but that didn't work with 1.1.0, because LibreSSL
  1024. # defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
  1025. # doesn't have these OpenSSL 1.1.0 functions. So check for individual
  1026. # functions.
  1027. AC_CHECK_FUNCS([OPENSSL_init_ssl BIO_get_data BIO_meth_new ASN1_STRING_get0_data])
  1028. # OpenSSL versions before 1.1.0 required setting callback functions, for
  1029. # thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
  1030. # function was removed.
  1031. AC_CHECK_FUNCS([CRYPTO_lock])
  1032. fi
  1033. if test "$with_pam" = yes ; then
  1034. AC_CHECK_LIB(pam, pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])])
  1035. fi
  1036. if test "$with_libxml" = yes ; then
  1037. AC_CHECK_LIB(xml2, xmlSaveToBuffer, [], [AC_MSG_ERROR([library 'xml2' (version >= 2.6.23) is required for XML support])])
  1038. fi
  1039. if test "$with_libxslt" = yes ; then
  1040. AC_CHECK_LIB(xslt, xsltCleanupGlobals, [], [AC_MSG_ERROR([library 'xslt' is required for XSLT support])])
  1041. fi
  1042. # Note: We can test for libldap_r only after we know PTHREAD_LIBS
  1043. if test "$with_ldap" = yes ; then
  1044. _LIBS="$LIBS"
  1045. if test "$PORTNAME" != "win32"; then
  1046. AC_CHECK_LIB(ldap, ldap_bind, [],
  1047. [AC_MSG_ERROR([library 'ldap' is required for LDAP])],
  1048. [$EXTRA_LDAP_LIBS])
  1049. LDAP_LIBS_BE="-lldap $EXTRA_LDAP_LIBS"
  1050. if test "$enable_thread_safety" = yes; then
  1051. # on some platforms ldap_r fails to link without PTHREAD_LIBS
  1052. AC_CHECK_LIB(ldap_r, ldap_simple_bind, [],
  1053. [AC_MSG_ERROR([library 'ldap_r' is required for LDAP])],
  1054. [$PTHREAD_CFLAGS $PTHREAD_LIBS $EXTRA_LDAP_LIBS])
  1055. LDAP_LIBS_FE="-lldap_r $EXTRA_LDAP_LIBS"
  1056. else
  1057. LDAP_LIBS_FE="-lldap $EXTRA_LDAP_LIBS"
  1058. fi
  1059. AC_CHECK_FUNCS([ldap_initialize])
  1060. else
  1061. AC_CHECK_LIB(wldap32, ldap_bind, [], [AC_MSG_ERROR([library 'wldap32' is required for LDAP])])
  1062. LDAP_LIBS_FE="-lwldap32"
  1063. LDAP_LIBS_BE="-lwldap32"
  1064. fi
  1065. LIBS="$_LIBS"
  1066. fi
  1067. AC_SUBST(LDAP_LIBS_FE)
  1068. AC_SUBST(LDAP_LIBS_BE)
  1069. # for contrib/sepgsql
  1070. if test "$with_selinux" = yes; then
  1071. AC_CHECK_LIB(selinux, security_compute_create_name, [],
  1072. [AC_MSG_ERROR([library 'libselinux', version 2.1.10 or newer, is required for SELinux support])])
  1073. fi
  1074. # for contrib/uuid-ossp
  1075. if test "$with_uuid" = bsd ; then
  1076. # On BSD, the UUID functions are in libc
  1077. AC_CHECK_FUNC(uuid_to_string,
  1078. [UUID_LIBS=""],
  1079. [AC_MSG_ERROR([BSD UUID functions are not present])])
  1080. elif test "$with_uuid" = e2fs ; then
  1081. # On macOS, the UUID functions are in libc
  1082. AC_CHECK_FUNC(uuid_generate,
  1083. [UUID_LIBS=""],
  1084. [AC_CHECK_LIB(uuid, uuid_generate,
  1085. [UUID_LIBS="-luuid"],
  1086. [AC_MSG_ERROR([library 'uuid' is required for E2FS UUID])])])
  1087. elif test "$with_uuid" = ossp ; then
  1088. AC_CHECK_LIB(ossp-uuid, uuid_export,
  1089. [UUID_LIBS="-lossp-uuid"],
  1090. [AC_CHECK_LIB(uuid, uuid_export,
  1091. [UUID_LIBS="-luuid"],
  1092. [AC_MSG_ERROR([library 'ossp-uuid' or 'uuid' is required for OSSP UUID])])])
  1093. fi
  1094. AC_SUBST(UUID_LIBS)
  1095. ##
  1096. ## Header files
  1097. ##
  1098. AC_HEADER_STDBOOL
  1099. AC_CHECK_HEADERS(m4_normalize([
  1100. atomic.h
  1101. copyfile.h
  1102. fp_class.h
  1103. getopt.h
  1104. ieeefp.h
  1105. ifaddrs.h
  1106. langinfo.h
  1107. mbarrier.h
  1108. poll.h
  1109. sys/epoll.h
  1110. sys/ipc.h
  1111. sys/prctl.h
  1112. sys/procctl.h
  1113. sys/pstat.h
  1114. sys/resource.h
  1115. sys/select.h
  1116. sys/sem.h
  1117. sys/shm.h
  1118. sys/sockio.h
  1119. sys/tas.h
  1120. sys/un.h
  1121. termios.h
  1122. ucred.h
  1123. utime.h
  1124. wchar.h
  1125. wctype.h
  1126. ]))
  1127. # On BSD, test for net/if.h will fail unless sys/socket.h
  1128. # is included first.
  1129. AC_CHECK_HEADERS(net/if.h, [], [],
  1130. [AC_INCLUDES_DEFAULT
  1131. #include <sys/socket.h>
  1132. ])
  1133. # On OpenBSD, test for sys/ucred.h will fail unless sys/param.h
  1134. # is included first.
  1135. AC_CHECK_HEADERS(sys/ucred.h, [], [],
  1136. [AC_INCLUDES_DEFAULT
  1137. #include <sys/param.h>
  1138. ])
  1139. # At least on IRIX, test for netinet/tcp.h will fail unless
  1140. # netinet/in.h is included first.
  1141. AC_CHECK_HEADERS(netinet/tcp.h, [], [],
  1142. [AC_INCLUDES_DEFAULT
  1143. #include <netinet/in.h>
  1144. ])
  1145. if expr x"$pgac_cv_check_readline" : 'x-lreadline' >/dev/null ; then
  1146. AC_CHECK_HEADERS(readline/readline.h, [],
  1147. [AC_CHECK_HEADERS(readline.h, [],
  1148. [AC_MSG_ERROR([readline header not found
  1149. If you have readline already installed, see config.log for details on the
  1150. failure. It is possible the compiler isn't looking in the proper directory.
  1151. Use --without-readline to disable readline support.])])])
  1152. AC_CHECK_HEADERS(readline/history.h, [],
  1153. [AC_CHECK_HEADERS(history.h, [],
  1154. [AC_MSG_ERROR([history header not found
  1155. If you have readline already installed, see config.log for details on the
  1156. failure. It is possible the compiler isn't looking in the proper directory.
  1157. Use --without-readline to disable readline support.])])])
  1158. fi
  1159. if expr x"$pgac_cv_check_readline" : 'x-ledit' >/dev/null ; then
  1160. # Some installations of libedit usurp /usr/include/readline/, which seems
  1161. # bad practice, since in combined installations readline will have its headers
  1162. # there. We might have to resort to AC_EGREP checks to make sure we found
  1163. # the proper header...
  1164. AC_CHECK_HEADERS(editline/readline.h, [],
  1165. [AC_CHECK_HEADERS(readline.h, [],
  1166. [AC_CHECK_HEADERS(readline/readline.h, [],
  1167. [AC_MSG_ERROR([readline header not found
  1168. If you have libedit already installed, see config.log for details on the
  1169. failure. It is possible the compiler isn't looking in the proper directory.
  1170. Use --without-readline to disable libedit support.])])])])
  1171. # Note: in a libedit installation, history.h is sometimes a dummy, and may
  1172. # not be there at all. Hence, don't complain if not found. We must check
  1173. # though, since in yet other versions it is an independent header.
  1174. AC_CHECK_HEADERS(editline/history.h, [],
  1175. [AC_CHECK_HEADERS(history.h, [],
  1176. [AC_CHECK_HEADERS(readline/history.h)])])
  1177. fi
  1178. if test "$with_zlib" = yes; then
  1179. AC_CHECK_HEADER(zlib.h, [], [AC_MSG_ERROR([zlib header not found
  1180. If you have zlib already installed, see config.log for details on the
  1181. failure. It is possible the compiler isn't looking in the proper directory.
  1182. Use --without-zlib to disable zlib support.])])
  1183. fi
  1184. if test "$with_gssapi" = yes ; then
  1185. AC_CHECK_HEADERS(gssapi/gssapi.h, [],
  1186. [AC_CHECK_HEADERS(gssapi.h, [], [AC_MSG_ERROR([gssapi.h header file is required for GSSAPI])])])
  1187. fi
  1188. if test "$with_openssl" = yes ; then
  1189. AC_CHECK_HEADER(openssl/ssl.h, [], [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL])])
  1190. AC_CHECK_HEADER(openssl/err.h, [], [AC_MSG_ERROR([header file <openssl/err.h> is required for OpenSSL])])
  1191. fi
  1192. if test "$with_pam" = yes ; then
  1193. AC_CHECK_HEADERS(security/pam_appl.h, [],
  1194. [AC_CHECK_HEADERS(pam/pam_appl.h, [],
  1195. [AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required for PAM.])])])
  1196. fi
  1197. if test "$with_bsd_auth" = yes ; then
  1198. AC_CHECK_HEADER(bsd_auth.h, [], [AC_MSG_ERROR([header file <bsd_auth.h> is required for BSD Authentication support])])
  1199. fi
  1200. if test "$with_systemd" = yes ; then
  1201. AC_CHECK_HEADER(systemd/sd-daemon.h, [], [AC_MSG_ERROR([header file <systemd/sd-daemon.h> is required for systemd support])])
  1202. fi
  1203. if test "$with_libxml" = yes ; then
  1204. AC_CHECK_HEADER(libxml/parser.h, [], [AC_MSG_ERROR([header file <libxml/parser.h> is required for XML support])])
  1205. fi
  1206. if test "$with_libxslt" = yes ; then
  1207. AC_CHECK_HEADER(libxslt/xslt.h, [], [AC_MSG_ERROR([header file <libxslt/xslt.h> is required for XSLT support])])
  1208. fi
  1209. if test "$with_ldap" = yes ; then
  1210. if test "$PORTNAME" != "win32"; then
  1211. AC_CHECK_HEADERS(ldap.h, [],
  1212. [AC_MSG_ERROR([header file <ldap.h> is required for LDAP])])
  1213. PGAC_LDAP_SAFE
  1214. else
  1215. AC_CHECK_HEADERS(winldap.h, [],
  1216. [AC_MSG_ERROR([header file <winldap.h> is required for LDAP])],
  1217. [AC_INCLUDES_DEFAULT
  1218. #include <windows.h>
  1219. ])
  1220. fi
  1221. fi
  1222. if test "$with_bonjour" = yes ; then
  1223. AC_CHECK_HEADER(dns_sd.h, [], [AC_MSG_ERROR([header file <dns_sd.h> is required for Bonjour])])
  1224. dnl At some point we might add something like
  1225. dnl AC_SEARCH_LIBS(DNSServiceRegister, dns_sd)
  1226. dnl but right now, what that would mainly accomplish is to encourage
  1227. dnl people to try to use the avahi implementation, which does not work.
  1228. dnl If you want to use Apple's own Bonjour code on another platform,
  1229. dnl just add -ldns_sd to LIBS manually.
  1230. fi
  1231. # for contrib/uuid-ossp
  1232. if test "$with_uuid" = bsd ; then
  1233. AC_CHECK_HEADERS(uuid.h,
  1234. [AC_EGREP_HEADER([uuid_to_string], uuid.h, [],
  1235. [AC_MSG_ERROR([header file <uuid.h> does not match BSD UUID library])])],
  1236. [AC_MSG_ERROR([header file <uuid.h> is required for BSD UUID])])
  1237. elif test "$with_uuid" = e2fs ; then
  1238. AC_CHECK_HEADERS(uuid/uuid.h,
  1239. [AC_EGREP_HEADER([uuid_generate], uuid/uuid.h, [],
  1240. [AC_MSG_ERROR([header file <uuid/uuid.h> does not match E2FS UUID library])])],
  1241. [AC_CHECK_HEADERS(uuid.h,
  1242. [AC_EGREP_HEADER([uuid_generate], uuid.h, [],
  1243. [AC_MSG_ERROR([header file <uuid.h> does not match E2FS UUID library])])],
  1244. [AC_MSG_ERROR([header file <uuid/uuid.h> or <uuid.h> is required for E2FS UUID])])])
  1245. elif test "$with_uuid" = ossp ; then
  1246. AC_CHECK_HEADERS(ossp/uuid.h,
  1247. [AC_EGREP_HEADER([uuid_export], ossp/uuid.h, [],
  1248. [AC_MSG_ERROR([header file <ossp/uuid.h> does not match OSSP UUID library])])],
  1249. [AC_CHECK_HEADERS(uuid.h,
  1250. [AC_EGREP_HEADER([uuid_export], uuid.h, [],
  1251. [AC_MSG_ERROR([header file <uuid.h> does not match OSSP UUID library])])],
  1252. [AC_MSG_ERROR([header file <ossp/uuid.h> or <uuid.h> is required for OSSP UUID])])])
  1253. fi
  1254. if test "$PORTNAME" = "win32" ; then
  1255. AC_CHECK_HEADERS(crtdefs.h)
  1256. fi
  1257. ##
  1258. ## Types, structures, compiler characteristics
  1259. ##
  1260. m4_defun([AC_PROG_CC_STDC], []) dnl We don't want that.
  1261. AC_C_BIGENDIAN
  1262. AC_C_INLINE
  1263. PGAC_PRINTF_ARCHETYPE
  1264. AC_C_FLEXIBLE_ARRAY_MEMBER
  1265. PGAC_C_SIGNED
  1266. PGAC_C_FUNCNAME_SUPPORT
  1267. PGAC_C_STATIC_ASSERT
  1268. PGAC_C_TYPEOF
  1269. PGAC_C_TYPES_COMPATIBLE
  1270. PGAC_C_BUILTIN_CONSTANT_P
  1271. PGAC_C_BUILTIN_UNREACHABLE
  1272. PGAC_C_COMPUTED_GOTO
  1273. PGAC_STRUCT_TIMEZONE
  1274. PGAC_UNION_SEMUN
  1275. PGAC_STRUCT_SOCKADDR_UN
  1276. PGAC_STRUCT_SOCKADDR_STORAGE
  1277. PGAC_STRUCT_SOCKADDR_STORAGE_MEMBERS
  1278. PGAC_STRUCT_ADDRINFO
  1279. AC_TYPE_INTPTR_T
  1280. AC_TYPE_UINTPTR_T
  1281. AC_TYPE_LONG_LONG_INT
  1282. PGAC_TYPE_LOCALE_T
  1283. # MSVC doesn't cope well with defining restrict to __restrict, the
  1284. # spelling it understands, because it conflicts with
  1285. # __declspec(restrict). Therefore we define pg_restrict to the
  1286. # appropriate definition, which presumably won't conflict.
  1287. #
  1288. # Allow platforms with buggy compilers to force restrict to not be
  1289. # used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
  1290. # template.
  1291. AC_C_RESTRICT
  1292. if test "$ac_cv_c_restrict" = "no" -o "x$FORCE_DISABLE_RESTRICT" = "xyes"; then
  1293. pg_restrict=""
  1294. else
  1295. pg_restrict="$ac_cv_c_restrict"
  1296. fi
  1297. AC_DEFINE_UNQUOTED([pg_restrict], [$pg_restrict],
  1298. [Define to keyword to use for C99 restrict support, or to nothing if not
  1299. supported])
  1300. AC_CHECK_TYPES([struct cmsgcred], [], [],
  1301. [#include <sys/socket.h>
  1302. #include <sys/param.h>
  1303. #ifdef HAVE_SYS_UCRED_H
  1304. #include <sys/ucred.h>
  1305. #endif])
  1306. AC_CHECK_TYPES([struct option], [], [],
  1307. [#ifdef HAVE_GETOPT_H
  1308. #include <getopt.h>
  1309. #endif])
  1310. if test "$with_zlib" = yes; then
  1311. # Check that <zlib.h> defines z_streamp (versions before about 1.0.4
  1312. # did not). While we could work around the lack of z_streamp, it
  1313. # seems unwise to encourage people to use such old zlib versions...
  1314. AC_CHECK_TYPE(z_streamp, [], [AC_MSG_ERROR([zlib version is too old
  1315. Use --without-zlib to disable zlib support.])],
  1316. [#include <zlib.h>])
  1317. fi
  1318. case $host_cpu in
  1319. x86_64)
  1320. # On x86_64, check if we can compile a popcntq instruction
  1321. AC_CACHE_CHECK([whether assembler supports x86_64 popcntq],
  1322. [pgac_cv_have_x86_64_popcntq],
  1323. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
  1324. [long long x = 1; long long r;
  1325. __asm__ __volatile__ (" popcntq %1,%0\n" : "=q"(r) : "rm"(x));])],
  1326. [pgac_cv_have_x86_64_popcntq=yes],
  1327. [pgac_cv_have_x86_64_popcntq=no])])
  1328. if test x"$pgac_cv_have_x86_64_popcntq" = xyes ; then
  1329. AC_DEFINE(HAVE_X86_64_POPCNTQ, 1, [Define to 1 if the assembler supports X86_64's POPCNTQ instruction.])
  1330. fi
  1331. ;;
  1332. ppc*|powerpc*)
  1333. # On PPC, check if assembler supports LWARX instruction's mutex hint bit
  1334. AC_CACHE_CHECK([whether assembler supports lwarx hint bit],
  1335. [pgac_cv_have_ppc_mutex_hint],
  1336. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
  1337. [int a = 0; int *p = &a; int r;
  1338. __asm__ __volatile__ (" lwarx %0,0,%1,1\n" : "=&r"(r) : "r"(p));])],
  1339. [pgac_cv_have_ppc_mutex_hint=yes],
  1340. [pgac_cv_have_ppc_mutex_hint=no])])
  1341. if test x"$pgac_cv_have_ppc_mutex_hint" = xyes ; then
  1342. AC_DEFINE(HAVE_PPC_LWARX_MUTEX_HINT, 1, [Define to 1 if the assembler supports PPC's LWARX mutex hint bit.])
  1343. fi
  1344. ;;
  1345. esac
  1346. # Check largefile support. You might think this is a system service not a
  1347. # compiler characteristic, but you'd be wrong. We must check this before
  1348. # probing existence of related functions such as fseeko, since the largefile
  1349. # defines can affect what is generated for that.
  1350. if test "$PORTNAME" != "win32"; then
  1351. AC_SYS_LARGEFILE
  1352. dnl Autoconf 2.69's AC_SYS_LARGEFILE believes it's a good idea to #define
  1353. dnl _DARWIN_USE_64_BIT_INODE, but it isn't: on macOS 10.5 that activates a
  1354. dnl bug that causes readdir() to sometimes return EINVAL. On later macOS
  1355. dnl versions where the feature actually works, it's on by default anyway.
  1356. AH_VERBATIM([_DARWIN_USE_64_BIT_INODE],[])
  1357. fi
  1358. dnl Check for largefile support (must be after AC_SYS_LARGEFILE)
  1359. AC_CHECK_SIZEOF([off_t])
  1360. # If we don't have largefile support, can't handle segsize >= 2GB.
  1361. if test "$ac_cv_sizeof_off_t" -lt 8 -a "$segsize" != "1"; then
  1362. AC_MSG_ERROR([Large file support is not enabled. Segment size cannot be larger than 1GB.])
  1363. fi
  1364. AC_CHECK_SIZEOF([bool], [],
  1365. [#ifdef HAVE_STDBOOL_H
  1366. #include <stdbool.h>
  1367. #endif])
  1368. ##
  1369. ## Functions, global variables
  1370. ##
  1371. PGAC_VAR_INT_TIMEZONE
  1372. AC_FUNC_ACCEPT_ARGTYPES
  1373. PGAC_FUNC_GETTIMEOFDAY_1ARG
  1374. PGAC_FUNC_WCSTOMBS_L
  1375. # Some versions of libedit contain strlcpy(), setproctitle(), and other
  1376. # symbols that that library has no business exposing to the world. Pending
  1377. # acquisition of a clue by those developers, ignore libedit (including its
  1378. # possible alias of libreadline) while checking for everything else.
  1379. LIBS_including_readline="$LIBS"
  1380. LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
  1381. AC_CHECK_FUNCS(m4_normalize([
  1382. cbrt
  1383. clock_gettime
  1384. copyfile
  1385. fdatasync
  1386. getifaddrs
  1387. getpeerucred
  1388. getrlimit
  1389. mbstowcs_l
  1390. memset_s
  1391. memmove
  1392. poll
  1393. posix_fallocate
  1394. ppoll
  1395. pstat
  1396. pthread_is_threaded_np
  1397. readlink
  1398. setproctitle
  1399. setproctitle_fast
  1400. setsid
  1401. shm_open
  1402. strchrnul
  1403. strsignal
  1404. symlink
  1405. sync_file_range
  1406. uselocale
  1407. utime
  1408. utimes
  1409. wcstombs_l
  1410. ]))
  1411. # These typically are compiler builtins, for which AC_CHECK_FUNCS fails.
  1412. PGAC_CHECK_BUILTIN_FUNC([__builtin_bswap16], [int x])
  1413. PGAC_CHECK_BUILTIN_FUNC([__builtin_bswap32], [int x])
  1414. PGAC_CHECK_BUILTIN_FUNC([__builtin_bswap64], [long int x])
  1415. # We assume that we needn't test all widths of these explicitly:
  1416. PGAC_CHECK_BUILTIN_FUNC([__builtin_clz], [unsigned int x])
  1417. PGAC_CHECK_BUILTIN_FUNC([__builtin_ctz], [unsigned int x])
  1418. PGAC_CHECK_BUILTIN_FUNC([__builtin_popcount], [unsigned int x])
  1419. AC_REPLACE_FUNCS(fseeko)
  1420. case $host_os in
  1421. # NetBSD uses a custom fseeko/ftello built on fsetpos/fgetpos
  1422. # Mingw uses macros to access Win32 API calls
  1423. netbsd*|mingw*)
  1424. AC_DEFINE(HAVE_FSEEKO, 1, [Define to 1 because replacement version used.])
  1425. ac_cv_func_fseeko=yes;;
  1426. *)
  1427. AC_FUNC_FSEEKO;;
  1428. esac
  1429. # posix_fadvise() is a no-op on Solaris, so don't incur function overhead
  1430. # by calling it, 2009-04-02
  1431. # http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libc/port/gen/posix_fadvise.c
  1432. dnl must use AS_IF here, else AC_REQUIRES inside AC_CHECK_DECLS malfunctions
  1433. AS_IF([test "$PORTNAME" != "solaris"], [
  1434. AC_CHECK_FUNCS(posix_fadvise)
  1435. AC_CHECK_DECLS(posix_fadvise, [], [], [#include <fcntl.h>])
  1436. ]) # fi
  1437. AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
  1438. AC_CHECK_DECLS([strlcat, strlcpy, strnlen])
  1439. # This is probably only present on macOS, but may as well check always
  1440. AC_CHECK_DECLS(F_FULLFSYNC, [], [], [#include <fcntl.h>])
  1441. AC_CHECK_DECLS([RTLD_GLOBAL, RTLD_NOW], [], [], [#include <dlfcn.h>])
  1442. AC_CHECK_TYPE([struct sockaddr_in6],
  1443. [AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if you have support for IPv6.])],
  1444. [],
  1445. [$ac_includes_default
  1446. #include <netinet/in.h>])
  1447. AC_CACHE_CHECK([for PS_STRINGS], [pgac_cv_var_PS_STRINGS],
  1448. [AC_LINK_IFELSE([AC_LANG_PROGRAM(
  1449. [#include <machine/vmparam.h>
  1450. #include <sys/exec.h>
  1451. ],
  1452. [PS_STRINGS->ps_nargvstr = 1;
  1453. PS_STRINGS->ps_argvstr = "foo";])],
  1454. [pgac_cv_var_PS_STRINGS=yes],
  1455. [pgac_cv_var_PS_STRINGS=no])])
  1456. if test "$pgac_cv_var_PS_STRINGS" = yes ; then
  1457. AC_DEFINE([HAVE_PS_STRINGS], 1, [Define to 1 if the PS_STRINGS thing exists.])
  1458. fi
  1459. dnl Cannot use AC_CHECK_FUNC because isinf may be a macro
  1460. AC_CACHE_CHECK([for isinf], ac_cv_func_isinf,
  1461. [AC_LINK_IFELSE([AC_LANG_PROGRAM([
  1462. #include <math.h>
  1463. double glob_double;
  1464. ],
  1465. [return isinf(glob_double) ? 0 : 1;])],
  1466. [ac_cv_func_isinf=yes],
  1467. [ac_cv_func_isinf=no])])
  1468. if test $ac_cv_func_isinf = yes ; then
  1469. AC_DEFINE(HAVE_ISINF, 1, [Define to 1 if you have isinf().])
  1470. else
  1471. AC_LIBOBJ(isinf)
  1472. # Look for a way to implement a substitute for isinf()
  1473. AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
  1474. fi
  1475. AC_REPLACE_FUNCS(m4_normalize([
  1476. dlopen
  1477. explicit_bzero
  1478. fls
  1479. getopt
  1480. getrusage
  1481. inet_aton
  1482. mkdtemp
  1483. pread
  1484. pwrite
  1485. random
  1486. rint
  1487. srandom
  1488. strlcat
  1489. strlcpy
  1490. strnlen
  1491. strtof
  1492. ]))
  1493. case $host_os in
  1494. # Cygwin and (apparently, based on test results) Mingw both
  1495. # have a broken strtof(), so substitute the same replacement
  1496. # code we use with VS2013. That's not a perfect fix, since
  1497. # (unlike with VS2013) it doesn't avoid double-rounding, but
  1498. # we have no better options. To get that, though, we have to
  1499. # force the file to be compiled despite HAVE_STRTOF.
  1500. mingw*|cygwin*)
  1501. AC_LIBOBJ([strtof])
  1502. AC_MSG_NOTICE([On $host_os we will use our strtof wrapper.])
  1503. ;;
  1504. esac
  1505. case $host_os in
  1506. # Windows uses a specialised env handler
  1507. # and doesn't need a replacement getpeereid because it doesn't use
  1508. # Unix sockets.
  1509. mingw*)
  1510. AC_DEFINE(HAVE_UNSETENV, 1, [Define to 1 because replacement version used.])
  1511. AC_DEFINE(HAVE_GETPEEREID, 1, [Define to 1 because function not required.])
  1512. ac_cv_func_unsetenv=yes
  1513. ac_cv_func_getpeereid=yes;;
  1514. *)
  1515. AC_REPLACE_FUNCS([unsetenv getpeereid])
  1516. ;;
  1517. esac
  1518. # System's version of getaddrinfo(), if any, may be used only if we found
  1519. # a definition for struct addrinfo; see notes in src/include/getaddrinfo.h.
  1520. # We use only our own getaddrinfo.c on Windows, but it's time to revisit that.
  1521. if test x"$ac_cv_type_struct_addrinfo" = xyes && \
  1522. test "$PORTNAME" != "win32"; then
  1523. AC_REPLACE_FUNCS([getaddrinfo])
  1524. else
  1525. AC_LIBOBJ(getaddrinfo)
  1526. fi
  1527. # Similarly, use system's getopt_long() only if system provides struct option.
  1528. if test x"$ac_cv_type_struct_option" = xyes ; then
  1529. AC_REPLACE_FUNCS([getopt_long])
  1530. else
  1531. AC_LIBOBJ(getopt_long)
  1532. fi
  1533. # On OpenBSD and Solaris, getopt() doesn't do what we want for long options
  1534. # (i.e., allow '-' as a flag character), so use our version on those platforms.
  1535. if test "$PORTNAME" = "openbsd" -o "$PORTNAME" = "solaris"; then
  1536. AC_LIBOBJ(getopt)
  1537. fi
  1538. # mingw has adopted a GNU-centric interpretation of optind/optreset,
  1539. # so always use our version on Windows.
  1540. if test "$PORTNAME" = "win32"; then
  1541. AC_LIBOBJ(getopt)
  1542. AC_LIBOBJ(getopt_long)
  1543. fi
  1544. # Win32 (really MinGW) support
  1545. if test "$PORTNAME" = "win32"; then
  1546. AC_CHECK_FUNCS(_configthreadlocale)
  1547. AC_REPLACE_FUNCS(gettimeofday)
  1548. AC_LIBOBJ(dirmod)
  1549. AC_LIBOBJ(kill)
  1550. AC_LIBOBJ(open)
  1551. AC_LIBOBJ(system)
  1552. AC_LIBOBJ(win32env)
  1553. AC_LIBOBJ(win32error)
  1554. AC_LIBOBJ(win32security)
  1555. AC_LIBOBJ(win32setlocale)
  1556. AC_DEFINE([HAVE_SYMLINK], 1,
  1557. [Define to 1 if you have the `symlink' function.])
  1558. AC_CHECK_TYPES(MINIDUMP_TYPE, [pgac_minidump_type=yes], [pgac_minidump_type=no], [
  1559. #define WIN32_LEAN_AND_MEAN
  1560. #include <windows.h>
  1561. #include <string.h>
  1562. #include <dbghelp.h>])
  1563. fi
  1564. if test x"$pgac_minidump_type" = x"yes" ; then
  1565. AC_SUBST(have_win32_dbghelp,yes)
  1566. else
  1567. AC_SUBST(have_win32_dbghelp,no)
  1568. fi
  1569. # Cygwin needs only a bit of that
  1570. if test "$PORTNAME" = "cygwin"; then
  1571. AC_LIBOBJ(dirmod)
  1572. fi
  1573. AC_CHECK_FUNC(syslog,
  1574. [AC_CHECK_HEADER(syslog.h,
  1575. [AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])
  1576. AC_CACHE_CHECK([for opterr], pgac_cv_var_int_opterr,
  1577. [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>],
  1578. [extern int opterr; opterr = 1;])],
  1579. [pgac_cv_var_int_opterr=yes],
  1580. [pgac_cv_var_int_opterr=no])])
  1581. if test x"$pgac_cv_var_int_opterr" = x"yes"; then
  1582. AC_DEFINE(HAVE_INT_OPTERR, 1, [Define to 1 if you have the global variable 'int opterr'.])
  1583. fi
  1584. AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
  1585. [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>],
  1586. [extern int optreset; optreset = 1;])],
  1587. [pgac_cv_var_int_optreset=yes],
  1588. [pgac_cv_var_int_optreset=no])])
  1589. if test x"$pgac_cv_var_int_optreset" = x"yes"; then
  1590. AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
  1591. fi
  1592. AC_CHECK_FUNCS([strtoll __strtoll strtoq], [break])
  1593. AC_CHECK_FUNCS([strtoull __strtoull strtouq], [break])
  1594. # strto[u]ll may exist but not be declared
  1595. AC_CHECK_DECLS([strtoll, strtoull])
  1596. if test "$with_icu" = yes; then
  1597. ac_save_CPPFLAGS=$CPPFLAGS
  1598. CPPFLAGS="$ICU_CFLAGS $CPPFLAGS"
  1599. # Verify we have ICU's header files
  1600. AC_CHECK_HEADER(unicode/ucol.h, [],
  1601. [AC_MSG_ERROR([header file <unicode/ucol.h> is required for ICU])])
  1602. CPPFLAGS=$ac_save_CPPFLAGS
  1603. fi
  1604. if test "$with_llvm" = yes; then
  1605. PGAC_CHECK_LLVM_FUNCTIONS()
  1606. fi
  1607. # Lastly, restore full LIBS list and check for readline/libedit symbols
  1608. LIBS="$LIBS_including_readline"
  1609. if test "$with_readline" = yes; then
  1610. PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
  1611. AC_CHECK_FUNCS([rl_completion_matches rl_filename_completion_function rl_reset_screen_size])
  1612. AC_CHECK_FUNCS([append_history history_truncate_file])
  1613. fi
  1614. # This test makes sure that run tests work at all. Sometimes a shared
  1615. # library is found by the linker, but the runtime linker can't find it.
  1616. # This check should come after all modifications of compiler or linker
  1617. # variables, and before any other run tests.
  1618. AC_MSG_CHECKING([test program])
  1619. AC_RUN_IFELSE([AC_LANG_SOURCE([int main() { return 0; }])],
  1620. [AC_MSG_RESULT(ok)],
  1621. [AC_MSG_RESULT(failed)
  1622. AC_MSG_ERROR([[
  1623. Could not execute a simple test program. This may be a problem
  1624. related to locating shared libraries. Check the file 'config.log'
  1625. for the exact reason.]])],
  1626. [AC_MSG_RESULT([cross-compiling])])
  1627. # --------------------
  1628. # Run tests below here
  1629. # --------------------
  1630. dnl Check to see if we have a working 64-bit integer type.
  1631. dnl Since Postgres 8.4, we no longer support compilers without a working
  1632. dnl 64-bit type; but we have to determine whether that type is called
  1633. dnl "long int" or "long long int".
  1634. PGAC_TYPE_64BIT_INT([long int])
  1635. if test x"$HAVE_LONG_INT_64" = x"yes" ; then
  1636. pg_int64_type="long int"
  1637. else
  1638. PGAC_TYPE_64BIT_INT([long long int])
  1639. if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
  1640. pg_int64_type="long long int"
  1641. else
  1642. AC_MSG_ERROR([Cannot find a working 64-bit integer type.])
  1643. fi
  1644. fi
  1645. AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
  1646. [Define to the name of a signed 64-bit integer type.])
  1647. # Select the printf length modifier that goes with that, too.
  1648. if test x"$pg_int64_type" = x"long long int" ; then
  1649. INT64_MODIFIER='"ll"'
  1650. else
  1651. INT64_MODIFIER='"l"'
  1652. fi
  1653. AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
  1654. [Define to the appropriate printf length modifier for 64-bit ints.])
  1655. # has to be down here, rather than with the other builtins, because
  1656. # the test uses PG_INT64_TYPE.
  1657. PGAC_C_BUILTIN_OP_OVERFLOW
  1658. # Check size of void *, size_t (enables tweaks for > 32bit address space)
  1659. AC_CHECK_SIZEOF([void *])
  1660. AC_CHECK_SIZEOF([size_t])
  1661. AC_CHECK_SIZEOF([long])
  1662. # Decide whether float4 is passed by value: user-selectable, enabled by default
  1663. AC_MSG_CHECKING([whether to build with float4 passed by value])
  1664. PGAC_ARG_BOOL(enable, float4-byval, yes, [disable float4 passed by value],
  1665. [AC_DEFINE([USE_FLOAT4_BYVAL], 1,
  1666. [Define to 1 if you want float4 values to be passed by value. (--enable-float4-byval)])
  1667. float4passbyval=true],
  1668. [float4passbyval=false])
  1669. AC_MSG_RESULT([$enable_float4_byval])
  1670. AC_DEFINE_UNQUOTED([FLOAT4PASSBYVAL], [$float4passbyval], [float4 values are passed by value if 'true', by reference if 'false'])
  1671. # Decide whether float8 is passed by value.
  1672. # Note: this setting also controls int8 and related types such as timestamp.
  1673. # If sizeof(Datum) >= 8, this is user-selectable, enabled by default.
  1674. # If not, trying to select it is an error.
  1675. AC_MSG_CHECKING([whether to build with float8 passed by value])
  1676. if test $ac_cv_sizeof_void_p -ge 8 ; then
  1677. PGAC_ARG_BOOL(enable, float8-byval, yes, [disable float8 passed by value])
  1678. else
  1679. PGAC_ARG_BOOL(enable, float8-byval, no, [disable float8 passed by value])
  1680. if test "$enable_float8_byval" = yes ; then
  1681. AC_MSG_ERROR([--enable-float8-byval is not supported on 32-bit platforms.])
  1682. fi
  1683. fi
  1684. if test "$enable_float8_byval" = yes ; then
  1685. AC_DEFINE([USE_FLOAT8_BYVAL], 1,
  1686. [Define to 1 if you want float8, int8, etc values to be passed by value. (--enable-float8-byval)])
  1687. float8passbyval=true
  1688. else
  1689. float8passbyval=false
  1690. fi
  1691. AC_MSG_RESULT([$enable_float8_byval])
  1692. AC_DEFINE_UNQUOTED([FLOAT8PASSBYVAL], [$float8passbyval], [float8, int8, and related values are passed by value if 'true', by reference if 'false'])
  1693. # Determine memory alignment requirements for the basic C data types.
  1694. AC_CHECK_ALIGNOF(short)
  1695. AC_CHECK_ALIGNOF(int)
  1696. AC_CHECK_ALIGNOF(long)
  1697. if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
  1698. AC_CHECK_ALIGNOF(long long int)
  1699. fi
  1700. AC_CHECK_ALIGNOF(double)
  1701. # Compute maximum alignment of any basic type.
  1702. # We assume long's alignment is at least as strong as char, short, or int;
  1703. # but we must check long long (if it is being used for int64) and double.
  1704. # Note that we intentionally do not consider any types wider than 64 bits,
  1705. # as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
  1706. # for disk and memory space.
  1707. MAX_ALIGNOF=$ac_cv_alignof_long
  1708. if test $MAX_ALIGNOF -lt $ac_cv_alignof_double ; then
  1709. MAX_ALIGNOF=$ac_cv_alignof_double
  1710. fi
  1711. if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ; then
  1712. MAX_ALIGNOF="$ac_cv_alignof_long_long_int"
  1713. fi
  1714. AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
  1715. # Some platforms predefine the types int8, int16, etc. Only check
  1716. # a (hopefully) representative subset.
  1717. AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
  1718. [#include <stdio.h>])
  1719. # Some compilers offer a 128-bit integer scalar type.
  1720. PGAC_TYPE_128BIT_INT
  1721. # Check for various atomic operations now that we have checked how to declare
  1722. # 64bit integers.
  1723. PGAC_HAVE_GCC__SYNC_CHAR_TAS
  1724. PGAC_HAVE_GCC__SYNC_INT32_TAS
  1725. PGAC_HAVE_GCC__SYNC_INT32_CAS
  1726. PGAC_HAVE_GCC__SYNC_INT64_CAS
  1727. PGAC_HAVE_GCC__ATOMIC_INT32_CAS
  1728. PGAC_HAVE_GCC__ATOMIC_INT64_CAS
  1729. # Check for x86 cpuid instruction
  1730. AC_CACHE_CHECK([for __get_cpuid], [pgac_cv__get_cpuid],
  1731. [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <cpuid.h>],
  1732. [[unsigned int exx[4] = {0, 0, 0, 0};
  1733. __get_cpuid(1, &exx[0], &exx[1], &exx[2], &exx[3]);
  1734. ]])],
  1735. [pgac_cv__get_cpuid="yes"],
  1736. [pgac_cv__get_cpuid="no"])])
  1737. if test x"$pgac_cv__get_cpuid" = x"yes"; then
  1738. AC_DEFINE(HAVE__GET_CPUID, 1, [Define to 1 if you have __get_cpuid.])
  1739. fi
  1740. AC_CACHE_CHECK([for __cpuid], [pgac_cv__cpuid],
  1741. [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <intrin.h>],
  1742. [[unsigned int exx[4] = {0, 0, 0, 0};
  1743. __get_cpuid(exx[0], 1);
  1744. ]])],
  1745. [pgac_cv__cpuid="yes"],
  1746. [pgac_cv__cpuid="no"])])
  1747. if test x"$pgac_cv__cpuid" = x"yes"; then
  1748. AC_DEFINE(HAVE__CPUID, 1, [Define to 1 if you have __cpuid.])
  1749. fi
  1750. # Check for Intel SSE 4.2 intrinsics to do CRC calculations.
  1751. #
  1752. # First check if the _mm_crc32_u8 and _mm_crc32_u64 intrinsics can be used
  1753. # with the default compiler flags. If not, check if adding the -msse4.2
  1754. # flag helps. CFLAGS_SSE42 is set to -msse4.2 if that's required.
  1755. PGAC_SSE42_CRC32_INTRINSICS([])
  1756. if test x"$pgac_sse42_crc32_intrinsics" != x"yes"; then
  1757. PGAC_SSE42_CRC32_INTRINSICS([-msse4.2])
  1758. fi
  1759. AC_SUBST(CFLAGS_SSE42)
  1760. # Are we targeting a processor that supports SSE 4.2? gcc, clang and icc all
  1761. # define __SSE4_2__ in that case.
  1762. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
  1763. #ifndef __SSE4_2__
  1764. #error __SSE4_2__ not defined
  1765. #endif
  1766. ])], [SSE4_2_TARGETED=1])
  1767. # Check for ARMv8 CRC Extension intrinsics to do CRC calculations.
  1768. #
  1769. # First check if __crc32c* intrinsics can be used with the default compiler
  1770. # flags. If not, check if adding -march=armv8-a+crc flag helps.
  1771. # CFLAGS_ARMV8_CRC32C is set if the extra flag is required.
  1772. PGAC_ARMV8_CRC32C_INTRINSICS([])
  1773. if test x"$pgac_armv8_crc32c_intrinsics" != x"yes"; then
  1774. PGAC_ARMV8_CRC32C_INTRINSICS([-march=armv8-a+crc])
  1775. fi
  1776. AC_SUBST(CFLAGS_ARMV8_CRC32C)
  1777. # Select CRC-32C implementation.
  1778. #
  1779. # If we are targeting a processor that has Intel SSE 4.2 instructions, we can
  1780. # use the special CRC instructions for calculating CRC-32C. If we're not
  1781. # targeting such a processor, but we can nevertheless produce code that uses
  1782. # the SSE intrinsics, perhaps with some extra CFLAGS, compile both
  1783. # implementations and select which one to use at runtime, depending on whether
  1784. # SSE 4.2 is supported by the processor we're running on.
  1785. #
  1786. # Similarly, if we are targeting an ARM processor that has the CRC
  1787. # instructions that are part of the ARMv8 CRC Extension, use them. And if
  1788. # we're not targeting such a processor, but can nevertheless produce code that
  1789. # uses the CRC instructions, compile both, and select at runtime.
  1790. #
  1791. # You can override this logic by setting the appropriate USE_*_CRC32 flag to 1
  1792. # in the template or configure command line.
  1793. if test x"$USE_SLICING_BY_8_CRC32C" = x"" && test x"$USE_SSE42_CRC32C" = x"" && test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"" && test x"$USE_ARMV8_CRC32C" = x"" && test x"$USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK" = x""; then
  1794. # Use Intel SSE 4.2 if available.
  1795. if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && test x"$SSE4_2_TARGETED" = x"1" ; then
  1796. USE_SSE42_CRC32C=1
  1797. else
  1798. # Intel SSE 4.2, with runtime check? The CPUID instruction is needed for
  1799. # the runtime check.
  1800. if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && (test x"$pgac_cv__get_cpuid" = x"yes" || test x"$pgac_cv__cpuid" = x"yes"); then
  1801. USE_SSE42_CRC32C_WITH_RUNTIME_CHECK=1
  1802. else
  1803. # Use ARM CRC Extension if available.
  1804. if test x"$pgac_armv8_crc32c_intrinsics" = x"yes" && test x"$CFLAGS_ARMV8_CRC32C" = x""; then
  1805. USE_ARMV8_CRC32C=1
  1806. else
  1807. # ARM CRC Extension, with runtime check?
  1808. if test x"$pgac_armv8_crc32c_intrinsics" = x"yes"; then
  1809. USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK=1
  1810. else
  1811. # fall back to slicing-by-8 algorithm, which doesn't require any
  1812. # special CPU support.
  1813. USE_SLICING_BY_8_CRC32C=1
  1814. fi
  1815. fi
  1816. fi
  1817. fi
  1818. fi
  1819. # Set PG_CRC32C_OBJS appropriately depending on the selected implementation.
  1820. AC_MSG_CHECKING([which CRC-32C implementation to use])
  1821. if test x"$USE_SSE42_CRC32C" = x"1"; then
  1822. AC_DEFINE(USE_SSE42_CRC32C, 1, [Define to 1 use Intel SSE 4.2 CRC instructions.])
  1823. PG_CRC32C_OBJS="pg_crc32c_sse42.o"
  1824. AC_MSG_RESULT(SSE 4.2)
  1825. else
  1826. if test x"$USE_SSE42_CRC32C_WITH_RUNTIME_CHECK" = x"1"; then
  1827. AC_DEFINE(USE_SSE42_CRC32C_WITH_RUNTIME_CHECK, 1, [Define to 1 to use Intel SSE 4.2 CRC instructions with a runtime check.])
  1828. PG_CRC32C_OBJS="pg_crc32c_sse42.o pg_crc32c_sb8.o pg_crc32c_sse42_choose.o"
  1829. AC_MSG_RESULT(SSE 4.2 with runtime check)
  1830. else
  1831. if test x"$USE_ARMV8_CRC32C" = x"1"; then
  1832. AC_DEFINE(USE_ARMV8_CRC32C, 1, [Define to 1 to use ARMv8 CRC Extension.])
  1833. PG_CRC32C_OBJS="pg_crc32c_armv8.o"
  1834. AC_MSG_RESULT(ARMv8 CRC instructions)
  1835. else
  1836. if test x"$USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK" = x"1"; then
  1837. AC_DEFINE(USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK, 1, [Define to 1 to use ARMv8 CRC Extension with a runtime check.])
  1838. PG_CRC32C_OBJS="pg_crc32c_armv8.o pg_crc32c_sb8.o pg_crc32c_armv8_choose.o"
  1839. AC_MSG_RESULT(ARMv8 CRC instructions with runtime check)
  1840. else
  1841. AC_DEFINE(USE_SLICING_BY_8_CRC32C, 1, [Define to 1 to use software CRC-32C implementation (slicing-by-8).])
  1842. PG_CRC32C_OBJS="pg_crc32c_sb8.o"
  1843. AC_MSG_RESULT(slicing-by-8)
  1844. fi
  1845. fi
  1846. fi
  1847. fi
  1848. AC_SUBST(PG_CRC32C_OBJS)
  1849. # Select semaphore implementation type.
  1850. if test "$PORTNAME" != "win32"; then
  1851. if test x"$PREFERRED_SEMAPHORES" = x"NAMED_POSIX" ; then
  1852. # Need sem_open for this
  1853. AC_SEARCH_LIBS(sem_open, [rt pthread], [USE_NAMED_POSIX_SEMAPHORES=1])
  1854. fi
  1855. if test x"$PREFERRED_SEMAPHORES" = x"UNNAMED_POSIX" ; then
  1856. # Need sem_init for this
  1857. AC_SEARCH_LIBS(sem_init, [rt pthread], [USE_UNNAMED_POSIX_SEMAPHORES=1])
  1858. fi
  1859. AC_MSG_CHECKING([which semaphore API to use])
  1860. if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
  1861. AC_DEFINE(USE_NAMED_POSIX_SEMAPHORES, 1, [Define to select named POSIX semaphores.])
  1862. SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
  1863. sematype="named POSIX"
  1864. else
  1865. if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
  1866. AC_DEFINE(USE_UNNAMED_POSIX_SEMAPHORES, 1, [Define to select unnamed POSIX semaphores.])
  1867. SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
  1868. sematype="unnamed POSIX"
  1869. else
  1870. AC_DEFINE(USE_SYSV_SEMAPHORES, 1, [Define to select SysV-style semaphores.])
  1871. SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
  1872. sematype="System V"
  1873. fi
  1874. fi
  1875. AC_MSG_RESULT([$sematype])
  1876. else
  1877. AC_DEFINE(USE_WIN32_SEMAPHORES, 1, [Define to select Win32-style semaphores.])
  1878. SEMA_IMPLEMENTATION="src/backend/port/win32_sema.c"
  1879. fi
  1880. # Select shared-memory implementation type.
  1881. if test "$PORTNAME" != "win32"; then
  1882. AC_DEFINE(USE_SYSV_SHARED_MEMORY, 1, [Define to select SysV-style shared memory.])
  1883. SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
  1884. else
  1885. AC_DEFINE(USE_WIN32_SHARED_MEMORY, 1, [Define to select Win32-style shared memory.])
  1886. SHMEM_IMPLEMENTATION="src/backend/port/win32_shmem.c"
  1887. fi
  1888. # Select random number source
  1889. #
  1890. # You can override this logic by setting the appropriate USE_*RANDOM flag to 1
  1891. # in the template or configure command line.
  1892. # If not selected manually, try to select a source automatically.
  1893. if test x"$USE_OPENSSL_RANDOM" = x"" && test x"$USE_WIN32_RANDOM" = x"" && test x"$USE_DEV_URANDOM" = x"" ; then
  1894. if test x"$with_openssl" = x"yes" ; then
  1895. USE_OPENSSL_RANDOM=1
  1896. elif test "$PORTNAME" = "win32" ; then
  1897. USE_WIN32_RANDOM=1
  1898. else
  1899. AC_CHECK_FILE([/dev/urandom], [], [])
  1900. if test x"$ac_cv_file__dev_urandom" = x"yes" ; then
  1901. USE_DEV_URANDOM=1
  1902. fi
  1903. fi
  1904. fi
  1905. AC_MSG_CHECKING([which random number source to use])
  1906. if test x"$USE_OPENSSL_RANDOM" = x"1" ; then
  1907. AC_DEFINE(USE_OPENSSL_RANDOM, 1, [Define to use OpenSSL for random number generation])
  1908. AC_MSG_RESULT([OpenSSL])
  1909. elif test x"$USE_WIN32_RANDOM" = x"1" ; then
  1910. AC_DEFINE(USE_WIN32_RANDOM, 1, [Define to use native Windows API for random number generation])
  1911. AC_MSG_RESULT([Windows native])
  1912. elif test x"$USE_DEV_URANDOM" = x"1" ; then
  1913. AC_DEFINE(USE_DEV_URANDOM, 1, [Define to use /dev/urandom for random number generation])
  1914. AC_MSG_RESULT([/dev/urandom])
  1915. else
  1916. AC_MSG_ERROR([
  1917. no source of strong random numbers was found
  1918. PostgreSQL can use OpenSSL or /dev/urandom as a source of random numbers.])
  1919. fi
  1920. # If not set in template file, set bytes to use libc memset()
  1921. if test x"$MEMSET_LOOP_LIMIT" = x"" ; then
  1922. MEMSET_LOOP_LIMIT=1024
  1923. fi
  1924. AC_DEFINE_UNQUOTED(MEMSET_LOOP_LIMIT, ${MEMSET_LOOP_LIMIT}, [Define bytes to use libc memset().])
  1925. if test "$enable_nls" = yes ; then
  1926. PGAC_CHECK_GETTEXT
  1927. fi
  1928. # Check for Tcl configuration script tclConfig.sh
  1929. if test "$with_tcl" = yes; then
  1930. PGAC_PATH_TCLCONFIGSH([$with_tclconfig])
  1931. PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH],
  1932. [TCL_INCLUDE_SPEC,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
  1933. AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one
  1934. if test "$TCL_SHARED_BUILD" != 1; then
  1935. AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library
  1936. Use --without-tcl to disable building PL/Tcl.])
  1937. fi
  1938. # now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
  1939. ac_save_CPPFLAGS=$CPPFLAGS
  1940. CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
  1941. AC_CHECK_HEADER(tcl.h, [], [AC_MSG_ERROR([header file <tcl.h> is required for Tcl])])
  1942. CPPFLAGS=$ac_save_CPPFLAGS
  1943. fi
  1944. # check for <perl.h>
  1945. if test "$with_perl" = yes; then
  1946. ac_save_CPPFLAGS=$CPPFLAGS
  1947. CPPFLAGS="$CPPFLAGS $perl_includespec"
  1948. AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])],
  1949. [#include <EXTERN.h>])
  1950. # While we're at it, check that we can link to libperl.
  1951. # On most platforms, if perl.h is there then libperl.so will be too, but at
  1952. # this writing Debian packages them separately. There is no known reason to
  1953. # waste cycles on separate probes for the Tcl or Python libraries, though.
  1954. pgac_save_LIBS=$LIBS
  1955. LIBS="$perl_embed_ldflags"
  1956. AC_MSG_CHECKING([for libperl])
  1957. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  1958. #include <EXTERN.h>
  1959. #include <perl.h>
  1960. ], [perl_alloc();])],
  1961. [AC_MSG_RESULT(yes)],
  1962. [AC_MSG_RESULT(no)
  1963. AC_MSG_ERROR([libperl library is required for Perl])])
  1964. LIBS=$pgac_save_LIBS
  1965. CPPFLAGS=$ac_save_CPPFLAGS
  1966. fi
  1967. # check for <Python.h>
  1968. if test "$with_python" = yes; then
  1969. ac_save_CPPFLAGS=$CPPFLAGS
  1970. CPPFLAGS="$python_includespec $CPPFLAGS"
  1971. AC_CHECK_HEADER(Python.h, [], [AC_MSG_ERROR([header file <Python.h> is required for Python])])
  1972. CPPFLAGS=$ac_save_CPPFLAGS
  1973. fi
  1974. #
  1975. # Check for DocBook and tools
  1976. #
  1977. PGAC_PATH_XMLLINT
  1978. PGAC_CHECK_DOCBOOK(4.5)
  1979. PGAC_PATH_PROGS(DBTOEPUB, dbtoepub)
  1980. PGAC_PATH_PROGS(XSLTPROC, xsltproc)
  1981. PGAC_PATH_PROGS(FOP, fop)
  1982. #
  1983. # Check for test tools
  1984. #
  1985. if test "$enable_tap_tests" = yes; then
  1986. # Check for necessary modules, unless user has specified the "prove" to use;
  1987. # in that case it's her responsibility to have a working configuration.
  1988. # (prove might be part of a different Perl installation than perl, eg on
  1989. # MSys, so the result of AX_PROG_PERL_MODULES could be irrelevant anyway.)
  1990. if test -z "$PROVE"; then
  1991. # Test::More and Time::HiRes are supposed to be part of core Perl,
  1992. # but some distros omit them in a minimal installation.
  1993. AX_PROG_PERL_MODULES([IPC::Run Test::More=0.87 Time::HiRes], ,
  1994. [AC_MSG_ERROR([Additional Perl modules are required to run TAP tests])])
  1995. fi
  1996. # Now make sure we know where prove is
  1997. PGAC_PATH_PROGS(PROVE, prove)
  1998. if test -z "$PROVE"; then
  1999. AC_MSG_ERROR([prove not found])
  2000. fi
  2001. fi
  2002. # Thread testing
  2003. # We have to run the thread test near the end so we have all our symbols
  2004. # defined. Cross compiling throws a warning.
  2005. #
  2006. if test "$enable_thread_safety" = yes; then
  2007. if test "$PORTNAME" != "win32"
  2008. then
  2009. AC_MSG_CHECKING([thread safety of required library functions])
  2010. _CFLAGS="$CFLAGS"
  2011. _LIBS="$LIBS"
  2012. CFLAGS="$CFLAGS $PTHREAD_CFLAGS -DIN_CONFIGURE"
  2013. LIBS="$LIBS $PTHREAD_LIBS"
  2014. AC_RUN_IFELSE(
  2015. [AC_LANG_SOURCE([[#include "$srcdir/src/test/thread/thread_test.c"]])],
  2016. [AC_MSG_RESULT(yes)],
  2017. [AC_MSG_RESULT(no)
  2018. AC_MSG_ERROR([thread test program failed
  2019. This platform is not thread-safe. Check the file 'config.log' or compile
  2020. and run src/test/thread/thread_test for the exact reason.
  2021. Use --disable-thread-safety to disable thread safety.])],
  2022. [AC_MSG_RESULT(maybe)
  2023. AC_MSG_WARN([
  2024. *** Skipping thread test program because of cross-compile build.
  2025. *** Run the program in src/test/thread on the target machine.
  2026. ])])
  2027. CFLAGS="$_CFLAGS"
  2028. LIBS="$_LIBS"
  2029. else
  2030. AC_MSG_WARN([*** skipping thread test on Win32])
  2031. fi
  2032. fi
  2033. # If compiler will take -Wl,--as-needed (or various platform-specific
  2034. # spellings thereof) then add that to LDFLAGS. This is much easier than
  2035. # trying to filter LIBS to the minimum for each executable.
  2036. # On (at least) some Red-Hat-derived systems, this switch breaks linking to
  2037. # libreadline; therefore we postpone testing it until we know what library
  2038. # dependencies readline has. The test code will try to link with $LIBS.
  2039. if test "$with_readline" = yes; then
  2040. link_test_func=readline
  2041. else
  2042. link_test_func=exit
  2043. fi
  2044. if test "$PORTNAME" = "darwin"; then
  2045. PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-dead_strip_dylibs], $link_test_func)
  2046. elif test "$PORTNAME" = "openbsd"; then
  2047. PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-Bdynamic], $link_test_func)
  2048. else
  2049. PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed], $link_test_func)
  2050. fi
  2051. # Create compiler version string
  2052. if test x"$GCC" = x"yes" ; then
  2053. cc_string=`${CC} --version | sed q`
  2054. case $cc_string in [[A-Za-z]]*) ;; *) cc_string="GCC $cc_string";; esac
  2055. elif test x"$SUN_STUDIO_CC" = x"yes" ; then
  2056. cc_string=`${CC} -V 2>&1 | sed q`
  2057. else
  2058. cc_string=$CC
  2059. fi
  2060. AC_DEFINE_UNQUOTED(PG_VERSION_STR,
  2061. ["PostgreSQL $PG_VERSION on $host, compiled by $cc_string, `expr $ac_cv_sizeof_void_p \* 8`-bit"],
  2062. [A string containing the version number, platform, and C compiler])
  2063. # Supply a numeric version string for use by 3rd party add-ons
  2064. # awk -F is a regex on some platforms, and not on others, so make "." a tab
  2065. [PG_VERSION_NUM="`echo "$PACKAGE_VERSION" | sed 's/[A-Za-z].*$//' |
  2066. tr '.' ' ' |
  2067. $AWK '{printf "%d%04d", $1, $2}'`"]
  2068. AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])
  2069. AC_SUBST(PG_VERSION_NUM)
  2070. # If we are inserting PG_SYSROOT into CPPFLAGS, do so symbolically not
  2071. # literally, so that it's possible to override it at build time using
  2072. # a command like "make ... PG_SYSROOT=path". This has to be done after
  2073. # we've finished all configure checks that depend on CPPFLAGS.
  2074. if test x"$PG_SYSROOT" != x; then
  2075. CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
  2076. fi
  2077. AC_SUBST(PG_SYSROOT)
  2078. # Begin output steps
  2079. AC_MSG_NOTICE([using compiler=$cc_string])
  2080. AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
  2081. AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
  2082. AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
  2083. # Currently only used when LLVM is used
  2084. if test "$with_llvm" = yes ; then
  2085. AC_MSG_NOTICE([using CXX=$CXX])
  2086. AC_MSG_NOTICE([using CXXFLAGS=$CXXFLAGS])
  2087. AC_MSG_NOTICE([using CLANG=$CLANG])
  2088. AC_MSG_NOTICE([using BITCODE_CFLAGS=$BITCODE_CFLAGS])
  2089. AC_MSG_NOTICE([using BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS])
  2090. fi
  2091. # prepare build tree if outside source tree
  2092. # Note 1: test -ef might not exist, but it's more reliable than `pwd`.
  2093. # Note 2: /bin/pwd might be better than shell's built-in at getting
  2094. # a symlink-free name.
  2095. if ( test "$srcdir" -ef . ) >/dev/null 2>&1 || test "`cd $srcdir && /bin/pwd`" = "`/bin/pwd`"; then
  2096. vpath_build=no
  2097. else
  2098. vpath_build=yes
  2099. if test "$no_create" != yes; then
  2100. _AS_ECHO_N([preparing build tree... ])
  2101. pgac_abs_top_srcdir=`cd "$srcdir" && pwd`
  2102. $SHELL "$ac_aux_dir/prep_buildtree" "$pgac_abs_top_srcdir" "." \
  2103. || AC_MSG_ERROR(failed)
  2104. AC_MSG_RESULT(done)
  2105. fi
  2106. fi
  2107. AC_SUBST(vpath_build)
  2108. AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
  2109. AC_CONFIG_LINKS([
  2110. src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}
  2111. src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}
  2112. src/include/pg_config_os.h:src/include/port/${template}.h
  2113. src/Makefile.port:src/makefiles/Makefile.${template}
  2114. ])
  2115. if test "$PORTNAME" = "win32"; then
  2116. AC_CONFIG_COMMANDS([check_win32_symlinks],[
  2117. # Links sometimes fail undetected on Mingw -
  2118. # so here we detect it and warn the user
  2119. for FILE in $CONFIG_LINKS
  2120. do
  2121. # test -e works for symlinks in the MinGW console
  2122. test -e `expr "$FILE" : '\([[^:]]*\)'` || AC_MSG_WARN([*** link for $FILE -- please fix by hand])
  2123. done
  2124. ])
  2125. fi
  2126. AC_CONFIG_HEADERS([src/include/pg_config.h],
  2127. [
  2128. # Update timestamp for pg_config.h (see Makefile.global)
  2129. echo >src/include/stamp-h
  2130. ])
  2131. AC_CONFIG_HEADERS([src/include/pg_config_ext.h],
  2132. [
  2133. # Update timestamp for pg_config_ext.h (see Makefile.global)
  2134. echo >src/include/stamp-ext-h
  2135. ])
  2136. AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h],
  2137. [echo >src/interfaces/ecpg/include/stamp-h])
  2138. AC_OUTPUT