curl-compilers.m4 50 KB

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