Add -Wshadow to the gcc command line options used when compiling the binutils.
[binutils.git] / bfd / warning.m4
blobb4a2f48f8ba21fc337fca7c99d4233a0a2d50b91
1 dnl Common configure.in fragment
3 AC_DEFUN([AM_BINUTILS_WARNINGS],[
4 GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow"
6 AC_ARG_ENABLE(werror,
7   [  --enable-werror         treat compile warnings as errors],
8   [case "${enableval}" in
9      yes | y) ERROR_ON_WARNING="yes" ;;
10      no | n)  ERROR_ON_WARNING="no" ;;
11      *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
12    esac])
14 # Enable -Wno-format by default when using gcc on mingw
15 case "${host}" in
16   *-*-mingw32*)
17     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
18       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
19     fi
20     ;;
21   *) ;;
22 esac
24 # Enable -Werror by default when using gcc
25 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
26     ERROR_ON_WARNING=yes
29 NO_WERROR=
30 if test "${ERROR_ON_WARNING}" = yes ; then
31     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
32     NO_WERROR="-Wno-error"
34                    
35 if test "${GCC}" = yes ; then
36   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
39 AC_ARG_ENABLE(build-warnings,
40 [  --enable-build-warnings enable build-time compiler warnings],
41 [case "${enableval}" in
42   yes)  WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
43   no)   if test "${GCC}" = yes ; then
44           WARN_CFLAGS="-w"
45         fi;;
46   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
47         WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
48   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
49         WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
50   *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
51 esac])
53 if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
54   echo "Setting warning flags = $WARN_CFLAGS" 6>&1
57 AC_SUBST(WARN_CFLAGS)
58 AC_SUBST(NO_WERROR)