Home | History | Annotate | Download | only in bfd
      1 dnl Common configure.ac fragment
      2 dnl
      3 dnl   Copyright (C) 2012-2014 Free Software Foundation, Inc.
      4 dnl
      5 dnl This file is free software; you can redistribute it and/or modify
      6 dnl it under the terms of the GNU General Public License as published by
      7 dnl the Free Software Foundation; either version 3 of the License, or
      8 dnl (at your option) any later version.
      9 dnl 
     10 dnl This program is distributed in the hope that it will be useful,
     11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 dnl GNU General Public License for more details.
     14 dnl 
     15 dnl You should have received a copy of the GNU General Public License
     16 dnl along with this program; see the file COPYING3.  If not see
     17 dnl <http://www.gnu.org/licenses/>.
     18 dnl
     19 
     20 AC_DEFUN([AM_BINUTILS_WARNINGS],[
     21 # Set the 'development' global.
     22 . $srcdir/../bfd/development.sh
     23 
     24 GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
     25 AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow")
     26 
     27 AC_ARG_ENABLE(werror,
     28   [  --enable-werror         treat compile warnings as errors],
     29   [case "${enableval}" in
     30      yes | y) ERROR_ON_WARNING="yes" ;;
     31      no | n)  ERROR_ON_WARNING="no" ;;
     32      *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
     33    esac])
     34 
     35 # Disable -Wformat by default when using gcc on mingw
     36 case "${host}" in
     37   *-*-mingw32*)
     38     if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
     39       GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
     40     fi
     41     ;;
     42   *) ;;
     43 esac
     44 
     45 # Enable -Werror by default when using gcc.  Turn it off for releases.
     46 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" -a "$development" = true ; then
     47     ERROR_ON_WARNING=yes
     48 fi
     49 
     50 NO_WERROR=
     51 if test "${ERROR_ON_WARNING}" = yes ; then
     52     GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
     53     NO_WERROR="-Wno-error"
     54 fi
     55 		   
     56 if test "${GCC}" = yes ; then
     57   WARN_CFLAGS="${GCC_WARN_CFLAGS}"
     58 fi
     59 
     60 AC_ARG_ENABLE(build-warnings,
     61 [  --enable-build-warnings enable build-time compiler warnings],
     62 [case "${enableval}" in
     63   yes)	WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
     64   no)	if test "${GCC}" = yes ; then
     65 	  WARN_CFLAGS="-w"
     66 	fi;;
     67   ,*)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
     68         WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
     69   *,)   t=`echo "${enableval}" | sed -e "s/,/ /g"`
     70         WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
     71   *)    WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
     72 esac])
     73 
     74 if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
     75   echo "Setting warning flags = $WARN_CFLAGS" 6>&1
     76 fi
     77 
     78 AC_SUBST(WARN_CFLAGS)
     79 AC_SUBST(NO_WERROR)
     80 ])
     81