]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - config/warnings.m4
Sync include/ChangeLog-9103 from GCC to fix invalid UTF-8.
[thirdparty/binutils-gdb.git] / config / warnings.m4
CommitLineData
9a8371d2
DD
1# Autoconf include file defining macros related to compile-time warnings.
2
aa075251 3# Copyright 2004, 2005, 2007 Free Software Foundation, Inc.
9a8371d2
DD
4
5#This file is part of GCC.
6
7#GCC is free software; you can redistribute it and/or modify it under
8#the terms of the GNU General Public License as published by the Free
9#Software Foundation; either version 2, or (at your option) any later
10#version.
11
12#GCC is distributed in the hope that it will be useful, but WITHOUT
13#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15#for more details.
16
17#You should have received a copy of the GNU General Public License
18#along with GCC; see the file COPYING. If not, write to the Free
6e4d0bcb
KC
19#Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20#02110-1301, USA.
9a8371d2 21
ceb92e78 22# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS)
aa075251 23# Sets @VARIABLE@ to the subset of the given options which the
9a8371d2
DD
24# compiler accepts.
25AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
26[AC_REQUIRE([AC_PROG_CC])dnl
aa075251
PB
27m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
28AC_SUBST(acx_Var)dnl
ceb92e78
PB
29m4_expand_once([acx_Var=
30],m4_quote(acx_Var=))dnl
9a8371d2
DD
31save_CFLAGS="$CFLAGS"
32for option in $1; do
33 AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
34 AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
35 [CFLAGS="$option"
36 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
37 [AS_VAR_SET(acx_Woption, yes)],
38 [AS_VAR_SET(acx_Woption, no)])
39 ])
40 AS_IF([test AS_VAR_GET(acx_Woption) = yes],
aa075251 41 [acx_Var="$acx_Var${acx_Var:+ }$option"])
9a8371d2
DD
42 AS_VAR_POPDEF([acx_Woption])dnl
43done
44CFLAGS="$save_CFLAGS"
aa075251 45m4_popdef([acx_Var])dnl
9a8371d2
DD
46])# ACX_PROG_CC_WARNING_OPTS
47
aa075251
PB
48# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC)
49# Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC
5452212a 50# and accepts all of those options simultaneously, otherwise to nothing.
9a8371d2
DD
51AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
52[AC_REQUIRE([AC_PROG_CC])dnl
aa075251
PB
53m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
54AC_SUBST(acx_Var)dnl
ceb92e78
PB
55m4_expand_once([acx_Var=
56],m4_quote(acx_Var=))dnl
9a8371d2 57AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_$1])dnl
f1166a09 58AS_IF([test "$GCC" = yes],
5452212a 59[AC_CACHE_CHECK([whether $CC supports -pedantic $1], acx_Pedantic,
9a8371d2
DD
60[save_CFLAGS="$CFLAGS"
61CFLAGS="-pedantic $1"
62AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
63 [AS_VAR_SET(acx_Pedantic, yes)],
64 [AS_VAR_SET(acx_Pedantic, no)])
65CFLAGS="$save_CFLAGS"])
66AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
aa075251 67 [acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
5452212a 68])
9a8371d2 69AS_VAR_POPDEF([acx_Pedantic])dnl
aa075251 70m4_popdef([acx_Var])dnl
9a8371d2
DD
71])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
72
ceb92e78
PB
73# ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
74# sets @VARIABLE@ to "-Werror" if the compiler is GCC >=x.y.z, or if
9a8371d2
DD
75# --enable-werror-always was given on the command line, otherwise
76# to nothing.
77# If the argument is the word "manual" instead of a version number,
ceb92e78 78# then @VARIABLE@ will be set to -Werror only if --enable-werror-always
9a8371d2
DD
79# appeared on the configure command line.
80AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
81[AC_REQUIRE([AC_PROG_CC])dnl
ceb92e78
PB
82m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
83AC_SUBST(acx_Var)dnl
84m4_expand_once([acx_Var=
85],m4_quote(acx_Var=))dnl
9a8371d2
DD
86AC_ARG_ENABLE(werror-always,
87 AS_HELP_STRING([--enable-werror-always],
88 [enable -Werror despite compiler version]),
89[], [enable_werror_always=no])
90AS_IF([test $enable_werror_always = yes],
ceb92e78 91 [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
9a8371d2
DD
92 m4_if($1, [manual],,
93 [AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl
94 AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers,
95 [set fnord `echo $1 | tr '.' ' '`
96 shift
97 AC_PREPROC_IFELSE(
98[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
99 < [$]1 * 10000 + [$]2 * 100 + [$]3
100#error insufficient
101#endif],
102 [AS_VAR_SET(acx_GCCvers, yes)],
103 [AS_VAR_SET(acx_GCCvers, no)])])
104 AS_IF([test AS_VAR_GET(acx_GCCvers) = yes],
ceb92e78
PB
105 [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
106 AS_VAR_POPDEF([acx_GCCvers])])
107m4_popdef([acx_Var])dnl
9a8371d2 108])# ACX_PROG_CC_WARNINGS_ARE_ERRORS