# -*- 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
[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 ----------------------------------------------------------------------
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])