curl-compilers.m4 51 KB

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