1 dnl a bug-fixed version of autoconf 2.12.
2 dnl first try to link library without $5, and only of that failed,
3 dnl try with $5 if specified.
4 dnl it adds $5 to $LIBS if it was needed -Erez.
5 dnl AC_CHECK_LIB2(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
6 dnl [, OTHER-LIBRARIES]]])
7 AC_DEFUN([AMU_CHECK_LIB2],
8 [AC_MSG_CHECKING([for $2 in -l$1])
9 dnl Use a cache variable name containing both the library and function name,
10 dnl because the test really is for library $1 defining function $2, not
11 dnl just for library $1. Separate tests with the same $1 and different $2s
12 dnl may have different results.
13 ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
14 AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
17 # first try with base library, without auxiliary library
20 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
21 [/* Override any gcc2 internal prototype to avoid an error. */
23 [/* We use char because int might match the return type of a gcc2
24 builtin and then its argument prototype would still apply. */
28 eval "ac_cv_lib_$ac_lib_var=\"$1\"",
29 eval "ac_cv_lib_$ac_lib_var=no")
31 # if OK, set to no auxiliary library, else try auxiliary library
32 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = no"; then
35 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
36 [/* Override any gcc2 internal prototype to avoid an error. */
38 [/* We use char because int might match the return type of a gcc2
39 builtin and then its argument prototype would still apply. */
43 eval "ac_cv_lib_$ac_lib_var=\"$1 $5\"",
44 eval "ac_cv_lib_$ac_lib_var=no")
49 ac_tmp="`eval echo '$''{ac_cv_lib_'$ac_lib_var'}'`"
50 if test "${ac_tmp}" != no; then
51 AC_MSG_RESULT(-l$ac_tmp)
54 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[[^a-zA-Z0-9_]]/_/g' \
55 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
57 AC_DEFINE_UNQUOTED($ac_tr_lib)
58 LIBS="-l$ac_tmp $LIBS"