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