[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Improve behavior of AC_CHECK_TOOL; introduce AC_CHECK_TARGET_TOO
From: |
Nathanael Nerode |
Subject: |
[PATCH] Improve behavior of AC_CHECK_TOOL; introduce AC_CHECK_TARGET_TOOL. |
Date: |
Mon, 13 Jan 2003 16:07:53 -0500 |
User-agent: |
Mutt/1.4i |
This patch changes the behavior of AC_CHECK_TOOL and friends in a subtle
way. After this patch, the ${host_alias} prefix is *required* when
build!=host. Working on GCC and related projects, this has proven to be
the desired behavior in all cases; I've never seen a case where finding and
using the native tools when cross-compiling is a good idea.
It also introduces an AC_CHECK_TARGET_TOOL macro, which checks for tools
normally native to the target, an oddity needed in gcc and probably useful
in other compiler projects which include runtime support libraries.
Testsuite passed. Some of the Fortran tests were skipped for
reasons utterly opaque to me.
I was forced to introduce two variables (in _AC_INIT_PARSE_ARGS) one of
which overlaps with the meaning of 'cross_compiling'; however, it's used
for a subtly different purpose than 'cross_compiling' is, and I didn't
want to screw around with the 'cross_compiling=maybe' nonsense. I also
think my names are clearer.
The whole logic for that part would be much simpler, and would work better
in some corner cases, if I made AC_CHECK_TOOL & company depend on
AC_CANONICAL_HOST and AC_CANONICAL_BUILD, so I could just check whether
$host = $build. However, I didn't want to add that dependency unless it
was considered desirable. Also, adding it broke the testsuite tests for
AC_CHECK_TOOL and company in a way I couldn't figure out how to fix. If this
method is considered preferable, I will submit the appropriate version of the
patch, but someone else will have to figure out how to fix the testsuite.
I hope this patch, or some alternate version of it, can go in soon...
* lib/autoconf/programs.m4 (AC_PATH_TOOL, AC_CHECK_TOOL,
AC_CHECK_TOOLS): Don't accept unprefixed tools if build!=host.
* lib/autoconf/programs.m4 (AC_CHECK_TARGET_TOOL): New macro.
* lib/autoconf/general.m4 (_AC_INIT_PARSE_ARGS): Introduce
ac_target_tool_prefix. Introduce ac_build_is_host and
ac_build_is_target.
* doc/autoconf.texi: Update AC_CHECK_TOOL documentation.
Add documentation for AC_CHECK_TARGET_TOOL.
* tests/mktests.sh: Add AC_CHECK_TARGET_TOOL to the ac_exclude_list.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.716
diff -u -r1.716 autoconf.texi
--- doc/autoconf.texi 3 Dec 2002 07:35:31 -0000 1.716
+++ doc/autoconf.texi 13 Jan 2003 20:59:15 -0000
@@ -3251,9 +3251,10 @@
@acindex CHECK_TOOL
Like @code{AC_CHECK_PROG}, but first looks for @var{prog-to-check-for}
with a prefix of the host type as determined by
address@hidden, followed by a dash (@pxref{Canonicalizing}).
-For example, if the user runs @samp{configure --host=i386-gnu}, then
-this call:
address@hidden, followed by a dash (@pxref{Canonicalizing}). If
+the host type is not the same as the build type, the prefix is required.
+For example, if the user runs @samp{configure --build=i386-gnu
--host=i386-gnu},
+then this call:
@example
AC_CHECK_TOOL(RANLIB, ranlib, :)
@end example
@@ -3261,6 +3262,29 @@
sets @code{RANLIB} to @file{i386-gnu-ranlib} if that program exists in
@code{PATH}, or otherwise to @samp{ranlib} if that program exists in
@code{PATH}, or to @samp{:} if neither program exists.
+If instead the user runs @samp{configure --host=i386-gnu}, it sets
address@hidden to @file{i386-gnu-ranlib} if that program exists in
address@hidden, or to @samp{:} if that program doesn't exist.
address@hidden defmac
+
address@hidden AC_CHECK_TARGET_TOOL (@var{variable}, @var{prog-to-check-for},
@ovar{value-if-not-found}, @ovar{path})
address@hidden CHECK_TARGET_TOOL
+Like @code{AC_CHECK_PROG}, but first looks for @var{prog-to-check-for}
+with a prefix of the target type as determined by
address@hidden, followed by a dash (@pxref{Canonicalizing}). If
+the target type is not the same as the build type, the prefix is required.
+For example, if the user runs @samp{configure --build=i386-gnu
--target=i386-gnu},
+then this call:
address@hidden
+AC_CHECK_TARGET_TOOL(RANLIB_FOR_TARGET, ranlib, :)
address@hidden example
address@hidden
+sets @code{RANLIB_FOR_TARGET} to @file{i386-gnu-ranlib} if that program exists
in
address@hidden, or otherwise to @samp{ranlib} if that program exists in
address@hidden, or to @samp{:} if neither program exists.
+If instead the user runs @samp{configure --target=i386-gnu}, it sets
address@hidden to @file{i386-gnu-ranlib} if that program exists in
address@hidden, or to @samp{:} if that program doesn't exist.
@end defmac
@defmac AC_CHECK_TOOLS (@var{variable}, @var{progs-to-check-for},
@ovar{value-if-not-found}, @ovar{path})
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.811
diff -u -r1.811 general.m4
--- lib/autoconf/general.m4 12 Nov 2002 10:54:46 -0000 1.811
+++ lib/autoconf/general.m4 13 Jan 2003 20:59:17 -0000
@@ -926,8 +926,41 @@
fi
fi
+# When can we use native tools in place of cross tools to the host?
+# When, in a certain sense, build=host. Cases:
+# 1. --host wasn't specified (defaults to build). Build=host.
+# 2. --host and --build were specified the same. Build=host.
+# 3. Otherwise, build!=host.
+if test "x$host_alias" = x ; then
+ ac_build_is_host=yes
+else
+ if test "x$host_alias" = "x$build_alias" ; then
+ ac_build_is_host=yes
+ else
+ ac_build_is_host=no
+ fi
+fi
+
+# When can we use native tools in place of cross tools to the target?
+# When, in a certain sense, build=target. Cases:
+# 1. --target wasn't specified (defaults to host). Same as build=host.
+# 2. --target and --build were specified the same. Build=target.
+# 3. Otherwise, build!=target.
+if test "x$target_alias" = x ; then
+ ac_build_is_target=$ac_build_is_host
+else
+ if test "x$target_alias" = "x$build_alias" ; then
+ ac_build_is_target=yes
+ else
+ ac_build_is_target=no
+ fi
+fi
+
ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+ac_target_tool_prefix=
+test -n "$target_alias" && ac_target_tool_prefix=$target_alias-
test "$silent" = yes && exec AS_MESSAGE_FD>/dev/null
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.13
diff -u -r1.13 programs.m4
--- lib/autoconf/programs.m4 31 Oct 2002 13:15:03 -0000 1.13
+++ lib/autoconf/programs.m4 13 Jan 2003 20:59:18 -0000
@@ -196,9 +196,16 @@
AC_PATH_PROG([$1], [${ac_tool_prefix}$2], , [$4])
fi
if test -z "$ac_cv_path_$1"; then
- ac_pt_$1=$$1
- AC_PATH_PROG([ac_pt_$1], [$2], [$3], [$4])
- $1=$ac_pt_$1
+ case $ac_build_is_host in
+ yes)
+ ac_pt_$1=$$1
+ AC_PATH_PROG([ac_pt_$1], [$2], [$3], [$4])
+ $1=$ac_pt_$1
+ ;;
+ no)
+ $1="$3"
+ ;;
+ esac
else
$1="$ac_cv_path_$1"
fi
@@ -213,15 +220,46 @@
AC_CHECK_PROG([$1], [${ac_tool_prefix}$2], [${ac_tool_prefix}$2], , [$4])
fi
if test -z "$ac_cv_prog_$1"; then
- ac_ct_$1=$$1
- AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [$3], [$4])
- $1=$ac_ct_$1
+ case $ac_build_is_host in
+ yes)
+ ac_ct_$1=$$1
+ AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [$3], [$4])
+ $1=$ac_ct_$1
+ ;;
+ no)
+ $1="$3"
+ ;;
+ esac
else
$1="$ac_cv_prog_$1"
fi
])# AC_CHECK_TOOL
+# AC_CHECK_TARGET_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
[PATH])
+# ------------------------------------------------------------------------
+# (Use different variables $1 and ac_ct_$1 so that cache vars don't conflict.)
+AC_DEFUN([AC_CHECK_TARGET_TOOL],
+[if test -n "$ac_tool_prefix"; then
+ AC_CHECK_PROG([$1], [${ac_target_tool_prefix}$2],
[${ac_target_tool_prefix}$2], , [$4])
+fi
+if test -z "$ac_cv_prog_$1"; then
+ case $ac_build_is_target in
+ yes)
+ ac_ctt_$1=$$1
+ AC_CHECK_PROG([ac_ctt_$1], [$2], [$2], [$3], [$4])
+ $1=$ac_ctt_$1
+ ;;
+ no)
+ $1="$3"
+ ;;
+ esac
+else
+ $1="$ac_cv_prog_$1"
+fi
+])# AC_CHECK_TARGET_TOOL
+
+
# AC_CHECK_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
# [PATH])
# ------------------------------------------------------------------
@@ -239,9 +277,16 @@
done
fi
if test -z "$$1"; then
- ac_ct_$1=$$1
- AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
- $1=$ac_ct_$1
+ case $ac_build_is_host in
+ yes)
+ ac_ct_$1=$$1
+ AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
+ $1=$ac_ct_$1
+ ;;
+ no)
+ $1="$3"
+ ;;
+ esac
fi
])# AC_CHECK_TOOLS
Index: tests/mktests.sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.29
diff -u -r1.29 mktests.sh
--- tests/mktests.sh 2 Sep 2002 06:44:27 -0000 1.29
+++ tests/mktests.sh 13 Jan 2003 20:59:19 -0000
@@ -128,7 +128,7 @@
#
ac_exclude_list='^AC_ARG_VAR$
^AC_CANONICALIZE|AC_PREFIX_PROGRAM|AC_PREREQ$
-^AC_CHECK_(DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|TOOL|TYPE)S?$
+^AC_CHECK_(DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|TOOL|TARGET_TOOL|TYPE)S?$
^AC_CONFIG
^AC_F77_FUNC$
^AC_(FUNC_GETLOADAVG|REPLACE_FNMATCH|FUNC_FNMATCH_GNU)$
- [PATCH] Improve behavior of AC_CHECK_TOOL; introduce AC_CHECK_TARGET_TOOL.,
Nathanael Nerode <=