]>
Commit | Line | Data |
---|---|---|
760b3e8b MF |
1 | dnl Copyright (C) 1997-2021 Free Software Foundation, Inc. |
2 | dnl | |
3 | dnl This program is free software; you can redistribute it and/or modify | |
4 | dnl it under the terms of the GNU General Public License as published by | |
5 | dnl the Free Software Foundation; either version 3 of the License, or | |
6 | dnl (at your option) any later version. | |
7 | dnl | |
8 | dnl This program is distributed in the hope that it will be useful, | |
9 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | dnl GNU General Public License for more details. | |
12 | dnl | |
13 | dnl You should have received a copy of the GNU General Public License | |
14 | dnl along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | dnl | |
16 | dnl --enable-build-warnings is for developers of the simulator. | |
17 | dnl it enables extra GCC specific warnings. | |
760b3e8b MF |
18 | AC_DEFUN([SIM_AC_OPTION_WARNINGS], |
19 | [ | |
20 | AC_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 | ||
982c3a65 | 28 | dnl Enable -Werror by default when using gcc |
760b3e8b | 29 | if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then |
982c3a65 | 30 | ERROR_ON_WARNING=yes |
760b3e8b MF |
31 | fi |
32 | ||
33 | WERROR_CFLAGS="" | |
982c3a65 MF |
34 | if test "${ERROR_ON_WARNING}" = yes ; then |
35 | WERROR_CFLAGS="-Werror" | |
36 | fi | |
760b3e8b MF |
37 | |
38 | build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \ | |
39 | -Wpointer-sign \ | |
40 | -Wno-unused -Wunused-value -Wunused-function \ | |
41 | -Wno-switch -Wno-char-subscripts -Wmissing-prototypes | |
42 | -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \ | |
43 | -Wold-style-declaration -Wold-style-definition" | |
44 | ||
45 | # Enable -Wno-format by default when using gcc on mingw since many | |
46 | # GCC versions complain about %I64. | |
47 | case "${host}" in | |
48 | *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;; | |
49 | *) build_warnings="$build_warnings -Wformat-nonliteral" ;; | |
50 | esac | |
51 | ||
52 | AC_ARG_ENABLE(build-warnings, | |
53 | AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]), | |
54 | [case "${enableval}" in | |
55 | yes) ;; | |
56 | no) build_warnings="-w";; | |
57 | ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
58 | build_warnings="${build_warnings} ${t}";; | |
59 | *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
60 | build_warnings="${t} ${build_warnings}";; | |
61 | *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
62 | esac | |
63 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
64 | echo "Setting compiler warning flags = $build_warnings" 6>&1 | |
65 | fi])dnl | |
66 | AC_ARG_ENABLE(sim-build-warnings, | |
67 | AS_HELP_STRING([--enable-sim-build-warnings], [enable SIM specific build-time compiler warnings if gcc is used]), | |
68 | [case "${enableval}" in | |
69 | yes) ;; | |
70 | no) build_warnings="-w";; | |
71 | ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
72 | build_warnings="${build_warnings} ${t}";; | |
73 | *,) t=`echo "${enableval}" | sed -e "s/,/ /g"` | |
74 | build_warnings="${t} ${build_warnings}";; | |
75 | *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;; | |
76 | esac | |
77 | if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then | |
78 | echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1 | |
79 | fi])dnl | |
80 | WARN_CFLAGS="" | |
81 | if test "x${build_warnings}" != x -a "x$GCC" = xyes | |
82 | then | |
83 | AC_MSG_CHECKING(compiler warning flags) | |
84 | # Separate out the -Werror flag as some files just cannot be | |
85 | # compiled with it enabled. | |
86 | for w in ${build_warnings}; do | |
87 | case $w in | |
88 | -Werr*) WERROR_CFLAGS=-Werror ;; | |
89 | *) # Check that GCC accepts it | |
90 | saved_CFLAGS="$CFLAGS" | |
1f195bc3 | 91 | CFLAGS="$CFLAGS -Werror $w" |
760b3e8b MF |
92 | AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",) |
93 | CFLAGS="$saved_CFLAGS" | |
94 | esac | |
95 | done | |
96 | AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS}) | |
97 | fi | |
98 | ]) | |
99 | AC_SUBST(WARN_CFLAGS) | |
100 | AC_SUBST(WERROR_CFLAGS) |