> The only downside to this patch is the fact that
> AC_PROG_CC and AC_PROG_CXX now rely on the
> AC_CHECK_TOOL_PREFIX macro which depends on
> AC_CANONICAL_HOST and AC_CANONICAL_BUILD.
I think this is abnormal: since AC_CHECK_TOOL is only interested in
user's input, in theory there is just no reason for it to depend on
config.*.
Here is a proposal which should solve the problem.
I built this patch following my own ideas, and in particular there os
something which is debatable, and I'd love to have opinions on this
(Ian? :).
This point is that if the user did not --build, then $build_alias=''
likewise for the two others. Before, $build_alias would have been the
same as as $build, i.e. computed by config.guess.
I think it is a good thing, since now we really know when the user
said something, and the situation is clearer wrt build, build_alias etc.
And it is abnormal to depend on $build_alias in situations where
'' would be wrong (IMHO).
This is 15-thing-alias.
Index: 0.325/ChangeLog
--- 0.325/ChangeLog Sun, 21 May 2000 00:17:19 +0200 akim (ace/34_ChangeLog 1.294 666)
+++ 0.325(w)/ChangeLog Sun, 21 May 2000 11:26:53 +0200 akim (ace/34_ChangeLog 1.294
+666)
@@ -1,5 +1,32 @@
2000-05-21 Akim Demaille <[EMAIL PROTECTED]>
+ The options --build etc. used to set `$build'. *If*
+ AC_CANONICAL_SYSTEM was run, then the value of `$build' given by
+ the user was saved into `$build_alias', and `$build' was
+ normalized using `config.sub'.
+
+ Now, let `--build' set `$build_alias' so that scripts with or
+ without `AC_CANONICAL_BUILD' have the same semantics. This allows
+ to use `AC_CHECK_TOOL' without requiring `config.guess' and
+ `config.sub' (which was bizarre anyway).
+
+ * acgeneral.m4 (_AC_INIT_PARSE_ARGS): --build, --host and --target
+ set `build_alias' etc.
+ (AC_CANONICALIZE): Mutate into...
+ (_AC_CANONICAL_SPLIT): this, which does not canonicalize, it just
+ computes `$foo_os' etc.
+ (_AC_CANONICAL_THING): Remove, too confusing.
+ (AC_CANONICAL_BUILD): Adjust.
+ Do not assign any value to `build_alias', just compute `build', and
+ `build_{cpy, vendor, os}'.
+ (AC_CANONICAL_HOST, AC_CANONICAL_TARGET): Likewise.
+ (AC_CHECK_TOOL_PREFIX): Fire your rule when `$host_alias' is
+ given, not when `$host != $build'.
+
+ * acgeneral.m4 (sinclude): Fix typo.
+
+2000-05-21 Akim Demaille <[EMAIL PROTECTED]>
+
* doc/autoconf.texi (Exiting from Shell Scripts): Move contents
into...
(Limitations of Builtins): this new node.
Index: 0.325/acgeneral.m4
--- 0.325/acgeneral.m4 Sat, 20 May 2000 22:58:47 +0200 akim (ace/27_acgeneral.
1.169.8.29 666)
+++ 0.325(w)/acgeneral.m4 Sun, 21 May 2000 11:23:54 +0200 akim (ace/27_acgeneral.
+1.169.8.29 666)
@@ -51,7 +51,7 @@
# Some people depend upon sinclude, disabled by libm4.
-define([sinclude], [buitin([sinclude], $@)])
+define([sinclude], [builtin([sinclude], $@)])
## ---------------- ##
## The diversions. ##
@@ -1001,9 +1001,9 @@ AC_DEFUN([_AC_INIT_PARSE_ARGS],
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
+ ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build=$ac_optarg ;;
+ build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c | -c)
@@ -1067,10 +1067,10 @@ AC_DEFUN([_AC_INIT_PARSE_ARGS],
-host | --host | --hos | --ho)
cross_compiling=yes
- ac_prev=host ;;
+ ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
cross_compiling=yes
- host=$ac_optarg ;;
+ host_alias=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
@@ -1208,9 +1208,9 @@ AC_DEFUN([_AC_INIT_PARSE_ARGS],
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
+ ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target=$ac_optarg ;;
+ target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
@@ -1277,7 +1277,7 @@ AC_DEFUN([_AC_INIT_PARSE_ARGS],
[*[^-a-zA-Z0-9.]*]) AC_MSG_WARN([invalid host type: $ac_option]);;
esac
AC_MSG_WARN([you should use --build, --host, --target])
- : ${build=$ac_option} ${host=$ac_option} ${target=$ac_option}
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
esac
@@ -1829,59 +1829,26 @@ AC_DEFUN([AC_CONFIG_AUX_DIRS],
# 3. Target defaults to host.
-# AC_CANONICALIZE(THING)
-# ----------------------
-# Canonicalize the appropriate THING, generating the variables THING,
-# THING_{alias cpu vendor os}, and the associated cache entries.
-AC_DEFUN([AC_CANONICALIZE],
-[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-ac_cv_$1=`$ac_config_sub $ac_cv_$1_alias` || exit 1
-ac_cv_$1_cpu=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\1/'`
-ac_cv_$1_vendor=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\2/'`
-ac_cv_$1_os=`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`
-AC_SUBST([$1], [$ac_cv_$1])dnl
-AC_SUBST([$1_alias], [$ac_cv_$1_alias])dnl
-AC_SUBST([$1_cpu], [$ac_cv_$1_cpu])dnl
-AC_SUBST([$1_vendor], [$ac_cv_$1_vendor])dnl
-AC_SUBST([$1_os], [$ac_cv_$1_os])dnl
-])# AC_CANONICALIZE
-
-
-# _AC_CANONICAL_THING(THING)
+# _AC_CANONICAL_SPLIT(THING)
# --------------------------
-# Worker routine for AC_CANONICAL_SYSTEM. THING is one of `host',
-# `target', or `build'. Canonicalize the appropriate thing. We also
-# redo the cache entries if the user specifies something different
-# from ac_cv_$THING_alias on the command line.
-define([_AC_CANONICAL_THING],
-[AC_MSG_CHECKING([$1 system type])
-if test "x$ac_cv_$1" = "x" ||
- (test "x$$1" != "x" && test "x$$1" != "x$ac_cv_$1_alias"); then
-
-dnl Set $1_alias.
- ac_cv_$1_alias=$$1
- test "x$ac_cv_$1_alias" = "x" &&
- m4_case([$1],
-[build],
- [{ ac_cv_build_alias=`$ac_config_guess` ||
- AC_MSG_ERROR(
- [cannot guess build (this machine) type; you must specify one]); }],
-[host],
- [ac_cv_host_alias=$build_alias],
-[target],
- [ac_cv_target_alias=$host_alias])
-else
- echo $ECHO_N "(cached) $ECHO_C" >&AC_FD_MSG
-fi
-AC_CANONICALIZE([$1])
-AC_MSG_RESULT($ac_cv_$1)[]dnl
-])# _AC_CANONICAL_THING
+# Generate the variables THING, THING_{alias cpu vendor os}.
+AC_DEFUN([_AC_CANONICAL_SPLIT],
+[AC_SUBST([$1], [$ac_cv_$1])dnl
+dnl FIXME: AC_SUBST([$1_alias], [$ac_cv_$1_alias])dnl
+AC_SUBST([$1_cpu],
+ [`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\1/'`])dnl
+AC_SUBST([$1_vendor],
+ [`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\2/'`])dnl
+AC_SUBST([$1_os],
+ [`echo $ac_cv_$1 | sed 's/^\([[^-]]*\)-\([[^-]]*\)-\(.*\)$/\3/'`])dnl
+])# _AC_CANONICAL_SPLIT
# AC_CANONICAL_BUILD
# ------------------
AC_DEFUN_ONCE([AC_CANONICAL_BUILD],
-[AC_DIVERT([HELP_CANON],
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_DIVERT([HELP_CANON],
[[
Hosts type:
--build=BUILD configure for buildinLD [guessed]]])dnl
@@ -1889,7 +1856,15 @@ AC_DEFUN_ONCE([AC_CANONICAL_BUILD],
$ac_config_sub sun4 >/dev/null 2>&1 ||
AC_MSG_ERROR([cannot run $ac_config_sub])
-_AC_CANONICAL_THING(build)[]dnl
+AC_CACHE_CHECK([build system type], [ac_cv_build],
+[ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+ ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+ AC_MSG_ERROR([cannot guess build type; you must specify one])
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || exit 1
+])
+_AC_CANONICAL_SPLIT(build)
])# AC_CANONICAL_BUILD
@@ -1899,7 +1874,13 @@ AC_DEFUN_ONCE([AC_CANONICAL_HOST],
[AC_REQUIRE([AC_CANONICAL_BUILD])dnl
AC_DIVERT([HELP_CANON],
[[ --host=HOST cross-compile to build programs running on HOST [BUILD]]])dnl
-_AC_CANONICAL_THING(host)[]dnl
+AC_CACHE_CHECK([host system type], [ac_cv_host],
+[ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+ ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || exit 1
+])
+_AC_CANONICAL_SPLIT([host])
])# AC_CANONICAL_HOST
@@ -1910,11 +1891,18 @@ AC_DEFUN_ONCE([AC_CANONICAL_TARGET],
AC_BEFORE([$0], [AC_ARG_PROGRAM])dnl
AC_DIVERT([HELP_CANON],
[[ --target=TARGET configure for building compilers for TARGET [HOST]]])dnl
-_AC_CANONICAL_THING(target)[]dnl
+AC_CACHE_CHECK([target system type], [ac_cv_target],
+[dnl Set target_alias.
+ac_cv_target_alias=$target_alias
+test "x$ac_cv_target_alias" = "x" &&
+ ac_cv_target_alias=$ac_cv_host_alias
+ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || exit 1
+])
+_AC_CANONICAL_SPLIT([target])
# The aliases save the names the user supplied, while $host etc.
# will get canonicalized.
-test "$host_alias" != "$target_alias" &&
+test -n "$target_alias" &&
test "$program_prefix$program_suffix$program_transform_name" = \
NONENONEs,x,x, &&
program_prefix=${target_alias}-[]dnl
@@ -2609,10 +2597,8 @@ AC_DEFUN([AC_PATH_PROGS],
# AC_CHECK_TOOL_PREFIX
# ---------------------
AC_DEFUN([AC_CHECK_TOOL_PREFIX],
-[AC_REQUIRE([AC_CANONICAL_HOST])dnl
-AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-if test $host != $build; then
- ac_tool_prefix=${host_alias}-
+[if test -n "$host_alias"; then
+ ac_tool_prefix=$host_alias-
else
ac_tool_prefix=
fi
Akim