autoconf-patches
[Top][All Lists]
Advanced

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

AC_CHECK_TOOL changes, take 2


From: bonzini
Subject: AC_CHECK_TOOL changes, take 2
Date: Thu, 18 Mar 2004 12:04:00 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031107 Debian/1.5-3

Here it is.

Also, I noted that:

1) sometimes TeX hangs on macros with an unbraced argument, such as

   @hdrindex alloca.h

Ok to change these to the braced form all over autoconf.texi?

2) maybe time has come to remove the "--host sets --build" (mis)feature of configure scripts? And what about "./configure host"?

Paolo
2004-03-16  Paolo Bonzini  <address@hidden>

        * lib/autoconf/programs.m4 (AC_PATH_TOOL, AC_CHECK_TOOL,
        AC_CHECK_TOOLS): Warn if a cross-tool is found without
        a prefix.
        (AC_PATH_TARGET_TOOL, AC_CHECK_TARGET_TOOL,
        AC_CHECK_TARGET_TOOLS): New macros.
        * doc/autoconf.texi (Generic Programs): Document
        (AC_PATH_TARGET_TOOL, AC_CHECK_TARGET_TOOL,
        AC_CHECK_TARGET_TOOLS, and warn for future changes
        in the behavior of AC_PATH_TOOL, AC_CHECK_TOOL and
        AC_CHECK_TOOLS.
        (Specifying Names): Document the reason for these future
        behavioral changes.
        * tests/mktests.sh: Do not generate tests for the
        new macros.

Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.803
diff -u -r1.803 autoconf.texi
--- doc/autoconf.texi   15 Mar 2004 22:00:06 -0000      1.803
+++ doc/autoconf.texi   18 Mar 2004 10:43:14 -0000
@@ -3438,6 +3438,23 @@
 is not changed.  Calls @code{AC_SUBST} for @var{variable}.
 @end defmac
 
address@hidden AC_CHECK_TARGET_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden
+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 tool cannot be found with a prefix, and if the build and target
+types are equal, then it is also searched for without a prefix.
+
+As noted in @ref{Specifying Names, , Specifying the system type}, the
+target is rarely specified, because most of the time it is the same
+as the host: it is the type of system for which any compiler tools in
+the package will produce code.  What this macro will look for is,
+for example, @emph{a tool @r{(assembler, linker, etc.)} that the
+compiler driver @r{(@command{gcc} for the @acronym{GNU} C Compiler)}
+will use to produce objects, archives or executables}.
address@hidden defmac
+
 @defmac AC_CHECK_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
 @acindex{CHECK_TOOL}
 Like @code{AC_CHECK_PROG}, but first looks for @var{prog-to-check-for}
@@ -3452,6 +3469,24 @@
 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.
+
+In the future, when cross-compiling this macro will @emph{not}
+accept program names that are not prefixed with the host type.
+For more information, @ref{Specifying Names}.
address@hidden defmac
+
address@hidden AC_CHECK_TARGET_TOOLS (@var{variable}, @var{progs-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden
+Like @code{AC_CHECK_TARGET_TOOL}, each of the tools in the list
address@hidden are checked with a prefix of the target type as
+determined by @code{AC_CANONICAL_TARGET}, followed by a dash
+(@pxref{Canonicalizing}).  If none of the tools can be found with a
+prefix, and if the build and target types are equal, then the first one
+without a prefix is used.  If a tool is found, set @var{variable} to
+the name of that program.  If none of the tools in the list are found,
+set @var{variable} to @var{value-if-not-found}; if @var{value-if-not-found}
+is not specified, the value of @var{variable} is not changed.  Calls
address@hidden for @var{variable}.
 @end defmac
 
 @defmac AC_CHECK_TOOLS (@var{variable}, @var{progs-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
@@ -3465,6 +3500,9 @@
 the list are found, set @var{variable} to @var{value-if-not-found}; if
 @var{value-if-not-found} is not specified, the value of @var{variable}
 is not changed.  Calls @code{AC_SUBST} for @var{variable}.
+
+In the future, when cross-compiling this macro will @emph{not}
+accept program names that are not prefixed with the host type.
 @end defmac
 
 @defmac AC_PATH_PROG (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
@@ -3480,10 +3518,19 @@
 found.
 @end defmac
 
address@hidden AC_PATH_TARGET_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
address@hidden
+Like @code{AC_CHECK_TARGET_TOOL}, but set @var{variable} to the entire
+path of the program if it is found.
address@hidden defmac
+
 @defmac AC_PATH_TOOL (@var{variable}, @var{prog-to-check-for}, 
@ovar{value-if-not-found}, @ovar{path})
 @acindex{PATH_TOOL}
 Like @code{AC_CHECK_TOOL}, but set @var{variable} to the entire
 path of the program if it is found.
+
+In the future, when cross-compiling this macro will @emph{not}
+accept program names that are not prefixed with the host type.
 @end defmac
 
 
@@ -12336,21 +12383,33 @@
 @option{--build}, not @option{--host}, since the latter enables
 cross-compilation.  For historical reasons, passing @option{--host} also
 changes the build type.  Therefore, whenever you specify @code{--host},
-be sure to specify @code{--build} too.  This will be fixed in the
-future.
+be sure to specify @code{--build} too; this will be fixed in the
+future.  So, to enter cross-compilation mode, use a command like this
 
 @example
 ./configure --build=i686-pc-linux-gnu --host=m68k-coff
 @end example
 
 @noindent
-will enter cross-compilation mode, but @command{configure} will fail if it
-can't run the code generated by the specified compiler if you configure
-as follows:
+Note that if you do not specify @option{--host}, @command{configure} will
+fail if it can't run the code generated by the specified compiler.  For
+example, configuring as follows will fail:
 
 @example
 ./configure CC=m68k-coff-gcc
 @end example
+
+In the future, when cross-compiling Autoconf will @emph{not}
+accept tools (compilers, linkers, assemblers) whose name is not
+prefixed with the host type.  The only case when this may be
+useful is when you really are not cross-compiling, but only
+building for a least-common-denominator architecture: an example
+is building for @code{i386-pc-linux-gnu} while running on an
address@hidden architecture.  In this case, some particular
+pairs might be similar enough to let you get away with the system
+compilers, but in general the compiler might make bogus assumptions
+on the host: if you know what you are doing, please create symbolic
+links from the host compiler to the build compiler.
 
 @cindex @command{config.sub}
 @command{configure} recognizes short aliases for many system types; for
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.21
diff -u -r1.21 programs.m4
--- lib/autoconf/programs.m4    30 Jan 2004 14:21:36 -0000      1.21
+++ lib/autoconf/programs.m4    18 Mar 2004 10:43:15 -0000
@@ -197,8 +197,17 @@
 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
+  AC_PATH_PROG([ac_pt_$1], [$2], [], [$4])
+  if test "x$ac_pt_$1" = x; then
+    $1="$3"
+  else
+    if test "$build" != "$host"; then
+      AC_MSG_WARN([In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to address@hidden)
+    fi
+    $1=$ac_pt_$1
+  fi
 else
   $1="$ac_cv_path_$1"
 fi
@@ -214,8 +223,17 @@
 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
+  AC_CHECK_PROG([ac_ct_$1], [$2], [$2], [], [$4])
+  if test "x$ac_ct_$1" = x; then
+    $1="$3"
+  else
+    if test "$build" != "$host"; then
+      AC_MSG_WARN([In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to address@hidden)
+    fi
+    $1=$ac_ct_$1
+  fi
 else
   $1="$ac_cv_prog_$1"
 fi
@@ -240,10 +258,86 @@
 fi
 if test -z "$$1"; then
   ac_ct_$1=$$1
-  AC_CHECK_PROGS([ac_ct_$1], [$2], [$3], [$4])
-  $1=$ac_ct_$1
+  AC_CHECK_PROGS([ac_ct_$1], [$2], [], [$4])
+  if test "x$ac_ct_$1" = x; then
+    $1="$3"
+  else
+    if test "$build" != "$host"; then
+      AC_MSG_WARN([In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to address@hidden)
+    fi
+    $1=$ac_ct_$1
+  fi
 fi
 ])# AC_CHECK_TOOLS
+
+
+# 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_PATH_PROG([$1], [$target_alias-$2], , [$4])
+if test -z "$ac_cv_path_$1"; then
+  if test "$build" = "$target"; 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
+])# AC_PATH_TARGET_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_BEFORE([$0], [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
+  else
+    $1="$3"
+  fi
+else
+  $1="$ac_cv_prog_$1"
+fi
+])# AC_CHECK_TARGET_TOOL
+
+
+# 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
+for ac_prog in $2
+do
+  AC_CHECK_PROG([$1],
+               [$target_alias-$ac_prog], [$target_alias-$ac_prog],,
+               [$4])
+  test -n "$$1" && break
+done
+if test -z "$$1"; then
+  if test "$build" = "$target"; 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_TARGET_TOOLS
 
 
 
Index: tests/acprograms.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/acprograms.at,v
retrieving revision 1.5
diff -u -r1.5 acprograms.at
--- tests/acprograms.at 23 Jan 2004 08:21:51 -0000      1.5
+++ tests/acprograms.at 18 Mar 2004 10:43:15 -0000
@@ -9,6 +9,9 @@
 AT_BANNER([Testing autoconf/programs macros.])
 
 # Modern macros.
+AT_CHECK_MACRO([AC_CHECK_TARGET_TOOL])
+AT_CHECK_MACRO([AC_CHECK_TARGET_TOOLS])
+AT_CHECK_MACRO([AC_PATH_TARGET_TOOL])
 AT_CHECK_MACRO([AC_PROG_AWK])
 AT_CHECK_MACRO([AC_PROG_FGREP])
 AT_CHECK_MACRO([AC_PROG_INSTALL])
Index: tests/foreign.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/foreign.at,v
retrieving revision 1.19
diff -u -r1.19 foreign.at
--- tests/foreign.at    22 May 2003 13:24:08 -0000      1.19
+++ tests/foreign.at    18 Mar 2004 10:43:15 -0000
@@ -48,6 +48,8 @@
 AC_CONFIG_AUX_DIR(.)
 AC_PROG_LIBTOOL
 ]])
