]> git.saurik.com Git - wxWidgets.git/blob - build/aclocal/ax_cflags_gcc_option.m4
Add new wxEVT_COMMAND_WEB_VIEW_TITLE_CHANGED event. Implement for all backends, exten...
[wxWidgets.git] / build / aclocal / ax_cflags_gcc_option.m4
1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ax_cflags_gcc_option.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
8 #
9 # DESCRIPTION
10 #
11 # AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like
12 # "checking CFLAGS for gcc -fvomit-frame ... yes" and adds the optionflag
13 # to CFLAGS if it is understood. You can override the shellvar-default of
14 # CFLAGS of course. The order of arguments stems from the explicit macros
15 # like AX_CFLAGS_WARN_ALL.
16 #
17 # The cousin AX_CXXFLAGS_GCC_OPTION would check for an option to add to
18 # CXXFLAGS - and it uses the autoconf setup for C++ instead of C (since it
19 # is possible to use different compilers for C and C++).
20 #
21 # The macro is a lot simpler than any special AX_CFLAGS_* macro (or
22 # ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
23 # However, if you use this macro in a few places, it would be great if you
24 # would make up a new function-macro and submit it to the ac-archive.
25 #
26 # - $1 option-to-check-for : required ("-option" as non-value)
27 # - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case)
28 # - $3 action-if-found : add value to shellvariable
29 # - $4 action-if-not-found : nothing
30 #
31 # Note: in earlier versions, $1-$2 were swapped. We try to detect the
32 # situation and accept a $2=~/-/ as being the old option-to-check-for.
33 #
34 # There are other variants that emerged from the original macro variant
35 # which did just test an option to be possibly added. However, some
36 # compilers accept an option silently, or possibly for just another option
37 # that was not intended. Therefore, we have to do a generic test for a
38 # compiler family. For gcc we check "-pedantic" being accepted which is
39 # also understood by compilers who just want to be compatible with gcc
40 # even when not being made from gcc sources.
41 #
42 # See also: AX_CFLAGS_SUN_OPTION, AX_CFLAGS_HPUX_OPTION,
43 # AX_CFLAGS_AIX_OPTION, and AX_CFLAGS_IRIX_OPTION.
44 #
45 # LAST MODIFICATION
46 #
47 # 2008-04-12
48 #
49 # COPYLEFT
50 #
51 # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
52 #
53 # This program is free software; you can redistribute it and/or modify it
54 # under the terms of the GNU General Public License as published by the
55 # Free Software Foundation; either version 2 of the License, or (at your
56 # option) any later version.
57 #
58 # This program is distributed in the hope that it will be useful, but
59 # WITHOUT ANY WARRANTY; without even the implied warranty of
60 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
61 # Public License for more details.
62 #
63 # You should have received a copy of the GNU General Public License along
64 # with this program. If not, see <http://www.gnu.org/licenses/>.
65 #
66 # As a special exception, the respective Autoconf Macro's copyright owner
67 # gives unlimited permission to copy, distribute and modify the configure
68 # scripts that are the output of Autoconf when processing the Macro. You
69 # need not follow the terms of the GNU General Public License when using
70 # or distributing such scripts, even though portions of the text of the
71 # Macro appear in them. The GNU General Public License (GPL) does govern
72 # all other use of the material that constitutes the Autoconf Macro.
73 #
74 # This special exception to the GPL applies to versions of the Autoconf
75 # Macro released by the Autoconf Macro Archive. When you make and
76 # distribute a modified version of the Autoconf Macro, you may extend this
77 # special exception to the GPL to apply to your modified version as well.
78
79 AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
80 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
81 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
82 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
83 VAR,[VAR="no, unknown"
84 AC_LANG_SAVE
85 AC_LANG_C
86 ac_save_[]FLAGS="$[]FLAGS"
87 for ac_arg dnl
88 in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC
89 "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC
90 #
91 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
92 AC_TRY_COMPILE([],[return 0;],
93 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
94 done
95 FLAGS="$ac_save_[]FLAGS"
96 AC_LANG_RESTORE
97 ])
98 case ".$VAR" in
99 .ok|.ok,*) m4_ifvaln($3,$3) ;;
100 .|.no|.no,*) m4_ifvaln($4,$4) ;;
101 *) m4_ifvaln($3,$3,[
102 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
103 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
104 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
105 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
106 fi ]) ;;
107 esac
108 AS_VAR_POPDEF([VAR])dnl
109 AS_VAR_POPDEF([FLAGS])dnl
110 ])
111
112
113 dnl the only difference - the LANG selection... and the default FLAGS
114
115 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl
116 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
117 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl
118 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
119 VAR,[VAR="no, unknown"
120 AC_LANG_SAVE
121 AC_LANG_CPLUSPLUS
122 ac_save_[]FLAGS="$[]FLAGS"
123 for ac_arg dnl
124 in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC
125 "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC
126 #
127 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
128 AC_TRY_COMPILE([],[return 0;],
129 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
130 done
131 FLAGS="$ac_save_[]FLAGS"
132 AC_LANG_RESTORE
133 ])
134 case ".$VAR" in
135 .ok|.ok,*) m4_ifvaln($3,$3) ;;
136 .|.no|.no,*) m4_ifvaln($4,$4) ;;
137 *) m4_ifvaln($3,$3,[
138 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
139 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
140 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
141 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
142 fi ]) ;;
143 esac
144 AS_VAR_POPDEF([VAR])dnl
145 AS_VAR_POPDEF([FLAGS])dnl
146 ])
147
148 dnl -------------------------------------------------------------------------
149
150 AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
151 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
152 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
153 AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
154 VAR,[VAR="no, unknown"
155 AC_LANG_SAVE
156 AC_LANG_C
157 ac_save_[]FLAGS="$[]FLAGS"
158 for ac_arg dnl
159 in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC
160 "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC
161 #
162 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
163 AC_TRY_COMPILE([],[return 0;],
164 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
165 done
166 FLAGS="$ac_save_[]FLAGS"
167 AC_LANG_RESTORE
168 ])
169 case ".$VAR" in
170 .ok|.ok,*) m4_ifvaln($3,$3) ;;
171 .|.no|.no,*) m4_ifvaln($4,$4) ;;
172 *) m4_ifvaln($3,$3,[
173 if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
174 then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
175 else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
176 m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
177 fi ]) ;;
178 esac
179 AS_VAR_POPDEF([VAR])dnl
180 AS_VAR_POPDEF([FLAGS])dnl
181 ])
182
183
184 dnl the only difference - the LANG selection... and the default FLAGS
185
186 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl
187 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
188 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl
189 AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
190 VAR,[VAR="no, unknown"
191 AC_LANG_SAVE
192 AC_LANG_CPLUSPLUS
193 ac_save_[]FLAGS="$[]FLAGS"
194 for ac_arg dnl
195 in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC
196 "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC
197 #
198 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
199 AC_TRY_COMPILE([],[return 0;],
200 [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
201 done
202 FLAGS="$ac_save_[]FLAGS"
203 AC_LANG_RESTORE
204 ])
205 case ".$VAR" in
206 .ok|.ok,*) m4_ifvaln($3,$3) ;;
207 .|.no|.no,*) m4_ifvaln($4,$4) ;;
208 *) m4_ifvaln($3,$3,[
209 if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
210 then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
211 else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
212 m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
213 fi ]) ;;
214 esac
215 AS_VAR_POPDEF([VAR])dnl
216 AS_VAR_POPDEF([FLAGS])dnl
217 ])
218
219 AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
220 [AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
221
222 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
223 [AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])])