autoconf: Back out Jeff Garzik's changes of 1998-12-28. He has better ones!

https://github.com/libsdl-org/autoconf/commit/2dd01747b7854bc901f9337935f20c1870b4e535

From 2dd01747b7854bc901f9337935f20c1870b4e535 Mon Sep 17 00:00:00 2001
From: Ben Elliston <[EMAIL REDACTED]>
Date: Mon, 4 Jan 1999 22:17:40 +0000
Subject: [PATCH] Back out Jeff Garzik's changes of 1998-12-28. He has better
 ones!

---
 ChangeLog                | 21 -----------
 acgeneral.m4             | 31 ++++------------
 acspecific.m4            |  1 -
 autoconf.texi            | 79 ++++++----------------------------------
 doc/autoconf.texi        | 79 ++++++----------------------------------
 lib/autoconf/general.m4  | 31 ++++------------
 lib/autoconf/specific.m4 |  1 -
 7 files changed, 40 insertions(+), 203 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 87f54aab..a0ac8e47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,27 +5,6 @@
 	* acspecific.m4 (AC_PROG_CXX_WORKS): Specify an explicit return
 	type for `main' to keep modern C++ compilers happy.
 
-1998-12-28  Jeff Garzik  <jgarzik@pobox.com>
-
-	* autoconf.texi:
-	  (AC_SEARCH_LIBS, AC_CHECK_FILE, AC_CHECK_FILES,
-	   AC_TRY_LINK_FUNC): Document.
-	  (AC_CHECK_LIB): Indicate the absence of
-	  	action-if-not-found will not kill default action.
-	  (AC_SYS_INTERPRETER): Alphabetize with rest of section,
-	  	s/ac_cv_sys_interpreter/interpval/
-
-	* acgeneral.m4:
-	  (AC_TRY_LINK_FUNC): Fix arg transposition.
-	  (AC_SEARCH_LIBS): Require autoconf 2.13, add other-libs arg,
-	  	default action now similar to AC_CHECK_LIB, returns
-		'searchval' shell var indicating which lib matched.
-	  (AC_CHECK_FILES): Add underscore to HAVE_file define.
-
-	* acspecific.m4:
-	  (AC_SYS_INTERPRETER): New shell var 'interpval' stores
-	  	internal var ac_cv_sys_interpreter.
-
 1998-12-27  Ben Elliston  <bje@cygnus.com>
 
 	* autoconf.texi (AC_PROG_INSTALL): Update.
diff --git a/acgeneral.m4 b/acgeneral.m4
index b951a118..6a69aa5b 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -1534,7 +1534,7 @@ dnl ACTION-IF-NOT-FOUND.
 
 AC_DEFUN(AC_TRY_LINK_FUNC,
 AC_TRY_LINK(dnl
-ifelse([$1], [main], , dnl Avoid conflicting decl of main.
+ifelse([$2], [main], , dnl Avoid conflicting decl of main.
 [/* Override any gcc2 internal prototype to avoid an error.  */
 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
 extern "C"
@@ -1549,41 +1549,26 @@ char $1();
 [$3]))
 
 
-dnl AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
-dnl		[, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
+dnl AC_SEARCH_LIBS(func, searchlibs, [action-if-found], [action-if-not-found])
 dnl Search for a library defining FUNC, if it's not already available.
 
 AC_DEFUN(AC_SEARCH_LIBS,
-[AC_PREREQ([2.13])
+[AC_PREREQ([2.12])
 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
 [ac_func_search_save_LIBS="$LIBS"
 ac_cv_search_$1="no"
 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
 test "$ac_cv_search_$1" = "no" && for i in $2; do
-LIBS="-l$i $5 $ac_func_search_save_LIBS"
+LIBS="-l$i $ac_func_search_save_LIBS"
 AC_TRY_LINK_FUNC([$1],
-[ac_cv_search_$1="$i"
+[ac_cv_search_$1="-l$i"
 break])
 done
 LIBS="$ac_func_search_save_LIBS"])
 if test "$ac_cv_search_$1" != "no"; then
-  if test "$ac_cv_search_$1" = "none required"; then
-    searchval="NONE"
-    $3
-  else
-    searchval="$ac_cv_search_$1"
-    ifelse([$3], , 
-      [changequote(, )dnl
-      ac_tr_lib=HAVE_LIB`echo $ac_cv_search_$1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-           -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
-      changequote([, ])dnl
-      AC_DEFINE_UNQUOTED($ac_tr_lib)
-      LIBS="-l$ac_cv_search_$1 $LIBS",
-      [$3])
-
-  fi
+  test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
+  $3
 else :
-  searchval=
   $4
 fi])
 
