curl-compilers.m4 54 KB

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