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 m4_PACKAGE_VERSION is an undocumented Autoconf macro.
16 dnl We use it because this fix is intended for 2.59 only.
17 dnl A feature test for the broken AC_CONFIG_SUBDIRS instead
18 dnl would be better but is tricky.
20 dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
21 dnl Redefine AC_CONFIG_SUBDIRS so aclocal pulls in this file
24 ifdef([m4_PACKAGE_VERSION],
25 [dnl AC_DEFUN a commonly used macro so this file is picked up.
26 m4_copy([AC_PREREQ], [_AC_PREREQ])
27 AC_DEFUN([AC_PREREQ], [frob])
28 m4_copy([_AC_PREREQ], [AC_PREREQ])
31 dnl Ensure exactly this Autoconf version is used
32 m4_ifndef([_GCC_AUTOCONF_VERSION],
33 [m4_define([_GCC_AUTOCONF_VERSION], [2.59])])
35 dnl Test for the exact version when AC_INIT is expanded.
36 dnl This allows to update the tree in steps (for testing)
38 dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y])
39 dnl in configure.ac before AC_INIT,
40 dnl without rewriting this file.
41 dnl Or for updating the whole tree at once with the definition above.
42 AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK],
43 [m4_if(m4_defn([_GCC_AUTOCONF_VERSION]),
44 m4_defn([m4_PACKAGE_VERSION]), [],
45 [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])])
47 m4_define([AC_INIT], m4_defn([AC_INIT])[
48 _GCC_AUTOCONF_VERSION_CHECK
51 m4_version_prereq([2.60],, [
52 dnl We use $ac_pwd in some of the overrides below; ensure its definition
53 m4_divert_push([PARSE_ARGS])dnl
55 m4_divert_pop([PARSE_ARGS])dnl
59 m4_version_prereq([2.60],, [
63 # This is a subroutine of AC_OUTPUT, but it does not go into
64 # config.status, rather, it is called after running config.status.
65 m4_define([_AC_OUTPUT_SUBDIRS],
68 # CONFIG_SUBDIRS section, as fixed in confsubdir.m4.
70 if test "$no_recursion" != yes; then
72 # Remove --cache-file and --srcdir arguments so they do not pile up.
73 ac_sub_configure_args=
75 eval "set x $ac_configure_args"
79 if test -n "$ac_prev"; then
84 -cache-file | --cache-file | --cache-fil | --cache-fi \
85 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
87 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
88 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
93 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
95 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
97 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
99 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
103 *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
105 ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;;
109 # Always prepend --prefix to ensure using the same prefix
110 # in subdir configurations.
111 ac_arg="--prefix=$prefix"
113 *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
115 ac_sub_configure_args="$ac_arg $ac_sub_configure_args"
118 for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
120 # Do not complain, so a configure script can configure whichever
121 # parts of a large source tree are present.
122 test -d "$srcdir/$ac_dir" || continue
124 AC_MSG_NOTICE([configuring in $ac_dir])
125 AS_MKDIR_P(["$ac_dir"])
126 _AC_SRCPATHS(["$ac_dir"])
130 # Check for guested configure; otherwise get Cygnus style configure.
131 if test -f "$ac_srcdir/configure.gnu"; then
132 ac_sub_configure=$ac_srcdir/configure.gnu
133 elif test -f "$ac_srcdir/configure"; then
134 ac_sub_configure=$ac_srcdir/configure
135 elif test -f "$ac_srcdir/configure.in"; then
136 # This should be Cygnus configure.
137 ac_sub_configure=$ac_aux_dir/configure
139 AC_MSG_WARN([no configuration information is in $ac_dir])
143 # The recursion is here.
144 if test -n "$ac_sub_configure"; then
145 # Make the cache file name correct relative to the subdirectory.
147 [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
149 ac_sub_cache_file=$ac_top_builddir$cache_file ;;
152 AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
153 # The eval makes quoting arguments work.
154 eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
155 --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
156 AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
162 ])# _AC_OUTPUT_SUBDIRS
165 m4_version_prereq([2.63],, [
167 # _AC_ARG_VAR_VALIDATE
168 # --------------------
169 # The code is the same as autoconf 2.59, but with a more lenient check
170 # on precious variables and an output of pwd that have been added in
172 m4_define([_AC_ARG_VAR_VALIDATE],
173 [m4_divert_text([INIT_PREPARE],
174 [# Check that the precious variables saved in the cache have kept the same
176 ac_cache_corrupted=false
177 for ac_var in `(set) 2>&1 |
178 sed -n 's/^ac_env_\([[a-zA-Z_0-9]]*\)_set=.*/\1/p'`; do
179 eval ac_old_set=\$ac_cv_env_${ac_var}_set
180 eval ac_new_set=\$ac_env_${ac_var}_set
181 eval ac_old_val="\$ac_cv_env_${ac_var}_value"
182 eval ac_new_val="\$ac_env_${ac_var}_value"
183 case $ac_old_set,$ac_new_set in
185 AS_MESSAGE([error: `$ac_var' was set to `$ac_old_val' in the previous run], 2)
186 ac_cache_corrupted=: ;;
188 AS_MESSAGE([error: `$ac_var' was not set in the previous run], 2)
189 ac_cache_corrupted=: ;;
192 if test "x$ac_old_val" != "x$ac_new_val"; then
193 # differences in whitespace do not lead to failure.
194 ac_old_val_w=`echo x $ac_old_val`
195 ac_new_val_w=`echo x $ac_new_val`
196 if test "$ac_old_val_w" != "$ac_new_val_w"; then
197 AS_MESSAGE([error: `$ac_var' has changed since the previous run:], 2)
200 AS_MESSAGE([warning: ignoring whitespace changes in `$ac_var' since the previous run:], 2)
201 eval $ac_var=\$ac_old_val
203 AS_MESSAGE([ former value: `$ac_old_val'], 2)
204 AS_MESSAGE([ current value: `$ac_new_val'], 2)
207 # Pass precious variables to config.status.
208 if test "$ac_new_set" = set; then
210 dnl If you change this globbing pattern, test it on an old shell --
211 dnl it's sensitive. Putting any kind of quote in it causes syntax errors.
212 [ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)]
213 ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
214 *) ac_arg=$ac_var=$ac_new_val ;;
216 case " $ac_configure_args " in
217 *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
218 *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
222 if $ac_cache_corrupted; then
223 AS_MESSAGE([error: in `$ac_pwd':], 2)
224 AS_MESSAGE([error: changes in the environment can compromise the build], 2)
225 AS_ERROR([run `make distclean' and/or `rm $cache_file' and start over])
227 ])# _AC_ARG_VAR_VALIDATE
230 m4_version_prereq([2.63],, [
232 # AC_MSG_FAILURE(ERROR, [EXIT-STATUS = 1])
233 # ----------------------------------------
234 # This is the same code as in 2.59 and 2.61, except it also outputs pwd.
235 m4_define([AC_MSG_FAILURE],
236 [{ AS_MESSAGE([error: in `$ac_pwd':], 2)
238 See `config.log' for more details.], [$2]); }])
242 m4_version_prereq([2.60],, [
243 dnl M4 1.6 and newer implement m4wrap using FIFO semantics, as required
244 dnl by Posix; earlier versions used LIFO semantics. Unfortunately,
245 dnl Autoconf versions before 2.60 require those LIFO semantics, so
246 dnl make sure to give it to them.
247 m4_define([m4_wrap], [m4_ifdef([_$0_text],
248 [m4_define([_$0_text], [$1]m4_defn([_$0_text]))],
249 [m4_define([_$0_text], [$1])m4_builtin([m4wrap],
250 [m4_default(m4_defn([_$0_text])m4_undefine([_$0_text]))])])])