OSDN Git Service

2008-04-23 Paolo Bonzini <bonzini@gnu.org>
[pf3gnuchains/gcc-fork.git] / config / override.m4
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
6 dnl This file should be a no-op for Autoconf versions != 2.59.
7 dnl It can be removed once the complete tree has moved to a
8 dnl newer Autoconf version.
9
10 dnl m4_PACKAGE_VERSION is an undocumented Autoconf macro.
11 dnl We use it because this fix is intended for 2.59 only.
12 dnl A feature test for the broken AC_CONFIG_SUBDIRS instead
13 dnl would be better but is tricky.
14 dnl
15 dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13.
16 dnl Redefine AC_CONFIG_SUBDIRS so aclocal pulls in this file
17 dnl when needed.
18
19 ifdef([m4_PACKAGE_VERSION],
20 [dnl AC_DEFUN a commonly used macro so this file is picked up.
21 m4_copy([AC_PREREQ], [_AC_PREREQ])
22 AC_DEFUN([AC_PREREQ], [frob])
23 m4_copy([_AC_PREREQ], [AC_PREREQ])
24
25 ifelse(m4_PACKAGE_VERSION, [2.59], [
26
27 # _AC_OUTPUT_SUBDIRS
28 # ------------------
29 # This is a subroutine of AC_OUTPUT, but it does not go into
30 # config.status, rather, it is called after running config.status.
31 m4_define([_AC_OUTPUT_SUBDIRS],
32 [
33 #
34 # CONFIG_SUBDIRS section, as fixed in confsubdir.m4.
35 #
36 if test "$no_recursion" != yes; then
37
38   # Remove --cache-file and --srcdir arguments so they do not pile up.
39   ac_sub_configure_args=
40   ac_prev=
41   eval "set x $ac_configure_args"
42   shift
43   for ac_arg
44   do
45     if test -n "$ac_prev"; then
46       ac_prev=
47       continue
48     fi
49     case $ac_arg in
50     -cache-file | --cache-file | --cache-fil | --cache-fi \
51     | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
52       ac_prev=cache_file ;;
53     -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
54     | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
55     | --c=*)
56       ;;
57     --config-cache | -C)
58       ;;
59     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
60       ac_prev=srcdir ;;
61     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
62       ;;
63     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
64       ac_prev=prefix ;;
65     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
66       ;;
67     *)
68       case $ac_arg in
69       *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
70       esac
71       ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;;
72     esac
73   done
74
75   # Always prepend --prefix to ensure using the same prefix
76   # in subdir configurations.
77   ac_arg="--prefix=$prefix"
78   case $ac_arg in
79   *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
80   esac
81   ac_sub_configure_args="$ac_arg $ac_sub_configure_args"
82
83   ac_popdir=`pwd`
84   for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
85
86     # Do not complain, so a configure script can configure whichever
87     # parts of a large source tree are present.
88     test -d "$srcdir/$ac_dir" || continue
89
90     AC_MSG_NOTICE([configuring in $ac_dir])
91     AS_MKDIR_P(["$ac_dir"])
92     _AC_SRCPATHS(["$ac_dir"])
93
94     cd "$ac_dir"
95
96     # Check for guested configure; otherwise get Cygnus style configure.
97     if test -f "$ac_srcdir/configure.gnu"; then
98       ac_sub_configure=$ac_srcdir/configure.gnu
99     elif test -f "$ac_srcdir/configure"; then
100       ac_sub_configure=$ac_srcdir/configure
101     elif test -f "$ac_srcdir/configure.in"; then
102       # This should be Cygnus configure.
103       ac_sub_configure=$ac_aux_dir/configure
104     else
105       AC_MSG_WARN([no configuration information is in $ac_dir])
106       ac_sub_configure=
107     fi
108
109     # The recursion is here.
110     if test -n "$ac_sub_configure"; then
111       # Make the cache file name correct relative to the subdirectory.
112       case $cache_file in
113       [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
114       *) # Relative path.
115         ac_sub_cache_file=$ac_top_builddir$cache_file ;;
116       esac
117
118       AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
119       # The eval makes quoting arguments work.
120       eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
121            --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
122         AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
123     fi
124
125     cd "$ac_popdir"
126   done
127 fi
128 ])# _AC_OUTPUT_SUBDIRS
129 ])
130
131 ifelse(m4_PACKAGE_VERSION, [2.62],, [
132
133 # _AC_ARG_VAR_VALIDATE
134 # --------------------
135 # The code is the same as autoconf 2.59, but with a more lenient check
136 # on precious variables that has been added in autoconf 2.62.
137 m4_define([_AC_ARG_VAR_VALIDATE],
138 [# Check that the precious variables saved in the cache have kept the same
139 # value.
140 ac_cache_corrupted=false
141 for ac_var in `(set) 2>&1 |
142                sed -n 's/^ac_env_\([[a-zA-Z_0-9]]*\)_set=.*/\1/p'`; do
143   eval ac_old_set=\$ac_cv_env_${ac_var}_set
144   eval ac_new_set=\$ac_env_${ac_var}_set
145   eval ac_old_val="\$ac_cv_env_${ac_var}_value"
146   eval ac_new_val="\$ac_env_${ac_var}_value"
147   case $ac_old_set,$ac_new_set in
148     set,)
149       AS_MESSAGE([error: `$ac_var' was set to `$ac_old_val' in the previous run], 2)
150       ac_cache_corrupted=: ;;
151     ,set)
152       AS_MESSAGE([error: `$ac_var' was not set in the previous run], 2)
153       ac_cache_corrupted=: ;;
154     ,);;
155     *)
156       if test "x$ac_old_val" != "x$ac_new_val"; then
157         # differences in whitespace do not lead to failure.
158         ac_old_val_w=`echo x $ac_old_val`
159         ac_new_val_w=`echo x $ac_new_val`
160         if test "$ac_old_val_w" != "$ac_new_val_w"; then
161           AS_MESSAGE([error: `$ac_var' has changed since the previous run:], 2)
162           ac_cache_corrupted=:
163         else
164           AS_MESSAGE([warning: ignoring whitespace changes in `$ac_var' since the previous run:], 2)
165           eval $ac_var=\$ac_old_val
166         fi
167         AS_MESSAGE([  former value:  `$ac_old_val'], 2)
168         AS_MESSAGE([  current value: `$ac_new_val'], 2)
169       fi;;
170   esac
171   # Pass precious variables to config.status.
172   if test "$ac_new_set" = set; then
173     case $ac_new_val in
174 dnl If you change this globbing pattern, test it on an old shell --
175 dnl it's sensitive.  Putting any kind of quote in it causes syntax errors.
176 [    *" "*|*"   "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)]
177       ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
178     *) ac_arg=$ac_var=$ac_new_val ;;
179     esac
180     case " $ac_configure_args " in
181       *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
182       *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
183     esac
184   fi
185 done
186 if $ac_cache_corrupted; then
187   AS_MESSAGE([error: changes in the environment can compromise the build], 2)
188   AS_ERROR([run `make distclean' and/or `rm $cache_file' and start over])
189 fi
190 ])# _AC_ARG_VAR_VALIDATE
191 ])])