Only enable warning options that the compiler actually understands.
authorBen Pfaff <blp@nicira.com>
Fri, 9 Jan 2009 00:24:26 +0000 (16:24 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 9 Jan 2009 00:24:26 +0000 (16:24 -0800)
acinclude.m4
configure.ac

index 1017ff7e458ea14a9285ad30306a60cd68346b04..fc856c5c51977ea8e10d2c16b52c67138e063682 100644 (file)
@@ -1,6 +1,6 @@
 # -*- autoconf -*-
 
-# Copyright (c) 2008 The Board of Trustees of The Leland Stanford
+# Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford
 # Junior University
 #
 # We are making the OpenFlow specification and associated documentation
@@ -196,4 +196,36 @@ AC_DEFUN([OFP_CHECK_DPKG_BUILDPACKAGE],
   [AC_CHECK_PROG([HAVE_DPKG_BUILDPACKAGE], [dpkg-buildpackage], [yes], [no])
    AM_CONDITIONAL([HAVE_DPKG_BUILDPACKAGE], 
                   [test $HAVE_DPKG_BUILDPACKAGE = yes])])
-   
+
+dnl ----------------------------------------------------------------------
+dnl These macros are from GNU PSPP, with the following original license:
+dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl OFP_CHECK_CC_OPTION([OPTION], [ACTION-IF-ACCEPTED], [ACTION-IF-REJECTED])
+dnl Check whether the given C compiler OPTION is accepted.
+dnl If so, execute ACTION-IF-ACCEPTED, otherwise ACTION-IF-REJECTED.
+AC_DEFUN([OFP_CHECK_CC_OPTION],
+[
+  m4_define([ofp_cv_name], [ofp_cv_[]m4_translit([$1], [-], [_])])dnl
+  AC_CACHE_CHECK([whether $CC accepts $1], [ofp_cv_name], 
+    [ofp_save_CFLAGS="$CFLAGS"
+     CFLAGS="$CFLAGS $1"
+     AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [ofp_cv_name[]=yes], [ofp_cv_name[]=no])
+     CFLAGS="$ofp_save_CFLAGS"])
+  if test $ofp_cv_name = yes; then
+    m4_if([$2], [], [;], [$2])
+  else
+    m4_if([$3], [], [:], [$3])
+  fi
+])
+
+dnl OFP_ENABLE_OPTION([OPTION])
+dnl Check whether the given C compiler OPTION is accepted.
+dnl If so, add it to CFLAGS.
+dnl Example: OFP_ENABLE_OPTION([-Wdeclaration-after-statement])
+AC_DEFUN([OFP_ENABLE_OPTION], 
+  [OFP_CHECK_CC_OPTION([$1], [CFLAGS="$CFLAGS $1"])])
+dnl ----------------------------------------------------------------------
index 733e343491bb5aea4143b13f109179eb91e0ec5c..f2d81633568040b8cde1ac24584fac8ccde503ef 100644 (file)
@@ -64,7 +64,21 @@ OFP_CHECK_LINUX(l24, 2.4, 2.4, KSRC24, L24_ENABLED)
 
 OFP_CHECK_DPKG_BUILDPACKAGE
 
-CFLAGS="$CFLAGS -Wall -Wno-sign-compare -Wpointer-arith -Wdeclaration-after-statement -Wformat-security -Wswitch-enum -Wunused-parameter -Wstrict-aliasing -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -Wno-override-init"
+OFP_ENABLE_OPTION([-Wall])
+OFP_ENABLE_OPTION([-Wno-sign-compare])
+OFP_ENABLE_OPTION([-Wpointer-arith])
+OFP_ENABLE_OPTION([-Wdeclaration-after-statement])
+OFP_ENABLE_OPTION([-Wformat-security])
+OFP_ENABLE_OPTION([-Wswitch-enum])
+OFP_ENABLE_OPTION([-Wunused-parameter])
+OFP_ENABLE_OPTION([-Wstrict-aliasing])
+OFP_ENABLE_OPTION([-Wbad-function-cast])
+OFP_ENABLE_OPTION([-Wcast-align])
+OFP_ENABLE_OPTION([-Wstrict-prototypes])
+OFP_ENABLE_OPTION([-Wold-style-definition])
+OFP_ENABLE_OPTION([-Wmissing-prototypes])
+OFP_ENABLE_OPTION([-Wmissing-field-initializers])
+OFP_ENABLE_OPTION([-Wno-override-init])
 
 OFP_ENABLE_EXT
 m4_include([ext.m4])