@@ -1920,7 +1905,7 @@ AC_DEFUN(AC_CHECK_FILES,
 do
 AC_CHECK_FILE($ac_file,
 [changequote(, )dnl
-  ac_tr_file=HAVE_`echo $ac_file | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  ac_tr_file=HAVE`echo $ac_file | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
 changequote([, ])dnl
   AC_DEFINE_UNQUOTED($ac_tr_file) $2], $3)dnl
 done
diff --git a/acspecific.m4 b/acspecific.m4
index 5c6f1c9e..0b9aab74 100644
--- a/acspecific.m4
+++ b/acspecific.m4
@@ -2225,7 +2225,6 @@ else
    ac_cv_sys_interpreter=no
 fi
 rm -f conftest])
-interpval="$ac_cv_sys_interpreter"
 ])
 
 define(AC_HAVE_POUNDBANG,
diff --git a/autoconf.texi b/autoconf.texi
index e4e62cd2..5152a0f1 100644
--- a/autoconf.texi
+++ b/autoconf.texi
@@ -1828,10 +1828,11 @@ name of the library; e.g., to check for @samp{-lmp}, use @samp{mp} as
 the @var{library} argument.
 
 @var{action-if-found} is a list of shell commands to run if the link
-with the library succeeds; @var{action-if-not-found} is a list of
-shell commands to run if the link fails.  If @var{action-if-found} is
-not specified, the default action will add @samp{-l@var{library}} to
-@code{LIBS} and define @samp{HAVE_LIB@var{library}} (in all capitals).
+with the library succeeds; @var{action-if-not-found} is a list of shell
+commands to run if the link fails.  If @var{action-if-found} and
+@var{action-if-not-found} are not specified, the default action is to
+add @samp{-l@var{library}} to @code{LIBS} and define
+@samp{HAVE_LIB@var{library}} (in all capitals).
 
 If linking with @var{library} results in unresolved symbols, which would
 be resolved by linking with additional libraries, give those libraries
@@ -1851,30 +1852,6 @@ all of those cases, the compiler is passed @samp{-lfoo}.  However,
 This macro is considered obsolete.
 @end defmac
 
-@defmac AC_SEARCH_LIBS (@var{function}, @var{search-libs} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
-@maindex SEARCH_LIBS
-Search for a library defining @var{function}, if it's not already
-available.  This equates to calling @code{AC_TRY_LINK_FUNC} first
-with no libraries, then for each library listed in @var{search-libs}.
-
-@var{action-if-found} is a list of shell commands to run if any
-link with a library succeeds; @var{action-if-not-found} is a list of
-shell commands to run if the link fails.  If @var{action-if-found}
-is not specified, the default action will add a matching
-value from @var{search-libs} if any to @code{LIBS}, and define
-@samp{HAVE_LIB@var{library}} (in all capitals).  Additionally, if
-the link succeeds, shell variable @code{searchval} will contain the
-matching library, or the string @code{NONE} if linking succeeded
-without a library.
-
-If linking with @var{library} results in unresolved symbols, which would
-be resolved by linking with additional libraries, give those libraries
-as the @var{other-libraries} argument, separated by spaces: @samp{-lXt
--lX11}.  Otherwise this macro will fail to detect that @var{function} is
-present, because linking the test program will always fail with
-unresolved symbols.
-@end defmac
-
 @node Library Functions, Header Files, Libraries, Existing Tests
 @section Library Functions
 
@@ -2766,26 +2743,13 @@ libraries.
 
 The following macros check for operating system services or capabilities.
 
-
-@defmac AC_CHECK_FILE (@var{file}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
-@maindex CHECK_FILE
-Checks for the existence of @var{file} in the native file system.
-This macro will generate a fatal error if cross-compiling.
-
-If the file is found and readable, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.
-@end defmac
-
-@defmac AC_CHECK_FILES (@var{files}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
-@maindex CHECK_FILES
-Checks for the existence of @var{files} in the native file system.
-This is equivalent to running @code{AC_CHECK_FILE} for each file
-in @var{files}.  This macro will generate a fatal error if
-cross-compiling.
-
-For each readable file found, run shell commands @var{action-if-found}
-and define @samp{HAVE_@var{file}} (in all capitals), otherwise run
-@var{action-if-not-found}.
+@defmac AC_SYS_INTERPRETER
+@maindex SYS_INTERPRETER
+Check whether the system supports starting scripts with a line of the
+form @samp{#! /bin/csh} to select the interpreter to use for the script.
+After running this macro, shell code in @code{configure.in} can check
+the variable @code{ac_cv_sys_interpreter}; it will be set to @samp{yes}
+if the system supports @samp{#!}, @samp{no} if not.
 @end defmac
 
 @defmac AC_PATH_X
@@ -2829,15 +2793,6 @@ found to the output variable @code{X_PRE_LIBS}.
 @c @code{LIBS} temporarily, like this:
 @end defmac
 
-@defmac AC_SYS_INTERPRETER
-@maindex SYS_INTERPRETER
-Check whether the system supports starting scripts with a line of the
-form @samp{#! /bin/csh} to select the interpreter to use for the script.
-After running this macro, shell code in @code{configure.in} can check
-the variable @code{ac_cv_sys_interpreter}; it will be set to @samp{yes}
-if the system supports @samp{#!}, @samp{no} if not.
-@end defmac
-
 @defmac AC_SYS_LONG_FILE_NAMES
 @maindex SYS_LONG_FILE_NAMES
 @cvindex HAVE_LONG_FILE_NAMES
@@ -3096,16 +3051,6 @@ If the file compiles and links successfully, run shell commands
 @var{action-if-found}, otherwise run @var{action-if-not-found}.
 @end defmac
 
-@defmac AC_TRY_LINK_FUNC (@var{function}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
-@maindex TRY_LINK_FUNC
-Depending on the current language (@pxref{Language Choice}), create a
-test program to see whether a program whose body consists of
-a prototype of and a call to @var{function} can be compiled and linked.
-
-If the file compiles and links successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.
-@end defmac
-
 @defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
 @maindex COMPILE_CHECK
 This is an obsolete version of @code{AC_TRY_LINK}, with the addition
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index e4e62cd2..5152a0f1 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -1828,10 +1828,11 @@ name of the library; e.g., to check for @samp{-lmp}, use @samp{mp} as
 the @var{library} argument.
 
 @var{action-if-found} is a list of shell commands to run if the link
-with the library succeeds; @var{action-if-not-found} is a list of
-shell commands to run if the link fails.  If @var{action-if-found} is
-not specified, the default action will add @samp{-l@var{library}} to
-@code{LIBS} and define @samp{HAVE_LIB@var{library}} (in all capitals).
+with the library succeeds; @var{action-if-not-found} is a list of shell
+commands to run if the link fails.  If @var{action-if-found} and
+@var{action-if-not-found} are not specified, the default action is to
+add @samp{-l@var{library}} to @code{LIBS} and define
+@samp{HAVE_LIB@var{library}} (in all capitals).
 
 If linking with @var{library} results in unresolved symbols, which would
 be resolved by linking with additional libraries, give those libraries
@@ -1851,30 +1852,6 @@ all of those cases, the compiler is passed @samp{-lfoo}.  However,
 This macro is considered obsolete.
 @end defmac
 
-@defmac AC_SEARCH_LIBS (@var{function}, @var{search-libs} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]})
-@maindex SEARCH_LIBS
-Search for a library defining @var{function}, if it's not already
-available.  This equates to calling @code{AC_TRY_LINK_FUNC} first
-with no libraries, then for each library listed in @var{search-libs}.
-
-@var{action-if-found} is a list of shell commands to run if any
-link with a library succeeds; @var{action-if-not-found} is a list of
-shell commands to run if the link fails.  If @var{action-if-found}
-is not specified, the default action will add a matching
-value from @var{search-libs} if any to @code{LIBS}, and define
-@samp{HAVE_LIB@var{library}} (in all capitals).  Additionally, if
-the link succeeds, shell variable @code{searchval} will contain the
-matching library, or the string @code{NONE} if linking succeeded
-without a library.
-
-If linking with @var{library} results in unresolved symbols, which would
-be resolved by linking with additional libraries, give those libraries
-as the @var{other-libraries} argument, separated by spaces: @samp{-lXt
--lX11}.  Otherwise this macro will fail to detect that @var{function} is
-present, because linking the test program will always fail with
-unresolved symbols.
-@end defmac
-
 @node Library Functions, Header Files, Libraries, Existing Tests
 @section Library Functions
 
@@ -2766,26 +2743,13 @@ libraries.
 
 The following macros check for operating system services or capabilities.
 
-
-@defmac AC_CHECK_FILE (@var{file}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
-@maindex CHECK_FILE
-Checks for the existence of @var{file} in the native file system.
-This macro will generate a fatal error if cross-compiling.
-
-If the file is found and readable, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.
-@end defmac
-
-@defmac AC_CHECK_FILES (@var{files}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
-@maindex CHECK_FILES
-Checks for the existence of @var{files} in the native file system.
-This is equivalent to running @code{AC_CHECK_FILE} for each file
-in @var{files}.  This macro will generate a fatal error if
-cross-compiling.
-
-For each readable file found, run shell commands @var{action-if-found}
-and define @samp{HAVE_@var{file}} (in all capitals), otherwise run
-@var{action-if-not-found}.
+@defmac AC_SYS_INTERPRETER
+@maindex SYS_INTERPRETER
+Check whether the system supports starting scripts with a line of the
+form @samp{#! /bin/csh} to select the interpreter to use for the script.
+After running this macro, shell code in @code{configure.in} can check
+the variable @code{ac_cv_sys_interpreter}; it will be set to @samp{yes}
+if the system supports @samp{#!}, @samp{no} if not.
 @end defmac
 
 @defmac AC_PATH_X
@@ -2829,15 +2793,6 @@ found to the output variable @code{X_PRE_LIBS}.
 @c @code{LIBS} temporarily, like this:
 @end defmac
 
-@defmac AC_SYS_INTERPRETER
-@maindex SYS_INTERPRETER
-Check whether the system supports starting scripts with a line of the
-form @samp{#! /bin/csh} to select the interpreter to use for the script.
-After running this macro, shell code in @code{configure.in} can check
-the variable @code{ac_cv_sys_interpreter}; it will be set to @samp{yes}
-if the system supports @samp{#!}, @samp{no} if not.
-@end defmac
-
 @defmac AC_SYS_LONG_FILE_NAMES
 @maindex SYS_LONG_FILE_NAMES
 @cvindex HAVE_LONG_FILE_NAMES
@@ -3096,16 +3051,6 @@ If the file compiles and links successfully, run shell commands
 @var{action-if-found}, otherwise run @var{action-if-not-found}.
 @end defmac
 
-@defmac AC_TRY_LINK_FUNC (@var{function}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]})
-@maindex TRY_LINK_FUNC
-Depending on the current language (@pxref{Language Choice}), create a
-test program to see whether a program whose body consists of
-a prototype of and a call to @var{function} can be compiled and linked.
-
-If the file compiles and links successfully, run shell commands
-@var{action-if-found}, otherwise run @var{action-if-not-found}.
-@end defmac
-
 @defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
 @maindex COMPILE_CHECK
 This is an obsolete version of @code{AC_TRY_LINK}, with the addition
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index b951a118..6a69aa5b 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1534,7 +1534,7 @@ dnl ACTION-IF-NOT-FOUND.
 
 AC_DEFUN(AC_TRY_LINK_FUNC,
 AC_TRY_LINK(dnl
-ifelse([$1], [main], , dnl Avoid conflicting decl of main.
+ifelse([$2], [main], , dnl Avoid conflicting decl of main.
 [/* Override any gcc2 internal prototype to avoid an error.  */
 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
 extern "C"
@@ -1549,41 +1549,26 @@ char $1();
 [$3]))
 
 
-dnl AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND
-dnl		[, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
+dnl AC_SEARCH_LIBS(func, searchlibs, [action-if-found], [action-if-not-found])
 dnl Search for a library defining FUNC, if it's not already available.
 
 AC_DEFUN(AC_SEARCH_LIBS,
-[AC_PREREQ([2.13])
+[AC_PREREQ([2.12])
 AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
 [ac_func_search_save_LIBS="$LIBS"
 ac_cv_search_$1="no"
 AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="none required"])
 test "$ac_cv_search_$1" = "no" && for i in $2; do
-LIBS="-l$i $5 $ac_func_search_save_LIBS"
+LIBS="-l$i $ac_func_search_save_LIBS"
 AC_TRY_LINK_FUNC([$1],
-[ac_cv_search_$1="$i"
+[ac_cv_search_$1="-l$i"
 break])
 done
 LIBS="$ac_func_search_save_LIBS"])
 if test "$ac_cv_search_$1" != "no"; then
-  if test "$ac_cv_search_$1" = "none required"; then
-    searchval="NONE"
-    $3
-  else
-    searchval="$ac_cv_search_$1"
-    ifelse([$3], , 
-      [changequote(, )dnl
-      ac_tr_lib=HAVE_LIB`echo $ac_cv_search_$1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-           -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
-      changequote([, ])dnl
-      AC_DEFINE_UNQUOTED($ac_tr_lib)
-      LIBS="-l$ac_cv_search_$1 $LIBS",
-      [$3])
-
-  fi
+  test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
+  $3
 else :
-  searchval=
   $4
 fi])
 
@@ -1920,7 +1905,7 @@ AC_DEFUN(AC_CHECK_FILES,
 do
 AC_CHECK_FILE($ac_file,
 [changequote(, )dnl
-  ac_tr_file=HAVE_`echo $ac_file | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  ac_tr_file=HAVE`echo $ac_file | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
 changequote([, ])dnl
   AC_DEFINE_UNQUOTED($ac_tr_file) $2], $3)dnl
 done
diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4
index 5c6f1c9e..0b9aab74 100644
--- a/lib/autoconf/specific.m4
+++ b/lib/autoconf/specific.m4
@@ -2225,7 +2225,6 @@ else
    ac_cv_sys_interpreter=no
 fi
 rm -f conftest])
-interpval="$ac_cv_sys_interpreter"
 ])
 
 define(AC_HAVE_POUNDBANG,