diff options
author | Jim Meyering <jim@meyering.net> | 1999-05-16 15:48:11 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-05-16 15:48:11 +0000 |
commit | 3d2009b52da16454bf0922399d4c8a0f0b5e05c3 (patch) | |
tree | 8bd1e54803f2261971b6c3ced9f74076c4794701 /m4/search-libs.m4 | |
parent | 73a206d970da218758f293b90a086faf5c941125 (diff) | |
download | coreutils-3d2009b52da16454bf0922399d4c8a0f0b5e05c3.tar.xz |
New file to override autoconf's AC_SEARCH_LIBS.
Diffstat (limited to 'm4/search-libs.m4')
-rw-r--r-- | m4/search-libs.m4 | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/m4/search-libs.m4 b/m4/search-libs.m4 new file mode 100644 index 000000000..6979ea8e5 --- /dev/null +++ b/m4/search-libs.m4 @@ -0,0 +1,44 @@ +#serial 1 + +dnl A replacement for autoconf's macro by the same name. This version +dnl uses `ac_lib' rather than `i' for the loop variable, but more importantly +dnl moves the ACTION-IF-FOUND ($3) into the inner `if'-block so that it is +dnl run only if one of the listed libraries ends up being used (and not in +dnl the `none required' case. +dnl I hope it's only temporary while we wait for that version to be fixed. +undefine(AC_SEARCH_LIBS) + +dnl AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS [, ACTION-IF-FOUND +dnl [, ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) +dnl Search for a library defining FUNC, if it's not already available. + +AC_DEFUN(AC_SEARCH_LIBS, +[ + AC_PREREQ([2.13]) + 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"]) + if test "$ac_cv_search_$1" = "no"; then + for ac_lib in $2; do + LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS" + AC_TRY_LINK_FUNC([$1], + [ac_cv_search_$1="-l$ac_lib" + break]) + done + fi + LIBS="$ac_func_search_save_LIBS" + ]) + + if test "$ac_cv_search_$1" = "no"; then + $4 + else + if test "$ac_cv_search_$1" = "none required"; then + $4 + else : + LIBS="$ac_cv_search_$1 $LIBS" + $3 + fi + fi +]) |