mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 15:48:49 -05:00
Moved most of the set-debug-options-depending-on-compiler logic to the new
CURL_CC_DEBUG_OPTS function in acinclude.m4
This commit is contained in:
parent
be62b27ce2
commit
4fa58560bf
86
acinclude.m4
86
acinclude.m4
@ -475,3 +475,89 @@ if test "$ac_cv_func_gethostbyname_r" = "yes"; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
|
dnl We create a function for detecting which compiler we use and then set as
|
||||||
|
dnl pendantic compiler options as possible for that particular compiler. The
|
||||||
|
dnl options are only used for debug-builds.
|
||||||
|
|
||||||
|
AC_DEFUN([CURL_CC_DEBUG_OPTS],
|
||||||
|
[
|
||||||
|
if test "$GCC" = "yes"; then
|
||||||
|
|
||||||
|
dnl figure out gcc version!
|
||||||
|
AC_MSG_CHECKING([gcc version])
|
||||||
|
gccver=`$CC -dumpversion`
|
||||||
|
num1=`echo $gccver | cut -d . -f1`
|
||||||
|
num2=`echo $gccver | cut -d . -f2`
|
||||||
|
gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
|
||||||
|
AC_MSG_RESULT($gccver)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([if this is icc in disguise])
|
||||||
|
AC_EGREP_CPP([^__ICC], [__ICC],
|
||||||
|
dnl action if the text is found, this it has not been replaced by the
|
||||||
|
dnl cpp
|
||||||
|
[ICC="no"]
|
||||||
|
AC_MSG_RESULT([no]),
|
||||||
|
dnl the text was not found, it was replaced by the cpp
|
||||||
|
[ICC="yes"]
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
)
|
||||||
|
|
||||||
|
if test "$ICC" = "yes"; then
|
||||||
|
dnl this is icc, not gcc.
|
||||||
|
WARN = ""
|
||||||
|
else dnl $ICC = yes
|
||||||
|
dnl
|
||||||
|
WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
|
||||||
|
|
||||||
|
dnl -Wcast-align is a bit too annoying ;-)
|
||||||
|
|
||||||
|
if test "$gccnum" -ge "296"; then
|
||||||
|
dnl gcc 2.96 or later
|
||||||
|
WARN="$WARN -Wfloat-equal"
|
||||||
|
|
||||||
|
if test "$gccnum" -gt "296"; then
|
||||||
|
dnl this option does not exist in 2.96
|
||||||
|
WARN="$WARN -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
|
||||||
|
if test "$gccnum" -ge "303"; then
|
||||||
|
dnl gcc 3.3 and later
|
||||||
|
WARN="$WARN -Wendif-labels -Wstrict-prototypes"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
NEWFLAGS=""
|
||||||
|
for flag in $CPPFLAGS; do
|
||||||
|
case "$flag" in
|
||||||
|
-I*)
|
||||||
|
dnl include path
|
||||||
|
add=`echo $flag | sed 's/^-I/-isystem /g'`
|
||||||
|
NEWFLAGS="$NEWFLAGS $add"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
CFLAGS="$CFLAGS $WARN $NEWFLAGS"
|
||||||
|
fi dnl $ICC = no
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
70
configure.ac
70
configure.ac
@ -1188,72 +1188,14 @@ AC_HELP_STRING([--disable-debug],[Disable debug options]),
|
|||||||
*) AC_MSG_RESULT(yes)
|
*) AC_MSG_RESULT(yes)
|
||||||
|
|
||||||
CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
|
CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
|
||||||
CFLAGS="$CFLAGS -g"
|
CFLAGS="$CFLAGS -g"
|
||||||
if test "$GCC" = "yes"; then
|
|
||||||
|
|
||||||
dnl figure out gcc version!
|
dnl set compiler "debug" options to become more picky, and remove
|
||||||
AC_MSG_CHECKING([gcc version])
|
dnl optimize options from CFLAGS
|
||||||
gccver=`$CC -dumpversion`
|
CURL_CC_DEBUG_OPTS
|
||||||
num1=`echo $gccver | cut -d . -f1`
|
|
||||||
num2=`echo $gccver | cut -d . -f2`
|
|
||||||
gccnum=`(expr $num1 "*" 100 + $num2) 2>/dev/null`
|
|
||||||
AC_MSG_RESULT($gccver)
|
|
||||||
|
|
||||||
if test "$gccnum" -lt "500"; then
|
|
||||||
dnl we only like gcc less than 5.0, since if it is above that it is
|
|
||||||
dnl likely just a compiler that looks like gcc (like icc 8.0)!
|
|
||||||
dnl here's the standard setup
|
|
||||||
WARN="-W -Wall -Wwrite-strings -pedantic -Wno-long-long -Wundef -Wpointer-arith -Wnested-externs -Winline -Wmissing-declarations -Wmissing-prototypes -Wsign-compare"
|
|
||||||
|
|
||||||
dnl -Wcast-align is a bit too annoying ;-)
|
|
||||||
|
|
||||||
if test "$gccnum" -ge "296"; then
|
|
||||||
dnl gcc 2.96 or later
|
|
||||||
WARN="$WARN -Wfloat-equal"
|
|
||||||
|
|
||||||
if test "$gccnum" -gt "296"; then
|
|
||||||
dnl this option does not exist in 2.96
|
|
||||||
WARN="$WARN -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
|
|
||||||
if test "$gccnum" -ge "303"; then
|
|
||||||
dnl gcc 3.3 and later
|
|
||||||
WARN="$WARN -Wendif-labels -Wstrict-prototypes"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
NEWFLAGS=""
|
|
||||||
for flag in $CPPFLAGS; do
|
|
||||||
case "$flag" in
|
|
||||||
-I*)
|
|
||||||
dnl include path
|
|
||||||
add=`echo $flag | sed 's/^-I/-isystem /g'`
|
|
||||||
NEWFLAGS="$NEWFLAGS $add"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
CFLAGS="$CFLAGS $WARN $NEWFLAGS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
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
|
|
||||||
;;
|
;;
|
||||||
esac ],
|
esac
|
||||||
|
],
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user