Fix typo in comment.
[gnulib.git] / m4 / search-libs.m4
1 #serial 5
2
3 dnl A replacement for autoconf's macro by the same name.  This version
4 dnl uses `ac_lib' rather than `i' for the loop variable, but more importantly
5 dnl moves the ACTION-IF-FOUND ([$]3) into the inner `if'-block so that it is
6 dnl run only if one of the listed libraries ends up being used (and not in
7 dnl the `none required' case.
8 dnl I hope it's only temporary while we wait for that version to be fixed.
9 undefine([AC_SEARCH_LIBS])
10
11 # AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS,
12 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
13 #                [OTHER-LIBRARIES])
14 # --------------------------------------------------------
15 # Search for a library defining FUNC, if it's not already available.
16 AC_DEFUN([AC_SEARCH_LIBS],
17 [
18   AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
19   [
20     ac_func_search_save_LIBS=$LIBS
21     ac_cv_search_$1=no
22     AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1='none required'])
23     if test "$ac_cv_search_$1" = no; then
24       for ac_lib in $2; do
25         LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
26         AC_TRY_LINK_FUNC([$1], [ac_cv_search_$1="-l$ac_lib"; break])
27       done
28     fi
29     LIBS=$ac_func_search_save_LIBS
30   ])
31
32   if test "$ac_cv_search_$1" = no; then :
33     $4
34   else
35     if test "$ac_cv_search_$1" = 'none required'; then :
36       $4
37     else
38       LIBS="$ac_cv_search_$1 $LIBS"
39       $3
40     fi
41   fi
42 ])