dnl [, OTHER-LIBRARIES]]])
AC_DEFUN(AC_CHECK_LIB,
[AC_MSG_CHECKING([for -l$1])
-changequote(, )dnl
-ac_lib_var=`echo $1 | tr '.-/+' '___p'`
-changequote([, ])dnl
+dnl Use a cache variable name containing both the library and function name,
+dnl because the test really is for library $1 defining function $2, not
+dnl just for library $1. Separate tests with the same $1 and different $2s
+dnl may have different results.
+ac_lib_var=`echo $1[_]$2 | tr '.-/+' '___p'`
AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
[ac_save_LIBS="$LIBS"
LIBS="-l$1 $5 $LIBS"
dnl [, OTHER-LIBRARIES]]])
AC_DEFUN(AC_CHECK_LIB,
[AC_MSG_CHECKING([for -l$1])
-changequote(, )dnl
-ac_lib_var=`echo $1 | tr '.-/+' '___p'`
-changequote([, ])dnl
+dnl Use a cache variable name containing both the library and function name,
+dnl because the test really is for library $1 defining function $2, not
+dnl just for library $1. Separate tests with the same $1 and different $2s
+dnl may have different results.
+ac_lib_var=`echo $1[_]$2 | tr '.-/+' '___p'`
AC_CACHE_VAL(ac_cv_lib_$ac_lib_var,
[ac_save_LIBS="$LIBS"
LIBS="-l$1 $5 $LIBS"