curl-compilers.m4 51 KB

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