1dnl -------------- 2dnl CHECK FOR NDBM 3dnl -------------- 4dnl 5dnl NMH_CHECK_DBM(include,library,action-if-found,action-if-not) 6 7dnl Check for presence of dbm_open() in the specified library 8dnl and with the specified include file (if libname is the empty 9dnl string then don't try to link against any particular library). 10 11dnl We set nmh_ndbm_found to 'yes' or 'no'; if found we set 12dnl nmh_ndbmheader to the first arg and nmh_ndbm to the second. 13 14dnl If this macro accepted a list of include,library tuples 15dnl to test in order that would be cleaner than the current 16dnl nest of calls in configure.in. 17 18dnl We try to link our own code fragment (which includes the 19dnl headers in the same way slocal.c does) rather than 20dnl using AC_CHECK_LIB because on later versions of libdb 21dnl the dbm_open() function is provided via a #define and 22dnl we don't want to hardcode searching for the internal 23dnl function that lies behind it. (AC_CHECK_LIB works by 24dnl defining its own bogus prototype rather than pulling in 25dnl the right header files.) 26 27dnl An oddity (bug) of this macro is that if you haven't 28dnl done AC_PROG_CC or something that implies it before 29dnl using this macro autoconf complains about a recursive 30dnl expansion. 31 32AC_DEFUN([NMH_CHECK_NDBM], 33[ 34if test "x$2" = "x"; then 35 nmh_libs= 36 AC_MSG_CHECKING([for dbm in $1]) 37else 38 nmh_libs="-l$2 " 39 AC_MSG_CHECKING([for dbm in $1 and $2]) 40fi 41 42dnl We don't try to cache the result, because that exceeds 43dnl my autoconf skills -- feel free to put it in :-> -- PMM 44 45nmh_saved_libs="$LIBS" 46LIBS="$nmh_libs $5 $LIBS" 47AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 48#define DB_DBM_HSEARCH 1 49#include <$1> 50]], 51[[dbm_open("",0,0);]])],[nmh_ndbm_found=yes],[nmh_ndbm_found=no]) 52LIBS="$nmh_saved_libs" 53 54if test "$nmh_ndbm_found" = "yes"; then 55 AC_MSG_RESULT(yes) 56 nmh_ndbmheader="$1" 57 nmh_ndbm="$2" 58 $3 59else 60 AC_MSG_RESULT(no) 61 $4 62 : 63fi 64])dnl 65