]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - crypto/heimdal/cf/db.m4
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / crypto / heimdal / cf / db.m4
1 dnl $Id: db.m4 15456 2005-06-16 21:04:43Z lha $
2 dnl
3 dnl tests for various db libraries
4 dnl
5 AC_DEFUN([rk_DB],[
6 AC_ARG_ENABLE(berkeley-db,
7                        AS_HELP_STRING([--disable-berkeley-db],
8                                       [if you don't want berkeley db]),[
9 ])
10
11 AC_ARG_ENABLE(ndbm-db,
12                        AS_HELP_STRING([--disable-ndbm-db],
13                                       [if you don't want ndbm db]),[
14 ])
15
16 have_ndbm=no
17 db_type=unknown
18
19 if test "$enable_berkeley_db" != no; then
20
21   AC_CHECK_HEADERS([                            \
22         db4/db.h                                \
23         db3/db.h                                \
24         db.h                                    \
25         db_185.h                                \
26   ])
27
28 dnl db_create is used by db3 and db4
29
30   AC_FIND_FUNC_NO_LIBS(db_create, db4 db3 db, [
31   #include <stdio.h>
32   #ifdef HAVE_DB4_DB_H
33   #include <db4/db.h>
34   #elif defined(HAVE_DB3_DB_H)
35   #include <db3/db.h>
36   #else
37   #include <db.h>
38   #endif
39   ],[NULL, NULL, 0])
40
41   if test "$ac_cv_func_db_create" = "yes"; then
42     db_type=db3
43     if test "$ac_cv_funclib_db_create" != "yes"; then
44       DBLIB="$ac_cv_funclib_db_create"
45     else
46       DBLIB=""
47     fi
48     AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4 library])
49   else
50
51 dnl dbopen is used by db1/db2
52
53     AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
54     #include <stdio.h>
55     #if defined(HAVE_DB2_DB_H)
56     #include <db2/db.h>
57     #elif defined(HAVE_DB_185_H)
58     #include <db_185.h>
59     #elif defined(HAVE_DB_H)
60     #include <db.h>
61     #else
62     #error no db.h
63     #endif
64     ],[NULL, 0, 0, 0, NULL])
65
66     if test "$ac_cv_func_dbopen" = "yes"; then
67       db_type=db1
68       if test "$ac_cv_funclib_dbopen" != "yes"; then
69         DBLIB="$ac_cv_funclib_dbopen"
70       else
71         DBLIB=""
72       fi
73       AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
74     fi
75   fi
76
77 dnl test for ndbm compatability
78
79   if test "$ac_cv_func_dbm_firstkey" != yes; then
80     AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
81     #include <stdio.h>
82     #define DB_DBM_HSEARCH 1
83     #include <db.h>
84     DBM *dbm;
85     ],[NULL])
86   
87     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
88       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
89         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
90       else
91         LIB_NDBM=""
92       fi
93       AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
94       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
95     else
96       $as_unset ac_cv_func_dbm_firstkey
97       $as_unset ac_cv_funclib_dbm_firstkey
98     fi
99   fi
100
101 fi # berkeley db
102
103 if test "$enable_ndbm_db" != "no"; then
104
105   if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
106
107     AC_CHECK_HEADERS([                          \
108         dbm.h                                   \
109         ndbm.h                                  \
110     ])
111   
112     AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
113     #include <stdio.h>
114     #if defined(HAVE_NDBM_H)
115     #include <ndbm.h>
116     #elif defined(HAVE_DBM_H)
117     #include <dbm.h>
118     #endif
119     DBM *dbm;
120     ],[NULL])
121   
122     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
123       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
124         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
125       else
126         LIB_NDBM=""
127       fi
128       AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
129       have_ndbm=yes
130       if test "$db_type" = "unknown"; then
131         db_type=ndbm
132         DBLIB="$LIB_NDBM"
133       fi
134     else
135   
136       $as_unset ac_cv_func_dbm_firstkey
137       $as_unset ac_cv_funclib_dbm_firstkey
138   
139       AC_CHECK_HEADERS([                                \
140           gdbm/ndbm.h                           \
141       ])
142   
143       AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
144       #include <stdio.h>
145       #include <gdbm/ndbm.h>
146       DBM *dbm;
147       ],[NULL])
148   
149       if test "$ac_cv_func_dbm_firstkey" = "yes"; then
150         if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
151         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
152         else
153         LIB_NDBM=""
154         fi
155         AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
156         have_ndbm=yes
157         if test "$db_type" = "unknown"; then
158         db_type=ndbm
159         DBLIB="$LIB_NDBM"
160         fi
161       fi
162     fi
163   fi #enable_ndbm_db
164 fi # unknown
165
166 if test "$have_ndbm" = "yes"; then
167   AC_MSG_CHECKING([if ndbm is implemented with db])
168   AC_RUN_IFELSE([AC_LANG_SOURCE([[
169 #include <unistd.h>
170 #include <fcntl.h>
171 #if defined(HAVE_GDBM_NDBM_H)
172 #include <gdbm/ndbm.h>
173 #elif defined(HAVE_NDBM_H)
174 #include <ndbm.h>
175 #elif defined(HAVE_DBM_H)
176 #include <dbm.h>
177 #endif
178 int main(int argc, char **argv)
179 {
180   DBM *d;
181
182   d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
183   if (d == NULL)
184     return 1;
185   dbm_close(d);
186   return 0;
187 }]])],[
188     if test -f conftest.db; then
189       AC_MSG_RESULT([yes])
190       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
191     else
192       AC_MSG_RESULT([no])
193     fi],[AC_MSG_RESULT([no])])
194 fi
195
196 AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
197 AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
198 AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
199
200 ## it's probably not correct to include LDFLAGS here, but we might
201 ## need it, for now just add any possible -L
202 z=""
203 for i in $LDFLAGS; do
204         case "$i" in
205         -L*) z="$z $i";;
206         esac
207 done
208 DBLIB="$z $DBLIB"
209 AC_SUBST(DBLIB)dnl
210 AC_SUBST(LIB_NDBM)dnl
211 ])