Commit | Line | Data |
---|---|---|
9e9b66a9 AM |
1 | dnl Common configure.in fragment |
2 | ||
3 | AC_DEFUN([AM_BINUTILS_WARNINGS],[ | |
d1a98e0c AM |
4 | GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes" |
5 | AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow") | |
9e9b66a9 AM |
6 | |
7 | AC_ARG_ENABLE(werror, | |
241a6c40 | 8 | [ --enable-werror treat compile warnings as errors], |
9e9b66a9 AM |
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 | ||
d1a98e0c | 15 | # Disable -Wformat by default when using gcc on mingw |
bb8541b9 L |
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 | ||
9e9b66a9 AM |
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 | |
49c96104 | 32 | GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror" |
9e9b66a9 AM |
33 | NO_WERROR="-Wno-error" |
34 | fi | |
35 | ||
49c96104 SE |
36 | if test "${GCC}" = yes ; then |
37 | WARN_CFLAGS="${GCC_WARN_CFLAGS}" | |
38 | fi | |
39 | ||
9e9b66a9 | 40 | AC_ARG_ENABLE(build-warnings, |
241a6c40 | 41 | [ --enable-build-warnings enable build-time compiler warnings], |
9e9b66a9 | 42 | [case "${enableval}" in |
49c96104 SE |
43 | yes) WARN_CFLAGS="${GCC_WARN_CFLAGS}";; |
44 | no) if test "${GCC}" = yes ; then | |
45 | WARN_CFLAGS="-w" | |
46 | fi;; | |
9e9b66a9 | 47 | ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` |
49c96104 | 48 | WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";; |
9e9b66a9 | 49 | *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` |
49c96104 | 50 | WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";; |
9e9b66a9 AM |
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 | ]) |