Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / warning.m4
CommitLineData
1110793a 1dnl Common configure.ac fragment
5bf135a7 2dnl
4b95cf5c 3dnl Copyright (C) 2012-2014 Free Software Foundation, Inc.
5bf135a7
NC
4dnl
5dnl This file is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This program is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this program; see the file COPYING3. If not see
17dnl <http://www.gnu.org/licenses/>.
18dnl
9e9b66a9
AM
19
20AC_DEFUN([AM_BINUTILS_WARNINGS],[
270c9937
JB
21# Set the 'development' global.
22. $srcdir/../bfd/development.sh
23
d1a98e0c
AM
24GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
25AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow")
9e9b66a9
AM
26
27AC_ARG_ENABLE(werror,
241a6c40 28 [ --enable-werror treat compile warnings as errors],
9e9b66a9
AM
29 [case "${enableval}" in
30 yes | y) ERROR_ON_WARNING="yes" ;;
31 no | n) ERROR_ON_WARNING="no" ;;
32 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
33 esac])
34
d1a98e0c 35# Disable -Wformat by default when using gcc on mingw
bb8541b9
L
36case "${host}" in
37 *-*-mingw32*)
38 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
39 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
40 fi
41 ;;
42 *) ;;
43esac
44
270c9937
JB
45# Enable -Werror by default when using gcc. Turn it off for releases.
46if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" -a "$development" = true ; then
9e9b66a9
AM
47 ERROR_ON_WARNING=yes
48fi
49
50NO_WERROR=
51if test "${ERROR_ON_WARNING}" = yes ; then
49c96104 52 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
9e9b66a9
AM
53 NO_WERROR="-Wno-error"
54fi
55
49c96104
SE
56if test "${GCC}" = yes ; then
57 WARN_CFLAGS="${GCC_WARN_CFLAGS}"
58fi
59
9e9b66a9 60AC_ARG_ENABLE(build-warnings,
241a6c40 61[ --enable-build-warnings enable build-time compiler warnings],
9e9b66a9 62[case "${enableval}" in
49c96104
SE
63 yes) WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
64 no) if test "${GCC}" = yes ; then
65 WARN_CFLAGS="-w"
66 fi;;
9e9b66a9 67 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
49c96104 68 WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
9e9b66a9 69 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
49c96104 70 WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
9e9b66a9
AM
71 *) WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
72esac])
73
74if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
75 echo "Setting warning flags = $WARN_CFLAGS" 6>&1
76fi
77
78AC_SUBST(WARN_CFLAGS)
79AC_SUBST(NO_WERROR)
80])
This page took 0.541417 seconds and 4 git commands to generate.