curl-compilers.m4 50 KB

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