cares-compilers.m4 45 KB

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