]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
1998-09-29 Ben Elliston <bje@cygnus.com>
authorBen Elliston <bje+keyword+gnu.7caf74@air.net.au>
Tue, 29 Sep 1998 03:05:56 +0000 (03:05 +0000)
committerBen Elliston <bje+keyword+gnu.7caf74@air.net.au>
Tue, 29 Sep 1998 03:05:56 +0000 (03:05 +0000)
* acgeneral.m4 (AC_SEARCH_LIBS): New macro. Searches a series of
libraries for a given function. Contributed by Jim Blandy
<jimb@cygnus.com>.
(AC_TRY_LINK_FUNC): New macro. Again, from Jim.

ChangeLog
acgeneral.m4
lib/autoconf/general.m4

index 3ede26f8e51d124f9245c552081d242396dd9051..78e6837ddc58d3c236cf5b14eaca813680ddb800 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+1998-09-29  Ben Elliston  <bje@cygnus.com>
+
+       * acgeneral.m4 (AC_SEARCH_LIBS): New macro. Searches a series of
+       libraries for a given function. Contributed by Jim Blandy
+       <jimb@cygnus.com>.
+       (AC_TRY_LINK_FUNC): New macro. Again, from Jim.
+
 1998-09-28  Ben Elliston  <bje@cygnus.com>
 
        * config.guess: Detect multiprocessor DC/OSx running on Pyramid
index d722ff2a17c56cb9efd0f8bc4fad0777687befc6..539388115126203b2c669ece7fcbb974c18aa5b4 100644 (file)
@@ -1483,6 +1483,31 @@ rm -fr conftest*])
 dnl ### Checking for 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.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 $ac_func_search_save_LIBS"
+AC_TRY_LINK_FUNC([$1],
+[ac_cv_search_$1="-l$i"
+break])
+done
+LIBS="$ac_func_search_save_LIBS"])
+if test "$ac_cv_search_$1" != "no"; then
+  test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
+  $3
+else :
+  $4
+fi])
+
+
+
 dnl AC_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
 dnl              [, OTHER-LIBRARIES]]])
 AC_DEFUN(AC_CHECK_LIB,
@@ -1690,6 +1715,27 @@ ifelse([$4], , , [  rm -rf conftest*
 fi
 rm -f conftest*])
 
+dnl AC_TRY_LINK_FUNC(func, action-if-found, action-if-not-found)
+dnl Try to link a program that calls FUNC, handling GCC builtins.  If
+dnl the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
+dnl ACTION-IF-NOT-FOUND.
+
+AC_DEFUN(AC_TRY_LINK_FUNC,
+AC_TRY_LINK(dnl
+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"
+#endif
+])dnl
+[/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $1();
+]),
+[$1()],
+[$2],
+[$3]))
+
 
 dnl ### Checking for run-time features
 
index d722ff2a17c56cb9efd0f8bc4fad0777687befc6..539388115126203b2c669ece7fcbb974c18aa5b4 100644 (file)
@@ -1483,6 +1483,31 @@ rm -fr conftest*])
 dnl ### Checking for 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.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 $ac_func_search_save_LIBS"
+AC_TRY_LINK_FUNC([$1],
+[ac_cv_search_$1="-l$i"
+break])
+done
+LIBS="$ac_func_search_save_LIBS"])
+if test "$ac_cv_search_$1" != "no"; then
+  test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
+  $3
+else :
+  $4
+fi])
+
+
+
 dnl AC_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
 dnl              [, OTHER-LIBRARIES]]])
 AC_DEFUN(AC_CHECK_LIB,
@@ -1690,6 +1715,27 @@ ifelse([$4], , , [  rm -rf conftest*
 fi
 rm -f conftest*])
 
+dnl AC_TRY_LINK_FUNC(func, action-if-found, action-if-not-found)
+dnl Try to link a program that calls FUNC, handling GCC builtins.  If
+dnl the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
+dnl ACTION-IF-NOT-FOUND.
+
+AC_DEFUN(AC_TRY_LINK_FUNC,
+AC_TRY_LINK(dnl
+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"
+#endif
+])dnl
+[/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $1();
+]),
+[$1()],
+[$2],
+[$3]))
+
 
 dnl ### Checking for run-time features