From dbc21ab2b5ba08f577c0f81f60fac12b196871a6 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 6 Nov 2011 13:22:16 -0800 Subject: [PATCH] configure: Add option --enable-Werror to add -Werror to CFLAGS. -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." The Autoconf code added in this commit, as well as this commit message, come from Open vSwitch. --- acinclude.m4 | 28 ++++++++++++++++++++++++++++ configure.ac | 1 + 2 files changed, 29 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 14d11dc7..52ac81ac 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -278,3 +278,31 @@ EOF AM_MAKEINFOFLAGS="$AM_MAKEINFOFLAGS -DMISSING_CLICKSEQUENCE" AC_SUBST([AM_MAKEINFOFLAGS]) fi]) + +# The following comes from Open vSwitch: +# ---------------------------------------------------------------------- +# Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +dnl PSPP_ENABLE_WERROR +AC_DEFUN([PSPP_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])]) + diff --git a/configure.ac b/configure.ac index 2ba3ba35..ce508eec 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ AC_ARG_ENABLE( [Attempt to allow building against older versions of dependent libraries])]) PSPP_ENABLE_OPTION(-Wdeclaration-after-statement) +PSPP_ENABLE_WERROR AM_CONDITIONAL(cc_is_gcc, test x"$GCC" = x"yes" ) -- 2.30.2