sync toplevel with gcc
[deliverable/binutils-gdb.git] / bfd / warning.m4
1 dnl Common configure.in fragment
2
3 AC_DEFUN([AM_BINUTILS_WARNINGS],[
4 GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
5 AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow")
6
7 AC_ARG_ENABLE(werror,
8 [ --enable-werror treat compile warnings as errors],
9 [case "${enableval}" in
10 yes | y) ERROR_ON_WARNING="yes" ;;
11 no | n) ERROR_ON_WARNING="no" ;;
12 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
13 esac])
14
15 # Disable -Wformat by default when using gcc on mingw
16 case "${host}" in
17 *-*-mingw32*)
18 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
19 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
20 fi
21 ;;
22 *) ;;
23 esac
24
25 # Enable -Werror by default when using gcc
26 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
27 ERROR_ON_WARNING=yes
28 fi
29
30 NO_WERROR=
31 if test "${ERROR_ON_WARNING}" = yes ; then
32 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
33 NO_WERROR="-Wno-error"
34 fi
35
36 if test "${GCC}" = yes ; then
37 WARN_CFLAGS="${GCC_WARN_CFLAGS}"
38 fi
39
40 AC_ARG_ENABLE(build-warnings,
41 [ --enable-build-warnings enable build-time compiler warnings],
42 [case "${enableval}" in
43 yes) WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
44 no) if test "${GCC}" = yes ; then
45 WARN_CFLAGS="-w"
46 fi;;
47 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
48 WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
49 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
50 WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
51 *) WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
52 esac])
53
54 if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
55 echo "Setting warning flags = $WARN_CFLAGS" 6>&1
56 fi
57
58 AC_SUBST(WARN_CFLAGS)
59 AC_SUBST(NO_WERROR)
60 ])
This page took 0.031357 seconds and 4 git commands to generate.