[byzanz] Update compiler warning machinery to 2009



commit ad99e4ca0227e6c3e8e9ee819dd5612bac4a9d2e
Author: Benjamin Otte <otte gnome org>
Date:   Sat Aug 15 16:20:39 2009 +0200

    Update compiler warning machinery to 2009

 configure.ac               |   10 ++--------
 macros/as-compiler-flag.m4 |   43 +++++++++++++++++++++++++++++++++----------
 2 files changed, 35 insertions(+), 18 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 864b12c..c7b71dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,16 +40,10 @@ dnl For interactive UNIX (a Sun thing)
 AC_ISC_POSIX
 
 dnl decide on error flags
-dnl if we support them, we set them unconditionally
-AS_COMPILER_FLAG(-Wall, ERROR_CFLAGS="-Wall", ERROR_CFLAGS="")
-dnl I want this but stupid headers don't let me
-dnl AS_COMPILER_FLAG(-Wshadow, ERROR_CFLAGS="$ERROR_CFLAGS -Wshadow")
-AS_COMPILER_FLAG(-Wfloat-equal, ERROR_CFLAGS="$ERROR_CFLAGS -Wfloat-equal")
-AS_COMPILER_FLAG(-Wextra -Wno-missing-field-initializers -Wno-unused-parameter, ERROR_CFLAGS="$ERROR_CFLAGS -Wextra -Wno-missing-field-initializers -Wno-unused-parameter")
-dnl if we're in nano >= 1, add -Werror if supported
+AS_COMPILER_FLAGS(ERROR_CFLAGS, "-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wswitch-default -Winit-self -Wmissing-include-dirs -Wundef -Waggregate-return -Wmissing-format-attribute -Wnested-externs -Wunsafe-loop-optimizations -Wpacked -Winvalid-pch -Wsync-nand")
 if test "x$BYZANZ_CVS" = "xyes"
 then
-  AS_COMPILER_FLAG(-Werror, ERROR_CFLAGS="$ERROR_CFLAGS -Werror")
+  AS_COMPILER_FLAGS(ERROR_CFLAGS, "-Werror")
 fi
 
 AC_HEADER_STDC([])
diff --git a/macros/as-compiler-flag.m4 b/macros/as-compiler-flag.m4
index 66179c2..0f660cf 100644
--- a/macros/as-compiler-flag.m4
+++ b/macros/as-compiler-flag.m4
@@ -4,7 +4,7 @@ dnl autostars m4 macro for detection of compiler flags
 
 dnl David Schleef <ds schleef org>
 
-dnl $Id$
+dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $
 
 dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
 dnl Tries to compile with the given CFLAGS.
@@ -18,22 +18,45 @@ AC_DEFUN([AS_COMPILER_FLAG],
   save_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $1"
 
-  AC_TRY_COMPILE([
-int main (int argc, char **argv)
-{
-#if 0
-], [
-#endif
-], [flag_ok=yes], [flag_ok=no])
+  AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
   CFLAGS="$save_CFLAGS"
 
   if test "X$flag_ok" = Xyes ; then
-    $2
+    m4_ifvaln([$2],[$2])
     true
   else
-    $3
+    m4_ifvaln([$3],[$3])
     true
   fi
   AC_MSG_RESULT([$flag_ok])
 ])
 
+dnl AS_COMPILER_FLAGS(VAR, FLAGS)
+dnl Tries to compile with the given CFLAGS.
+
+AC_DEFUN([AS_COMPILER_FLAGS],
+[
+  list=$2
+  flags_supported=""
+  flags_unsupported=""
+  AC_MSG_CHECKING([for supported compiler flags])
+  for each in $list
+  do
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $each"
+    AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
+    CFLAGS="$save_CFLAGS"
+
+    if test "X$flag_ok" = Xyes ; then
+      flags_supported="$flags_supported $each"
+    else
+      flags_unsupported="$flags_unsupported $each"
+    fi
+  done
+  AC_MSG_RESULT([$flags_supported])
+  if test "X$flags_unsupported" != X ; then
+    AC_MSG_WARN([unsupported compiler flags: $flags_unsupported])
+  fi
+  $1="$$1 $flags_supported"
+])
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]