+# Some libtoolize complain if you don't have an aclocal.m4.
+AT_CHECK([echo '# generated automatically by aclocal' > aclocal.m4])
 AT_CHECK([libtoolize], 0, [stdout], ignore)
 
 # Some broken libtoolize fail to install a functional config.guess.
Index: tests/mktests.sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.39
diff -u -r1.39 mktests.sh
--- tests/mktests.sh    15 Mar 2004 22:00:06 -0000      1.39
+++ tests/mktests.sh    18 Mar 2004 10:43:15 -0000
@@ -82,7 +82,8 @@
 # - AC_CANONICALIZE, AC_PREFIX_PROGRAM, AC_PREREQ
 #   Need an argument.
 #
-# - AC_CHECK alignof, decl, file, func, header, lib, member, prog, sizeof, type
+# - AC_CHECK decl, file, func, header, lib, member, prog, sizeof, host/target
+#   tool, type
 #   Performed in the semantics tests.
 #
 # - AC_CONFIG
@@ -98,7 +99,8 @@
 # - AC_LANG*
 #   Heavily used by other macros.
 #
-# - AC_PATH_PROGS?, AC_F77_FUNC, AC_FC_FUNC, AC_FC_SRCEXT
+# - AC_PATH_PROGS?, AC_PATH_TOOL, AC_PATH_TARGET_TOOL, AC_F77_FUNC, AC_FC_FUNC,
+#   AC_FC_SRCEXT
 #   They produce `= val' because $1, the variable used to store the result,
 #   is empty.
 #
@@ -131,7 +133,7 @@
 #
 ac_exclude_list='^AC_ARG_VAR$
 ^AC_CANONICALIZE|AC_PREFIX_PROGRAM|AC_PREREQ$
-^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|TOOL|TYPE)S?$
+^AC_CHECK_(ALIGNOF|DECL|FILE|FUNC|HEADER|LIB|MEMBER|PROG|SIZEOF|(TARGET_)?TOOL|TYPE)S?$
 ^AC_CONFIG
 ^AC_(F77|FC)_FUNC$
 ^AC_FC_(FUNC|FREEFORM|SRCEXT)$
@@ -143,7 +145,7 @@
 ^AC_LINK_FILES$
 ^AC_LIST_MEMBER_OF$
 ^AC_OUTPUT$
-^AC_PATH_(TOOL|PROG)S?$
+^AC_PATH_((TARGET_)?TOOL|PROG)S?$
 ^AC_REPLACE_(FNMATCH|FUNCS)$
 ^AC_SEARCH_LIBS$
 ^(AC_TRY.*|AC_RUN_LOG)$

reply via email to

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