1 dnl Common configure.in fragment
3 dnl Copyright 2012 Free Software Foundation
5 dnl This file is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; see the file COPYING3. If not see
17 dnl <http://www.gnu.org/licenses/>.
20 AC_DEFUN([AM_BINUTILS_WARNINGS],[
21 GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
22 AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow")
25 [ --enable-werror treat compile warnings as errors],
26 [case "${enableval}" in
27 yes | y) ERROR_ON_WARNING="yes" ;;
28 no | n) ERROR_ON_WARNING="no" ;;
29 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
32 # Disable -Wformat by default when using gcc on mingw
35 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
36 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
42 # Enable -Werror by default when using gcc
43 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
48 if test "${ERROR_ON_WARNING}" = yes ; then
49 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
50 NO_WERROR="-Wno-error"
53 if test "${GCC}" = yes ; then
54 WARN_CFLAGS="${GCC_WARN_CFLAGS}"
57 AC_ARG_ENABLE(build-warnings,
58 [ --enable-build-warnings enable build-time compiler warnings],
59 [case "${enableval}" in
60 yes) WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
61 no) if test "${GCC}" = yes ; then
64 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
65 WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
66 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
67 WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
68 *) WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
71 if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
72 echo "Setting warning flags = $WARN_CFLAGS" 6>&1