#ifdef it all out so we compile with heimdal-0.7.2
[arla.git] / cf / krb-find-db.m4
blobdabc5ff410f6a376c03a37f75e9c695d0f1e2343
1 dnl $Id$
2 dnl
3 dnl find a suitable database library
4 dnl
5 dnl AC_FIND_DB(libraries)
6 AC_DEFUN([KRB_FIND_DB], [
8 lib_dbm=no
9 lib_db=no
11 for i in $1; do
13         if test "$i"; then
14                 m="lib$i"
15                 l="-l$i"
16         else
17                 m="libc"
18                 l=""
19         fi      
21         AC_MSG_CHECKING(for dbm_open in $m)
22         AC_CACHE_VAL(ac_cv_krb_dbm_open_$m, [
24         save_LIBS="$LIBS"
25         LIBS="$l $LIBS"
26         AC_TRY_RUN([
27 #include <unistd.h>
28 #include <fcntl.h>
29 #if defined(HAVE_NDBM_H)
30 #include <ndbm.h>
31 #elif defined(HAVE_GDBM_NDBM_H)
32 #include <gdbm/ndbm.h>
33 #elif defined(HAVE_DBM_H)
34 #include <dbm.h>
35 #elif defined(HAVE_RPCSVC_DBM_H)
36 #include <rpcsvc/dbm.h>
37 #elif defined(HAVE_DB_H)
38 #define DB_DBM_HSEARCH 1
39 #include <db.h>
40 #endif
41 int main()
43   DBM *d;
45   d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
46   if(d == NULL)
47     return 1;
48   dbm_close(d);
49   return 0;
50 }], [
51         if test -f conftest.db; then
52                 ac_res=db
53         else
54                 ac_res=dbm
55         fi], ac_res=no, ac_res=no)
57         LIBS="$save_LIBS"
59         eval ac_cv_krb_dbm_open_$m=$ac_res])
60         eval ac_res=\$ac_cv_krb_dbm_open_$m
61         AC_MSG_RESULT($ac_res)
63         if test "$lib_dbm" = no -a $ac_res = dbm; then
64                 lib_dbm="$l"
65         elif test "$lib_db" = no -a $ac_res = db; then
66                 lib_db="$l"
67                 break
68         fi
69 done
71 AC_MSG_CHECKING(for NDBM library)
72 ac_ndbm=no
73 if test "$lib_db" != no; then
74         LIB_DBM="$lib_db"
75         ac_ndbm=yes
76         AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files ending in .db).])
77         if test "$LIB_DBM"; then
78                 ac_res="yes, $LIB_DBM"
79         else
80                 ac_res=yes
81         fi
82 elif test "$lib_dbm" != no; then
83         LIB_DBM="$lib_dbm"
84         ac_ndbm=yes
85         if test "$LIB_DBM"; then
86                 ac_res="yes, $LIB_DBM"
87         else
88                 ac_res=yes
89         fi
90 else
91         LIB_DBM=""
92         ac_res=no
94 test "$ac_ndbm" = yes && AC_DEFINE(NDBM, 1, [Define if you have NDBM (and not DBM)])dnl
95 AC_SUBST(LIB_DBM)
96 DBLIB="$LIB_DBM"
97 AC_SUBST(DBLIB)
98 AC_MSG_RESULT($ac_res)