1 # Autoconf include file defining macros related to compile-time warnings.
3 # Copyright 2004, 2005 Free Software Foundation, Inc.
5 #This file is part of GCC.
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
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
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
19 #Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
22 # ACX_PROG_CC_WARNING_OPTS([-Wfoo -Wbar -Wbaz])
23 # Sets @WARN_CFLAGS@ to the subset of the given options which the
25 AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
26 [AC_REQUIRE([AC_PROG_CC])dnl
27 AC_SUBST([WARN_CFLAGS])dnl
31 AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
32 AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
34 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
35 [AS_VAR_SET(acx_Woption, yes)],
36 [AS_VAR_SET(acx_Woption, no)])
38 AS_IF([test AS_VAR_GET(acx_Woption) = yes],
39 [WARN_CFLAGS="$WARN_CFLAGS${WARN_CFLAGS:+ }$option"])
40 AS_VAR_POPDEF([acx_Woption])dnl
43 ])# ACX_PROG_CC_WARNING_OPTS
45 # ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long ...])
46 # Sets WARN_PEDANTIC to "-pedantic" + the argument, if the compiler is GCC
47 # and accepts all of those options simultaneously, otherwise to nothing.
48 AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
49 [AC_REQUIRE([AC_PROG_CC])dnl
50 AC_SUBST([WARN_PEDANTIC])dnl
51 AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_$1])dnl
53 AS_IF([test "$GCC" = yes],
54 [AC_CACHE_CHECK([whether $CC supports -pedantic $1], acx_Pedantic,
55 [save_CFLAGS="$CFLAGS"
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
58 [AS_VAR_SET(acx_Pedantic, yes)],
59 [AS_VAR_SET(acx_Pedantic, no)])
60 CFLAGS="$save_CFLAGS"])
61 AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
62 [WARN_PEDANTIC="-pedantic $1"])
64 AS_VAR_POPDEF([acx_Pedantic])dnl
65 ])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
67 # ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z])
68 # sets WERROR to "-Werror" if the compiler is GCC >=x.y.z, or if
69 # --enable-werror-always was given on the command line, otherwise
71 # If the argument is the word "manual" instead of a version number,
72 # then WERROR will be set to -Werror only if --enable-werror-always
73 # appeared on the configure command line.
74 AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
75 [AC_REQUIRE([AC_PROG_CC])dnl
78 AC_ARG_ENABLE(werror-always,
79 AS_HELP_STRING([--enable-werror-always],
80 [enable -Werror despite compiler version]),
81 [], [enable_werror_always=no])
82 AS_IF([test $enable_werror_always = yes],
85 [AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl
86 AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers,
87 [set fnord `echo $1 | tr '.' ' '`
90 [#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
91 < [$]1 * 10000 + [$]2 * 100 + [$]3
94 [AS_VAR_SET(acx_GCCvers, yes)],
95 [AS_VAR_SET(acx_GCCvers, no)])])
96 AS_IF([test AS_VAR_GET(acx_GCCvers) = yes],
98 AS_VAR_POPDEF([acx_GCCvers])]))
99 ])# ACX_PROG_CC_WARNINGS_ARE_ERRORS