curl-compilers.m4 50 KB

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