build: fix detecting support for -Wno-* compiler flags
authorThomas Haller <thaller@redhat.com>
Tue, 24 Feb 2015 17:11:21 +0000 (18:11 +0100)
committerThomas Haller <thaller@redhat.com>
Tue, 24 Feb 2015 17:43:44 +0000 (18:43 +0100)
Since GCC 4.4, gcc does not warn about unknown -Wno-* flags. At
least, it does not warning unless another warning is raised as well
(https://gcc.gnu.org/wiki/FAQ#wnowarning).

We didn't notice up to now, because we only tested flags that GCC
actually supports.

Hack around this, by checking for the -W* counterpart instead.

m4/compiler_warnings.m4

index c05a26d..412acb9 100644 (file)
@@ -30,7 +30,8 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
                      -Wundef -Wimplicit-function-declaration \
                      -Wpointer-arith -Winit-self \
                      -Wmissing-include-dirs; do
-               CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_EXTRA $option $CFLAGS_SAVED"
+               dnl GCC 4.4 does not warn when checking for -Wno-* flags (https://gcc.gnu.org/wiki/FAQ#wnowarning)
+               CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_EXTRA $(printf '%s' "$option" | sed 's/^-Wno-/-W/')  $CFLAGS_SAVED"
                AC_MSG_CHECKING([whether gcc understands $option])
                AC_TRY_COMPILE([], [],
                        has_option=yes,