mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-18 15:20:56 +03:00
acinclude.m4: fix indentation [ci skip]
Also match indentation of curl's `m4/curl-compilers.m4` for easier syncing.
This commit is contained in:
640
acinclude.m4
640
acinclude.m4
@@ -151,24 +151,24 @@ dnl sets the $ICC variable to "yes" or "no"
|
||||
dnl **********************************************************************
|
||||
AC_DEFUN([CURL_DETECT_ICC],
|
||||
[
|
||||
ICC="no"
|
||||
AC_MSG_CHECKING([for icc in use])
|
||||
if test "$GCC" = "yes"; then
|
||||
dnl check if this is icc acting as gcc in disguise
|
||||
AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
|
||||
dnl action if the text is found, this it has not been replaced by the
|
||||
dnl cpp
|
||||
ICC="no",
|
||||
dnl the text was not found, it was replaced by the cpp
|
||||
ICC="yes"
|
||||
AC_MSG_RESULT([yes])
|
||||
[$1]
|
||||
)
|
||||
fi
|
||||
if test "$ICC" = "no"; then
|
||||
# this is not ICC
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
ICC="no"
|
||||
AC_MSG_CHECKING([for icc in use])
|
||||
if test "$GCC" = "yes"; then
|
||||
dnl check if this is icc acting as gcc in disguise
|
||||
AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
|
||||
dnl action if the text is found, this it has not been replaced by the
|
||||
dnl cpp
|
||||
ICC="no",
|
||||
dnl the text was not found, it was replaced by the cpp
|
||||
ICC="yes"
|
||||
AC_MSG_RESULT([yes])
|
||||
[$1]
|
||||
)
|
||||
fi
|
||||
if test "$ICC" = "no"; then
|
||||
# this is not ICC
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
])
|
||||
|
||||
dnl We create a function for detecting which compiler we use and then set as
|
||||
@@ -177,319 +177,323 @@ dnl options are only used for debug-builds.
|
||||
|
||||
AC_DEFUN([CURL_CC_DEBUG_OPTS],
|
||||
[
|
||||
if test "z$CLANG" = "z"; then
|
||||
CURL_CHECK_COMPILER_CLANG
|
||||
if test "z$compiler_id" = "zCLANG"; then
|
||||
CLANG="yes"
|
||||
else
|
||||
CLANG="no"
|
||||
fi
|
||||
fi
|
||||
if test "z$ICC" = "z"; then
|
||||
CURL_DETECT_ICC
|
||||
if test "z$CLANG" = "z"; then
|
||||
CURL_CHECK_COMPILER_CLANG
|
||||
if test "z$compiler_id" = "zCLANG"; then
|
||||
CLANG="yes"
|
||||
else
|
||||
CLANG="no"
|
||||
fi
|
||||
fi
|
||||
if test "z$ICC" = "z"; then
|
||||
CURL_DETECT_ICC
|
||||
fi
|
||||
|
||||
if test "$CLANG" = "yes"; then
|
||||
if test "$CLANG" = "yes"; then
|
||||
|
||||
dnl figure out clang version!
|
||||
AC_MSG_CHECKING([clang version])
|
||||
fullclangver=`$CC -v 2>&1 | grep version`
|
||||
clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
|
||||
if test -z "$clangver"; then
|
||||
if echo $fullclangver | grep "Apple LLVM version " >/dev/null; then
|
||||
dnl Starting with Xcode 7 / clang 3.7, Apple clang won't tell its upstream version
|
||||
clangver="3.7"
|
||||
else
|
||||
clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
|
||||
fi
|
||||
fi
|
||||
clangvhi=`echo $clangver | cut -d . -f1`
|
||||
clangvlo=`echo $clangver | cut -d . -f2`
|
||||
compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
|
||||
AC_MSG_RESULT($compiler_num)
|
||||
# indentation to match curl's m4/curl-compilers.m4
|
||||
|
||||
tmp_CFLAGS="-pedantic"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
|
||||
#
|
||||
dnl Only clang 1.1 or later
|
||||
if test "$compiler_num" -ge "101"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 2.7 or later
|
||||
if test "$compiler_num" -ge "207"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [empty-body])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 2.8 or later
|
||||
if test "$compiler_num" -ge "208"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [ignored-qualifiers])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 2.9 or later
|
||||
if test "$compiler_num" -ge "209"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.0 or later (possibly earlier)
|
||||
if test "$compiler_num" -ge "300"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS"
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.2 or later
|
||||
if test "$compiler_num" -ge "302"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
|
||||
case $host_os in
|
||||
cygwin* | mingw*)
|
||||
dnl skip missing-variable-declarations warnings for cygwin and
|
||||
dnl mingw because the libtool wrapper executable causes them
|
||||
;;
|
||||
*)
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.4 or later
|
||||
if test "$compiler_num" -ge "304"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.6 or later
|
||||
if test "$compiler_num" -ge "306"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.9 or later
|
||||
if test "$compiler_num" -ge "309"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma])
|
||||
# avoid the varargs warning, fixed in 4.0
|
||||
# https://bugs.llvm.org/show_bug.cgi?id=29140
|
||||
if test "$compiler_num" -lt "400"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
|
||||
fi
|
||||
fi
|
||||
dnl clang 7 or later
|
||||
if test "$compiler_num" -ge "700"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
|
||||
fi
|
||||
dnl figure out clang version!
|
||||
AC_MSG_CHECKING([clang version])
|
||||
fullclangver=`$CC -v 2>&1 | grep version`
|
||||
clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
|
||||
if test -z "$clangver"; then
|
||||
if echo $fullclangver | grep "Apple LLVM version " >/dev/null; then
|
||||
dnl Starting with Xcode 7 / clang 3.7, Apple clang won't tell its upstream version
|
||||
clangver="3.7"
|
||||
else
|
||||
clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
|
||||
fi
|
||||
fi
|
||||
clangvhi=`echo $clangver | cut -d . -f1`
|
||||
clangvlo=`echo $clangver | cut -d . -f2`
|
||||
compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
|
||||
AC_MSG_RESULT($compiler_num)
|
||||
|
||||
CFLAGS="$CFLAGS $tmp_CFLAGS"
|
||||
|
||||
AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS])
|
||||
|
||||
elif test "$GCC" = "yes"; then
|
||||
|
||||
dnl figure out gcc version!
|
||||
AC_MSG_CHECKING([gcc version])
|
||||
# strip '-suffix' parts, e.g. Ubuntu Windows cross-gcc returns '10-win32'
|
||||
gccver=`$CC -dumpversion | sed -E 's/-.+$//'`
|
||||
num1=`echo $gccver | cut -d . -f1`
|
||||
num2=`echo $gccver | cut -d . -f2`
|
||||
compiler_num=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
|
||||
AC_MSG_RESULT($gccver)
|
||||
|
||||
if test "$ICC" = "yes"; then
|
||||
dnl this is icc, not gcc.
|
||||
|
||||
dnl ICC warnings we ignore:
|
||||
dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
|
||||
dnl "invalid format string conversion"
|
||||
dnl * 279 warns on static conditions in while expressions
|
||||
dnl * 981 warns on "operands are evaluated in unspecified order"
|
||||
dnl * 1418 "external definition with no prior declaration"
|
||||
dnl * 1419 warns on "external declaration in primary source file"
|
||||
dnl which we know and do on purpose.
|
||||
|
||||
tmp_CFLAGS="-wd279,269,981,1418,1419"
|
||||
|
||||
if test "$compiler_num" -gt "600"; then
|
||||
dnl icc 6.0 and older doesn't have the -Wall flag
|
||||
tmp_CFLAGS="-Wall $tmp_CFLAGS"
|
||||
fi
|
||||
else dnl $ICC = yes
|
||||
dnl this is a set of options we believe *ALL* gcc versions support:
|
||||
tmp_CFLAGS="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
|
||||
|
||||
if test "$compiler_num" -ge "207"; then
|
||||
dnl gcc 2.7 or later
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -gt "295"; then
|
||||
dnl only if the compiler is newer than 2.95 since we got lots of
|
||||
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
|
||||
dnl gcc 2.95.4 on FreeBSD 4.9!
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long -Wno-multichar"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -ge "296"; then
|
||||
dnl gcc 2.96 or later
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -gt "296"; then
|
||||
dnl this option does not exist in 2.96
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
|
||||
fi
|
||||
|
||||
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
|
||||
dnl on i686-Linux as it gives us heaps with false positives.
|
||||
dnl Also, on gcc 4.0.X it is totally unbearable and complains all
|
||||
dnl over making it unusable for generic purposes. Let's not use it.
|
||||
|
||||
if test "$compiler_num" -ge "303"; then
|
||||
dnl gcc 3.3 and later
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -ge "304"; then
|
||||
# try these on gcc 3.4
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
|
||||
fi
|
||||
|
||||
dnl Only gcc 4.0 or later
|
||||
if test "$compiler_num" -ge "400"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.1 or later (possibly earlier)
|
||||
if test "$compiler_num" -ge "401"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.2 or later
|
||||
if test "$compiler_num" -ge "402"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.3 or later
|
||||
if test "$compiler_num" -ge "403"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
|
||||
dnl required for -Warray-bounds, included in -Wall
|
||||
tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.5 or later
|
||||
if test "$compiler_num" -ge "405"; then
|
||||
dnl Only windows targets
|
||||
case $host_os in
|
||||
mingw*)
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.6 or later
|
||||
if test "$compiler_num" -ge "406"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
|
||||
fi
|
||||
#
|
||||
dnl only gcc 4.8 or later
|
||||
if test "$compiler_num" -ge "408"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 5 or later
|
||||
if test "$compiler_num" -ge "500"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 6 or later
|
||||
if test "$compiler_num" -ge "600"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 7 or later
|
||||
if test "$compiler_num" -ge "700"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=1" # =2 causes false positives
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 10 or later
|
||||
if test "$compiler_num" -ge "1000"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
|
||||
fi
|
||||
|
||||
for flag in $CPPFLAGS; do
|
||||
case "$flag" in
|
||||
-I*)
|
||||
dnl Include path, provide a -isystem option for the same dir
|
||||
dnl to prevent warnings in those dirs. The -isystem was not very
|
||||
dnl reliable on earlier gcc versions.
|
||||
add=`echo $flag | sed 's/^-I/-isystem /g'`
|
||||
tmp_CFLAGS="$tmp_CFLAGS $add"
|
||||
tmp_CFLAGS="-pedantic"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [all extra])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [pointer-arith write-strings])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shadow])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [inline nested-externs])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-prototypes])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shorten-64-to-32])
|
||||
#
|
||||
dnl Only clang 1.1 or later
|
||||
if test "$compiler_num" -ge "101"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 2.7 or later
|
||||
if test "$compiler_num" -ge "207"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [empty-body])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 2.8 or later
|
||||
if test "$compiler_num" -ge "208"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [ignored-qualifiers])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 2.9 or later
|
||||
if test "$compiler_num" -ge "209"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-sign-overflow])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.0 or later (possibly earlier)
|
||||
if test "$compiler_num" -ge "300"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS"
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.2 or later
|
||||
if test "$compiler_num" -ge "302"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
|
||||
case $host_os in
|
||||
cygwin* | mingw*)
|
||||
dnl skip missing-variable-declarations warnings for cygwin and
|
||||
dnl mingw because the libtool wrapper executable causes them
|
||||
;;
|
||||
esac
|
||||
done
|
||||
*)
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-variable-declarations])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.4 or later
|
||||
if test "$compiler_num" -ge "304"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.6 or later
|
||||
if test "$compiler_num" -ge "306"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
|
||||
fi
|
||||
#
|
||||
dnl Only clang 3.9 or later
|
||||
if test "$compiler_num" -ge "309"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [comma])
|
||||
# avoid the varargs warning, fixed in 4.0
|
||||
# https://bugs.llvm.org/show_bug.cgi?id=29140
|
||||
if test "$compiler_num" -lt "400"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
|
||||
fi
|
||||
fi
|
||||
dnl clang 7 or later
|
||||
if test "$compiler_num" -ge "700"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [assign-enum])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [extra-semi-stmt])
|
||||
fi
|
||||
|
||||
fi dnl $ICC = no
|
||||
CFLAGS="$CFLAGS $tmp_CFLAGS"
|
||||
|
||||
CFLAGS="$CFLAGS $tmp_CFLAGS"
|
||||
AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS])
|
||||
|
||||
AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS])
|
||||
elif test "$GCC" = "yes"; then
|
||||
|
||||
else dnl $GCC = yes
|
||||
# indentation to match curl's m4/curl-compilers.m4
|
||||
|
||||
AC_MSG_NOTICE([Added no extra compiler options])
|
||||
dnl figure out gcc version!
|
||||
AC_MSG_CHECKING([gcc version])
|
||||
# strip '-suffix' parts, e.g. Ubuntu Windows cross-gcc returns '10-win32'
|
||||
gccver=`$CC -dumpversion | sed -E 's/-.+$//'`
|
||||
num1=`echo $gccver | cut -d . -f1`
|
||||
num2=`echo $gccver | cut -d . -f2`
|
||||
compiler_num=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
|
||||
AC_MSG_RESULT($gccver)
|
||||
|
||||
fi dnl $GCC = yes
|
||||
if test "$ICC" = "yes"; then
|
||||
dnl this is icc, not gcc.
|
||||
|
||||
dnl strip off optimizer flags
|
||||
NEWFLAGS=""
|
||||
for flag in $CFLAGS; do
|
||||
case "$flag" in
|
||||
-O*)
|
||||
dnl echo "cut off $flag"
|
||||
;;
|
||||
*)
|
||||
NEWFLAGS="$NEWFLAGS $flag"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
CFLAGS=$NEWFLAGS
|
||||
dnl ICC warnings we ignore:
|
||||
dnl * 269 warns on our "%Od" printf formatters for curl_off_t output:
|
||||
dnl "invalid format string conversion"
|
||||
dnl * 279 warns on static conditions in while expressions
|
||||
dnl * 981 warns on "operands are evaluated in unspecified order"
|
||||
dnl * 1418 "external definition with no prior declaration"
|
||||
dnl * 1419 warns on "external declaration in primary source file"
|
||||
dnl which we know and do on purpose.
|
||||
|
||||
tmp_CFLAGS="-wd279,269,981,1418,1419"
|
||||
|
||||
if test "$compiler_num" -gt "600"; then
|
||||
dnl icc 6.0 and older doesn't have the -Wall flag
|
||||
tmp_CFLAGS="-Wall $tmp_CFLAGS"
|
||||
fi
|
||||
else dnl $ICC = yes
|
||||
dnl this is a set of options we believe *ALL* gcc versions support:
|
||||
tmp_CFLAGS="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
|
||||
|
||||
if test "$compiler_num" -ge "207"; then
|
||||
dnl gcc 2.7 or later
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-declarations])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -gt "295"; then
|
||||
dnl only if the compiler is newer than 2.95 since we got lots of
|
||||
dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
|
||||
dnl gcc 2.95.4 on FreeBSD 4.9!
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long -Wno-multichar"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [bad-function-cast])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused shadow])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -ge "296"; then
|
||||
dnl gcc 2.96 or later
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [float-equal])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [sign-compare])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [undef])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -gt "296"; then
|
||||
dnl this option does not exist in 2.96
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
|
||||
fi
|
||||
|
||||
dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
|
||||
dnl on i686-Linux as it gives us heaps with false positives.
|
||||
dnl Also, on gcc 4.0.X it is totally unbearable and complains all
|
||||
dnl over making it unusable for generic purposes. Let's not use it.
|
||||
|
||||
if test "$compiler_num" -ge "303"; then
|
||||
dnl gcc 3.3 and later
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [endif-labels strict-prototypes])
|
||||
fi
|
||||
|
||||
if test "$compiler_num" -ge "304"; then
|
||||
# try these on gcc 3.4
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [declaration-after-statement])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [old-style-definition])
|
||||
fi
|
||||
|
||||
dnl Only gcc 4.0 or later
|
||||
if test "$compiler_num" -ge "400"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.1 or later (possibly earlier)
|
||||
if test "$compiler_num" -ge "401"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.2 or later
|
||||
if test "$compiler_num" -ge "402"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [cast-align])
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.3 or later
|
||||
if test "$compiler_num" -ge "403"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [type-limits old-style-declaration])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [missing-parameter-type empty-body])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [clobbered ignored-qualifiers])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [conversion])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-sign-conversion"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [vla])
|
||||
dnl required for -Warray-bounds, included in -Wall
|
||||
tmp_CFLAGS="$tmp_CFLAGS -ftree-vrp"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.5 or later
|
||||
if test "$compiler_num" -ge "405"; then
|
||||
dnl Only windows targets
|
||||
case $host_os in
|
||||
mingw*)
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 4.6 or later
|
||||
if test "$compiler_num" -ge "406"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [double-promotion])
|
||||
fi
|
||||
#
|
||||
dnl only gcc 4.8 or later
|
||||
if test "$compiler_num" -ge "408"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wformat=2"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 5 or later
|
||||
if test "$compiler_num" -ge "500"; then
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Warray-bounds=2"
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 6 or later
|
||||
if test "$compiler_num" -ge "600"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [shift-negative-value])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [null-dereference])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -fdelete-null-pointer-checks"
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-cond])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [unused-const-variable])
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 7 or later
|
||||
if test "$compiler_num" -ge "700"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [duplicated-branches])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [restrict])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [alloc-zero])
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
|
||||
tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=1" # =2 causes false positives
|
||||
fi
|
||||
#
|
||||
dnl Only gcc 10 or later
|
||||
if test "$compiler_num" -ge "1000"; then
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [arith-conversion])
|
||||
CURL_ADD_COMPILER_WARNINGS([tmp_CFLAGS], [enum-conversion])
|
||||
fi
|
||||
|
||||
for flag in $CPPFLAGS; do
|
||||
case "$flag" in
|
||||
-I*)
|
||||
dnl Include path, provide a -isystem option for the same dir
|
||||
dnl to prevent warnings in those dirs. The -isystem was not very
|
||||
dnl reliable on earlier gcc versions.
|
||||
add=`echo $flag | sed 's/^-I/-isystem /g'`
|
||||
tmp_CFLAGS="$tmp_CFLAGS $add"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
fi dnl $ICC = no
|
||||
|
||||
CFLAGS="$CFLAGS $tmp_CFLAGS"
|
||||
|
||||
AC_MSG_NOTICE([Added this set of compiler options: $tmp_CFLAGS])
|
||||
|
||||
else dnl $GCC = yes
|
||||
|
||||
AC_MSG_NOTICE([Added no extra compiler options])
|
||||
|
||||
fi dnl $GCC = yes
|
||||
|
||||
dnl strip off optimizer flags
|
||||
NEWFLAGS=""
|
||||
for flag in $CFLAGS; do
|
||||
case "$flag" in
|
||||
-O*)
|
||||
dnl echo "cut off $flag"
|
||||
;;
|
||||
*)
|
||||
NEWFLAGS="$NEWFLAGS $flag"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
CFLAGS=$NEWFLAGS
|
||||
|
||||
]) dnl end of AC_DEFUN()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user