autoconf: 1999-10-05 Akim Demaille <akim@epita.fr> (ae4ed)

https://github.com/libsdl-org/autoconf/commit/ae4ed6653031311d9dab7ab5c09b0d714fb4200b

From ae4ed6653031311d9dab7ab5c09b0d714fb4200b Mon Sep 17 00:00:00 2001
From: Akim Demaille <[EMAIL REDACTED]>
Date: Tue, 5 Oct 1999 08:26:16 +0000
Subject: [PATCH] 1999-10-05  Akim Demaille  <akim@epita.fr>

	Implement AC_PATH_TOOL.
	Submited by Gary V. Vaughan.

	* acgeneral.m4 (AC_PATH_TOOL): New macro.
	* autoconf.texi (Generic Programs): Document.
---
 ChangeLog               |  8 +++++
 TODO                    |  1 +
 acgeneral.m4            | 65 +++++++++++++++++++++++++++++------------
 autoconf.texi           | 20 +++++++++++++
 doc/autoconf.texi       | 20 +++++++++++++
 lib/autoconf/general.m4 | 65 +++++++++++++++++++++++++++++------------
 6 files changed, 143 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a723118..ef5f37fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+1999-10-05  Akim Demaille  <akim@epita.fr>
+
+	Implement AC_PATH_TOOL.
+	Submited by Gary V. Vaughan.
+
+	* acgeneral.m4 (AC_PATH_TOOL): New macro.
+	* autoconf.texi (Generic Programs): Document.
+
 1999-10-05  Akim Demaille  <akim@epita.fr>
 
 	Handle arbitrary version numbers.
diff --git a/TODO b/TODO
index ed0d44f9..fdcf7b42 100644
--- a/TODO
+++ b/TODO
@@ -13,6 +13,7 @@ These are things mandatory to fulfill before releasing 2.15.  There
 are also suggestions we should either satisfy right now (they're
 easy), or remove (obsoleted since then).
 
+** AC_C_STRUCT_MEMBER needs a full rewrite.
 
 ** AC_CHECK_HEADER should not template config.h entries.
 Its entry in autoheader.m4 should be removed.
diff --git a/acgeneral.m4 b/acgeneral.m4
index c5d2a04f..9817860d 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -2041,8 +2041,10 @@ $1="$ac_cv_c_struct_member_$1"])
 dnl ### Checking for programs
 
 
-dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR, VALUE-IF-FOUND
-dnl               [, [VALUE-IF-NOT-FOUND] [, [PATH] [, [REJECT]]]])
+dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR
+dnl               [, VALUE-IF-FOUND [, VALUE-IF-NOT-FOUND]
+dnl               [, PATH [, REJECT]]])
+dnl ------------------------------------------------------
 AC_DEFUN(AC_CHECK_PROG,
 [# Extract the first word of "$2", so it can be a program name with args.
 set dummy $2; ac_word=[$]2
@@ -2105,7 +2107,21 @@ else
   AC_MSG_RESULT(no)
 fi
 AC_SUBST($1)dnl
-])
+])dnl AC_CHECK_PROG
+
+
+dnl AC_CHECK_PROGS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
+dnl                [, PATH]])
+dnl -----------------------------------------------------------------
+AC_DEFUN(AC_CHECK_PROGS,
+[for ac_prog in $2
+do
+AC_CHECK_PROG($1, [$]ac_prog, [$]ac_prog, , $4)
+test -n "[$]$1" && break
+done
+ifelse([$3], , , [test -n "[$]$1" || $1="$3"
+])])
+
 
 dnl AC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
 dnl -------------------------------------------------------------------------
@@ -2148,19 +2164,10 @@ fi
 AC_SUBST($1)dnl
 ])
 
-dnl AC_CHECK_PROGS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
-dnl                [, PATH]])
-AC_DEFUN(AC_CHECK_PROGS,
-[for ac_prog in $2
-do
-AC_CHECK_PROG($1, [$]ac_prog, [$]ac_prog, , $4)
-test -n "[$]$1" && break
-done
-ifelse([$3], , , [test -n "[$]$1" || $1="$3"
-])])
 
 dnl AC_PATH_PROGS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
 dnl               [, PATH]])
