You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

curl-compilers.m4 49KB

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