curl-compilers.m4 47 KB

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