Hi Dave,

Thanks for the bug report.

* dave erickson wrote on Wed, Aug 13, 2008 at 03:57:31PM CEST:
> 
> I have a problem with AC_CHECK_TARGET_TOOL setting the standard
> environment variables It finds the system version tools like ar
> instead of x86_64-ar  and notes them, it finds  '/usr/bin/ar" but then
> doesn't set AR properly.
> In the configure.ac  I have a section looking for tools with target
> canonical names
> 
> AC_CHECK_TARGET_TOOL([CPP], cpp [], [])       
[...]
> AC_SUBST(CPP)
[...]
> And then when configure is finished, the config.log has some sort of
> intermediate values instead of the final environment values
> 
> like AR='ac_ct_AR' which then crashes when I try and use AR.  Why is
> configure not putting the target variables into the common environment
> variables?
> 
> For example 
> CPP='ac_ct_CPP'
> CXX='ac_ct_CXX'
> 
> And yet CC is set properly
> CC='gcc'

Wow, the AC_CHECK_TARGET* are pretty broken.  No wonder, they are not
exercised by the test suite at all.  :-/  They are also virtually
unused by other packages.

Dave, you are aware that the *TARGET* macros only make sense to use
if the package you are writing is a compiler that can act as a cross
compiler?  If not, then please look at the macros without TARGET in
their name.

The bit fixing most of the issues you reported is the missing '$' in
AC_CHECK_TARGET_TOOL.  I think the macros are wrong in warning about a
previous AC_CANONICAL_TARGET, however.  Shouldn't it rather be that they
should require it?

I'm still looking for a good testsuite addition for these macros.

OK to apply?

Thanks,
Ralf

2008-08-14  Ralf Wildenhues  <[EMAIL PROTECTED]>

        * lib/autoconf/programs.m4 (AC_CHECK_TOOLS, AC_PATH_TARGET_TOOL)
        (AC_CHECK_TARGET_TOOL, AC_CHECK_TARGET_TOOLS): Require, do not
        warn about previous AC_CANONICAL_TARGET.
        (AC_CHECK_TARGET_TOOL): Add missing `$' making the macro
        unusable in the non-cross-compiling case.
        * NEWS, THANKS: Update.
        Report by Dave Erickson.

diff --git a/NEWS b/NEWS
index dbff114..5fc03d8 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,8 @@ GNU Autoconf NEWS - User visible changes.
    2.62 when using macros such as AC_AIX that were made obsolete in
    favor of the more portable AC_USE_SYSTEM_EXTENSIONS.
 
+** AC_CHECK_TARGET_TOOLS is usable in the non-cross-compile case.
+
 ** Newly obsolete macros
    The following macro has been marked obsolete, since current porting
    targets can safely assume C89 semantics that signal handlers return
diff --git a/lib/autoconf/programs.m4 b/lib/autoconf/programs.m4
index e7e72c0..f2245fb 100644
--- a/lib/autoconf/programs.m4
+++ b/lib/autoconf/programs.m4
@@ -291,10 +291,10 @@ fi
 
 
 # AC_PATH_TARGET_TOOL(VARIABLE, PROG-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND], 
[PATH])
-# -----------------------------------------------------------------------
+# 
------------------------------------------------------------------------------
 # (Use different variables $1 and ac_pt_$1 so that cache vars don't conflict.)
 AC_DEFUN([AC_PATH_TARGET_TOOL],
-[AC_BEFORE([$0], [AC_CANONICAL_TARGET])dnl
+[AC_REQUIRE([AC_CANONICAL_TARGET])dnl
 AC_PATH_PROG([$1], [$target_alias-$2], , [$4])
 if test -z "$ac_cv_path_$1"; then
   if test "$build" = "$target"; then
@@ -311,16 +311,16 @@ fi
 
 
 # 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_BEFORE([$0], [AC_CANONICAL_TARGET])dnl
+[AC_REQUIRE([AC_CANONICAL_TARGET])dnl
 AC_CHECK_PROG([$1], [$target_alias-$2], [$target_alias-$2], , [$4])
 if test -z "$ac_cv_prog_$1"; then
   if test "$build" = "$target"; then
     ac_ct_$1=$$1
     _AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [$3], [$4])
-    $1=ac_ct_$1
+    $1=$ac_ct_$1
   else
     $1="$3"
   fi
@@ -332,12 +332,12 @@ fi
 
 # AC_CHECK_TARGET_TOOLS(VARIABLE, PROGS-TO-CHECK-FOR, [VALUE-IF-NOT-FOUND],
 #                      [PATH])
-# ------------------------------------------------------------------
+# -------------------------------------------------------------------------
 # Check for each tool in PROGS-TO-CHECK-FOR with the cross prefix. If
 # none can be found with a cross prefix, then use the first one that
 # was found without the cross prefix.
 AC_DEFUN([AC_CHECK_TARGET_TOOLS],
-[AC_BEFORE([$0], [AC_CANONICAL_TARGET])dnl
+[AC_REQUIRE([AC_CANONICAL_TARGET])dnl
 for ac_prog in $2
 do
   AC_CHECK_PROG([$1],


Reply via email to