1dnl Common configure.in fragment 2 3AC_DEFUN([AM_BINUTILS_WARNINGS],[ 4GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes" 5AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow") 6 7AC_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 16case "${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 *) ;; 23esac 24 25# Enable -Werror by default when using gcc 26if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then 27 ERROR_ON_WARNING=yes 28fi 29 30NO_WERROR= 31if test "${ERROR_ON_WARNING}" = yes ; then 32 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror" 33 NO_WERROR="-Wno-error" 34fi 35 36if test "${GCC}" = yes ; then 37 WARN_CFLAGS="${GCC_WARN_CFLAGS}" 38fi 39 40AC_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"`;; 52esac]) 53 54if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then 55 echo "Setting warning flags = $WARN_CFLAGS" 6>&1 56fi 57 58AC_SUBST(WARN_CFLAGS) 59AC_SUBST(NO_WERROR) 60]) 61