Build unavailable-stack frames for tracepoint.
[deliverable/binutils-gdb.git] / gdb / warning.m4
CommitLineData
b835bb52
MF
1dnl Autoconf configure script for GDB, the GNU debugger.
2dnl Copyright (C) 1995-2016 Free Software Foundation, Inc.
3dnl
4dnl This file is part of GDB.
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 3 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19AC_DEFUN([AM_GDB_WARNINGS],[
20AC_ARG_ENABLE(werror,
21 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
22 [case "${enableval}" in
23 yes | y) ERROR_ON_WARNING="yes" ;;
24 no | n) ERROR_ON_WARNING="no" ;;
25 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
26 esac])
27
28# Enable -Werror by default when using gcc. Turn it off for releases.
29if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
30 ERROR_ON_WARNING=yes
31fi
32
33WERROR_CFLAGS=""
34if test "${ERROR_ON_WARNING}" = yes ; then
35 WERROR_CFLAGS="-Werror"
36fi
37
38# These options work in either C or C++ modes.
39build_warnings="-Wall -Wpointer-arith \
40-Wno-unused -Wunused-value -Wunused-function \
41-Wno-switch -Wno-char-subscripts \
42-Wempty-body"
43
44# Now add in C and C++ specific options, depending on mode.
45if test "$enable_build_with_cxx" = "yes"; then
46 build_warnings="$build_warnings -Wno-sign-compare -Wno-write-strings \
47-Wno-narrowing"
48else
49 build_warnings="$build_warnings -Wpointer-sign -Wmissing-prototypes \
50-Wdeclaration-after-statement -Wmissing-parameter-type \
51-Wold-style-declaration -Wold-style-definition"
52fi
53
54# Enable -Wno-format by default when using gcc on mingw since many
55# GCC versions complain about %I64.
56case "${host}" in
57 *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
58 *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
59esac
60
61AC_ARG_ENABLE(build-warnings,
62AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
63[case "${enableval}" in
64 yes) ;;
65 no) build_warnings="-w";;
66 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
67 build_warnings="${build_warnings} ${t}";;
68 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
69 build_warnings="${t} ${build_warnings}";;
70 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
71esac
72if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
73 echo "Setting compiler warning flags = $build_warnings" 6>&1
74fi])dnl
75AC_ARG_ENABLE(gdb-build-warnings,
76AS_HELP_STRING([--enable-gdb-build-warnings], [enable GDB specific build-time compiler warnings if gcc is used]),
77[case "${enableval}" in
78 yes) ;;
79 no) build_warnings="-w";;
80 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
81 build_warnings="${build_warnings} ${t}";;
82 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
83 build_warnings="${t} ${build_warnings}";;
84 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
85esac
86if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
87 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
88fi])dnl
89
90# The set of warnings supported by a C++ compiler is not the same as
91# of the C compiler.
92if test "$enable_build_with_cxx" = "yes"; then
93 AC_LANG_PUSH([C++])
94fi
95
96WARN_CFLAGS=""
97if test "x${build_warnings}" != x -a "x$GCC" = xyes
98then
99 AC_MSG_CHECKING(compiler warning flags)
100 # Separate out the -Werror flag as some files just cannot be
101 # compiled with it enabled.
102 for w in ${build_warnings}; do
103 # GCC does not complain about -Wno-unknown-warning. Invert
104 # and test -Wunknown-warning instead.
105 case $w in
106 -Wno-*)
107 wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
108 *)
109 wtest=$w ;;
110 esac
111
112 case $w in
113 -Werr*) WERROR_CFLAGS=-Werror ;;
114 *)
115 # Check whether GCC accepts it.
116 saved_CFLAGS="$CFLAGS"
117 CFLAGS="$CFLAGS $wtest"
118 saved_CXXFLAGS="$CXXFLAGS"
119 CXXFLAGS="$CXXFLAGS $wtest"
120 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
121 CFLAGS="$saved_CFLAGS"
122 CXXFLAGS="$saved_CXXFLAGS"
123 esac
124 done
125 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
126fi
127AC_SUBST(WARN_CFLAGS)
128AC_SUBST(WERROR_CFLAGS)
129
130if test "$enable_build_with_cxx" = "yes"; then
131 AC_LANG_POP([C++])
132fi
133])
This page took 0.040189 seconds and 4 git commands to generate.