From 569cf4daca0dad4e942003ae135db2f42ee22716 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 8 Jan 2009 16:24:26 -0800 Subject: [PATCH] Only enable warning options that the compiler actually understands. --- acinclude.m4 | 36 ++++++++++++++++++++++++++++++++++-- configure.ac | 16 +++++++++++++++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 1017ff7e..fc856c5c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 ---------------------------------------------------------------------- diff --git a/configure.ac b/configure.ac index 733e3434..f2d81633 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) -- 2.30.2