source: trunk/libs/newlib/src/config/warnings.m4 @ 686

Last change on this file since 686 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 8.4 KB
Line 
1# Autoconf include file defining macros related to compile-time warnings.
2
3# Copyright 2004, 2005, 2007, 2009, 2011 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 3, 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 COPYING3.  If not see
19#<http://www.gnu.org/licenses/>.
20
21# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS])
22#   Sets @VARIABLE@ to the subset of the given options which the
23#   compiler accepts.
24AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
25[AC_REQUIRE([AC_PROG_CC])dnl
26AC_LANG_PUSH(C)
27m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
28AC_SUBST(acx_Var)dnl
29m4_expand_once([acx_Var=
30],m4_quote(acx_Var=))dnl
31save_CFLAGS="$CFLAGS"
32for real_option in $1; do
33  # Do the check with the no- prefix removed since gcc silently
34  # accepts any -Wno-* option on purpose
35  case $real_option in
36    -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
37    *) option=$real_option ;;
38  esac
39  AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
40  AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
41    [CFLAGS="$option"
42    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
43      [AS_VAR_SET(acx_Woption, yes)],
44      [AS_VAR_SET(acx_Woption, no)])
45  ])
46  AS_IF([test AS_VAR_GET(acx_Woption) = yes],
47        [acx_Var="$acx_Var${acx_Var:+ }$real_option"])
48  AS_VAR_POPDEF([acx_Woption])dnl
49done
50CFLAGS="$save_CFLAGS"
51m4_popdef([acx_Var])dnl
52AC_LANG_POP(C)
53])# ACX_PROG_CC_WARNING_OPTS
54
55# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
56#   Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC
57#   and accepts all of those options simultaneously, otherwise to nothing.
58AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
59[AC_REQUIRE([AC_PROG_CC])dnl
60AC_LANG_PUSH(C)
61m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
62AC_SUBST(acx_Var)dnl
63m4_expand_once([acx_Var=
64],m4_quote(acx_Var=))dnl
65# Do the check with the no- prefix removed from the warning options
66# since gcc silently accepts any -Wno-* option on purpose
67m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
68AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
69AS_IF([test "$GCC" = yes],
70[AC_CACHE_CHECK([whether $CC supports -pedantic ]acx_Woptions, acx_Pedantic,
71[save_CFLAGS="$CFLAGS"
72CFLAGS="-pedantic acx_Woptions"
73AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
74   [AS_VAR_SET(acx_Pedantic, yes)],
75   [AS_VAR_SET(acx_Pedantic, no)])
76CFLAGS="$save_CFLAGS"])
77AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
78      [acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
79])
80AS_VAR_POPDEF([acx_Pedantic])dnl
81m4_popdef([acx_Woptions])dnl
82m4_popdef([acx_Var])dnl
83AC_LANG_POP(C)
84])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
85
86# ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
87#   sets @VARIABLE@ to "-Werror" if the compiler is GCC >=x.y.z, or if
88#   --enable-werror-always was given on the command line, otherwise
89#   to nothing.
90#   If the argument is the word "manual" instead of a version number,
91#   then @VARIABLE@ will be set to -Werror only if --enable-werror-always
92#   appeared on the configure command line.
93AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
94[AC_REQUIRE([AC_PROG_CC])dnl
95AC_LANG_PUSH(C)
96m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
97AC_SUBST(acx_Var)dnl
98m4_expand_once([acx_Var=
99],m4_quote(acx_Var=))dnl
100AC_ARG_ENABLE(werror-always,
101    AS_HELP_STRING([--enable-werror-always],
102                   [enable -Werror despite compiler version]),
103[], [enable_werror_always=no])
104AS_IF([test $enable_werror_always = yes],
105      [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
106 m4_if($1, [manual],,
107 [AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl
108  AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers,
109    [set fnord `echo $1 | tr '.' ' '`
110     shift
111     AC_PREPROC_IFELSE(
112[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
113  < [$]1 * 10000 + [$]2 * 100 + [$]3
114#error insufficient
115#endif],
116   [AS_VAR_SET(acx_GCCvers, yes)],
117   [AS_VAR_SET(acx_GCCvers, no)])])
118 AS_IF([test AS_VAR_GET(acx_GCCvers) = yes],
119       [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
120  AS_VAR_POPDEF([acx_GCCvers])])
121m4_popdef([acx_Var])dnl
122AC_LANG_POP(C)
123])# ACX_PROG_CC_WARNINGS_ARE_ERRORS
124
125# ACX_PROG_CXX_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CXXFLAGS])
126#   Sets @VARIABLE@ to the subset of the given options which the
127#   compiler accepts.
128AC_DEFUN([ACX_PROG_CXX_WARNING_OPTS],
129[AC_REQUIRE([AC_PROG_CXX])dnl
130AC_LANG_PUSH(C++)
131m4_pushdef([acx_Var], [m4_default([$2], [WARN_CXXFLAGS])])dnl
132AC_SUBST(acx_Var)dnl
133m4_expand_once([acx_Var=
134],m4_quote(acx_Var=))dnl
135save_CXXFLAGS="$CXXFLAGS"
136for real_option in $1; do
137  # Do the check with the no- prefix removed since gcc silently
138  # accepts any -Wno-* option on purpose
139  case $real_option in
140    -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
141    *) option=$real_option ;;
142  esac
143  AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
144  AC_CACHE_CHECK([whether $CXX supports $option], acx_Woption,
145    [CXXFLAGS="$option"
146    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
147      [AS_VAR_SET(acx_Woption, yes)],
148      [AS_VAR_SET(acx_Woption, no)])
149  ])
150  AS_IF([test AS_VAR_GET(acx_Woption) = yes],
151        [acx_Var="$acx_Var${acx_Var:+ }$real_option"])
152  AS_VAR_POPDEF([acx_Woption])dnl
153done
154CXXFLAGS="$save_CXXFLAGS"
155m4_popdef([acx_Var])dnl
156AC_LANG_POP(C++)
157])# ACX_PROG_CXX_WARNING_OPTS
158
159# ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
160#   Append to VARIABLE "-pedantic" + the argument, if the compiler is G++
161#   and accepts all of those options simultaneously, otherwise to nothing.
162AC_DEFUN([ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC],
163[AC_REQUIRE([AC_PROG_CXX])dnl
164AC_LANG_PUSH(C++)
165m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
166AC_SUBST(acx_Var)dnl
167m4_expand_once([acx_Var=
168],m4_quote(acx_Var=))dnl
169# Do the check with the no- prefix removed from the warning options
170# since gcc silently accepts any -Wno-* option on purpose
171m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
172AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
173AS_IF([test "$GXX" = yes],
174[AC_CACHE_CHECK([whether $CXX supports -pedantic ]acx_Woptions, acx_Pedantic,
175[save_CXXFLAGS="$CXXFLAGS"
176CXXFLAGS="-pedantic acx_Woptions"
177AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
178   [AS_VAR_SET(acx_Pedantic, yes)],
179   [AS_VAR_SET(acx_Pedantic, no)])
180CXXFLAGS="$save_CXXFLAGS"])
181AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
182      [acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
183])
184AS_VAR_POPDEF([acx_Pedantic])dnl
185m4_popdef([acx_Woptions])dnl
186m4_popdef([acx_Var])dnl
187AC_LANG_POP(C++)
188])# ACX_PROG_CXX_WARNING_ALMOST_PEDANTIC
189
190# ACX_PROG_CXX_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
191#   sets @VARIABLE@ to "-Werror" if the compiler is G++ >=x.y.z, or if
192#   --enable-werror-always was given on the command line, otherwise
193#   to nothing.
194#   If the argument is the word "manual" instead of a version number,
195#   then @VARIABLE@ will be set to -Werror only if --enable-werror-always
196#   appeared on the configure command line.
197AC_DEFUN([ACX_PROG_CXX_WARNINGS_ARE_ERRORS],
198[AC_REQUIRE([AC_PROG_CXX])dnl
199AC_LANG_PUSH(C++)
200m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
201AC_SUBST(acx_Var)dnl
202m4_expand_once([acx_Var=
203],m4_quote(acx_Var=))dnl
204AC_ARG_ENABLE(werror-always,
205    AS_HELP_STRING([--enable-werror-always],
206                   [enable -Werror despite compiler version]),
207[], [enable_werror_always=no])
208AS_IF([test $enable_werror_always = yes],
209      [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
210 m4_if($1, [manual],,
211 [AS_VAR_PUSHDEF([acx_GXXvers], [acx_cv_prog_cxx_gxx_$1_or_newer])dnl
212  AC_CACHE_CHECK([whether $CXX is G++ >=$1], acx_GXXvers,
213    [set fnord `echo $1 | tr '.' ' '`
214     shift
215     AC_PREPROC_IFELSE(
216[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
217  < [$]1 * 10000 + [$]2 * 100 + [$]3
218#error insufficient
219#endif],
220   [AS_VAR_SET(acx_GXXvers, yes)],
221   [AS_VAR_SET(acx_GXXvers, no)])])
222 AS_IF([test AS_VAR_GET(acx_GXXvers) = yes],
223       [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
224  AS_VAR_POPDEF([acx_GXXvers])])
225m4_popdef([acx_Var])dnl
226AC_LANG_POP(C++)
227])# ACX_PROG_CXX_WARNINGS_ARE_ERRORS
Note: See TracBrowser for help on using the repository browser.