autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] improve AC_CHECK_TOOL, introduce AC_CHECK_TARGET_TOOL (v. 3)


From: Nathanael Nerode
Subject: [PATCH] improve AC_CHECK_TOOL, introduce AC_CHECK_TARGET_TOOL (v. 3)
Date: Sun, 19 Jan 2003 18:37:08 -0500
User-agent: Mutt/1.4i

Fixes cut-and-paste error.
---

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
used to build programs/libraries which run on the target, an oddity needed
in gcc and probably useful in other compiler projects which include runtime
support libraries.  This belongs in autoconf mainline because it's
general-purpose support and deserves the support section in 
_AC_INIT_PARSE_ARGS.  Note that I am not submitting specific macros *built*
on this, of which there are many.

This introduces AC_REQUIRE on AC_CANONICAL_BUILD and AC_CANONCIAL_HOST to 
AC_CHECK_TOOL and friends.  I submitted a version which didn't and was told
to submit this version.

Testsuite mostly passed.  Failures and skips:
 43: compile.at:114    FAILED near `compile.at:139'
 49: c.at:59           FAILED near `c.at:68'
These two are due to the AC_REQUIRE introduction; the tests need to have an
appropriate AC_CONFIG_SUBDIR added to them, but I couldn't figure out how.

 64: fortran.at:51     ok (skipped near `fortran.at:51')
 65: acfortran.at:7    ok (skipped near `acfortran.at:7')
 66: acfortran.at:8    ok (skipped near `acfortran.at:8')
 67: acfortran.at:9    ok (skipped near `acfortran.at:9')
I don't know why these fortran tests are being skipped.

Note also that there's a change in acgeneral.at which I don't understand the 
reason
for; the testsuite architecture is quite mystifying to me.

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.
        * 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   19 Jan 2003 18:13:24 -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     19 Jan 2003 18:13:28 -0000
@@ -929,6 +929,9 @@
 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
 
 m4_divert_pop([PARSE_ARGS])dnl
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    19 Jan 2003 18:13:28 -0000
@@ -192,13 +192,19 @@
 # -----------------------------------------------------------------------
 # (Use different variables $1 and ac_pt_$1 so that cache vars don't conflict.)
 AC_DEFUN([AC_PATH_TOOL],
-[if test -n "$ac_tool_prefix"; then
+[AC_REQUIRE([AC_CANONICAL_BUILD])
+AC_REQUIRE([AC_CANONICAL_HOST])
+if test -n "$ac_tool_prefix"; then
   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
+  if test $build = $host ; then
+    ac_pt_$1=$$1
+    AC_PATH_PROG([ac_pt_$1], [$2], [$3], [$4])
+    $1=$ac_pt_$1
+  else
+    $1="$3"
+  fi
 else
   $1="$ac_cv_path_$1"
 fi
@@ -209,19 +215,48 @@
 # ------------------------------------------------------------------------
 # (Use different variables $1 and ac_ct_$1 so that cache vars don't conflict.)
 AC_DEFUN([AC_CHECK_TOOL],
-[if test -n "$ac_tool_prefix"; then
+[AC_REQUIRE([AC_CANONICAL_BUILD])
+AC_REQUIRE([AC_CANONICAL_HOST])
+if test -n "$ac_tool_prefix"; then
   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
+  if test $build = $host ; then
+    ac_ct_$1=$$1
+    AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [$3], [$4])
+    $1=$ac_ct_$1
+  else
+    $1="$3"
+  fi
 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],
+[AC_REQUIRE([AC_CANONICAL_BUILD])
+AC_REQUIRE([AC_CANONICAL_TARGET])
+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
+  if test $build = $target ; then
+    ac_ctt_$1=$$1
+    AC_CHECK_PROG([ac_ctt_$1], [$2], [$2], [$3], [$4])
+    $1=$ac_ctt_$1
+  else
+    $1="$3"
+  fi
+else
+  $1="$ac_cv_prog_$1"
+fi
+])# AC_CHECK_TARGET_TOOL
+
+
 # AC_CHECK_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
 #                [PATH])
 # ------------------------------------------------------------------
@@ -229,7 +264,9 @@
 # none can be found with a cross prefix, then use the first one that
 # was found without the cross prefix.
 AC_DEFUN([AC_CHECK_TOOLS],
-[if test -n "$ac_tool_prefix"; then
+[AC_REQUIRE([AC_CANONICAL_BUILD])
+AC_REQUIRE([AC_CANONICAL_HOST])
+if test -n "$ac_tool_prefix"; then
   for ac_prog in $2
   do
     AC_CHECK_PROG([$1],
@@ -239,9 +276,13 @@
   done
 fi
 if test -z "$$1"; then
-  ac_ct_$1=$$1
-  AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
-  $1=$ac_ct_$1
+  if test $build = $host ; then
+    ac_ct_$1=$$1
+    AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
+    $1=$ac_ct_$1
+  else
+    $1="$3"
+  fi
 fi
 ])# AC_CHECK_TOOLS
 
Index: tests/acgeneral.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/acgeneral.at,v
retrieving revision 1.6
diff -u -r1.6 acgeneral.at
--- tests/acgeneral.at  27 Oct 2002 18:30:39 -0000      1.6
+++ tests/acgeneral.at  19 Jan 2003 18:13:29 -0000
@@ -7,7 +7,6 @@
 AT_CHECK_MACRO([AC_ARG_ENABLE])
 AT_CHECK_MACRO([AC_ARG_PROGRAM])
 AT_CHECK_MACRO([AC_ARG_WITH])
-AT_CHECK_MACRO([AC_CANONICAL_TARGET])
 AT_CHECK_MACRO([AC_EGREP_CPP])
 AT_CHECK_MACRO([AC_EGREP_HEADER])
 AT_CHECK_MACRO([AC_PREFIX_DEFAULT])
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    19 Jan 2003 18:13:30 -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)$




reply via email to

[Prev in Thread] Current Thread [Next in Thread]