curl-compilers.m4 50 KB

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