+dnl ----------------------------------------------------------------
 AC_DEFUN(AC_PATH_PROGS,
 [for ac_prog in $2
 do
@@ -2170,6 +2177,11 @@ done
 ifelse([$3], , , [test -n "[$]$1" || $1="$3"
 ])])
 
+
+
+
+dnl ### Checking for tools
+
 dnl Internal subroutine.
 AC_DEFUN(AC_CHECK_TOOL_PREFIX,
 [AC_REQUIRE([AC_CANONICAL_HOST])AC_REQUIRE([AC_CANONICAL_BUILD])dnl
@@ -2180,18 +2192,35 @@ else
 fi
 ])
 
+dnl AC_PATH_TOOL(VARIABLE, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH]])
+dnl ------------------------------------------------------------------------
+AC_DEFUN(AC_PATH_TOOL,
+[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
+AC_PATH_PROG($1, ${ac_tool_prefix}$2, ${ac_tool_prefix}$2,
+             ifelse([$3], , [$2], ), $4)
+ifelse([$3], , , [
+if test -z "$ac_cv_prog_$1"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_PATH_PROG($1, $2, $2, $3)
+  else
+    $1="$3"
+  fi
+fi])
+])
+
 dnl AC_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH]])
+dnl -------------------------------------------------------------------------
 AC_DEFUN(AC_CHECK_TOOL,
 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
 AC_CHECK_PROG($1, ${ac_tool_prefix}$2, ${ac_tool_prefix}$2,
 	      ifelse([$3], , [$2], ), $4)
 ifelse([$3], , , [
 if test -z "$ac_cv_prog_$1"; then
-if test -n "$ac_tool_prefix"; then
-  AC_CHECK_PROG($1, $2, $2, $3)
-else
-  $1="$3"
-fi
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG($1, $2, $2, $3)
+  else
+    $1="$3"
+  fi
 fi])
 ])
 
diff --git a/autoconf.texi b/autoconf.texi
index f0d75a46..7cbed2e2 100644
--- a/autoconf.texi
+++ b/autoconf.texi
@@ -1916,6 +1916,26 @@ are found, set @var{variable} to the entire path of the program
 found.
 @end defmac
 
+@defmac AC_PATH_TOOL (@var{variable}, @var{prog-to-check-for} @r{[},
+@var{value-if-not-found} @r{[}, @var{path}@r{]]})
+@maindex PATH_TOOL
+Like @code{AC_PATH_PROG}, but first looks for @var{prog-to-check-for}
+with a prefix of the host type as determined by
+@code{AC_CANONICAL_HOST},
+followed by a dash (@pxref{Canonicalizing}).  For example, if the user
+runs @samp{configure --host=i386-gnu}, then this call:
+@example
+AC_PATH_TOOL(FILE, file, :, /usr/bin:$PATH)
+@end example
+@noindent
+sets @code{FILE} to @file{/usr/bin/i386-gnu-file}, for example, if
+that program is found at @file{/usr/bin} in @code{PATH}, or to
+@samp{/usr/bin/file}, for example, if @emph{that} program is found at
+@file{/usr/bin} in @code{PATH}, or to @samp{:} if neither program can
+be found.
+@end defmac
+
+
 @node Libraries, Library Functions, Alternative Programs, Existing Tests
 @section Library Files
 
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index f0d75a46..7cbed2e2 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -1916,6 +1916,26 @@ are found, set @var{variable} to the entire path of the program
 found.
 @end defmac
 
+@defmac AC_PATH_TOOL (@var{variable}, @var{prog-to-check-for} @r{[},
+@var{value-if-not-found} @r{[}, @var{path}@r{]]})
+@maindex PATH_TOOL
+Like @code{AC_PATH_PROG}, but first looks for @var{prog-to-check-for}
+with a prefix of the host type as determined by
+@code{AC_CANONICAL_HOST},
+followed by a dash (@pxref{Canonicalizing}).  For example, if the user
+runs @samp{configure --host=i386-gnu}, then this call:
+@example
+AC_PATH_TOOL(FILE, file, :, /usr/bin:$PATH)
+@end example
+@noindent
+sets @code{FILE} to @file{/usr/bin/i386-gnu-file}, for example, if
+that program is found at @file{/usr/bin} in @code{PATH}, or to
+@samp{/usr/bin/file}, for example, if @emph{that} program is found at
+@file{/usr/bin} in @code{PATH}, or to @samp{:} if neither program can
+be found.
+@end defmac
+
+
 @node Libraries, Library Functions, Alternative Programs, Existing Tests
 @section Library Files
 
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index c5d2a04f..9817860d 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2041,8 +2041,10 @@ $1="$ac_cv_c_struct_member_$1"])
 dnl ### Checking for programs
 
 
-dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR, VALUE-IF-FOUND
-dnl               [, [VALUE-IF-NOT-FOUND] [, [PATH] [, [REJECT]]]])
+dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR
+dnl               [, VALUE-IF-FOUND [, VALUE-IF-NOT-FOUND]
+dnl               [, PATH [, REJECT]]])
+dnl ------------------------------------------------------
 AC_DEFUN(AC_CHECK_PROG,
 [# Extract the first word of "$2", so it can be a program name with args.
 set dummy $2; ac_word=[$]2
@@ -2105,7 +2107,21 @@ else
   AC_MSG_RESULT(no)
 fi
 AC_SUBST($1)dnl
-])
+])dnl AC_CHECK_PROG
+
+
+dnl AC_CHECK_PROGS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
+dnl                [, PATH]])
+dnl -----------------------------------------------------------------
+AC_DEFUN(AC_CHECK_PROGS,
+[for ac_prog in $2
+do
+AC_CHECK_PROG($1, [$]ac_prog, [$]ac_prog, , $4)
+test -n "[$]$1" && break
+done
+ifelse([$3], , , [test -n "[$]$1" || $1="$3"
+])])
+
 
 dnl AC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
 dnl -------------------------------------------------------------------------
@@ -2148,19 +2164,10 @@ fi
 AC_SUBST($1)dnl
 ])
 
-dnl AC_CHECK_PROGS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
-dnl                [, PATH]])
-AC_DEFUN(AC_CHECK_PROGS,
-[for ac_prog in $2
-do
-AC_CHECK_PROG($1, [$]ac_prog, [$]ac_prog, , $4)
-test -n "[$]$1" && break
-done
-ifelse([$3], , , [test -n "[$]$1" || $1="$3"
-])])
 
 dnl AC_PATH_PROGS(VARIABLE, PROGS-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND
 dnl               [, PATH]])
+dnl ----------------------------------------------------------------
 AC_DEFUN(AC_PATH_PROGS,
 [for ac_prog in $2
 do
@@ -2170,6 +2177,11 @@ done
 ifelse([$3], , , [test -n "[$]$1" || $1="$3"
 ])])
 
+
+
+
+dnl ### Checking for tools
+
 dnl Internal subroutine.
 AC_DEFUN(AC_CHECK_TOOL_PREFIX,
 [AC_REQUIRE([AC_CANONICAL_HOST])AC_REQUIRE([AC_CANONICAL_BUILD])dnl
@@ -2180,18 +2192,35 @@ else
 fi
 ])
 
+dnl AC_PATH_TOOL(VARIABLE, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH]])
+dnl ------------------------------------------------------------------------
+AC_DEFUN(AC_PATH_TOOL,
+[AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
+AC_PATH_PROG($1, ${ac_tool_prefix}$2, ${ac_tool_prefix}$2,
+             ifelse([$3], , [$2], ), $4)
+ifelse([$3], , , [
+if test -z "$ac_cv_prog_$1"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_PATH_PROG($1, $2, $2, $3)
+  else
+    $1="$3"
+  fi
+fi])
+])
+
 dnl AC_CHECK_TOOL(VARIABLE, PROG-TO-CHECK-FOR[, VALUE-IF-NOT-FOUND [, PATH]])
+dnl -------------------------------------------------------------------------
 AC_DEFUN(AC_CHECK_TOOL,
 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl
 AC_CHECK_PROG($1, ${ac_tool_prefix}$2, ${ac_tool_prefix}$2,
 	      ifelse([$3], , [$2], ), $4)
 ifelse([$3], , , [
 if test -z "$ac_cv_prog_$1"; then
-if test -n "$ac_tool_prefix"; then
-  AC_CHECK_PROG($1, $2, $2, $3)
-else
-  $1="$3"
-fi
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG($1, $2, $2, $3)
+  else
+    $1="$3"
+  fi
 fi])
 ])