curl-compilers.m4 49 KB

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