2009-04-22 00:50:45 +00:00
|
|
|
AC_DEFUN([NM_COMPILER_WARNINGS],
|
|
|
|
[AC_ARG_ENABLE(more-warnings,
|
2012-01-29 21:01:56 +00:00
|
|
|
AS_HELP_STRING([--enable-more-warnings], [Possible values: no/yes/error]),
|
|
|
|
set_more_warnings="$enableval",set_more_warnings=error)
|
2011-04-26 18:55:52 +00:00
|
|
|
AC_MSG_CHECKING(for more warnings)
|
2009-04-22 00:50:45 +00:00
|
|
|
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
|
|
|
|
AC_MSG_RESULT(yes)
|
2014-10-29 10:52:47 +00:00
|
|
|
CFLAGS_SAVED="$CFLAGS"
|
|
|
|
CFLAGS_MORE_WARNINGS="-Wall -std=gnu89"
|
2009-04-22 00:50:45 +00:00
|
|
|
|
2014-07-26 18:11:31 +00:00
|
|
|
dnl clang only warns about unknown warnings, unless
|
|
|
|
dnl called with "-Werror=unknown-warning-option"
|
|
|
|
dnl Test if the compiler supports that, and if it does
|
|
|
|
dnl attach it to the CFLAGS.
|
2014-10-29 10:52:47 +00:00
|
|
|
CFLAGS_EXTRA="-Werror=unknown-warning-option"
|
|
|
|
CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_EXTRA $CFLAGS_SAVED"
|
2014-07-26 18:11:31 +00:00
|
|
|
AC_TRY_COMPILE([], [],
|
|
|
|
has_option=yes,
|
|
|
|
has_option=no,)
|
|
|
|
if test $has_option = no; then
|
2014-10-29 10:52:47 +00:00
|
|
|
CFLAGS_EXTRA=
|
2014-07-26 18:11:31 +00:00
|
|
|
fi
|
|
|
|
unset has_option
|
|
|
|
|
2009-04-22 00:50:45 +00:00
|
|
|
for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \
|
2014-04-02 13:24:56 +00:00
|
|
|
-Wdeclaration-after-statement -Wformat-security \
|
2009-04-22 00:50:45 +00:00
|
|
|
-Wfloat-equal -Wno-unused-parameter -Wno-sign-compare \
|
2014-10-29 11:59:51 +00:00
|
|
|
-Wstrict-prototypes \
|
2011-04-14 18:16:55 +00:00
|
|
|
-fno-strict-aliasing -Wno-unused-but-set-variable \
|
2012-07-30 15:58:15 +00:00
|
|
|
-Wundef -Wimplicit-function-declaration \
|
|
|
|
-Wpointer-arith -Winit-self \
|
2014-07-22 17:38:20 +00:00
|
|
|
-Wmissing-include-dirs; do
|
2014-10-29 10:52:47 +00:00
|
|
|
CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_EXTRA $option $CFLAGS_SAVED"
|
2009-04-22 00:50:45 +00:00
|
|
|
AC_MSG_CHECKING([whether gcc understands $option])
|
|
|
|
AC_TRY_COMPILE([], [],
|
|
|
|
has_option=yes,
|
|
|
|
has_option=no,)
|
2014-10-29 10:52:47 +00:00
|
|
|
if test $has_option != no; then
|
|
|
|
CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS $option"
|
2009-04-22 00:50:45 +00:00
|
|
|
fi
|
|
|
|
AC_MSG_RESULT($has_option)
|
|
|
|
unset has_option
|
|
|
|
done
|
|
|
|
unset option
|
2014-10-29 10:52:47 +00:00
|
|
|
unset CFLAGS_EXTRA
|
2012-01-29 21:01:56 +00:00
|
|
|
if test "x$set_more_warnings" = xerror; then
|
2014-10-29 10:52:47 +00:00
|
|
|
CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS -Werror"
|
2012-01-29 21:01:56 +00:00
|
|
|
fi
|
2014-10-29 10:52:47 +00:00
|
|
|
CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_SAVED"
|
|
|
|
unset CFLAGS_SAVED
|
2009-04-22 00:50:45 +00:00
|
|
|
else
|
|
|
|
AC_MSG_RESULT(no)
|
|
|
|
fi
|
|
|
|
])
|