configure: Add option --enable-Werror to add -Werror to CFLAGS.
authorBen Pfaff <blp@nicira.com>
Tue, 12 Apr 2011 18:43:11 +0000 (11:43 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 12 Apr 2011 20:41:36 +0000 (13:41 -0700)
-Werror is useful for development, but it screws up configure because it's
impossible to guess what new warnings compilers will add in the future.
This commit adds a new configure option to add CFLAGS after the configure
checks are done.

The use of AC_CONFIG_COMMANDS_PRE is based on Eric Blake's suggestion on
the autoconf mailing list: "AC_CONFIG_COMMANDS_PRE probably fits the bill
as the ideal macro to use for guaranteeing that you inject your shell code
at the last possible moment."

Requested-by: Andrew Evans <aevans@nicira.com>
acinclude.m4
configure.ac

index fa6f534deb3cfa4f1f276a7cc77ca0a67083c643..69e61e0e916e2bdad20db4273c7e72a0c3fec88b 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+dnl OVS_ENABLE_WERROR
+AC_DEFUN([OVS_ENABLE_WERROR],
+  [AC_ARG_ENABLE(
+     [Werror],
+     [AC_HELP_STRING([--enable-Werror], [Add -Werror to CFLAGS])],
+     [], [enable_Werror=no])
+   AC_CONFIG_COMMANDS_PRE(
+     [if test "X$enable_Werror" = Xyes; then
+        CFLAGS="$CFLAGS -Werror"
+      fi])])
+
 dnl OVS_CHECK_LINUX26
 dnl
 dnl Configure linux kernel source tree 
index 5a2b5c0c42db0832e17472690e7a6a6269b28089..5b5f47ed99cda07ed696e1f6e4b9bc0dfac2014b 100644 (file)
@@ -84,6 +84,7 @@ OVS_ENABLE_OPTION([-Wmissing-field-initializers])
 OVS_ENABLE_OPTION([-Wno-override-init])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
 OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER])
+OVS_ENABLE_WERROR
 
 AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)