curl-compilers.m4 43 KB

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