2009-08-02 Paolo Bonzini <bonzini@gnu.org
[official-gcc.git] / config / override.m4
blobbf112db99a89f35fdc48b272de18fd7a03501eca
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)
7 dnl
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.
11 dnl
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.
29 dnl
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
32 dnl when needed.
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.59])])
45 dnl Test for the exact version when AC_INIT is expanded.
46 dnl This allows to update the tree in steps (for testing)
47 dnl by putting
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
61 m4_version_prereq([2.60],, [
62 dnl We use $ac_pwd in some of the overrides below; ensure its definition
63 m4_divert_push([PARSE_ARGS])dnl
64 ac_pwd=`pwd`
65 m4_divert_pop([PARSE_ARGS])dnl
69 m4_version_prereq([2.60],, [
71 # _AC_OUTPUT_SUBDIRS
72 # ------------------
73 # This is a subroutine of AC_OUTPUT, but it does not go into
74 # config.status, rather, it is called after running config.status.
75 m4_define([_AC_OUTPUT_SUBDIRS],
78 # CONFIG_SUBDIRS section, as fixed in confsubdir.m4.
80 if test "$no_recursion" != yes; then
82   # Remove --cache-file and --srcdir arguments so they do not pile up.
83   ac_sub_configure_args=
84   ac_prev=
85   eval "set x $ac_configure_args"
86   shift
87   for ac_arg
88   do
89     if test -n "$ac_prev"; then
90       ac_prev=
91       continue
92     fi
93     case $ac_arg in
94     -cache-file | --cache-file | --cache-fil | --cache-fi \
95     | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
96       ac_prev=cache_file ;;
97     -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
98     | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
99     | --c=*)
100       ;;
101     --config-cache | -C)
102       ;;
103     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
104       ac_prev=srcdir ;;
105     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
106       ;;
107     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
108       ac_prev=prefix ;;
109     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
110       ;;
111     *)
112       case $ac_arg in
113       *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
114       esac
115       ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;;
116     esac
117   done
119   # Always prepend --prefix to ensure using the same prefix
120   # in subdir configurations.
121   ac_arg="--prefix=$prefix"
122   case $ac_arg in
123   *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
124   esac
125   ac_sub_configure_args="$ac_arg $ac_sub_configure_args"
127   ac_popdir=`pwd`
128   for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
130     # Do not complain, so a configure script can configure whichever
131     # parts of a large source tree are present.
132     test -d "$srcdir/$ac_dir" || continue
134     AC_MSG_NOTICE([configuring in $ac_dir])
135     AS_MKDIR_P(["$ac_dir"])
136     _AC_SRCPATHS(["$ac_dir"])
138     cd "$ac_dir"
140     # Check for guested configure; otherwise get Cygnus style configure.
141     if test -f "$ac_srcdir/configure.gnu"; then
142       ac_sub_configure=$ac_srcdir/configure.gnu
143     elif test -f "$ac_srcdir/configure"; then
144       ac_sub_configure=$ac_srcdir/configure
145     elif test -f "$ac_srcdir/configure.in"; then
146       # This should be Cygnus configure.
147       ac_sub_configure=$ac_aux_dir/configure
148     else
149       AC_MSG_WARN([no configuration information is in $ac_dir])
150       ac_sub_configure=
151     fi
153     # The recursion is here.
154     if test -n "$ac_sub_configure"; then
155       # Make the cache file name correct relative to the subdirectory.
156       case $cache_file in
157       [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
158       *) # Relative path.
159         ac_sub_cache_file=$ac_top_builddir$cache_file ;;
160       esac
162       AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
163       # The eval makes quoting arguments work.
164       eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
165            --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
166         AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
167     fi
169     cd "$ac_popdir"
170   done
172 ])# _AC_OUTPUT_SUBDIRS
175 m4_version_prereq([2.63],, [
177 # _AC_ARG_VAR_VALIDATE
178 # --------------------
179 # The code is the same as autoconf 2.59, but with a more lenient check
180 # on precious variables and an output of pwd that have been added in
181 # autoconf 2.62.
182 m4_define([_AC_ARG_VAR_VALIDATE],
183 [m4_divert_text([INIT_PREPARE],
184 [# Check that the precious variables saved in the cache have kept the same
185 # value.
186 ac_cache_corrupted=false
187 for ac_var in `(set) 2>&1 |
188                sed -n 's/^ac_env_\([[a-zA-Z_0-9]]*\)_set=.*/\1/p'`; do
189   eval ac_old_set=\$ac_cv_env_${ac_var}_set
190   eval ac_new_set=\$ac_env_${ac_var}_set
191   eval ac_old_val="\$ac_cv_env_${ac_var}_value"
192   eval ac_new_val="\$ac_env_${ac_var}_value"
193   case $ac_old_set,$ac_new_set in
194     set,)
195       AS_MESSAGE([error: `$ac_var' was set to `$ac_old_val' in the previous run], 2)
196       ac_cache_corrupted=: ;;
197     ,set)
198       AS_MESSAGE([error: `$ac_var' was not set in the previous run], 2)
199       ac_cache_corrupted=: ;;
200     ,);;
201     *)
202       if test "x$ac_old_val" != "x$ac_new_val"; then
203         # differences in whitespace do not lead to failure.
204         ac_old_val_w=`echo x $ac_old_val`
205         ac_new_val_w=`echo x $ac_new_val`
206         if test "$ac_old_val_w" != "$ac_new_val_w"; then
207           AS_MESSAGE([error: `$ac_var' has changed since the previous run:], 2)
208           ac_cache_corrupted=:
209         else
210           AS_MESSAGE([warning: ignoring whitespace changes in `$ac_var' since the previous run:], 2)
211           eval $ac_var=\$ac_old_val
212         fi
213         AS_MESSAGE([  former value:  `$ac_old_val'], 2)
214         AS_MESSAGE([  current value: `$ac_new_val'], 2)
215       fi;;
216   esac
217   # Pass precious variables to config.status.
218   if test "$ac_new_set" = set; then
219     case $ac_new_val in
220 dnl If you change this globbing pattern, test it on an old shell --
221 dnl it's sensitive.  Putting any kind of quote in it causes syntax errors.
222 [    *" "*|*"   "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)]
223       ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
224     *) ac_arg=$ac_var=$ac_new_val ;;
225     esac
226     case " $ac_configure_args " in
227       *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
228       *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
229     esac
230   fi
231 done
232 if $ac_cache_corrupted; then
233   AS_MESSAGE([error: in `$ac_pwd':], 2)
234   AS_MESSAGE([error: changes in the environment can compromise the build], 2)
235   AS_ERROR([run `make distclean' and/or `rm $cache_file' and start over])
236 fi])dnl
237 ])# _AC_ARG_VAR_VALIDATE
240 m4_version_prereq([2.63],, [
242 # AC_MSG_FAILURE(ERROR, [EXIT-STATUS = 1])
243 # ----------------------------------------
244 # This is the same code as in 2.59 and 2.61, except it also outputs pwd.
245 m4_define([AC_MSG_FAILURE],
246 [{ AS_MESSAGE([error: in `$ac_pwd':], 2)
247 AC_MSG_ERROR([$1
248 See `config.log' for more details.], [$2]); }])
252 m4_version_prereq([2.60],, [
253 dnl M4 1.6 and newer implement m4wrap using FIFO semantics, as required
254 dnl by Posix; earlier versions used LIFO semantics.  Unfortunately,
255 dnl Autoconf versions before 2.60 require those LIFO semantics, so
256 dnl make sure to give it to them.
257 m4_define([m4_wrap], [m4_ifdef([_$0_text],
258   [m4_define([_$0_text], [$1]m4_defn([_$0_text]))],
259   [m4_define([_$0_text], [$1])m4_builtin([m4wrap],
260     [m4_default(m4_defn([_$0_text])m4_undefine([_$0_text]))])])])