* configure.ac: Only disable a language library if no language needs
[deliverable/binutils-gdb.git] / config / warnings.m4
CommitLineData
9a8371d2
DD
1# Autoconf include file defining macros related to compile-time warnings.
2
ca892441 3# Copyright 2004, 2005, 2007, 2009 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
ca892441 9#Software Foundation; either version 3, or (at your option) any later
9a8371d2
DD
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
ca892441
RW
18#along with GCC; see the file COPYING3. If not see
19#<http://www.gnu.org/licenses/>.
9a8371d2 20
ceb92e78 21# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS)
aa075251 22# Sets @VARIABLE@ to the subset of the given options which the
9a8371d2
DD
23# compiler accepts.
24AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
25[AC_REQUIRE([AC_PROG_CC])dnl
aa075251
PB
26m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
27AC_SUBST(acx_Var)dnl
ceb92e78
PB
28m4_expand_once([acx_Var=
29],m4_quote(acx_Var=))dnl
9a8371d2
DD
30save_CFLAGS="$CFLAGS"
31for option in $1; do
32 AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
33 AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
34 [CFLAGS="$option"
35 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
36 [AS_VAR_SET(acx_Woption, yes)],
37 [AS_VAR_SET(acx_Woption, no)])
38 ])
39 AS_IF([test AS_VAR_GET(acx_Woption) = yes],
aa075251 40 [acx_Var="$acx_Var${acx_Var:+ }$option"])
9a8371d2
DD
41 AS_VAR_POPDEF([acx_Woption])dnl
42done
43CFLAGS="$save_CFLAGS"
aa075251 44m4_popdef([acx_Var])dnl
9a8371d2
DD
45])# ACX_PROG_CC_WARNING_OPTS
46
aa075251
PB
47# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC)
48# Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC
5452212a 49# and accepts all of those options simultaneously, otherwise to nothing.
9a8371d2
DD
50AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
51[AC_REQUIRE([AC_PROG_CC])dnl
aa075251
PB
52m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
53AC_SUBST(acx_Var)dnl
ceb92e78
PB
54m4_expand_once([acx_Var=
55],m4_quote(acx_Var=))dnl
9a8371d2 56AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_$1])dnl
f1166a09 57AS_IF([test "$GCC" = yes],
5452212a 58[AC_CACHE_CHECK([whether $CC supports -pedantic $1], acx_Pedantic,
9a8371d2
DD
59[save_CFLAGS="$CFLAGS"
60CFLAGS="-pedantic $1"
61AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
62 [AS_VAR_SET(acx_Pedantic, yes)],
63 [AS_VAR_SET(acx_Pedantic, no)])
64CFLAGS="$save_CFLAGS"])
65AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
aa075251 66 [acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
5452212a 67])
9a8371d2 68AS_VAR_POPDEF([acx_Pedantic])dnl
aa075251 69m4_popdef([acx_Var])dnl
9a8371d2
DD
70])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
71
ceb92e78
PB
72# ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
73# sets @VARIABLE@ to "-Werror" if the compiler is GCC >=x.y.z, or if
9a8371d2
DD
74# --enable-werror-always was given on the command line, otherwise
75# to nothing.
76# If the argument is the word "manual" instead of a version number,
ceb92e78 77# then @VARIABLE@ will be set to -Werror only if --enable-werror-always
9a8371d2
DD
78# appeared on the configure command line.
79AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
80[AC_REQUIRE([AC_PROG_CC])dnl
ceb92e78
PB
81m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
82AC_SUBST(acx_Var)dnl
83m4_expand_once([acx_Var=
84],m4_quote(acx_Var=))dnl
9a8371d2
DD
85AC_ARG_ENABLE(werror-always,
86 AS_HELP_STRING([--enable-werror-always],
87 [enable -Werror despite compiler version]),
88[], [enable_werror_always=no])
89AS_IF([test $enable_werror_always = yes],
ceb92e78 90 [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
9a8371d2
DD
91 m4_if($1, [manual],,
92 [AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl
93 AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers,
94 [set fnord `echo $1 | tr '.' ' '`
95 shift
96 AC_PREPROC_IFELSE(
97[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
98 < [$]1 * 10000 + [$]2 * 100 + [$]3
99#error insufficient
100#endif],
101 [AS_VAR_SET(acx_GCCvers, yes)],
102 [AS_VAR_SET(acx_GCCvers, no)])])
103 AS_IF([test AS_VAR_GET(acx_GCCvers) = yes],
ceb92e78
PB
104 [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
105 AS_VAR_POPDEF([acx_GCCvers])])
106m4_popdef([acx_Var])dnl
9a8371d2 107])# ACX_PROG_CC_WARNINGS_ARE_ERRORS
This page took 0.22627 seconds and 4 git commands to generate.