curl-compilers.m4 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. # SPDX-License-Identifier: curl
  22. #
  23. #***************************************************************************
  24. # File version for 'aclocal' use. Keep it a single number.
  25. # serial 67
  26. dnl CURL_CHECK_COMPILER
  27. dnl -------------------------------------------------
  28. dnl Verify if the C compiler being used is known.
  29. AC_DEFUN([CURL_CHECK_COMPILER], [
  30. #
  31. compiler_id="unknown"
  32. compiler_ver=""
  33. compiler_num="0"
  34. #
  35. flags_dbg_yes="unknown"
  36. flags_opt_all="unknown"
  37. flags_opt_yes="unknown"
  38. flags_opt_off="unknown"
  39. #
  40. flags_prefer_cppflags="no"
  41. #
  42. CURL_CHECK_COMPILER_DEC_C
  43. CURL_CHECK_COMPILER_HPUX_C
  44. CURL_CHECK_COMPILER_IBM_C
  45. CURL_CHECK_COMPILER_INTEL_C
  46. CURL_CHECK_COMPILER_CLANG
  47. CURL_CHECK_COMPILER_GNU_C
  48. case $host in
  49. mips-sgi-irix*)
  50. CURL_CHECK_COMPILER_SGI_MIPSPRO_C
  51. CURL_CHECK_COMPILER_SGI_MIPS_C
  52. ;;
  53. esac
  54. CURL_CHECK_COMPILER_SUNPRO_C
  55. CURL_CHECK_COMPILER_TINY_C
  56. #
  57. if test "$compiler_id" = "unknown"; then
  58. cat <<_EOF 1>&2
  59. ***
  60. *** Warning: This configure script does not have information about the
  61. *** compiler you are using, relative to the flags required to enable or
  62. *** disable generation of debug info, optimization options or warnings.
  63. ***
  64. *** Whatever settings are present in CFLAGS will be used for this run.
  65. ***
  66. *** If you wish to help the curl project to better support your compiler
  67. *** you can report this and the required info on the libcurl development
  68. *** mailing list: https://lists.haxx.selistinfo/curl-library/
  69. ***
  70. _EOF
  71. fi
  72. ])
  73. dnl CURL_CHECK_COMPILER_CLANG
  74. dnl -------------------------------------------------
  75. dnl Verify if compiler being used is clang.
  76. AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [
  77. AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
  78. AC_MSG_CHECKING([if compiler is clang])
  79. CURL_CHECK_DEF([__clang__], [], [silent])
  80. if test "$curl_cv_have_def___clang__" = "yes"; then
  81. AC_MSG_RESULT([yes])
  82. AC_MSG_CHECKING([if compiler is xlclang])
  83. CURL_CHECK_DEF([__ibmxl__], [], [silent])
  84. if test "$curl_cv_have_def___ibmxl__" = "yes" ; then
  85. dnl IBM's almost-compatible clang version
  86. AC_MSG_RESULT([yes])
  87. compiler_id="XLCLANG"
  88. else
  89. AC_MSG_RESULT([no])
  90. compiler_id="CLANG"
  91. fi
  92. AC_MSG_CHECKING([if compiler is Apple clang])
  93. fullclangver=`$CC -v 2>&1 | grep version`
  94. if echo $fullclangver | grep 'Apple' >/dev/null; then
  95. AC_MSG_RESULT([yes])
  96. appleclang=1
  97. compiler_id="APPLECLANG"
  98. else
  99. AC_MSG_RESULT([no])
  100. appleclang=0
  101. fi
  102. AC_MSG_CHECKING([compiler version])
  103. clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
  104. if test -z "$clangver"; then
  105. clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
  106. oldapple=0
  107. else
  108. oldapple=1
  109. fi
  110. clangvhi=`echo $clangver | cut -d . -f1`
  111. clangvlo=`echo $clangver | cut -d . -f2`
  112. compiler_ver="$clangver"
  113. compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
  114. if test "$appleclang" = '1' && test "$oldapple" = '0'; then
  115. dnl Starting with Xcode 7 / clang 3.7, Apple clang won't tell its upstream version
  116. if test "$compiler_num" -ge '1300'; then compiler_num='1200'
  117. elif test "$compiler_num" -ge '1205'; then compiler_num='1101'
  118. elif test "$compiler_num" -ge '1204'; then compiler_num='1000'
  119. elif test "$compiler_num" -ge '1107'; then compiler_num='900'
  120. elif test "$compiler_num" -ge '1103'; then compiler_num='800'
  121. elif test "$compiler_num" -ge '1003'; then compiler_num='700'
  122. elif test "$compiler_num" -ge '1001'; then compiler_num='600'
  123. elif test "$compiler_num" -ge '904'; then compiler_num='500'
  124. elif test "$compiler_num" -ge '902'; then compiler_num='400'
  125. elif test "$compiler_num" -ge '803'; then compiler_num='309'
  126. elif test "$compiler_num" -ge '703'; then compiler_num='308'
  127. else compiler_num='307'
  128. fi
  129. fi
  130. AC_MSG_RESULT([clang '$compiler_num' (raw: '$fullclangver' / '$clangver')])
  131. flags_dbg_yes="-g"
  132. flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4"
  133. flags_opt_yes="-O2"
  134. flags_opt_off="-O0"
  135. else
  136. AC_MSG_RESULT([no])
  137. fi
  138. ])
  139. dnl CURL_CHECK_COMPILER_DEC_C
  140. dnl -------------------------------------------------
  141. dnl Verify if compiler being used is DEC C.
  142. AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
  143. AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
  144. CURL_CHECK_DEF([__DECC], [], [silent])
  145. CURL_CHECK_DEF([__DECC_VER], [], [silent])
  146. if test "$curl_cv_have_def___DECC" = "yes" &&
  147. test "$curl_cv_have_def___DECC_VER" = "yes"; then
  148. AC_MSG_RESULT([yes])
  149. compiler_id="DEC_C"
  150. flags_dbg_yes="-g2"
  151. flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
  152. flags_opt_yes="-O1"
  153. flags_opt_off="-O0"
  154. else
  155. AC_MSG_RESULT([no])
  156. fi
  157. ])
  158. dnl CURL_CHECK_COMPILER_GNU_C
  159. dnl -------------------------------------------------
  160. dnl Verify if compiler being used is GNU C
  161. dnl
  162. dnl $compiler_num will be set to MAJOR * 100 + MINOR for gcc less than version
  163. dnl 7 and just $MAJOR * 100 for gcc version 7 and later.
  164. dnl
  165. dnl Examples:
  166. dnl Version 1.2.3 => 102
  167. dnl Version 2.95 => 295
  168. dnl Version 4.7 => 407
  169. dnl Version 9.2.1 => 900
  170. dnl
  171. AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
  172. AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
  173. AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl
  174. AC_MSG_CHECKING([if compiler is GNU C])
  175. CURL_CHECK_DEF([__GNUC__], [], [silent])
  176. if test "$curl_cv_have_def___GNUC__" = "yes" &&
  177. test "$compiler_id" = "unknown"; then
  178. AC_MSG_RESULT([yes])
  179. compiler_id="GNU_C"
  180. AC_MSG_CHECKING([compiler version])
  181. # strip '-suffix' parts, e.g. Ubuntu Windows cross-gcc returns '10-win32'
  182. gccver=`$CC -dumpversion | "$SED" 's/-.\{1,\}$//'`
  183. gccvhi=`echo $gccver | cut -d . -f1`
  184. if echo $gccver | grep -F '.' >/dev/null; then
  185. gccvlo=`echo $gccver | cut -d . -f2`
  186. else
  187. gccvlo="0"
  188. fi
  189. compiler_ver="$gccver"
  190. compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
  191. AC_MSG_RESULT([gcc '$compiler_num' (raw: '$gccver')])
  192. flags_dbg_yes="-g"
  193. flags_opt_all="-O -O0 -O1 -O2 -O3 -Os -Og -Ofast"
  194. flags_opt_yes="-O2"
  195. flags_opt_off="-O0"
  196. else
  197. AC_MSG_RESULT([no])
  198. fi
  199. ])
  200. dnl CURL_CHECK_COMPILER_HPUX_C
  201. dnl -------------------------------------------------
  202. dnl Verify if compiler being used is HP-UX C.
  203. AC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [
  204. AC_MSG_CHECKING([if compiler is HP-UX C])
  205. CURL_CHECK_DEF([__HP_cc], [], [silent])
  206. if test "$curl_cv_have_def___HP_cc" = "yes"; then
  207. AC_MSG_RESULT([yes])
  208. compiler_id="HP_UX_C"
  209. flags_dbg_yes="-g"
  210. flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
  211. flags_opt_yes="+O2"
  212. flags_opt_off="+O0"
  213. else
  214. AC_MSG_RESULT([no])
  215. fi
  216. ])
  217. dnl CURL_CHECK_COMPILER_IBM_C
  218. dnl -------------------------------------------------
  219. dnl Verify if compiler being used is IBM C.
  220. AC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [
  221. AC_MSG_CHECKING([if compiler is IBM C])
  222. CURL_CHECK_DEF([__IBMC__], [], [silent])
  223. if test "$curl_cv_have_def___IBMC__" = "yes"; then
  224. AC_MSG_RESULT([yes])
  225. compiler_id="IBM_C"
  226. flags_dbg_yes="-g"
  227. flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
  228. flags_opt_all="$flags_opt_all -qnooptimize"
  229. flags_opt_all="$flags_opt_all -qoptimize=0"
  230. flags_opt_all="$flags_opt_all -qoptimize=1"
  231. flags_opt_all="$flags_opt_all -qoptimize=2"
  232. flags_opt_all="$flags_opt_all -qoptimize=3"
  233. flags_opt_all="$flags_opt_all -qoptimize=4"
  234. flags_opt_all="$flags_opt_all -qoptimize=5"
  235. flags_opt_yes="-O2"
  236. flags_opt_off="-qnooptimize"
  237. flags_prefer_cppflags="yes"
  238. else
  239. AC_MSG_RESULT([no])
  240. fi
  241. ])
  242. dnl CURL_CHECK_COMPILER_INTEL_C
  243. dnl -------------------------------------------------
  244. dnl Verify if compiler being used is Intel C.
  245. AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
  246. AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
  247. AC_MSG_CHECKING([if compiler is Intel C])
  248. CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
  249. if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
  250. AC_MSG_RESULT([yes])
  251. AC_MSG_CHECKING([compiler version])
  252. compiler_num="$curl_cv_def___INTEL_COMPILER"
  253. compiler_ver=`echo "$compiler_num" | cut -c -2 | $SED 's/^0//'`.`echo "$compiler_num" | cut -c 3-4 | $SED 's/^0//'`
  254. AC_MSG_RESULT([Intel C '$compiler_num'])
  255. CURL_CHECK_DEF([__unix__], [], [silent])
  256. if test "$curl_cv_have_def___unix__" = "yes"; then
  257. compiler_id="INTEL_UNIX_C"
  258. flags_dbg_yes="-g"
  259. flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
  260. flags_opt_yes="-O2"
  261. flags_opt_off="-O0"
  262. else
  263. compiler_id="INTEL_WINDOWS_C"
  264. flags_dbg_yes="/Zi /Oy-"
  265. flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
  266. flags_opt_yes="/O2"
  267. flags_opt_off="/Od"
  268. fi
  269. else
  270. AC_MSG_RESULT([no])
  271. fi
  272. ])
  273. dnl CURL_CHECK_COMPILER_SGI_MIPS_C
  274. dnl -------------------------------------------------
  275. dnl Verify if compiler being used is SGI MIPS C.
  276. AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
  277. AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
  278. AC_MSG_CHECKING([if compiler is SGI MIPS C])
  279. CURL_CHECK_DEF([__GNUC__], [], [silent])
  280. CURL_CHECK_DEF([__sgi], [], [silent])
  281. if test "$curl_cv_have_def___GNUC__" = "no" &&
  282. test "$curl_cv_have_def___sgi" = "yes" &&
  283. test "$compiler_id" = "unknown"; then
  284. AC_MSG_RESULT([yes])
  285. compiler_id="SGI_MIPS_C"
  286. flags_dbg_yes="-g"
  287. flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
  288. flags_opt_yes="-O2"
  289. flags_opt_off="-O0"
  290. else
  291. AC_MSG_RESULT([no])
  292. fi
  293. ])
  294. dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
  295. dnl -------------------------------------------------
  296. dnl Verify if compiler being used is SGI MIPSpro C.
  297. AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
  298. AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
  299. AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
  300. CURL_CHECK_DEF([__GNUC__], [], [silent])
  301. CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
  302. CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
  303. if test "$curl_cv_have_def___GNUC__" = "no" &&
  304. (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
  305. test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
  306. AC_MSG_RESULT([yes])
  307. compiler_id="SGI_MIPSPRO_C"
  308. flags_dbg_yes="-g"
  309. flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
  310. flags_opt_yes="-O2"
  311. flags_opt_off="-O0"
  312. else
  313. AC_MSG_RESULT([no])
  314. fi
  315. ])
  316. dnl CURL_CHECK_COMPILER_SUNPRO_C
  317. dnl -------------------------------------------------
  318. dnl Verify if compiler being used is SunPro C.
  319. AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
  320. AC_MSG_CHECKING([if compiler is SunPro C])
  321. CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
  322. if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
  323. AC_MSG_RESULT([yes])
  324. compiler_id="SUNPRO_C"
  325. flags_dbg_yes="-g"
  326. flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
  327. flags_opt_yes="-xO2"
  328. flags_opt_off=""
  329. else
  330. AC_MSG_RESULT([no])
  331. fi
  332. ])
  333. dnl CURL_CHECK_COMPILER_TINY_C
  334. dnl -------------------------------------------------
  335. dnl Verify if compiler being used is Tiny C.
  336. AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
  337. AC_MSG_CHECKING([if compiler is Tiny C])
  338. CURL_CHECK_DEF([__TINYC__], [], [silent])
  339. if test "$curl_cv_have_def___TINYC__" = "yes"; then
  340. AC_MSG_RESULT([yes])
  341. compiler_id="TINY_C"
  342. flags_dbg_yes="-g"
  343. flags_opt_all=""
  344. flags_opt_yes=""
  345. flags_opt_off=""
  346. else
  347. AC_MSG_RESULT([no])
  348. fi
  349. ])
  350. dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
  351. dnl -------------------------------------------------
  352. dnl Changes standard include paths present in CFLAGS
  353. dnl and CPPFLAGS into isystem include paths. This is
  354. dnl done to prevent GNUC from generating warnings on
  355. dnl headers from these locations, although on ancient
  356. dnl GNUC versions these warnings are not silenced.
  357. AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
  358. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  359. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  360. AC_MSG_CHECKING([convert -I options to -isystem])
  361. if test "$compiler_id" = "GNU_C" ||
  362. test "$compiler_id" = "CLANG" -o "$compiler_id" = "APPLECLANG"; then
  363. AC_MSG_RESULT([yes])
  364. tmp_has_include="no"
  365. tmp_chg_FLAGS="$CFLAGS"
  366. for word1 in $tmp_chg_FLAGS; do
  367. case "$word1" in
  368. -I*)
  369. tmp_has_include="yes"
  370. ;;
  371. esac
  372. done
  373. if test "$tmp_has_include" = "yes"; then
  374. tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
  375. tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
  376. CFLAGS="$tmp_chg_FLAGS"
  377. squeeze CFLAGS
  378. fi
  379. tmp_has_include="no"
  380. tmp_chg_FLAGS="$CPPFLAGS"
  381. for word1 in $tmp_chg_FLAGS; do
  382. case "$word1" in
  383. -I*)
  384. tmp_has_include="yes"
  385. ;;
  386. esac
  387. done
  388. if test "$tmp_has_include" = "yes"; then
  389. tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
  390. tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
  391. CPPFLAGS="$tmp_chg_FLAGS"
  392. squeeze CPPFLAGS
  393. fi
  394. else
  395. AC_MSG_RESULT([no])
  396. fi
  397. ])
  398. dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
  399. dnl -------------------------------------------------
  400. dnl Verify if the C compiler seems to work with the
  401. dnl settings that are 'active' at the time the test
  402. dnl is performed.
  403. AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
  404. dnl compilation capability verification
  405. tmp_compiler_works="unknown"
  406. AC_COMPILE_IFELSE([
  407. AC_LANG_PROGRAM([[
  408. ]],[[
  409. int i = 1;
  410. return i;
  411. ]])
  412. ],[
  413. tmp_compiler_works="yes"
  414. ],[
  415. tmp_compiler_works="no"
  416. echo " " >&6
  417. sed 's/^/cc-fail: /' conftest.err >&6
  418. echo " " >&6
  419. ])
  420. dnl linking capability verification
  421. if test "$tmp_compiler_works" = "yes"; then
  422. AC_LINK_IFELSE([
  423. AC_LANG_PROGRAM([[
  424. ]],[[
  425. int i = 1;
  426. return i;
  427. ]])
  428. ],[
  429. tmp_compiler_works="yes"
  430. ],[
  431. tmp_compiler_works="no"
  432. echo " " >&6
  433. sed 's/^/link-fail: /' conftest.err >&6
  434. echo " " >&6
  435. ])
  436. fi
  437. dnl only do runtime verification when not cross-compiling
  438. if test "x$cross_compiling" != "xyes" &&
  439. test "$tmp_compiler_works" = "yes"; then
  440. CURL_RUN_IFELSE([
  441. AC_LANG_PROGRAM([[
  442. #ifdef __STDC__
  443. # include <stdlib.h>
  444. #endif
  445. ]],[[
  446. int i = 0;
  447. exit(i);
  448. ]])
  449. ],[
  450. tmp_compiler_works="yes"
  451. ],[
  452. tmp_compiler_works="no"
  453. echo " " >&6
  454. echo "run-fail: test program exited with status $ac_status" >&6
  455. echo " " >&6
  456. ])
  457. fi
  458. dnl branch upon test result
  459. if test "$tmp_compiler_works" = "yes"; then
  460. ifelse($1,,:,[$1])
  461. ifelse($2,,,[else
  462. $2])
  463. fi
  464. ])
  465. dnl CURL_SET_COMPILER_BASIC_OPTS
  466. dnl -------------------------------------------------
  467. dnl Sets compiler specific options/flags which do not
  468. dnl depend on configure's debug, optimize or warnings
  469. dnl options.
  470. AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
  471. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  472. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  473. #
  474. if test "$compiler_id" != "unknown"; then
  475. #
  476. tmp_save_CPPFLAGS="$CPPFLAGS"
  477. tmp_save_CFLAGS="$CFLAGS"
  478. tmp_CPPFLAGS=""
  479. tmp_CFLAGS=""
  480. #
  481. case "$compiler_id" in
  482. #
  483. CLANG|APPLECLANG)
  484. #
  485. dnl Disable warnings for unused arguments, otherwise clang will
  486. dnl warn about compile-time arguments used during link-time, like
  487. dnl -O and -g and -pedantic.
  488. tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
  489. tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration"
  490. ;;
  491. #
  492. DEC_C)
  493. #
  494. dnl Select strict ANSI C compiler mode
  495. tmp_CFLAGS="$tmp_CFLAGS -std1"
  496. dnl Turn off optimizer ANSI C aliasing rules
  497. tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
  498. dnl Generate warnings for missing function prototypes
  499. tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
  500. dnl Change some warnings into fatal errors
  501. tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
  502. ;;
  503. #
  504. GNU_C)
  505. #
  506. dnl turn implicit-function-declaration warning into error,
  507. dnl at least gcc 2.95 and later support this
  508. if test "$compiler_num" -ge "295"; then
  509. tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration"
  510. fi
  511. ;;
  512. #
  513. HP_UX_C)
  514. #
  515. dnl Disallow run-time dereferencing of null pointers
  516. tmp_CFLAGS="$tmp_CFLAGS -z"
  517. dnl Disable some remarks
  518. dnl #4227: padding struct with n bytes to align member
  519. dnl #4255: padding size of struct with n bytes to alignment boundary
  520. tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
  521. ;;
  522. #
  523. IBM_C)
  524. #
  525. dnl Ensure that compiler optimizations are always thread-safe.
  526. tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
  527. dnl Disable type based strict aliasing optimizations, using worst
  528. dnl case aliasing assumptions when compiling. Type based aliasing
  529. dnl would restrict the lvalues that could be safely used to access
  530. dnl a data object.
  531. tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
  532. dnl Force compiler to stop after the compilation phase, without
  533. dnl generating an object code file when compilation has errors.
  534. tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
  535. ;;
  536. #
  537. INTEL_UNIX_C)
  538. #
  539. dnl On Unix this compiler uses gcc's header files, so
  540. dnl we select ANSI C89 dialect plus GNU extensions.
  541. tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
  542. dnl Change some warnings into errors
  543. dnl #140: too many arguments in function call
  544. dnl #147: declaration is incompatible with 'previous one'
  545. dnl #165: too few arguments in function call
  546. dnl #266: function declared implicitly
  547. tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-error 140,147,165,266"
  548. dnl Disable some remarks
  549. dnl #279: controlling expression is constant
  550. dnl #981: operands are evaluated in unspecified order
  551. dnl #1025: zero extending result of unary operation
  552. dnl #1469: "cc" clobber ignored
  553. dnl #2259: non-pointer conversion from X to Y may lose significant bits
  554. tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-disable 279,981,1025,1469,2259"
  555. ;;
  556. #
  557. INTEL_WINDOWS_C)
  558. #
  559. dnl Placeholder
  560. tmp_CFLAGS="$tmp_CFLAGS"
  561. ;;
  562. #
  563. SGI_MIPS_C)
  564. #
  565. dnl Placeholder
  566. tmp_CFLAGS="$tmp_CFLAGS"
  567. ;;
  568. #
  569. SGI_MIPSPRO_C)
  570. #
  571. dnl Placeholder
  572. tmp_CFLAGS="$tmp_CFLAGS"
  573. ;;
  574. #
  575. SUNPRO_C)
  576. #
  577. dnl Placeholder
  578. tmp_CFLAGS="$tmp_CFLAGS"
  579. ;;
  580. #
  581. TINY_C)
  582. #
  583. dnl Placeholder
  584. tmp_CFLAGS="$tmp_CFLAGS"
  585. ;;
  586. #
  587. esac
  588. #
  589. squeeze tmp_CPPFLAGS
  590. squeeze tmp_CFLAGS
  591. #
  592. if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
  593. AC_MSG_CHECKING([if compiler accepts some basic options])
  594. CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
  595. CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
  596. squeeze CPPFLAGS
  597. squeeze CFLAGS
  598. CURL_COMPILER_WORKS_IFELSE([
  599. AC_MSG_RESULT([yes])
  600. AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
  601. ],[
  602. AC_MSG_RESULT([no])
  603. AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
  604. dnl restore initial settings
  605. CPPFLAGS="$tmp_save_CPPFLAGS"
  606. CFLAGS="$tmp_save_CFLAGS"
  607. ])
  608. fi
  609. #
  610. fi
  611. ])
  612. dnl CURL_SET_COMPILER_DEBUG_OPTS
  613. dnl -------------------------------------------------
  614. dnl Sets compiler specific options/flags which depend
  615. dnl on configure's debug option.
  616. AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
  617. AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
  618. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  619. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  620. #
  621. if test "$compiler_id" != "unknown"; then
  622. #
  623. tmp_save_CFLAGS="$CFLAGS"
  624. tmp_save_CPPFLAGS="$CPPFLAGS"
  625. #
  626. tmp_options=""
  627. tmp_CFLAGS="$CFLAGS"
  628. tmp_CPPFLAGS="$CPPFLAGS"
  629. #
  630. if test "$want_debug" = "yes"; then
  631. AC_MSG_CHECKING([if compiler accepts debug enabling options])
  632. tmp_options="$flags_dbg_yes"
  633. fi
  634. #
  635. if test "$flags_prefer_cppflags" = "yes"; then
  636. CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
  637. CFLAGS="$tmp_CFLAGS"
  638. else
  639. CPPFLAGS="$tmp_CPPFLAGS"
  640. CFLAGS="$tmp_CFLAGS $tmp_options"
  641. fi
  642. squeeze CPPFLAGS
  643. squeeze CFLAGS
  644. fi
  645. ])
  646. dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
  647. dnl -------------------------------------------------
  648. dnl Sets compiler specific options/flags which depend
  649. dnl on configure's optimize option.
  650. AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
  651. AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
  652. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  653. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  654. #
  655. if test "$compiler_id" != "unknown"; then
  656. #
  657. tmp_save_CFLAGS="$CFLAGS"
  658. tmp_save_CPPFLAGS="$CPPFLAGS"
  659. #
  660. tmp_options=""
  661. tmp_CFLAGS="$CFLAGS"
  662. tmp_CPPFLAGS="$CPPFLAGS"
  663. honor_optimize_option="yes"
  664. #
  665. dnl If optimization request setting has not been explicitly specified,
  666. dnl it has been derived from the debug setting and initially assumed.
  667. dnl This initially assumed optimizer setting will finally be ignored
  668. dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
  669. dnl that an initially assumed optimizer setting might not be honored.
  670. #
  671. if test "$want_optimize" = "assume_no" ||
  672. test "$want_optimize" = "assume_yes"; then
  673. AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
  674. CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
  675. honor_optimize_option="no"
  676. ])
  677. CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
  678. honor_optimize_option="no"
  679. ])
  680. AC_MSG_RESULT([$honor_optimize_option])
  681. if test "$honor_optimize_option" = "yes"; then
  682. if test "$want_optimize" = "assume_yes"; then
  683. want_optimize="yes"
  684. fi
  685. if test "$want_optimize" = "assume_no"; then
  686. want_optimize="no"
  687. fi
  688. fi
  689. fi
  690. #
  691. if test "$honor_optimize_option" = "yes"; then
  692. CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
  693. CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
  694. if test "$want_optimize" = "yes"; then
  695. AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
  696. tmp_options="$flags_opt_yes"
  697. fi
  698. if test "$want_optimize" = "no"; then
  699. AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
  700. tmp_options="$flags_opt_off"
  701. fi
  702. if test "$flags_prefer_cppflags" = "yes"; then
  703. CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
  704. CFLAGS="$tmp_CFLAGS"
  705. else
  706. CPPFLAGS="$tmp_CPPFLAGS"
  707. CFLAGS="$tmp_CFLAGS $tmp_options"
  708. fi
  709. squeeze CPPFLAGS
  710. squeeze CFLAGS
  711. CURL_COMPILER_WORKS_IFELSE([
  712. AC_MSG_RESULT([yes])
  713. AC_MSG_NOTICE([compiler options added: $tmp_options])
  714. ],[
  715. AC_MSG_RESULT([no])
  716. AC_MSG_WARN([compiler options rejected: $tmp_options])
  717. dnl restore initial settings
  718. CPPFLAGS="$tmp_save_CPPFLAGS"
  719. CFLAGS="$tmp_save_CFLAGS"
  720. ])
  721. fi
  722. #
  723. fi
  724. ])
  725. dnl CURL_SET_COMPILER_WARNING_OPTS
  726. dnl -------------------------------------------------
  727. dnl Sets compiler options/flags which depend on
  728. dnl configure's warnings given option.
  729. AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
  730. AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
  731. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  732. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  733. #
  734. if test "$compiler_id" != "unknown"; then
  735. #
  736. tmp_save_CPPFLAGS="$CPPFLAGS"
  737. tmp_save_CFLAGS="$CFLAGS"
  738. tmp_CPPFLAGS=""
  739. tmp_CFLAGS=""
  740. #
  741. case "$compiler_id" in
  742. #
  743. CLANG|APPLECLANG)
  744. #
  745. if test "$want_warnings" = "yes"; then
  746. tmp_CFLAGS="$tmp_CFLAGS -pedantic"
  747. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra])
  748. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
  749. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow])
  750. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
  751. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
  752. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
  753. tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
  754. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
  755. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
  756. tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
  757. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
  758. tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
  759. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
  760. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
  761. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
  762. tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
  763. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
  764. #
  765. dnl Only clang 1.1 or later
  766. if test "$compiler_num" -ge "101"; then
  767. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
  768. fi
  769. #
  770. dnl Only clang 2.7 or later
  771. if test "$compiler_num" -ge "207"; then
  772. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [address])
  773. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [attributes])
  774. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
  775. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
  776. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [div-by-zero format-security])
  777. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [empty-body])
  778. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-field-initializers])
  779. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-noreturn])
  780. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
  781. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [redundant-decls])
  782. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [switch-enum]) # Not used because this basically disallows default case
  783. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits])
  784. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-macros]) # Not practical
  785. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code unused-parameter])
  786. fi
  787. #
  788. dnl Only clang 2.8 or later
  789. if test "$compiler_num" -ge "208"; then
  790. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [ignored-qualifiers])
  791. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
  792. fi
  793. #
  794. dnl Only clang 2.9 or later
  795. if test "$compiler_num" -ge "209"; then
  796. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion])
  797. tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME
  798. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
  799. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs
  800. fi
  801. #
  802. dnl Only clang 3.0 or later
  803. if test "$compiler_num" -ge "300"; then
  804. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [language-extension-token])
  805. tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
  806. fi
  807. #
  808. dnl Only clang 3.2 or later
  809. if test "$compiler_num" -ge "302"; then
  810. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
  811. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sometimes-uninitialized])
  812. case $host_os in
  813. cygwin* | mingw*)
  814. dnl skip missing-variable-declarations warnings for Cygwin and
  815. dnl MinGW because the libtool wrapper executable causes them
  816. ;;
  817. *)
  818. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
  819. ;;
  820. esac
  821. fi
  822. #
  823. dnl Only clang 3.4 or later
  824. if test "$compiler_num" -ge "304"; then
  825. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [header-guard])
  826. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
  827. fi
  828. #
  829. dnl Only clang 3.5 or later
  830. if test "$compiler_num" -ge "305"; then
  831. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pragmas])
  832. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code-break]) # Not used: Silent in "unity" builds
  833. fi
  834. #
  835. dnl Only clang 3.6 or later
  836. if test "$compiler_num" -ge "306"; then
  837. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
  838. fi
  839. #
  840. dnl Only clang 3.9 or later
  841. if test "$compiler_num" -ge "309"; then
  842. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma])
  843. # avoid the varargs warning, fixed in 4.0
  844. # https://bugs.llvm.org/show_bug.cgi?id=29140
  845. if test "$compiler_num" -lt "400"; then
  846. tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
  847. fi
  848. fi
  849. dnl clang 7 or later
  850. if test "$compiler_num" -ge "700"; then
  851. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
  852. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
  853. fi
  854. dnl clang 10 or later
  855. if test "$compiler_num" -ge "1000"; then
  856. tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough" # we have silencing markup for clang 10.0 and above only
  857. fi
  858. fi
  859. ;;
  860. #
  861. DEC_C)
  862. #
  863. if test "$want_warnings" = "yes"; then
  864. dnl Select a higher warning level than default level2
  865. tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
  866. fi
  867. ;;
  868. #
  869. GNU_C)
  870. #
  871. if test "$want_warnings" = "yes"; then
  872. #
  873. dnl Do not enable -pedantic when cross-compiling with a gcc older
  874. dnl than 3.0, to avoid warnings from third party system headers.
  875. if test "x$cross_compiling" != "xyes" ||
  876. test "$compiler_num" -ge "300"; then
  877. tmp_CFLAGS="$tmp_CFLAGS -pedantic"
  878. fi
  879. #
  880. dnl Set of options we believe *ALL* gcc versions support:
  881. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
  882. tmp_CFLAGS="$tmp_CFLAGS -W"
  883. #
  884. dnl Only gcc 1.4 or later
  885. if test "$compiler_num" -ge "104"; then
  886. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
  887. dnl If not cross-compiling with a gcc older than 3.0
  888. if test "x$cross_compiling" != "xyes" ||
  889. test "$compiler_num" -ge "300"; then
  890. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow])
  891. fi
  892. fi
  893. #
  894. dnl Only gcc 2.7 or later
  895. if test "$compiler_num" -ge "207"; then
  896. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
  897. dnl If not cross-compiling with a gcc older than 3.0
  898. if test "x$cross_compiling" != "xyes" ||
  899. test "$compiler_num" -ge "300"; then
  900. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
  901. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
  902. fi
  903. fi
  904. #
  905. dnl Only gcc 2.95 or later
  906. if test "$compiler_num" -ge "295"; then
  907. tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
  908. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
  909. fi
  910. #
  911. dnl Only gcc 2.96 or later
  912. if test "$compiler_num" -ge "296"; then
  913. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
  914. tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
  915. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
  916. dnl -Wundef used only if gcc is 2.96 or later since we get
  917. dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
  918. dnl headers with gcc 2.95.4 on FreeBSD 4.9
  919. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
  920. fi
  921. #
  922. dnl Only gcc 2.97 or later
  923. if test "$compiler_num" -ge "297"; then
  924. tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
  925. fi
  926. #
  927. dnl Only gcc 3.0 or later
  928. if test "$compiler_num" -ge "300"; then
  929. dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
  930. dnl on i686-Linux as it gives us heaps with false positives.
  931. dnl Also, on gcc 4.0.X it is totally unbearable and complains all
  932. dnl over making it unusable for generic purposes. Let's not use it.
  933. tmp_CFLAGS="$tmp_CFLAGS"
  934. fi
  935. #
  936. dnl Only gcc 3.3 or later
  937. if test "$compiler_num" -ge "303"; then
  938. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
  939. fi
  940. #
  941. dnl Only gcc 3.4 or later
  942. if test "$compiler_num" -ge "304"; then
  943. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
  944. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
  945. fi
  946. #
  947. dnl Only gcc 4.0 or later
  948. if test "$compiler_num" -ge "400"; then
  949. tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
  950. fi
  951. #
  952. dnl Only gcc 4.1 or later
  953. if test "$compiler_num" -ge "401"; then
  954. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [attributes])
  955. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [div-by-zero format-security])
  956. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-field-initializers])
  957. case $host in
  958. *-*-msys*)
  959. ;;
  960. *)
  961. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-noreturn]) # Seen to clash with libtool-generated stub code
  962. ;;
  963. esac
  964. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code unused-parameter])
  965. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs
  966. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pragmas])
  967. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [redundant-decls])
  968. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [switch-enum]) # Not used because this basically disallows default case
  969. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-macros]) # Not practical
  970. fi
  971. #
  972. dnl Only gcc 4.2 or later
  973. if test "$compiler_num" -ge "402"; then
  974. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
  975. fi
  976. #
  977. dnl Only gcc 4.3 or later
  978. if test "$compiler_num" -ge "403"; then
  979. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [address])
  980. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
  981. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
  982. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
  983. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion trampolines])
  984. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion])
  985. tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME
  986. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
  987. dnl required for -Warray-bounds, included in -Wall
  988. tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
  989. fi
  990. #
  991. dnl Only gcc 4.5 or later
  992. if test "$compiler_num" -ge "405"; then
  993. dnl Only Windows targets
  994. if test "$curl_cv_native_windows" = "yes"; then
  995. tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
  996. fi
  997. fi
  998. #
  999. dnl Only gcc 4.6 or later
  1000. if test "$compiler_num" -ge "406"; then
  1001. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
  1002. fi
  1003. #
  1004. dnl only gcc 4.8 or later
  1005. if test "$compiler_num" -ge "408"; then
  1006. tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
  1007. fi
  1008. #
  1009. dnl Only gcc 5 or later
  1010. if test "$compiler_num" -ge "500"; then
  1011. tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2"
  1012. fi
  1013. #
  1014. dnl Only gcc 6 or later
  1015. if test "$compiler_num" -ge "600"; then
  1016. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
  1017. tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
  1018. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference])
  1019. tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks"
  1020. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond])
  1021. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
  1022. fi
  1023. #
  1024. dnl Only gcc 7 or later
  1025. if test "$compiler_num" -ge "700"; then
  1026. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
  1027. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
  1028. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
  1029. tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2"
  1030. tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough"
  1031. fi
  1032. #
  1033. dnl Only gcc 10 or later
  1034. if test "$compiler_num" -ge "1000"; then
  1035. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion])
  1036. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
  1037. fi
  1038. #
  1039. fi
  1040. #
  1041. dnl Do not issue warnings for code in system include paths.
  1042. if test "$compiler_num" -ge "300"; then
  1043. tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
  1044. else
  1045. dnl When cross-compiling with a gcc older than 3.0, disable
  1046. dnl some warnings triggered on third party system headers.
  1047. if test "x$cross_compiling" = "xyes"; then
  1048. if test "$compiler_num" -ge "104"; then
  1049. dnl gcc 1.4 or later
  1050. tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
  1051. fi
  1052. if test "$compiler_num" -ge "207"; then
  1053. dnl gcc 2.7 or later
  1054. tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
  1055. tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
  1056. fi
  1057. fi
  1058. fi
  1059. ;;
  1060. #
  1061. HP_UX_C)
  1062. #
  1063. if test "$want_warnings" = "yes"; then
  1064. dnl Issue all warnings
  1065. tmp_CFLAGS="$tmp_CFLAGS +w1"
  1066. fi
  1067. ;;
  1068. #
  1069. IBM_C)
  1070. #
  1071. dnl Placeholder
  1072. tmp_CFLAGS="$tmp_CFLAGS"
  1073. ;;
  1074. #
  1075. INTEL_UNIX_C)
  1076. #
  1077. if test "$want_warnings" = "yes"; then
  1078. if test "$compiler_num" -gt "600"; then
  1079. dnl Show errors, warnings, and remarks
  1080. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
  1081. dnl Perform extra compile-time code checking
  1082. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
  1083. dnl Warn on nested comments
  1084. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
  1085. dnl Show warnings relative to deprecated features
  1086. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
  1087. dnl Enable warnings for missing prototypes
  1088. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
  1089. dnl Enable warnings for 64-bit portability issues
  1090. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
  1091. dnl Enable warnings for questionable pointer arithmetic
  1092. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
  1093. dnl Check for function return typw issues
  1094. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
  1095. dnl Warn on variable declarations hiding a previous one
  1096. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
  1097. dnl Warn when a variable is used before initialized
  1098. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
  1099. dnl Warn if a declared function is not used
  1100. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
  1101. fi
  1102. fi
  1103. dnl Disable using EBP register in optimizations
  1104. tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
  1105. dnl Disable use of ANSI C aliasing rules in optimizations
  1106. tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
  1107. dnl Value-safe optimizations on floating-point data
  1108. tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
  1109. ;;
  1110. #
  1111. INTEL_WINDOWS_C)
  1112. #
  1113. dnl Placeholder
  1114. tmp_CFLAGS="$tmp_CFLAGS"
  1115. ;;
  1116. #
  1117. SGI_MIPS_C)
  1118. #
  1119. if test "$want_warnings" = "yes"; then
  1120. dnl Perform stricter semantic and lint-like checks
  1121. tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
  1122. fi
  1123. ;;
  1124. #
  1125. SGI_MIPSPRO_C)
  1126. #
  1127. if test "$want_warnings" = "yes"; then
  1128. dnl Perform stricter semantic and lint-like checks
  1129. tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
  1130. dnl Disable some remarks
  1131. dnl #1209: controlling expression is constant
  1132. tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
  1133. fi
  1134. ;;
  1135. #
  1136. SUNPRO_C)
  1137. #
  1138. if test "$want_warnings" = "yes"; then
  1139. dnl Perform stricter semantic and lint-like checks
  1140. tmp_CFLAGS="$tmp_CFLAGS -v"
  1141. fi
  1142. ;;
  1143. #
  1144. TINY_C)
  1145. #
  1146. if test "$want_warnings" = "yes"; then
  1147. dnl Activate all warnings
  1148. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
  1149. dnl Make string constants be of type const char *
  1150. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [write-strings])
  1151. dnl Warn use of unsupported GCC features ignored by TCC
  1152. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unsupported])
  1153. fi
  1154. ;;
  1155. #
  1156. esac
  1157. #
  1158. squeeze tmp_CPPFLAGS
  1159. squeeze tmp_CFLAGS
  1160. #
  1161. if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
  1162. AC_MSG_CHECKING([if compiler accepts strict warning options])
  1163. CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
  1164. CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
  1165. squeeze CPPFLAGS
  1166. squeeze CFLAGS
  1167. CURL_COMPILER_WORKS_IFELSE([
  1168. AC_MSG_RESULT([yes])
  1169. AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
  1170. ],[
  1171. AC_MSG_RESULT([no])
  1172. AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
  1173. dnl restore initial settings
  1174. CPPFLAGS="$tmp_save_CPPFLAGS"
  1175. CFLAGS="$tmp_save_CFLAGS"
  1176. ])
  1177. fi
  1178. #
  1179. fi
  1180. ])
  1181. dnl CURL_SHFUNC_SQUEEZE
  1182. dnl -------------------------------------------------
  1183. dnl Declares a shell function squeeze() which removes
  1184. dnl redundant whitespace out of a shell variable.
  1185. AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
  1186. squeeze() {
  1187. _sqz_result=""
  1188. eval _sqz_input=\[$][$]1
  1189. for _sqz_token in $_sqz_input; do
  1190. if test -z "$_sqz_result"; then
  1191. _sqz_result="$_sqz_token"
  1192. else
  1193. _sqz_result="$_sqz_result $_sqz_token"
  1194. fi
  1195. done
  1196. eval [$]1=\$_sqz_result
  1197. return 0
  1198. }
  1199. ])
  1200. dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
  1201. dnl -------------------------------------------------
  1202. dnl Verifies if the compiler actually halts after the
  1203. dnl compilation phase without generating any object
  1204. dnl code file, when the source compiles with errors.
  1205. AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
  1206. AC_MSG_CHECKING([if compiler halts on compilation errors])
  1207. AC_COMPILE_IFELSE([
  1208. AC_LANG_PROGRAM([[
  1209. ]],[[
  1210. #error force compilation error
  1211. ]])
  1212. ],[
  1213. AC_MSG_RESULT([no])
  1214. AC_MSG_ERROR([compiler does not halt on compilation errors.])
  1215. ],[
  1216. AC_MSG_RESULT([yes])
  1217. ])
  1218. ])
  1219. dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
  1220. dnl -------------------------------------------------
  1221. dnl Verifies if the compiler actually halts after the
  1222. dnl compilation phase without generating any object
  1223. dnl code file, when the source code tries to define a
  1224. dnl type for a constant array with negative dimension.
  1225. AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
  1226. AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
  1227. AC_MSG_CHECKING([if compiler halts on negative sized arrays])
  1228. AC_COMPILE_IFELSE([
  1229. AC_LANG_PROGRAM([[
  1230. typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
  1231. ]],[[
  1232. bad_t dummy;
  1233. ]])
  1234. ],[
  1235. AC_MSG_RESULT([no])
  1236. AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
  1237. ],[
  1238. AC_MSG_RESULT([yes])
  1239. ])
  1240. ])
  1241. dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
  1242. dnl -------------------------------------------------
  1243. dnl Verifies if the compiler is capable of handling the
  1244. dnl size of a struct member, struct which is a function
  1245. dnl result, as a compilation-time condition inside the
  1246. dnl type definition of a constant array.
  1247. AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
  1248. AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
  1249. AC_MSG_CHECKING([if compiler struct member size checking works])
  1250. tst_compiler_check_one_works="unknown"
  1251. AC_COMPILE_IFELSE([
  1252. AC_LANG_PROGRAM([[
  1253. struct mystruct {
  1254. int mi;
  1255. char mc;
  1256. struct mystruct *next;
  1257. };
  1258. struct mystruct myfunc();
  1259. typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
  1260. typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
  1261. ]],[[
  1262. good_t1 dummy1;
  1263. good_t2 dummy2;
  1264. ]])
  1265. ],[
  1266. tst_compiler_check_one_works="yes"
  1267. ],[
  1268. tst_compiler_check_one_works="no"
  1269. sed 's/^/cc-src: /' conftest.$ac_ext >&6
  1270. sed 's/^/cc-err: /' conftest.err >&6
  1271. ])
  1272. tst_compiler_check_two_works="unknown"
  1273. AC_COMPILE_IFELSE([
  1274. AC_LANG_PROGRAM([[
  1275. struct mystruct {
  1276. int mi;
  1277. char mc;
  1278. struct mystruct *next;
  1279. };
  1280. struct mystruct myfunc();
  1281. typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
  1282. typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
  1283. ]],[[
  1284. bad_t1 dummy1;
  1285. bad_t2 dummy2;
  1286. ]])
  1287. ],[
  1288. tst_compiler_check_two_works="no"
  1289. ],[
  1290. tst_compiler_check_two_works="yes"
  1291. ])
  1292. if test "$tst_compiler_check_one_works" = "yes" &&
  1293. test "$tst_compiler_check_two_works" = "yes"; then
  1294. AC_MSG_RESULT([yes])
  1295. else
  1296. AC_MSG_RESULT([no])
  1297. AC_MSG_ERROR([compiler fails struct member size checking.])
  1298. fi
  1299. ])
  1300. dnl CURL_CHECK_COMPILER_SYMBOL_HIDING
  1301. dnl -------------------------------------------------
  1302. dnl Verify if compiler supports hiding library internal symbols, setting
  1303. dnl shell variable supports_symbol_hiding value as appropriate, as well as
  1304. dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported.
  1305. AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
  1306. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  1307. AC_BEFORE([$0],[CURL_CONFIGURE_SYMBOL_HIDING])dnl
  1308. AC_MSG_CHECKING([if compiler supports hiding library internal symbols])
  1309. supports_symbol_hiding="no"
  1310. symbol_hiding_CFLAGS=""
  1311. symbol_hiding_EXTERN=""
  1312. tmp_CFLAGS=""
  1313. tmp_EXTERN=""
  1314. case "$compiler_id" in
  1315. CLANG|APPLECLANG)
  1316. dnl All versions of clang support -fvisibility=
  1317. tmp_EXTERN="__attribute__((__visibility__(\"default\")))"
  1318. tmp_CFLAGS="-fvisibility=hidden"
  1319. supports_symbol_hiding="yes"
  1320. ;;
  1321. GNU_C)
  1322. dnl Only gcc 3.4 or later
  1323. if test "$compiler_num" -ge "304"; then
  1324. if $CC --help --verbose 2>/dev/null | grep fvisibility= >/dev/null ; then
  1325. tmp_EXTERN="__attribute__((__visibility__(\"default\")))"
  1326. tmp_CFLAGS="-fvisibility=hidden"
  1327. supports_symbol_hiding="yes"
  1328. fi
  1329. fi
  1330. ;;
  1331. INTEL_UNIX_C)
  1332. dnl Only icc 9.0 or later
  1333. if test "$compiler_num" -ge "900"; then
  1334. if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
  1335. tmp_save_CFLAGS="$CFLAGS"
  1336. CFLAGS="$CFLAGS -fvisibility=hidden"
  1337. AC_LINK_IFELSE([
  1338. AC_LANG_PROGRAM([[
  1339. #include <stdio.h>
  1340. ]],[[
  1341. printf("icc fvisibility bug test");
  1342. ]])
  1343. ],[
  1344. tmp_EXTERN="__attribute__((__visibility__(\"default\")))"
  1345. tmp_CFLAGS="-fvisibility=hidden"
  1346. supports_symbol_hiding="yes"
  1347. ])
  1348. CFLAGS="$tmp_save_CFLAGS"
  1349. fi
  1350. fi
  1351. ;;
  1352. SUNPRO_C)
  1353. if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
  1354. tmp_EXTERN="__global"
  1355. tmp_CFLAGS="-xldscope=hidden"
  1356. supports_symbol_hiding="yes"
  1357. fi
  1358. ;;
  1359. esac
  1360. if test "$supports_symbol_hiding" = "yes"; then
  1361. tmp_save_CFLAGS="$CFLAGS"
  1362. CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
  1363. squeeze CFLAGS
  1364. AC_COMPILE_IFELSE([
  1365. AC_LANG_PROGRAM([[
  1366. $tmp_EXTERN char *dummy(char *buff);
  1367. char *dummy(char *buff)
  1368. {
  1369. if(buff)
  1370. return ++buff;
  1371. else
  1372. return buff;
  1373. }
  1374. ]],[[
  1375. char b[16];
  1376. char *r = dummy(&b[0]);
  1377. if(r)
  1378. return (int)*r;
  1379. ]])
  1380. ],[
  1381. supports_symbol_hiding="yes"
  1382. if test -f conftest.err; then
  1383. grep 'visibility' conftest.err >/dev/null
  1384. if test "$?" -eq "0"; then
  1385. supports_symbol_hiding="no"
  1386. fi
  1387. fi
  1388. ],[
  1389. supports_symbol_hiding="no"
  1390. echo " " >&6
  1391. sed 's/^/cc-src: /' conftest.$ac_ext >&6
  1392. sed 's/^/cc-err: /' conftest.err >&6
  1393. echo " " >&6
  1394. ])
  1395. CFLAGS="$tmp_save_CFLAGS"
  1396. fi
  1397. if test "$supports_symbol_hiding" = "yes"; then
  1398. AC_MSG_RESULT([yes])
  1399. symbol_hiding_CFLAGS="$tmp_CFLAGS"
  1400. symbol_hiding_EXTERN="$tmp_EXTERN"
  1401. else
  1402. AC_MSG_RESULT([no])
  1403. fi
  1404. ])
  1405. dnl CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH
  1406. dnl -------------------------------------------------
  1407. dnl Verifies if the compiler actually halts after the
  1408. dnl compilation phase without generating any object
  1409. dnl code file, when the source code tries to redefine
  1410. dnl a prototype which does not match previous one.
  1411. AC_DEFUN([CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH], [
  1412. AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
  1413. AC_MSG_CHECKING([if compiler halts on function prototype mismatch])
  1414. AC_COMPILE_IFELSE([
  1415. AC_LANG_PROGRAM([[
  1416. #include <stdlib.h>
  1417. int rand(int n);
  1418. int rand(int n)
  1419. {
  1420. if(n)
  1421. return ++n;
  1422. else
  1423. return n;
  1424. }
  1425. ]],[[
  1426. int i[2]={0,0};
  1427. int j = rand(i[0]);
  1428. if(j)
  1429. return j;
  1430. ]])
  1431. ],[
  1432. AC_MSG_RESULT([no])
  1433. AC_MSG_ERROR([compiler does not halt on function prototype mismatch.])
  1434. ],[
  1435. AC_MSG_RESULT([yes])
  1436. ])
  1437. ])
  1438. dnl CURL_VAR_MATCH (VARNAME, VALUE)
  1439. dnl -------------------------------------------------
  1440. dnl Verifies if shell variable VARNAME contains VALUE.
  1441. dnl Contents of variable VARNAME and VALUE are handled
  1442. dnl as whitespace separated lists of words. If at least
  1443. dnl one word of VALUE is present in VARNAME the match
  1444. dnl is considered positive, otherwise false.
  1445. AC_DEFUN([CURL_VAR_MATCH], [
  1446. ac_var_match_word="no"
  1447. for word1 in $[$1]; do
  1448. for word2 in [$2]; do
  1449. if test "$word1" = "$word2"; then
  1450. ac_var_match_word="yes"
  1451. fi
  1452. done
  1453. done
  1454. ])
  1455. dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
  1456. dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
  1457. dnl -------------------------------------------------
  1458. dnl This performs a CURL_VAR_MATCH check and executes
  1459. dnl first branch if the match is positive, otherwise
  1460. dnl the second branch is executed.
  1461. AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
  1462. CURL_VAR_MATCH([$1],[$2])
  1463. if test "$ac_var_match_word" = "yes"; then
  1464. ifelse($3,,:,[$3])
  1465. ifelse($4,,,[else
  1466. $4])
  1467. fi
  1468. ])
  1469. dnl CURL_VAR_STRIP (VARNAME, VALUE)
  1470. dnl -------------------------------------------------
  1471. dnl Contents of variable VARNAME and VALUE are handled
  1472. dnl as whitespace separated lists of words. Each word
  1473. dnl from VALUE is removed from VARNAME when present.
  1474. AC_DEFUN([CURL_VAR_STRIP], [
  1475. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  1476. ac_var_stripped=""
  1477. for word1 in $[$1]; do
  1478. ac_var_strip_word="no"
  1479. for word2 in [$2]; do
  1480. if test "$word1" = "$word2"; then
  1481. ac_var_strip_word="yes"
  1482. fi
  1483. done
  1484. if test "$ac_var_strip_word" = "no"; then
  1485. ac_var_stripped="$ac_var_stripped $word1"
  1486. fi
  1487. done
  1488. dnl squeeze whitespace out of result
  1489. [$1]="$ac_var_stripped"
  1490. squeeze [$1]
  1491. ])
  1492. dnl CURL_ADD_COMPILER_WARNINGS (WARNING-LIST, NEW-WARNINGS)
  1493. dnl -------------------------------------------------------
  1494. dnl Contents of variable WARNING-LIST and NEW-WARNINGS are
  1495. dnl handled as whitespace separated lists of words.
  1496. dnl Add each compiler warning from NEW-WARNINGS that has not
  1497. dnl been disabled via CFLAGS to WARNING-LIST.
  1498. AC_DEFUN([CURL_ADD_COMPILER_WARNINGS], [
  1499. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  1500. ac_var_added_warnings=""
  1501. for warning in [$2]; do
  1502. CURL_VAR_MATCH(CFLAGS, [-Wno-$warning -W$warning])
  1503. if test "$ac_var_match_word" = "no"; then
  1504. ac_var_added_warnings="$ac_var_added_warnings -W$warning"
  1505. fi
  1506. done
  1507. dnl squeeze whitespace out of result
  1508. [$1]="$[$1] $ac_var_added_warnings"
  1509. squeeze [$1]
  1510. ])