curl-compilers.m4 51 KB

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