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