configure.ac: Detect working gcc warning flags
authorMarko Kreen <markokr@gmail.com>
Mon, 13 Apr 2009 14:14:35 +0000 (17:14 +0300)
committerMarko Kreen <markokr@gmail.com>
Mon, 13 Apr 2009 14:14:35 +0000 (17:14 +0300)
configure.ac

index 04fcd72cefa1f963cfc887cf51d615d2d0d9c231..2233ae444b567b29d23a893999e4a63b8f24775f 100644 (file)
@@ -75,6 +75,26 @@ fi
 AC_PROG_CC
 AC_PROG_CPP
 
+dnl Additional gcc tuning
+if test x"$GCC" = xyes; then
+  AC_MSG_CHECKING([for working warning switches])
+  good_CFLAGS="$CFLAGS"
+  warnings=""
+  flags="-Wall -Wextra"
+  # turn off noise from Wextra
+  flags="$flags -Wno-unused-parameter -Wno-missing-field-initializers"
+  # Wextra does not turn those on?
+  flags="$flags -Wmissing-prototypes -Wpointer-arith -Wendif-labels"
+  flags="$flags -Wdeclaration-after-statement -Wold-style-definition"
+  flags="$flags -Wstrict-prototypes -Wundef -Wformat -Wnonnull -Wstrict-overflow"
+  for f in $flags; do
+    CFLAGS="$good_CFLAGS $warnings $f"
+    AC_COMPILE_IFELSE([void foo(void){}], [warnings="$warnings $f"])
+  done
+  CFLAGS="$good_CFLAGS $warnings"
+  AC_MSG_RESULT([$warnings])
+fi
+
 # autoconf does not want to find 'install', if not using automake...
 INSTALL=install