curl-compilers.m4 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582
  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" 's/-.\{1,\}$//'`
  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. tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration"
  482. ;;
  483. #
  484. DEC_C)
  485. #
  486. dnl Select strict ANSI C compiler mode
  487. tmp_CFLAGS="$tmp_CFLAGS -std1"
  488. dnl Turn off optimizer ANSI C aliasing rules
  489. tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
  490. dnl Generate warnings for missing function prototypes
  491. tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
  492. dnl Change some warnings into fatal errors
  493. tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
  494. ;;
  495. #
  496. GNU_C)
  497. #
  498. dnl turn implicit-function-declaration warning into error,
  499. dnl at least gcc 2.95 and later support this
  500. if test "$compiler_num" -ge "295"; then
  501. tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration"
  502. fi
  503. ;;
  504. #
  505. HP_UX_C)
  506. #
  507. dnl Disallow run-time dereferencing of null pointers
  508. tmp_CFLAGS="$tmp_CFLAGS -z"
  509. dnl Disable some remarks
  510. dnl #4227: padding struct with n bytes to align member
  511. dnl #4255: padding size of struct with n bytes to alignment boundary
  512. tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
  513. ;;
  514. #
  515. IBM_C)
  516. #
  517. dnl Ensure that compiler optimizations are always thread-safe.
  518. tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
  519. dnl Disable type based strict aliasing optimizations, using worst
  520. dnl case aliasing assumptions when compiling. Type based aliasing
  521. dnl would restrict the lvalues that could be safely used to access
  522. dnl a data object.
  523. tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
  524. dnl Force compiler to stop after the compilation phase, without
  525. dnl generating an object code file when compilation has errors.
  526. tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
  527. ;;
  528. #
  529. INTEL_UNIX_C)
  530. #
  531. dnl On Unix this compiler uses gcc's header files, so
  532. dnl we select ANSI C89 dialect plus GNU extensions.
  533. tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
  534. dnl Change some warnings into errors
  535. dnl #140: too many arguments in function call
  536. dnl #147: declaration is incompatible with 'previous one'
  537. dnl #165: too few arguments in function call
  538. dnl #266: function declared implicitly
  539. tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-error 140,147,165,266"
  540. dnl Disable some remarks
  541. dnl #279: controlling expression is constant
  542. dnl #981: operands are evaluated in unspecified order
  543. dnl #1025: zero extending result of unary operation
  544. dnl #1469: "cc" clobber ignored
  545. dnl #2259: non-pointer conversion from X to Y may lose significant bits
  546. tmp_CPPFLAGS="$tmp_CPPFLAGS -diag-disable 279,981,1025,1469,2259"
  547. ;;
  548. #
  549. INTEL_WINDOWS_C)
  550. #
  551. dnl Placeholder
  552. tmp_CFLAGS="$tmp_CFLAGS"
  553. ;;
  554. #
  555. SGI_MIPS_C)
  556. #
  557. dnl Placeholder
  558. tmp_CFLAGS="$tmp_CFLAGS"
  559. ;;
  560. #
  561. SGI_MIPSPRO_C)
  562. #
  563. dnl Placeholder
  564. tmp_CFLAGS="$tmp_CFLAGS"
  565. ;;
  566. #
  567. SUNPRO_C)
  568. #
  569. dnl Placeholder
  570. tmp_CFLAGS="$tmp_CFLAGS"
  571. ;;
  572. #
  573. TINY_C)
  574. #
  575. dnl Placeholder
  576. tmp_CFLAGS="$tmp_CFLAGS"
  577. ;;
  578. #
  579. esac
  580. #
  581. squeeze tmp_CPPFLAGS
  582. squeeze tmp_CFLAGS
  583. #
  584. if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
  585. AC_MSG_CHECKING([if compiler accepts some basic options])
  586. CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
  587. CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
  588. squeeze CPPFLAGS
  589. squeeze CFLAGS
  590. CURL_COMPILER_WORKS_IFELSE([
  591. AC_MSG_RESULT([yes])
  592. AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
  593. ],[
  594. AC_MSG_RESULT([no])
  595. AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
  596. dnl restore initial settings
  597. CPPFLAGS="$tmp_save_CPPFLAGS"
  598. CFLAGS="$tmp_save_CFLAGS"
  599. ])
  600. fi
  601. #
  602. fi
  603. ])
  604. dnl CURL_SET_COMPILER_DEBUG_OPTS
  605. dnl -------------------------------------------------
  606. dnl Sets compiler specific options/flags which depend
  607. dnl on configure's debug option.
  608. AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
  609. AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
  610. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  611. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  612. #
  613. if test "$compiler_id" != "unknown"; then
  614. #
  615. tmp_save_CFLAGS="$CFLAGS"
  616. tmp_save_CPPFLAGS="$CPPFLAGS"
  617. #
  618. tmp_options=""
  619. tmp_CFLAGS="$CFLAGS"
  620. tmp_CPPFLAGS="$CPPFLAGS"
  621. #
  622. if test "$want_debug" = "yes"; then
  623. AC_MSG_CHECKING([if compiler accepts debug enabling options])
  624. tmp_options="$flags_dbg_yes"
  625. fi
  626. #
  627. if test "$flags_prefer_cppflags" = "yes"; then
  628. CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
  629. CFLAGS="$tmp_CFLAGS"
  630. else
  631. CPPFLAGS="$tmp_CPPFLAGS"
  632. CFLAGS="$tmp_CFLAGS $tmp_options"
  633. fi
  634. squeeze CPPFLAGS
  635. squeeze CFLAGS
  636. fi
  637. ])
  638. dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
  639. dnl -------------------------------------------------
  640. dnl Sets compiler specific options/flags which depend
  641. dnl on configure's optimize option.
  642. AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
  643. AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
  644. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  645. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  646. #
  647. if test "$compiler_id" != "unknown"; then
  648. #
  649. tmp_save_CFLAGS="$CFLAGS"
  650. tmp_save_CPPFLAGS="$CPPFLAGS"
  651. #
  652. tmp_options=""
  653. tmp_CFLAGS="$CFLAGS"
  654. tmp_CPPFLAGS="$CPPFLAGS"
  655. honor_optimize_option="yes"
  656. #
  657. dnl If optimization request setting has not been explicitly specified,
  658. dnl it has been derived from the debug setting and initially assumed.
  659. dnl This initially assumed optimizer setting will finally be ignored
  660. dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
  661. dnl that an initially assumed optimizer setting might not be honored.
  662. #
  663. if test "$want_optimize" = "assume_no" ||
  664. test "$want_optimize" = "assume_yes"; then
  665. AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
  666. CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
  667. honor_optimize_option="no"
  668. ])
  669. CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
  670. honor_optimize_option="no"
  671. ])
  672. AC_MSG_RESULT([$honor_optimize_option])
  673. if test "$honor_optimize_option" = "yes"; then
  674. if test "$want_optimize" = "assume_yes"; then
  675. want_optimize="yes"
  676. fi
  677. if test "$want_optimize" = "assume_no"; then
  678. want_optimize="no"
  679. fi
  680. fi
  681. fi
  682. #
  683. if test "$honor_optimize_option" = "yes"; then
  684. CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
  685. CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
  686. if test "$want_optimize" = "yes"; then
  687. AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
  688. tmp_options="$flags_opt_yes"
  689. fi
  690. if test "$want_optimize" = "no"; then
  691. AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
  692. tmp_options="$flags_opt_off"
  693. fi
  694. if test "$flags_prefer_cppflags" = "yes"; then
  695. CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
  696. CFLAGS="$tmp_CFLAGS"
  697. else
  698. CPPFLAGS="$tmp_CPPFLAGS"
  699. CFLAGS="$tmp_CFLAGS $tmp_options"
  700. fi
  701. squeeze CPPFLAGS
  702. squeeze CFLAGS
  703. CURL_COMPILER_WORKS_IFELSE([
  704. AC_MSG_RESULT([yes])
  705. AC_MSG_NOTICE([compiler options added: $tmp_options])
  706. ],[
  707. AC_MSG_RESULT([no])
  708. AC_MSG_WARN([compiler options rejected: $tmp_options])
  709. dnl restore initial settings
  710. CPPFLAGS="$tmp_save_CPPFLAGS"
  711. CFLAGS="$tmp_save_CFLAGS"
  712. ])
  713. fi
  714. #
  715. fi
  716. ])
  717. dnl CURL_SET_COMPILER_WARNING_OPTS
  718. dnl -------------------------------------------------
  719. dnl Sets compiler options/flags which depend on
  720. dnl configure's warnings given option.
  721. AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
  722. AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
  723. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  724. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  725. #
  726. if test "$compiler_id" != "unknown"; then
  727. #
  728. tmp_save_CPPFLAGS="$CPPFLAGS"
  729. tmp_save_CFLAGS="$CFLAGS"
  730. tmp_CPPFLAGS=""
  731. tmp_CFLAGS=""
  732. #
  733. case "$compiler_id" in
  734. #
  735. CLANG)
  736. #
  737. if test "$want_warnings" = "yes"; then
  738. tmp_CFLAGS="$tmp_CFLAGS -pedantic"
  739. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra])
  740. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
  741. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow])
  742. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
  743. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
  744. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
  745. tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
  746. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
  747. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
  748. tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
  749. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
  750. tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
  751. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
  752. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
  753. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
  754. tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
  755. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
  756. #
  757. dnl Only clang 1.1 or later
  758. if test "$compiler_num" -ge "101"; then
  759. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
  760. fi
  761. #
  762. dnl Only clang 2.7 or later
  763. if test "$compiler_num" -ge "207"; then
  764. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [address])
  765. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [attributes])
  766. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
  767. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
  768. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [div-by-zero format-security])
  769. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [empty-body])
  770. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-field-initializers])
  771. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-noreturn])
  772. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
  773. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [redundant-decls])
  774. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [switch-enum]) # Not used because this basically disallows default case
  775. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits])
  776. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-macros]) # Not practical
  777. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code unused-parameter])
  778. fi
  779. #
  780. dnl Only clang 2.8 or later
  781. if test "$compiler_num" -ge "208"; then
  782. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [ignored-qualifiers])
  783. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
  784. fi
  785. #
  786. dnl Only clang 2.9 or later
  787. if test "$compiler_num" -ge "209"; then
  788. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion])
  789. tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME
  790. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
  791. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs
  792. fi
  793. #
  794. dnl Only clang 3.0 or later
  795. if test "$compiler_num" -ge "300"; then
  796. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [language-extension-token])
  797. tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
  798. fi
  799. #
  800. dnl Only clang 3.2 or later
  801. if test "$compiler_num" -ge "302"; then
  802. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
  803. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sometimes-uninitialized])
  804. case $host_os in
  805. cygwin* | mingw*)
  806. dnl skip missing-variable-declarations warnings for Cygwin and
  807. dnl MinGW because the libtool wrapper executable causes them
  808. ;;
  809. *)
  810. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
  811. ;;
  812. esac
  813. fi
  814. #
  815. dnl Only clang 3.4 or later
  816. if test "$compiler_num" -ge "304"; then
  817. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [header-guard])
  818. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
  819. fi
  820. #
  821. dnl Only clang 3.5 or later
  822. if test "$compiler_num" -ge "305"; then
  823. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pragmas])
  824. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code-break])
  825. fi
  826. #
  827. dnl Only clang 3.6 or later
  828. if test "$compiler_num" -ge "306"; then
  829. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
  830. fi
  831. #
  832. dnl Only clang 3.9 or later
  833. if test "$compiler_num" -ge "309"; then
  834. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma])
  835. # avoid the varargs warning, fixed in 4.0
  836. # https://bugs.llvm.org/show_bug.cgi?id=29140
  837. if test "$compiler_num" -lt "400"; then
  838. tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
  839. fi
  840. fi
  841. dnl clang 7 or later
  842. if test "$compiler_num" -ge "700"; then
  843. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
  844. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
  845. fi
  846. dnl clang 10 or later
  847. if test "$compiler_num" -ge "1000"; then
  848. tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough" # we have silencing markup for clang 10.0 and above only
  849. fi
  850. fi
  851. ;;
  852. #
  853. DEC_C)
  854. #
  855. if test "$want_warnings" = "yes"; then
  856. dnl Select a higher warning level than default level2
  857. tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
  858. fi
  859. ;;
  860. #
  861. GNU_C)
  862. #
  863. if test "$want_warnings" = "yes"; then
  864. #
  865. dnl Do not enable -pedantic when cross-compiling with a gcc older
  866. dnl than 3.0, to avoid warnings from third party system headers.
  867. if test "x$cross_compiling" != "xyes" ||
  868. test "$compiler_num" -ge "300"; then
  869. tmp_CFLAGS="$tmp_CFLAGS -pedantic"
  870. fi
  871. #
  872. dnl Set of options we believe *ALL* gcc versions support:
  873. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
  874. tmp_CFLAGS="$tmp_CFLAGS -W"
  875. #
  876. dnl Only gcc 1.4 or later
  877. if test "$compiler_num" -ge "104"; then
  878. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
  879. dnl If not cross-compiling with a gcc older than 3.0
  880. if test "x$cross_compiling" != "xyes" ||
  881. test "$compiler_num" -ge "300"; then
  882. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow])
  883. fi
  884. fi
  885. #
  886. dnl Only gcc 2.7 or later
  887. if test "$compiler_num" -ge "207"; then
  888. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
  889. dnl If not cross-compiling with a gcc older than 3.0
  890. if test "x$cross_compiling" != "xyes" ||
  891. test "$compiler_num" -ge "300"; then
  892. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
  893. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
  894. fi
  895. fi
  896. #
  897. dnl Only gcc 2.95 or later
  898. if test "$compiler_num" -ge "295"; then
  899. tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
  900. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
  901. fi
  902. #
  903. dnl Only gcc 2.96 or later
  904. if test "$compiler_num" -ge "296"; then
  905. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
  906. tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
  907. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
  908. dnl -Wundef used only if gcc is 2.96 or later since we get
  909. dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
  910. dnl headers with gcc 2.95.4 on FreeBSD 4.9
  911. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
  912. fi
  913. #
  914. dnl Only gcc 2.97 or later
  915. if test "$compiler_num" -ge "297"; then
  916. tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
  917. fi
  918. #
  919. dnl Only gcc 3.0 or later
  920. if test "$compiler_num" -ge "300"; then
  921. dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
  922. dnl on i686-Linux as it gives us heaps with false positives.
  923. dnl Also, on gcc 4.0.X it is totally unbearable and complains all
  924. dnl over making it unusable for generic purposes. Let's not use it.
  925. tmp_CFLAGS="$tmp_CFLAGS"
  926. fi
  927. #
  928. dnl Only gcc 3.3 or later
  929. if test "$compiler_num" -ge "303"; then
  930. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
  931. fi
  932. #
  933. dnl Only gcc 3.4 or later
  934. if test "$compiler_num" -ge "304"; then
  935. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
  936. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
  937. fi
  938. #
  939. dnl Only gcc 4.0 or later
  940. if test "$compiler_num" -ge "400"; then
  941. tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
  942. fi
  943. #
  944. dnl Only gcc 4.1 or later
  945. if test "$compiler_num" -ge "401"; then
  946. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [attributes])
  947. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [div-by-zero format-security])
  948. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-field-initializers])
  949. case $host in
  950. *-*-msys*)
  951. ;;
  952. *)
  953. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-noreturn]) # Seen to clash with libtool-generated stub code
  954. ;;
  955. esac
  956. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unreachable-code unused-parameter])
  957. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [padded]) # Not used because we cannot change public structs
  958. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pragmas])
  959. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [redundant-decls])
  960. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [switch-enum]) # Not used because this basically disallows default case
  961. # CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-macros]) # Not practical
  962. fi
  963. #
  964. dnl Only gcc 4.2 or later
  965. if test "$compiler_num" -ge "402"; then
  966. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
  967. fi
  968. #
  969. dnl Only gcc 4.3 or later
  970. if test "$compiler_num" -ge "403"; then
  971. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [address])
  972. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
  973. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
  974. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
  975. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion trampolines])
  976. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-conversion])
  977. tmp_CFLAGS="$tmp_CFLAGS -Wno-error=sign-conversion" # FIXME
  978. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
  979. dnl required for -Warray-bounds, included in -Wall
  980. tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
  981. fi
  982. #
  983. dnl Only gcc 4.5 or later
  984. if test "$compiler_num" -ge "405"; then
  985. dnl Only Windows targets
  986. if test "$curl_cv_native_windows" = "yes"; then
  987. tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
  988. fi
  989. fi
  990. #
  991. dnl Only gcc 4.6 or later
  992. if test "$compiler_num" -ge "406"; then
  993. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
  994. fi
  995. #
  996. dnl only gcc 4.8 or later
  997. if test "$compiler_num" -ge "408"; then
  998. tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
  999. fi
  1000. #
  1001. dnl Only gcc 5 or later
  1002. if test "$compiler_num" -ge "500"; then
  1003. tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2"
  1004. fi
  1005. #
  1006. dnl Only gcc 6 or later
  1007. if test "$compiler_num" -ge "600"; then
  1008. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
  1009. tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
  1010. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference])
  1011. tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks"
  1012. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond])
  1013. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
  1014. fi
  1015. #
  1016. dnl Only gcc 7 or later
  1017. if test "$compiler_num" -ge "700"; then
  1018. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
  1019. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
  1020. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
  1021. tmp_CFLAGS="$tmp_CFLAGS -Wno-format-overflow"
  1022. tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2"
  1023. tmp_CFLAGS="$tmp_CFLAGS -Wimplicit-fallthrough"
  1024. fi
  1025. #
  1026. dnl Only gcc 10 or later
  1027. if test "$compiler_num" -ge "1000"; then
  1028. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion])
  1029. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
  1030. fi
  1031. #
  1032. fi
  1033. #
  1034. dnl Do not issue warnings for code in system include paths.
  1035. if test "$compiler_num" -ge "300"; then
  1036. tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
  1037. else
  1038. dnl When cross-compiling with a gcc older than 3.0, disable
  1039. dnl some warnings triggered on third party system headers.
  1040. if test "x$cross_compiling" = "xyes"; then
  1041. if test "$compiler_num" -ge "104"; then
  1042. dnl gcc 1.4 or later
  1043. tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
  1044. fi
  1045. if test "$compiler_num" -ge "207"; then
  1046. dnl gcc 2.7 or later
  1047. tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
  1048. tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
  1049. fi
  1050. fi
  1051. fi
  1052. ;;
  1053. #
  1054. HP_UX_C)
  1055. #
  1056. if test "$want_warnings" = "yes"; then
  1057. dnl Issue all warnings
  1058. tmp_CFLAGS="$tmp_CFLAGS +w1"
  1059. fi
  1060. ;;
  1061. #
  1062. IBM_C)
  1063. #
  1064. dnl Placeholder
  1065. tmp_CFLAGS="$tmp_CFLAGS"
  1066. ;;
  1067. #
  1068. INTEL_UNIX_C)
  1069. #
  1070. if test "$want_warnings" = "yes"; then
  1071. if test "$compiler_num" -gt "600"; then
  1072. dnl Show errors, warnings, and remarks
  1073. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
  1074. dnl Perform extra compile-time code checking
  1075. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
  1076. dnl Warn on nested comments
  1077. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
  1078. dnl Show warnings relative to deprecated features
  1079. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
  1080. dnl Enable warnings for missing prototypes
  1081. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
  1082. dnl Enable warnings for 64-bit portability issues
  1083. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
  1084. dnl Enable warnings for questionable pointer arithmetic
  1085. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
  1086. dnl Check for function return typw issues
  1087. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
  1088. dnl Warn on variable declarations hiding a previous one
  1089. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
  1090. dnl Warn when a variable is used before initialized
  1091. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
  1092. dnl Warn if a declared function is not used
  1093. tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
  1094. fi
  1095. fi
  1096. dnl Disable using EBP register in optimizations
  1097. tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
  1098. dnl Disable use of ANSI C aliasing rules in optimizations
  1099. tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
  1100. dnl Value-safe optimizations on floating-point data
  1101. tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
  1102. ;;
  1103. #
  1104. INTEL_WINDOWS_C)
  1105. #
  1106. dnl Placeholder
  1107. tmp_CFLAGS="$tmp_CFLAGS"
  1108. ;;
  1109. #
  1110. SGI_MIPS_C)
  1111. #
  1112. if test "$want_warnings" = "yes"; then
  1113. dnl Perform stricter semantic and lint-like checks
  1114. tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
  1115. fi
  1116. ;;
  1117. #
  1118. SGI_MIPSPRO_C)
  1119. #
  1120. if test "$want_warnings" = "yes"; then
  1121. dnl Perform stricter semantic and lint-like checks
  1122. tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
  1123. dnl Disable some remarks
  1124. dnl #1209: controlling expression is constant
  1125. tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
  1126. fi
  1127. ;;
  1128. #
  1129. SUNPRO_C)
  1130. #
  1131. if test "$want_warnings" = "yes"; then
  1132. dnl Perform stricter semantic and lint-like checks
  1133. tmp_CFLAGS="$tmp_CFLAGS -v"
  1134. fi
  1135. ;;
  1136. #
  1137. TINY_C)
  1138. #
  1139. if test "$want_warnings" = "yes"; then
  1140. dnl Activate all warnings
  1141. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all])
  1142. dnl Make string constants be of type const char *
  1143. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [write-strings])
  1144. dnl Warn use of unsupported GCC features ignored by TCC
  1145. CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unsupported])
  1146. fi
  1147. ;;
  1148. #
  1149. esac
  1150. #
  1151. squeeze tmp_CPPFLAGS
  1152. squeeze tmp_CFLAGS
  1153. #
  1154. if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
  1155. AC_MSG_CHECKING([if compiler accepts strict warning options])
  1156. CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
  1157. CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
  1158. squeeze CPPFLAGS
  1159. squeeze CFLAGS
  1160. CURL_COMPILER_WORKS_IFELSE([
  1161. AC_MSG_RESULT([yes])
  1162. AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
  1163. ],[
  1164. AC_MSG_RESULT([no])
  1165. AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
  1166. dnl restore initial settings
  1167. CPPFLAGS="$tmp_save_CPPFLAGS"
  1168. CFLAGS="$tmp_save_CFLAGS"
  1169. ])
  1170. fi
  1171. #
  1172. fi
  1173. ])
  1174. dnl CURL_SHFUNC_SQUEEZE
  1175. dnl -------------------------------------------------
  1176. dnl Declares a shell function squeeze() which removes
  1177. dnl redundant whitespace out of a shell variable.
  1178. AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
  1179. squeeze() {
  1180. _sqz_result=""
  1181. eval _sqz_input=\[$][$]1
  1182. for _sqz_token in $_sqz_input; do
  1183. if test -z "$_sqz_result"; then
  1184. _sqz_result="$_sqz_token"
  1185. else
  1186. _sqz_result="$_sqz_result $_sqz_token"
  1187. fi
  1188. done
  1189. eval [$]1=\$_sqz_result
  1190. return 0
  1191. }
  1192. ])
  1193. dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
  1194. dnl -------------------------------------------------
  1195. dnl Verifies if the compiler actually halts after the
  1196. dnl compilation phase without generating any object
  1197. dnl code file, when the source compiles with errors.
  1198. AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
  1199. AC_MSG_CHECKING([if compiler halts on compilation errors])
  1200. AC_COMPILE_IFELSE([
  1201. AC_LANG_PROGRAM([[
  1202. ]],[[
  1203. force compilation error
  1204. ]])
  1205. ],[
  1206. AC_MSG_RESULT([no])
  1207. AC_MSG_ERROR([compiler does not halt on compilation errors.])
  1208. ],[
  1209. AC_MSG_RESULT([yes])
  1210. ])
  1211. ])
  1212. dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
  1213. dnl -------------------------------------------------
  1214. dnl Verifies if the compiler actually halts after the
  1215. dnl compilation phase without generating any object
  1216. dnl code file, when the source code tries to define a
  1217. dnl type for a constant array with negative dimension.
  1218. AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
  1219. AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
  1220. AC_MSG_CHECKING([if compiler halts on negative sized arrays])
  1221. AC_COMPILE_IFELSE([
  1222. AC_LANG_PROGRAM([[
  1223. typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
  1224. ]],[[
  1225. bad_t dummy;
  1226. ]])
  1227. ],[
  1228. AC_MSG_RESULT([no])
  1229. AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
  1230. ],[
  1231. AC_MSG_RESULT([yes])
  1232. ])
  1233. ])
  1234. dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
  1235. dnl -------------------------------------------------
  1236. dnl Verifies if the compiler is capable of handling the
  1237. dnl size of a struct member, struct which is a function
  1238. dnl result, as a compilation-time condition inside the
  1239. dnl type definition of a constant array.
  1240. AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
  1241. AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
  1242. AC_MSG_CHECKING([if compiler struct member size checking works])
  1243. tst_compiler_check_one_works="unknown"
  1244. AC_COMPILE_IFELSE([
  1245. AC_LANG_PROGRAM([[
  1246. struct mystruct {
  1247. int mi;
  1248. char mc;
  1249. struct mystruct *next;
  1250. };
  1251. struct mystruct myfunc();
  1252. typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
  1253. typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
  1254. ]],[[
  1255. good_t1 dummy1;
  1256. good_t2 dummy2;
  1257. ]])
  1258. ],[
  1259. tst_compiler_check_one_works="yes"
  1260. ],[
  1261. tst_compiler_check_one_works="no"
  1262. sed 's/^/cc-src: /' conftest.$ac_ext >&6
  1263. sed 's/^/cc-err: /' conftest.err >&6
  1264. ])
  1265. tst_compiler_check_two_works="unknown"
  1266. AC_COMPILE_IFELSE([
  1267. AC_LANG_PROGRAM([[
  1268. struct mystruct {
  1269. int mi;
  1270. char mc;
  1271. struct mystruct *next;
  1272. };
  1273. struct mystruct myfunc();
  1274. typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
  1275. typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
  1276. ]],[[
  1277. bad_t1 dummy1;
  1278. bad_t2 dummy2;
  1279. ]])
  1280. ],[
  1281. tst_compiler_check_two_works="no"
  1282. ],[
  1283. tst_compiler_check_two_works="yes"
  1284. ])
  1285. if test "$tst_compiler_check_one_works" = "yes" &&
  1286. test "$tst_compiler_check_two_works" = "yes"; then
  1287. AC_MSG_RESULT([yes])
  1288. else
  1289. AC_MSG_RESULT([no])
  1290. AC_MSG_ERROR([compiler fails struct member size checking.])
  1291. fi
  1292. ])
  1293. dnl CURL_CHECK_COMPILER_SYMBOL_HIDING
  1294. dnl -------------------------------------------------
  1295. dnl Verify if compiler supports hiding library internal symbols, setting
  1296. dnl shell variable supports_symbol_hiding value as appropriate, as well as
  1297. dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported.
  1298. AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
  1299. AC_REQUIRE([CURL_CHECK_COMPILER])dnl
  1300. AC_BEFORE([$0],[CURL_CONFIGURE_SYMBOL_HIDING])dnl
  1301. AC_MSG_CHECKING([if compiler supports hiding library internal symbols])
  1302. supports_symbol_hiding="no"
  1303. symbol_hiding_CFLAGS=""
  1304. symbol_hiding_EXTERN=""
  1305. tmp_CFLAGS=""
  1306. tmp_EXTERN=""
  1307. case "$compiler_id" in
  1308. CLANG)
  1309. dnl All versions of clang support -fvisibility=
  1310. tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
  1311. tmp_CFLAGS="-fvisibility=hidden"
  1312. supports_symbol_hiding="yes"
  1313. ;;
  1314. GNU_C)
  1315. dnl Only gcc 3.4 or later
  1316. if test "$compiler_num" -ge "304"; then
  1317. if $CC --help --verbose 2>/dev/null | grep fvisibility= >/dev/null ; then
  1318. tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
  1319. tmp_CFLAGS="-fvisibility=hidden"
  1320. supports_symbol_hiding="yes"
  1321. fi
  1322. fi
  1323. ;;
  1324. INTEL_UNIX_C)
  1325. dnl Only icc 9.0 or later
  1326. if test "$compiler_num" -ge "900"; then
  1327. if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
  1328. tmp_save_CFLAGS="$CFLAGS"
  1329. CFLAGS="$CFLAGS -fvisibility=hidden"
  1330. AC_LINK_IFELSE([
  1331. AC_LANG_PROGRAM([[
  1332. # include <stdio.h>
  1333. ]],[[
  1334. printf("icc fvisibility bug test");
  1335. ]])
  1336. ],[
  1337. tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
  1338. tmp_CFLAGS="-fvisibility=hidden"
  1339. supports_symbol_hiding="yes"
  1340. ])
  1341. CFLAGS="$tmp_save_CFLAGS"
  1342. fi
  1343. fi
  1344. ;;
  1345. SUNPRO_C)
  1346. if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
  1347. tmp_EXTERN="__global"
  1348. tmp_CFLAGS="-xldscope=hidden"
  1349. supports_symbol_hiding="yes"
  1350. fi
  1351. ;;
  1352. esac
  1353. if test "$supports_symbol_hiding" = "yes"; then
  1354. tmp_save_CFLAGS="$CFLAGS"
  1355. CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
  1356. squeeze CFLAGS
  1357. AC_COMPILE_IFELSE([
  1358. AC_LANG_PROGRAM([[
  1359. $tmp_EXTERN char *dummy(char *buff);
  1360. char *dummy(char *buff)
  1361. {
  1362. if(buff)
  1363. return ++buff;
  1364. else
  1365. return buff;
  1366. }
  1367. ]],[[
  1368. char b[16];
  1369. char *r = dummy(&b[0]);
  1370. if(r)
  1371. return (int)*r;
  1372. ]])
  1373. ],[
  1374. supports_symbol_hiding="yes"
  1375. if test -f conftest.err; then
  1376. grep 'visibility' conftest.err >/dev/null
  1377. if test "$?" -eq "0"; then
  1378. supports_symbol_hiding="no"
  1379. fi
  1380. fi
  1381. ],[
  1382. supports_symbol_hiding="no"
  1383. echo " " >&6
  1384. sed 's/^/cc-src: /' conftest.$ac_ext >&6
  1385. sed 's/^/cc-err: /' conftest.err >&6
  1386. echo " " >&6
  1387. ])
  1388. CFLAGS="$tmp_save_CFLAGS"
  1389. fi
  1390. if test "$supports_symbol_hiding" = "yes"; then
  1391. AC_MSG_RESULT([yes])
  1392. symbol_hiding_CFLAGS="$tmp_CFLAGS"
  1393. symbol_hiding_EXTERN="$tmp_EXTERN"
  1394. else
  1395. AC_MSG_RESULT([no])
  1396. fi
  1397. ])
  1398. dnl CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH
  1399. dnl -------------------------------------------------
  1400. dnl Verifies if the compiler actually halts after the
  1401. dnl compilation phase without generating any object
  1402. dnl code file, when the source code tries to redefine
  1403. dnl a prototype which does not match previous one.
  1404. AC_DEFUN([CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH], [
  1405. AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
  1406. AC_MSG_CHECKING([if compiler halts on function prototype mismatch])
  1407. AC_COMPILE_IFELSE([
  1408. AC_LANG_PROGRAM([[
  1409. # include <stdlib.h>
  1410. int rand(int n);
  1411. int rand(int n)
  1412. {
  1413. if(n)
  1414. return ++n;
  1415. else
  1416. return n;
  1417. }
  1418. ]],[[
  1419. int i[2]={0,0};
  1420. int j = rand(i[0]);
  1421. if(j)
  1422. return j;
  1423. ]])
  1424. ],[
  1425. AC_MSG_RESULT([no])
  1426. AC_MSG_ERROR([compiler does not halt on function prototype mismatch.])
  1427. ],[
  1428. AC_MSG_RESULT([yes])
  1429. ])
  1430. ])
  1431. dnl CURL_VAR_MATCH (VARNAME, VALUE)
  1432. dnl -------------------------------------------------
  1433. dnl Verifies if shell variable VARNAME contains VALUE.
  1434. dnl Contents of variable VARNAME and VALUE are handled
  1435. dnl as whitespace separated lists of words. If at least
  1436. dnl one word of VALUE is present in VARNAME the match
  1437. dnl is considered positive, otherwise false.
  1438. AC_DEFUN([CURL_VAR_MATCH], [
  1439. ac_var_match_word="no"
  1440. for word1 in $[$1]; do
  1441. for word2 in [$2]; do
  1442. if test "$word1" = "$word2"; then
  1443. ac_var_match_word="yes"
  1444. fi
  1445. done
  1446. done
  1447. ])
  1448. dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
  1449. dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
  1450. dnl -------------------------------------------------
  1451. dnl This performs a CURL_VAR_MATCH check and executes
  1452. dnl first branch if the match is positive, otherwise
  1453. dnl the second branch is executed.
  1454. AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
  1455. CURL_VAR_MATCH([$1],[$2])
  1456. if test "$ac_var_match_word" = "yes"; then
  1457. ifelse($3,,:,[$3])
  1458. ifelse($4,,,[else
  1459. $4])
  1460. fi
  1461. ])
  1462. dnl CURL_VAR_STRIP (VARNAME, VALUE)
  1463. dnl -------------------------------------------------
  1464. dnl Contents of variable VARNAME and VALUE are handled
  1465. dnl as whitespace separated lists of words. Each word
  1466. dnl from VALUE is removed from VARNAME when present.
  1467. AC_DEFUN([CURL_VAR_STRIP], [
  1468. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  1469. ac_var_stripped=""
  1470. for word1 in $[$1]; do
  1471. ac_var_strip_word="no"
  1472. for word2 in [$2]; do
  1473. if test "$word1" = "$word2"; then
  1474. ac_var_strip_word="yes"
  1475. fi
  1476. done
  1477. if test "$ac_var_strip_word" = "no"; then
  1478. ac_var_stripped="$ac_var_stripped $word1"
  1479. fi
  1480. done
  1481. dnl squeeze whitespace out of result
  1482. [$1]="$ac_var_stripped"
  1483. squeeze [$1]
  1484. ])
  1485. dnl CURL_ADD_COMPILER_WARNINGS (WARNING-LIST, NEW-WARNINGS)
  1486. dnl -------------------------------------------------------
  1487. dnl Contents of variable WARNING-LIST and NEW-WARNINGS are
  1488. dnl handled as whitespace separated lists of words.
  1489. dnl Add each compiler warning from NEW-WARNINGS that has not
  1490. dnl been disabled via CFLAGS to WARNING-LIST.
  1491. AC_DEFUN([CURL_ADD_COMPILER_WARNINGS], [
  1492. AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
  1493. ac_var_added_warnings=""
  1494. for warning in [$2]; do
  1495. CURL_VAR_MATCH(CFLAGS, [-Wno-$warning -W$warning])
  1496. if test "$ac_var_match_word" = "no"; then
  1497. ac_var_added_warnings="$ac_var_added_warnings -W$warning"
  1498. fi
  1499. done
  1500. dnl squeeze whitespace out of result
  1501. [$1]="$[$1] $ac_var_added_warnings"
  1502. squeeze [$1]
  1503. ])