add doxygen support and json export document support
[heimdal.git] / cf / db.m4
blob5c9460f17108d21dd2c88938d596dc1c5456ba1d
1 dnl $Id$
2 dnl
3 dnl tests for various db libraries
4 dnl
6 AC_DEFUN([rk_DB],[
7 AC_ARG_WITH(berkeley-db,
8                        AS_HELP_STRING([--with-berkeley-db],
9                                       [enable support for berkeley db @<:@default=check@:>@]),
10                        [],
11                        [with_berkeley_db=check])
13 dbheader=""
14 AC_ARG_WITH(berkeley-db-include,
15                        AS_HELP_STRING([--with-berkeley-db-include=dir],
16                                       [use berkeley-db headers in dir]),
17                        [dbheader=$withval],
18                        [with_berkeley_db_include=check])
20 AC_ARG_ENABLE(ndbm-db,
21                        AS_HELP_STRING([--disable-ndbm-db],
22                                       [if you don't want ndbm db]),[
25 AC_ARG_ENABLE(mdb-db,
26                        AS_HELP_STRING([--disable-mdb-db],
27                                       [if you don't want OpenLDAP libmdb db]),[
30 have_ndbm=no
31 db_type=unknown
33 AS_IF([test "x$with_berkeley_db" != xno],
34   [AS_IF([test "x$with_berkeley_db_include" != xcheck],
35     [AC_CHECK_HEADERS(["$dbheader/db.h"],
36                    [AC_SUBST([DBHEADER], [$dbheader])
37                     AC_DEFINE([HAVE_DBHEADER], [1],
38                                       [Define if you have user supplied header location])
39                    ],
40                    [if test "x$with_berkeley_db_include" != xcheck; then
41                      AC_MSG_FAILURE(
42                        [--with-berkeley-db-include was given but include test failed])
43                     fi
44                    ])],
45     [AC_CHECK_HEADERS([                                 \
46                    db5/db.h                             \
47                    db4/db.h                             \
48                    db3/db.h                             \
49                    db.h                                 \
50     ])])
52 dnl db_create is used by db3 and db4 and db5
54   AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [
55   #include <stdio.h>
56   #ifdef HAVE_DBHEADER
57   #include <$dbheader/db.h>
58   #elif HAVE_DB5_DB_H
59   #include <db5/db.h>
60   #elif HAVE_DB4_DB_H
61   #include <db4/db.h>
62   #elif defined(HAVE_DB3_DB_H)
63   #include <db3/db.h>
64   #else
65   #include <db.h>
66   #endif
67   ],[NULL, NULL, 0])
69   if test "$ac_cv_func_db_create" = "yes"; then
70     db_type=db3
71     if test "$ac_cv_funclib_db_create" != "yes"; then
72       DBLIB="$ac_cv_funclib_db_create"
73     else
74       DBLIB=""
75     fi
76     AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library])
77   fi
79 dnl dbopen is used by db1/db2
81   AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
82   #include <stdio.h>
83   #if defined(HAVE_DB2_DB_H)
84   #include <db2/db.h>
85   #elif defined(HAVE_DB_H)
86   #include <db.h>
87   #else
88   #error no db.h
89   #endif
90   ],[NULL, 0, 0, 0, NULL])
92   if test "$ac_cv_func_dbopen" = "yes"; then
93     db_type=db1
94     if test "$ac_cv_funclib_dbopen" != "yes"; then
95       DBLIB="$ac_cv_funclib_dbopen"
96     else
97       DBLIB=""
98     fi
99     AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
100   fi
102 dnl test for ndbm compatability
104   if test "$ac_cv_func_dbm_firstkey" != yes; then
105     AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
106     #include <stdio.h>
107     #define DB_DBM_HSEARCH 1
108     #include <db.h>
109     DBM *dbm;
110     ],[NULL])
111   
112     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
113       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
114         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
115       else
116         LIB_NDBM=""
117       fi
118       AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
119       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
120     else
121       $as_unset ac_cv_func_dbm_firstkey
122       $as_unset ac_cv_funclib_dbm_firstkey
123     fi
124   fi
126 ]) # fi berkeley db
128 if test "$enable_mdb_db" != "no"; then
129   if test "$db_type" = "unknown"; then
130     AC_CHECK_HEADER(mdb.h, [
131                 AC_CHECK_LIB(mdb, mdb_env_create, db_type=mdb; DBLIB="-lmdb"
132                 AC_DEFINE(HAVE_MDB, 1, [define if you have the OpenLDAP mdb library]))])
133   fi
136 if test "$enable_ndbm_db" != "no"; then
138   if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
140     AC_CHECK_HEADERS([                          \
141         dbm.h                                   \
142         ndbm.h                                  \
143     ])
144   
145     AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
146     #include <stdio.h>
147     #if defined(HAVE_NDBM_H)
148     #include <ndbm.h>
149     #elif defined(HAVE_DBM_H)
150     #include <dbm.h>
151     #endif
152     DBM *dbm;
153     ],[NULL])
154   
155     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
156       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
157         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
158       else
159         LIB_NDBM=""
160       fi
161       AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
162       have_ndbm=yes
163       if test "$db_type" = "unknown"; then
164         db_type=ndbm
165         DBLIB="$LIB_NDBM"
166       fi
167     else
168   
169       $as_unset ac_cv_func_dbm_firstkey
170       $as_unset ac_cv_funclib_dbm_firstkey
171   
172       AC_CHECK_HEADERS([                                \
173           gdbm/ndbm.h                           \
174       ])
175   
176       AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
177       #include <stdio.h>
178       #include <gdbm/ndbm.h>
179       DBM *dbm;
180       ],[NULL])
181   
182       if test "$ac_cv_func_dbm_firstkey" = "yes"; then
183         if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
184         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
185         else
186         LIB_NDBM=""
187         fi
188         AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
189         have_ndbm=yes
190         if test "$db_type" = "unknown"; then
191         db_type=ndbm
192         DBLIB="$LIB_NDBM"
193         fi
194       fi
195     fi
196   fi #enable_ndbm_db
197 fi # unknown
199 if test "$have_ndbm" = "yes"; then
200   AC_MSG_CHECKING([if ndbm is implemented with db])
201   AC_RUN_IFELSE([AC_LANG_SOURCE([[
202 #include <unistd.h>
203 #include <fcntl.h>
204 #if defined(HAVE_GDBM_NDBM_H)
205 #include <gdbm/ndbm.h>
206 #elif defined(HAVE_NDBM_H)
207 #include <ndbm.h>
208 #elif defined(HAVE_DBM_H)
209 #include <dbm.h>
210 #endif
211 int main(int argc, char **argv)
213   DBM *d;
215   d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
216   if (d == NULL)
217     return 1;
218   dbm_close(d);
219   return 0;
220 }]])],[
221     if test -f conftest.db; then
222       AC_MSG_RESULT([yes])
223       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
224     else
225       AC_MSG_RESULT([no])
226     fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])])
229 AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
230 AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
231 AM_CONDITIONAL(HAVE_MDB, test "$db_type" = mdb)dnl
232 AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
233 AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl
235 ## it's probably not correct to include LDFLAGS here, but we might
236 ## need it, for now just add any possible -L
237 z=""
238 for i in $LDFLAGS; do
239         case "$i" in
240         -L*) z="$z $i";;
241         esac
242 done
243 DBLIB="$z $DBLIB"
244 AC_SUBST(DBLIB)dnl
245 AC_SUBST(LIB_NDBM)dnl