Commit | Line | Data |
---|---|---|
9a8371d2 DD |
1 | # Autoconf include file defining macros related to compile-time warnings. |
2 | ||
3 | # Copyright 2004 Free Software Foundation, Inc. | |
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 | |
19 | #Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | #02111-1307, USA. | |
21 | ||
22 | # ACX_PROG_CC_WARNING_OPTS([-Wfoo -Wbar -Wbaz]) | |
23 | # Sets @WARN_CFLAGS@ to the subset of the given options which the | |
24 | # compiler accepts. | |
25 | AC_DEFUN([ACX_PROG_CC_WARNING_OPTS], | |
26 | [AC_REQUIRE([AC_PROG_CC])dnl | |
27 | AC_SUBST([WARN_CFLAGS])dnl | |
28 | WARN_CFLAGS= | |
29 | save_CFLAGS="$CFLAGS" | |
30 | for option in $1; do | |
31 | AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option]) | |
32 | AC_CACHE_CHECK([whether $CC supports $option], acx_Woption, | |
33 | [CFLAGS="$option" | |
34 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], | |
35 | [AS_VAR_SET(acx_Woption, yes)], | |
36 | [AS_VAR_SET(acx_Woption, no)]) | |
37 | ]) | |
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 | |
41 | done | |
42 | CFLAGS="$save_CFLAGS" | |
43 | ])# ACX_PROG_CC_WARNING_OPTS | |
44 | ||
45 | # ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long ...]) | |
46 | # Sets WARN_PEDANTIC to "-pedantic" + the argument, if the compiler | |
47 | # 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 | |
52 | WARN_PEDANTIC= | |
53 | AC_CACHE_CHECK([whether $CC supports -pedantic $1], acx_Pedantic, | |
54 | [save_CFLAGS="$CFLAGS" | |
55 | CFLAGS="-pedantic $1" | |
56 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], | |
57 | [AS_VAR_SET(acx_Pedantic, yes)], | |
58 | [AS_VAR_SET(acx_Pedantic, no)]) | |
59 | CFLAGS="$save_CFLAGS"]) | |
60 | AS_IF([test AS_VAR_GET(acx_Pedantic) = yes], | |
61 | [WARN_PEDANTIC="-pedantic $1"]) | |
62 | AS_VAR_POPDEF([acx_Pedantic])dnl | |
63 | ])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC | |
64 | ||
65 | # ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z]) | |
66 | # sets WERROR to "-Werror" if the compiler is GCC >=x.y.z, or if | |
67 | # --enable-werror-always was given on the command line, otherwise | |
68 | # to nothing. | |
69 | # If the argument is the word "manual" instead of a version number, | |
70 | # then WERROR will be set to -Werror only if --enable-werror-always | |
71 | # appeared on the configure command line. | |
72 | AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS], | |
73 | [AC_REQUIRE([AC_PROG_CC])dnl | |
74 | AC_SUBST([WERROR])dnl | |
75 | WERROR= | |
76 | AC_ARG_ENABLE(werror-always, | |
77 | AS_HELP_STRING([--enable-werror-always], | |
78 | [enable -Werror despite compiler version]), | |
79 | [], [enable_werror_always=no]) | |
80 | AS_IF([test $enable_werror_always = yes], | |
81 | [WERROR=-Werror], | |
82 | m4_if($1, [manual],, | |
83 | [AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl | |
84 | AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers, | |
85 | [set fnord `echo $1 | tr '.' ' '` | |
86 | shift | |
87 | AC_PREPROC_IFELSE( | |
88 | [#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \ | |
89 | < [$]1 * 10000 + [$]2 * 100 + [$]3 | |
90 | #error insufficient | |
91 | #endif], | |
92 | [AS_VAR_SET(acx_GCCvers, yes)], | |
93 | [AS_VAR_SET(acx_GCCvers, no)])]) | |
94 | AS_IF([test AS_VAR_GET(acx_GCCvers) = yes], | |
95 | [WERROR=-WerrorB]) | |
96 | AS_VAR_POPDEF([acx_GCCvers])])) | |
97 | ])# ACX_PROG_CC_WARNINGS_ARE_ERRORS |