Windows: Enable weak crypto by default
[heimdal.git] / cf / db.m4
blob3fbdfd813693f3f81d95de457cb0e7e5080db517
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 have_ndbm=no
26 db_type=unknown
28 AS_IF([test "x$with_berkeley_db" != xno],
29   [AS_IF([test "x$with_berkeley_db_include" != xcheck],
30     [AC_CHECK_HEADERS(["$dbheader/db.h"],
31                    [AC_SUBST([DBHEADER], [$dbheader])
32                     AC_DEFINE([HAVE_DBHEADER], [1],
33                                       [Define if you have user supplied header location])
34                    ],
35                    [if test "x$with_berkeley_db_include" != xcheck; then
36                      AC_MSG_FAILURE(
37                        [--with-berkeley-db-include was given but include test failed])
38                     fi
39                    ])],
40     [AC_CHECK_HEADERS([                                 \
41                    db5/db.h                             \
42                    db4/db.h                             \
43                    db3/db.h                             \
44                    db.h                                 \
45                    db_185.h                             \
46     ])])
48 dnl db_create is used by db3 and db4 and db5
50   AC_FIND_FUNC_NO_LIBS(db_create, [$dbheader] db5 db4 db3 db, [
51   #include <stdio.h>
52   #ifdef HAVE_DBHEADER
53   #include <$dbheader/db.h>
54   #elif HAVE_DB5_DB_H
55   #include <db5/db.h>
56   #elif HAVE_DB4_DB_H
57   #include <db4/db.h>
58   #elif defined(HAVE_DB3_DB_H)
59   #include <db3/db.h>
60   #else
61   #include <db.h>
62   #endif
63   ],[NULL, NULL, 0])
65   if test "$ac_cv_func_db_create" = "yes"; then
66     db_type=db3
67     if test "$ac_cv_funclib_db_create" != "yes"; then
68       DBLIB="$ac_cv_funclib_db_create"
69     else
70       DBLIB=""
71     fi
72     AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3/4/5 library])
73   else
75 dnl dbopen is used by db1/db2
77     AC_FIND_FUNC_NO_LIBS(dbopen, db2 db, [
78     #include <stdio.h>
79     #if defined(HAVE_DB2_DB_H)
80     #include <db2/db.h>
81     #elif defined(HAVE_DB_185_H)
82     #include <db_185.h>
83     #elif defined(HAVE_DB_H)
84     #include <db.h>
85     #else
86     #error no db.h
87     #endif
88     ],[NULL, 0, 0, 0, NULL])
90     if test "$ac_cv_func_dbopen" = "yes"; then
91       db_type=db1
92       if test "$ac_cv_funclib_dbopen" != "yes"; then
93         DBLIB="$ac_cv_funclib_dbopen"
94       else
95         DBLIB=""
96       fi
97       AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library])
98     fi
99   fi
101 dnl test for ndbm compatability
103   if test "$ac_cv_func_dbm_firstkey" != yes; then
104     AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen $ac_cv_funclib_db_create, [
105     #include <stdio.h>
106     #define DB_DBM_HSEARCH 1
107     #include <db.h>
108     DBM *dbm;
109     ],[NULL])
110   
111     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
112       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
113         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
114       else
115         LIB_NDBM=""
116       fi
117       AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db])
118       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
119     else
120       $as_unset ac_cv_func_dbm_firstkey
121       $as_unset ac_cv_funclib_dbm_firstkey
122     fi
123   fi
125 ]) # fi berkeley db
127 if test "$enable_ndbm_db" != "no"; then
129   if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then
131     AC_CHECK_HEADERS([                          \
132         dbm.h                                   \
133         ndbm.h                                  \
134     ])
135   
136     AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [
137     #include <stdio.h>
138     #if defined(HAVE_NDBM_H)
139     #include <ndbm.h>
140     #elif defined(HAVE_DBM_H)
141     #include <dbm.h>
142     #endif
143     DBM *dbm;
144     ],[NULL])
145   
146     if test "$ac_cv_func_dbm_firstkey" = "yes"; then
147       if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
148         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
149       else
150         LIB_NDBM=""
151       fi
152       AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
153       have_ndbm=yes
154       if test "$db_type" = "unknown"; then
155         db_type=ndbm
156         DBLIB="$LIB_NDBM"
157       fi
158     else
159   
160       $as_unset ac_cv_func_dbm_firstkey
161       $as_unset ac_cv_funclib_dbm_firstkey
162   
163       AC_CHECK_HEADERS([                                \
164           gdbm/ndbm.h                           \
165       ])
166   
167       AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [
168       #include <stdio.h>
169       #include <gdbm/ndbm.h>
170       DBM *dbm;
171       ],[NULL])
172   
173       if test "$ac_cv_func_dbm_firstkey" = "yes"; then
174         if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then
175         LIB_NDBM="$ac_cv_funclib_dbm_firstkey"
176         else
177         LIB_NDBM=""
178         fi
179         AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl
180         have_ndbm=yes
181         if test "$db_type" = "unknown"; then
182         db_type=ndbm
183         DBLIB="$LIB_NDBM"
184         fi
185       fi
186     fi
187   fi #enable_ndbm_db
188 fi # unknown
190 if test "$have_ndbm" = "yes"; then
191   AC_MSG_CHECKING([if ndbm is implemented with db])
192   AC_RUN_IFELSE([AC_LANG_SOURCE([[
193 #include <unistd.h>
194 #include <fcntl.h>
195 #if defined(HAVE_GDBM_NDBM_H)
196 #include <gdbm/ndbm.h>
197 #elif defined(HAVE_NDBM_H)
198 #include <ndbm.h>
199 #elif defined(HAVE_DBM_H)
200 #include <dbm.h>
201 #endif
202 int main(int argc, char **argv)
204   DBM *d;
206   d = dbm_open("conftest", O_RDWR | O_CREAT, 0666);
207   if (d == NULL)
208     return 1;
209   dbm_close(d);
210   return 0;
211 }]])],[
212     if test -f conftest.db; then
213       AC_MSG_RESULT([yes])
214       AC_DEFINE(HAVE_NEW_DB, 1, [Define if NDBM really is DB (creates files *.db)])
215     else
216       AC_MSG_RESULT([no])
217     fi],[AC_MSG_RESULT([no])],[AC_MSG_RESULT([no-cross])])
220 AM_CONDITIONAL(HAVE_DB1, test "$db_type" = db1)dnl
221 AM_CONDITIONAL(HAVE_DB3, test "$db_type" = db3)dnl
222 AM_CONDITIONAL(HAVE_NDBM, test "$db_type" = ndbm)dnl
223 AM_CONDITIONAL(HAVE_DBHEADER, test "$dbheader" != "")dnl
225 ## it's probably not correct to include LDFLAGS here, but we might
226 ## need it, for now just add any possible -L
227 z=""
228 for i in $LDFLAGS; do
229         case "$i" in
230         -L*) z="$z $i";;
231         esac
232 done
233 DBLIB="$z $DBLIB"
234 AC_SUBST(DBLIB)dnl
235 AC_SUBST(LIB_NDBM)dnl