2007-09-30 Mike Frysinger <vapier@gentoo.org>
[binutils.git] / bfd / warning.m4
blobb366cadeb29365e92156d87b3c800560c9d9730b
1 dnl Common configure.in fragment
3 AC_DEFUN([AM_BINUTILS_WARNINGS],[
4 GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
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 -Werror by default when using gcc
15 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
16     ERROR_ON_WARNING=yes
19 NO_WERROR=
20 if test "${ERROR_ON_WARNING}" = yes ; then
21     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
22     NO_WERROR="-Wno-error"
24                    
25 if test "${GCC}" = yes ; then
26   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
29 AC_ARG_ENABLE(build-warnings,
30 [  --enable-build-warnings enable build-time compiler warnings],
31 [case "${enableval}" in
32   yes)  WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
33   no)   if test "${GCC}" = yes ; then
34           WARN_CFLAGS="-w"
35         fi;;
36   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
37         WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
38   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
39         WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
40   *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
41 esac])
43 if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
44   echo "Setting warning flags = $WARN_CFLAGS" 6>&1
47 AC_SUBST(WARN_CFLAGS)
48 AC_SUBST(NO_WERROR)