1 dnl Fix Autoconf-2.59 bugs: by overriding broken internal
2 dnl Autoconf macros with backports of the 2.60+ fix.
3 dnl - AC_CONFIG_SUBDIRS whitespace mangling,
4 dnl - more lenient precious variable checks
5 dnl - better configure error message
6 dnl - reliance on non-Posix m4wrap (M4 1.6 or newer implement FIFO)
8 dnl The override bits of this file should be a no-op for the newest
9 dnl Autoconf version, which means they can be removed once the complete
10 dnl tree has moved to a new enough Autoconf version.
12 dnl The _GCC_AUTOCONF_VERSION_TEST ensures that exactly the desired
13 dnl Autoconf version is used. It should be kept for consistency.
15 dnl Provide m4_copy_force and m4_rename_force for old Autoconf versions.
17 m4_ifndef([m4_copy_force],
18 [m4_define([m4_copy_force],
19 [m4_ifdef([$2], [m4_undefine([$2])])m4_copy($@)])])
21 m4_ifndef([m4_rename_force],
22 [m4_define([m4_rename_force],
23 [m4_ifdef([$2], [m4_undefine([$2])])m4_rename($@)])])
25 dnl m4_PACKAGE_VERSION is an undocumented Autoconf macro.
26 dnl We use it because this fix is intended for 2.59 only.
27 dnl A feature test for the broken AC_CONFIG_SUBDIRS instead
28 dnl would be better but is tricky.
30 dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
31 dnl Redefine AC_CONFIG_SUBDIRS so aclocal pulls in this file
34 ifdef([m4_PACKAGE_VERSION],
35 [dnl AC_DEFUN a commonly used macro so this file is picked up.
36 m4_copy([AC_PREREQ], [_AC_PREREQ])
37 AC_DEFUN([AC_PREREQ], [frob])
38 m4_copy_force([_AC_PREREQ], [AC_PREREQ])
41 dnl Ensure exactly this Autoconf version is used
42 m4_ifndef([_GCC_AUTOCONF_VERSION],
43 [m4_define([_GCC_AUTOCONF_VERSION], [2.64])])
45 dnl Test for the exact version when AC_INIT is expanded.
46 dnl This allows to update the tree in steps (for testing)
48 dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
49 dnl in configure.ac before AC_INIT,
50 dnl without rewriting this file.
51 dnl Or for updating the whole tree at once with the definition above.
52 AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
53 [m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
54 m4_defn([m4_PACKAGE_VERSION]), [],
55 [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
57 m4_define([AC_INIT], m4_defn([AC_INIT])[
58 _GCC_AUTOCONF_VERSION_CHECK
62 dnl Turn AC_DISABLE_OPTION_CHECKING into a no-op if not defined.
63 m4_ifndef([AC_DISABLE_OPTION_CHECKING],
64 [m4_define([AC_DISABLE_OPTION_CHECKING])])
67 dnl Fix 2.64 cross compile detection for AVR and RTEMS
68 dnl by not trying to compile fopen.
69 m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64],
70 [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77],
71 [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])])
74 m4_version_prereq([2.60],, [
75 dnl We use $ac_pwd in some of the overrides below; ensure its definition
76 m4_divert_push([PARSE_ARGS])dnl
78 m4_divert_pop([PARSE_ARGS])dnl
82 m4_version_prereq([2.60],, [
86 # This is a subroutine of AC_OUTPUT, but it does not go into
87 # config.status, rather, it is called after running config.status.
88 m4_define([_AC_OUTPUT_SUBDIRS],
91 # CONFIG_SUBDIRS section, as fixed in confsubdir.m4.
93 if test "$no_recursion" != yes; then
95 # Remove --cache-file and --srcdir arguments so they do not pile up.
96 ac_sub_configure_args=
98 eval "set x $ac_configure_args"
102 if test -n "$ac_prev"; then
107 -cache-file | --cache-file | --cache-fil | --cache-fi \
108 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
109 ac_prev=cache_file ;;
110 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
111 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
116 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
118 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
120 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
122 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
126 *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
128 ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;;
132 # Always prepend --prefix to ensure using the same prefix
133 # in subdir configurations.
134 ac_arg="--prefix=$prefix"
136 *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
138 ac_sub_configure_args="$ac_arg $ac_sub_configure_args"
141 for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
143 # Do not complain, so a configure script can configure whichever
144 # parts of a large source tree are present.
145 test -d "$srcdir/$ac_dir" || continue
147 AC_MSG_NOTICE([configuring in $ac_dir])
148 AS_MKDIR_P(["$ac_dir"])
149 _AC_SRCPATHS(["$ac_dir"])
153 # Check for guested configure; otherwise get Cygnus style configure.
154 if test -f "$ac_srcdir/configure.gnu"; then
155 ac_sub_configure=$ac_srcdir/configure.gnu
156 elif test -f "$ac_srcdir/configure"; then
157 ac_sub_configure=$ac_srcdir/configure
158 elif test -f "$ac_srcdir/configure.in"; then
159 # This should be Cygnus configure.
160 ac_sub_configure=$ac_aux_dir/configure
162 AC_MSG_WARN([no configuration information is in $ac_dir])
166 # The recursion is here.
167 if test -n "$ac_sub_configure"; then
168 # Make the cache file name correct relative to the subdirectory.
170 [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
172 ac_sub_cache_file=$ac_top_builddir$cache_file ;;
175 AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
176 # The eval makes quoting arguments work.
177 eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
178 --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
179 AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
185 ])# _AC_OUTPUT_SUBDIRS
188 m4_version_prereq([2.63],, [
190 # _AC_ARG_VAR_VALIDATE
191 # --------------------
192 # The code is the same as autoconf 2.59, but with a more lenient check
193 # on precious variables and an output of pwd that have been added in
195 m4_define([_AC_ARG_VAR_VALIDATE],
196 [m4_divert_text([INIT_PREPARE],
197 [# Check that the precious variables saved in the cache have kept the same
199 ac_cache_corrupted=false
200 for ac_var in `(set) 2>&1 |
201 sed -n 's/^ac_env_\([[a-zA-Z_0-9]]*\)_set=.*/\1/p'`; do
202 eval ac_old_set=\$ac_cv_env_${ac_var}_set
203 eval ac_new_set=\$ac_env_${ac_var}_set
204 eval ac_old_val="\$ac_cv_env_${ac_var}_value"
205 eval ac_new_val="\$ac_env_${ac_var}_value"
206 case $ac_old_set,$ac_new_set in
208 AS_MESSAGE([error: `$ac_var' was set to `$ac_old_val' in the previous run], 2)
209 ac_cache_corrupted=: ;;
211 AS_MESSAGE([error: `$ac_var' was not set in the previous run], 2)
212 ac_cache_corrupted=: ;;
215 if test "x$ac_old_val" != "x$ac_new_val"; then
216 # differences in whitespace do not lead to failure.
217 ac_old_val_w=`echo x $ac_old_val`
218 ac_new_val_w=`echo x $ac_new_val`
219 if test "$ac_old_val_w" != "$ac_new_val_w"; then
220 AS_MESSAGE([error: `$ac_var' has changed since the previous run:], 2)
223 AS_MESSAGE([warning: ignoring whitespace changes in `$ac_var' since the previous run:], 2)
224 eval $ac_var=\$ac_old_val
226 AS_MESSAGE([ former value: `$ac_old_val'], 2)
227 AS_MESSAGE([ current value: `$ac_new_val'], 2)
230 # Pass precious variables to config.status.
231 if test "$ac_new_set" = set; then
233 dnl If you change this globbing pattern, test it on an old shell --
234 dnl it's sensitive. Putting any kind of quote in it causes syntax errors.
235 [ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)]
236 ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
237 *) ac_arg=$ac_var=$ac_new_val ;;
239 case " $ac_configure_args " in
240 *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
241 *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
245 if $ac_cache_corrupted; then
246 AS_MESSAGE([error: in `$ac_pwd':], 2)
247 AS_MESSAGE([error: changes in the environment can compromise the build], 2)
248 AS_ERROR([run `make distclean' and/or `rm $cache_file' and start over])
250 ])# _AC_ARG_VAR_VALIDATE
253 m4_version_prereq([2.63],, [
255 # AC_MSG_FAILURE(ERROR, [EXIT-STATUS = 1])
256 # ----------------------------------------
257 # This is the same code as in 2.59 and 2.61, except it also outputs pwd.
258 m4_define([AC_MSG_FAILURE],
259 [{ AS_MESSAGE([error: in `$ac_pwd':], 2)
261 See `config.log' for more details.], [$2]); }])
265 m4_version_prereq([2.60],, [
266 dnl M4 1.6 and newer implement m4wrap using FIFO semantics, as required
267 dnl by Posix; earlier versions used LIFO semantics. Unfortunately,
268 dnl Autoconf versions before 2.60 require those LIFO semantics, so
269 dnl make sure to give it to them.
270 m4_define([m4_wrap], [m4_ifdef([_$0_text],
271 [m4_define([_$0_text], [$1]m4_defn([_$0_text]))],
272 [m4_define([_$0_text], [$1])m4_builtin([m4wrap],
273 [m4_default(m4_defn([_$0_text])m4_undefine([_$0_text]))])])])
276 m4_version_prereq([2.66],, [
277 dnl We need AC_CHECK_DECL which works for overloaded C++ functions.
279 # _AC_CHECK_DECL_BODY
280 # -------------------
281 # Shell function body for AC_CHECK_DECL.
282 m4_define([_AC_CHECK_DECL_BODY],
283 [ AS_LINENO_PUSH([$[]1])
284 [as_decl_name=`echo $][2|sed 's/ *(.*//'`]
285 [as_decl_use=`echo $][2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`]
286 AC_CACHE_CHECK([whether $as_decl_name is declared], [$[]3],
287 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]4],
288 [@%:@ifndef $[]as_decl_name
289 @%:@ifdef __cplusplus
290 (void) $[]as_decl_use;
292 (void) $[]as_decl_name;
296 [AS_VAR_SET([$[]3], [yes])],
297 [AS_VAR_SET([$[]3], [no])])])
299 ])# _AC_CHECK_DECL_BODY
301 # _AC_CHECK_DECLS(SYMBOL, ACTION-IF_FOUND, ACTION-IF-NOT-FOUND,
303 # -------------------------------------------------------------
304 # Helper to AC_CHECK_DECLS, which generates the check for a single
305 # SYMBOL with INCLUDES, performs the AC_DEFINE, then expands
306 # ACTION-IF-FOUND or ACTION-IF-NOT-FOUND.
307 m4_define([_AC_CHECK_DECLS],
308 [AC_CHECK_DECL([$1], [ac_have_decl=1], [ac_have_decl=0], [$4])]dnl
309 [AC_DEFINE_UNQUOTED(AS_TR_CPP(m4_bpatsubst(HAVE_DECL_[$1],[ *(.*])),
311 [Define to 1 if you have the declaration of `$1',
312 and to 0 if you don't.])]dnl
313 [m4_ifvaln([$2$3], [AS_IF([test $ac_have_decl = 1], [$2], [$3])])])