From: Ben Elliston Date: Tue, 29 Sep 1998 03:05:56 +0000 (+0000) Subject: 1998-09-29 Ben Elliston X-Git-Tag: autoconf-2-13-rc1~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=735534e4d89145784871b9d4bff943b580da4bc5;p=thirdparty%2Fautoconf.git 1998-09-29 Ben Elliston * acgeneral.m4 (AC_SEARCH_LIBS): New macro. Searches a series of libraries for a given function. Contributed by Jim Blandy . (AC_TRY_LINK_FUNC): New macro. Again, from Jim. --- diff --git a/ChangeLog b/ChangeLog index 3ede26f8..78e6837d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1998-09-29 Ben Elliston + + * acgeneral.m4 (AC_SEARCH_LIBS): New macro. Searches a series of + libraries for a given function. Contributed by Jim Blandy + . + (AC_TRY_LINK_FUNC): New macro. Again, from Jim. + 1998-09-28 Ben Elliston * config.guess: Detect multiprocessor DC/OSx running on Pyramid diff --git a/acgeneral.m4 b/acgeneral.m4 index d722ff2a..53938811 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -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 diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index d722ff2a..53938811 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -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