curl-compilers.m4 54 KB

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