curl-compilers.m4 53 KB

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