curl-compilers.m4 53 KB

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