changeset 8938:35e18344fae8

configure.in: options for compiler warning flags
author John W. Eaton <jwe@octave.org>
date Mon, 09 Mar 2009 13:23:05 -0400
parents f27b2c95817f
children 4e1fed5d847b
files ChangeLog configure.in
diffstat 2 files changed, 46 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 09 16:03:17 2009 +0100
+++ b/ChangeLog	Mon Mar 09 13:23:05 2009 -0400
@@ -1,3 +1,10 @@
+2009-03-09  John W. Eaton  <jwe@octave.org>
+
+	* configure.in (--enable-extra-warning-flags): New option to
+	control extra compiler warning flags.
+	(--enable-strict-warning-flags): Rename from --enable-picky-flags.
+	(GXX_STRICT_FLAGS): Remove -Wenum-clash from the list.
+
 2009-03-08  Søren Hauberg  <hauberg@gmail.com>
 
 	* NEWS: Mention 'histc'.
--- a/configure.in	Mon Mar 09 16:03:17 2009 +0100
+++ b/configure.in	Mon Mar 09 13:23:05 2009 -0400
@@ -1925,19 +1925,25 @@
 ### Maybe add -Wall, -W, and -Wshadow to compiler flags now that we're
 ### done feature testing. 
 
-if test -z "$EXTERN_CFLAGS"; then
+try_extra_warning_flags=true
+AC_ARG_ENABLE(extra-warning-flags,
+  [AS_HELP_STRING([--enable-extra-warning-flags],
+     [add -Wall, -W, -Wshadow, and -Wold-style-cast options to CFLAGS and CXXFLAGS  (on by default, but only if the compiler appears to accept them)])],
+  [if test "$enableval" = no; then
+     try_extra_warning_flags=false
+   fi], [])
+
+if $try_extra_warning_flags; then
   OCTAVE_CC_FLAG(-Wall, [
-	WARN_CFLAGS="$WARN_CFLAGS -Wall";
-	AC_MSG_RESULT([adding -Wall to WARN_CFLAGS])])
+    WARN_CFLAGS="$WARN_CFLAGS -Wall";
+    AC_MSG_RESULT([adding -Wall to WARN_CFLAGS])])
   OCTAVE_CC_FLAG(-W, [
-	WARN_CFLAGS="$WARN_CFLAGS -W";
-	AC_MSG_RESULT([adding -W to WARN_CFLAGS])])
+    WARN_CFLAGS="$WARN_CFLAGS -W";
+    AC_MSG_RESULT([adding -W to WARN_CFLAGS])])
   OCTAVE_CC_FLAG(-Wshadow, [
-	WARN_CFLAGS="$WARN_CFLAGS -Wshadow";
-	AC_MSG_RESULT([adding -Wshadow to WARN_CFLAGS])])
-fi
+    WARN_CFLAGS="$WARN_CFLAGS -Wshadow";
+    AC_MSG_RESULT([adding -Wshadow to WARN_CFLAGS])])
 
-if test -z "$EXTERN_CXXFLAGS"; then
   OCTAVE_CXX_FLAG(-Wall, [
     WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall";
     AC_MSG_RESULT([adding -Wall to WARN_CXXFLAGS])])
@@ -1952,33 +1958,33 @@
     AC_MSG_RESULT([adding -Wold-style-cast to WARN_CXXFLAGS])])
 fi
 
-GCC_PICKY_FLAGS="-Wcast-align -Wcast-qual -Wmissing-prototypes \
+GCC_STRICT_FLAGS="-Wcast-align -Wcast-qual -Wmissing-prototypes \
   -Wpointer-arith -Wstrict-prototypes -Wwrite-strings"
 
-GXX_PICKY_FLAGS="-Wcast-align -Wcast-qual -Wpointer-arith \
-  -Wwrite-strings -Weffc++ -Wenum-clash"
+GXX_STRICT_FLAGS="-Wcast-align -Wcast-qual -Wpointer-arith \
+  -Wwrite-strings -Weffc++"
+
+try_strict_warning_flags=false
+
+AC_ARG_ENABLE(strict-warning-flags,
+  [AS_HELP_STRING([--enable-strict-warning-flags],
+     [add extra strict warning options to CFLAGS and CXXFLAGS (off by default)])],
+  [if test "$enableval" = yes; then
+     try_strict_warning_flags=true
+   fi], [])
 
-AC_ARG_ENABLE(picky-flags,
-  [AS_HELP_STRING([--enable-picky-flags],
-     [add extra warning options to CFLAGS, CXXFLAGS, FFLAGS])],
-  [if test "$enableval" = no; then
-     true
-   elif test "$enableval" = yes; then
-     if test -z "$EXTERN_CFLAGS"; then
-       for flag in $GCC_PICKY_FLAGS; do
-	 OCTAVE_CC_FLAG($flag, [
-	   WARN_CFLAGS="$WARN_CFLAGS $flag";
-	   AC_MSG_RESULT([adding $flag to WARN_CFLAGS])])
-       done
-     fi
-     if test -z "$EXTERN_CXXFLAGS"; then
-       for flag in $GXX_PICKY_FLAGS; do
-	 OCTAVE_CXX_FLAG($flag, [
-	   WARN_CXXFLAGS="$WARN_CXXFLAGS $flag";
-	   AC_MSG_RESULT([adding $flag to WARN_CXXFLAGS])])
-       done
-     fi
-   fi], [])
+if $try_strict_warning_flags; then
+  for flag in $GCC_STRICT_FLAGS; do
+    OCTAVE_CC_FLAG($flag, [
+      WARN_CFLAGS="$WARN_CFLAGS $flag";
+      AC_MSG_RESULT([adding $flag to WARN_CFLAGS])])
+  done
+  for flag in $GXX_STRICT_FLAGS; do
+    OCTAVE_CXX_FLAG($flag, [
+      WARN_CXXFLAGS="$WARN_CXXFLAGS $flag";
+      AC_MSG_RESULT([adding $flag to WARN_CXXFLAGS])])
+  done
+fi
 
 AC_SUBST(WARN_CFLAGS)
 AC_SUBST(WARN_CXXFLAGS)