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 79KB

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