[network-manager-applet: 6/7] build: update m4 macro compiler_warnings.m4/compiler_options.m4
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet: 6/7] build: update m4 macro compiler_warnings.m4/compiler_options.m4
- Date: Mon, 6 Jun 2016 12:54:50 +0000 (UTC)
commit 9b003381815b50ce762fa9eadeebc786b955fbe5
Author: Thomas Haller <thaller redhat com>
Date: Mon Jun 6 13:28:21 2016 +0200
build: update m4 macro compiler_warnings.m4/compiler_options.m4
Taken from NetworkManager repository.
m4/{compiler_warnings.m4 => compiler_options.m4} | 55 ++++++++++++----------
1 files changed, 30 insertions(+), 25 deletions(-)
---
diff --git a/m4/compiler_warnings.m4 b/m4/compiler_options.m4
similarity index 72%
rename from m4/compiler_warnings.m4
rename to m4/compiler_options.m4
index b7acee5..fa11c52 100644
--- a/m4/compiler_warnings.m4
+++ b/m4/compiler_options.m4
@@ -1,17 +1,17 @@
-dnl Check whether a particular compiler flag works with code provided,
-dnl disable it in CFLAGS if the check fails.
-AC_DEFUN([NM_COMPILER_WARNING], [
+AC_DEFUN([_NM_COMPILER_FLAG], [
CFLAGS_SAVED="$CFLAGS"
- CFLAGS="$CFLAGS -Werror -W$1"
- AC_MSG_CHECKING(whether -W$1 works)
+ CFLAGS="$CFLAGS $GLIB_CFLAGS -Werror $1"
+ AC_MSG_CHECKING([whether $1 works as expected])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])], [
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[$2]])], [
AC_MSG_RESULT(yes)
- CFLAGS="$CFLAGS_SAVED -W$1"
+ CFLAGS="$CFLAGS_SAVED"
+ $3
],[
AC_MSG_RESULT(no)
- CFLAGS="$CFLAGS_SAVED -Wno-$1"
+ CFLAGS="$CFLAGS_SAVED"
+ $4
])
],[
AC_MSG_RESULT(not supported)
@@ -19,10 +19,25 @@ AC_DEFUN([NM_COMPILER_WARNING], [
])
])
+dnl Check whether a particular compiler flag is supported,
+dnl add it to CFLAGS if it is
+AC_DEFUN([NM_COMPILER_FLAG], [
+ _NM_COMPILER_FLAG([$1], [], [
+ CFLAGS="$CFLAGS $1"
+ $2
+ ], [$3])
+])
+
+dnl Check whether a particular warning is not emitted with code provided,
+dnl disable it in CFLAGS if the check fails.
+AC_DEFUN([NM_COMPILER_WARNING], [
+ _NM_COMPILER_FLAG([-W$1], [$2], [CFLAGS="$CFLAGS -W$1"], [CFLAGS="$CFLAGS -Wno-$1"])
+])
+
AC_DEFUN([NM_COMPILER_WARNINGS],
[AC_ARG_ENABLE(more-warnings,
AS_HELP_STRING([--enable-more-warnings], [Possible values: no/yes/error]),
- set_more_warnings="$enableval",set_more_warnings=error)
+ set_more_warnings="$enableval",set_more_warnings=yes)
AC_MSG_CHECKING(for more warnings)
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
AC_MSG_RESULT(yes)
@@ -40,7 +55,6 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
dnl attach it to the CFLAGS.
NM_COMPILER_WARNING([unknown-warning-option], [])
- CFLAGS_SAVED="$CFLAGS"
CFLAGS_MORE_WARNINGS="-Wall -std=gnu89"
if test "x$set_more_warnings" = xerror; then
@@ -50,28 +64,19 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \
-Wdeclaration-after-statement -Wformat-security \
-Wfloat-equal -Wno-unused-parameter -Wno-sign-compare \
+ -Wno-duplicate-decl-specifier \
-Wstrict-prototypes \
- -fno-strict-aliasing -Wno-unused-but-set-variable \
+ -Wno-unused-but-set-variable \
+ -Wno-format-y2k \
-Wundef -Wimplicit-function-declaration \
- -Wpointer-arith -Winit-self \
- -Wmissing-include-dirs -Waggregate-return; do
+ -Wpointer-arith -Winit-self -Wformat-nonliteral \
+ -Wmissing-include-dirs -Wno-pragmas; do
dnl GCC 4.4 does not warn when checking for -Wno-* flags
(https://gcc.gnu.org/wiki/FAQ#wnowarning)
- CFLAGS="$CFLAGS_MORE_WARNINGS $(printf '%s' "$option" | sed 's/^-Wno-/-W/') $CFLAGS_SAVED"
- AC_MSG_CHECKING([whether compiler understands $option])
- AC_TRY_COMPILE([], [],
- has_option=yes,
- has_option=no,)
- if test $has_option != no; then
- CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS $option"
- fi
- AC_MSG_RESULT($has_option)
- unset has_option
+ _NM_COMPILER_FLAG([$(printf '%s' "$option" | sed 's/^-Wno-/-W/')], [],
+ [CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS $option"], [])
done
unset option
- CFLAGS="$CFLAGS_SAVED"
- unset CFLAGS_SAVED
-
dnl Disable warnings triggered by known compiler problems
dnl https://bugzilla.gnome.org/show_bug.cgi?id=745821
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]