1 |
jmc |
1.1 |
dnl $Id: berkdb.m4,v 1.11 2003/04/15 22:25:41 rjs3 Exp $ |
2 |
|
|
|
3 |
|
|
AC_DEFUN(CMU_DB_INC_WHERE1, [ |
4 |
|
|
saved_CPPFLAGS=$CPPFLAGS |
5 |
|
|
CPPFLAGS="$saved_CPPFLAGS -I$1" |
6 |
|
|
AC_TRY_COMPILE([#include <db.h>], |
7 |
|
|
[DB *db; |
8 |
|
|
db_create(&db, NULL, 0); |
9 |
|
|
db->open(db, "foo.db", NULL, DB_UNKNOWN, DB_RDONLY, 0644);], |
10 |
|
|
ac_cv_found_db_inc=yes, |
11 |
|
|
ac_cv_found_db_inc=no) |
12 |
|
|
CPPFLAGS=$saved_CPPFLAGS |
13 |
|
|
]) |
14 |
|
|
|
15 |
|
|
AC_DEFUN(CMU_DB_INC_WHERE, [ |
16 |
|
|
for i in $1; do |
17 |
|
|
AC_MSG_CHECKING(for db headers in $i) |
18 |
|
|
CMU_DB_INC_WHERE1($i) |
19 |
|
|
CMU_TEST_INCPATH($i, db) |
20 |
|
|
if test "$ac_cv_found_db_inc" = "yes"; then |
21 |
|
|
ac_cv_db_where_inc=$i |
22 |
|
|
AC_MSG_RESULT(found) |
23 |
|
|
break |
24 |
|
|
else |
25 |
|
|
AC_MSG_RESULT(not found) |
26 |
|
|
fi |
27 |
|
|
done |
28 |
|
|
]) |
29 |
|
|
|
30 |
|
|
# |
31 |
|
|
# Test for lib files |
32 |
|
|
# |
33 |
|
|
|
34 |
|
|
AC_DEFUN(CMU_DB3_LIB_WHERE1, [ |
35 |
|
|
AC_REQUIRE([CMU_AFS]) |
36 |
|
|
AC_REQUIRE([CMU_KRB4]) |
37 |
|
|
saved_LIBS=$LIBS |
38 |
|
|
LIBS="$saved_LIBS -L$1 -ldb-3" |
39 |
|
|
AC_TRY_LINK(, |
40 |
|
|
[db_env_create();], |
41 |
|
|
[ac_cv_found_db_3_lib=yes], |
42 |
|
|
ac_cv_found_db_3_lib=no) |
43 |
|
|
LIBS=$saved_LIBS |
44 |
|
|
]) |
45 |
|
|
AC_DEFUN(CMU_DB4_LIB_WHERE1, [ |
46 |
|
|
AC_REQUIRE([CMU_AFS]) |
47 |
|
|
AC_REQUIRE([CMU_KRB4]) |
48 |
|
|
saved_LIBS=$LIBS |
49 |
|
|
LIBS="$saved_LIBS -L$1 -ldb-4" |
50 |
|
|
AC_TRY_LINK(, |
51 |
|
|
[db_env_create();], |
52 |
|
|
[ac_cv_found_db_4_lib=yes], |
53 |
|
|
ac_cv_found_db_4_lib=no) |
54 |
|
|
LIBS=$saved_LIBS |
55 |
|
|
]) |
56 |
|
|
|
57 |
|
|
AC_DEFUN(CMU_DB_LIB_WHERE, [ |
58 |
|
|
for i in $1; do |
59 |
|
|
AC_MSG_CHECKING(for db libraries in $i) |
60 |
|
|
if test "$enable_db4" = "yes"; then |
61 |
|
|
CMU_DB4_LIB_WHERE1($i) |
62 |
|
|
CMU_TEST_LIBPATH($i, [db-4]) |
63 |
|
|
ac_cv_found_db_lib=$ac_cv_found_db_4_lib |
64 |
|
|
else |
65 |
|
|
CMU_DB3_LIB_WHERE1($i) |
66 |
|
|
CMU_TEST_LIBPATH($i, [db-3]) |
67 |
|
|
ac_cv_found_db_lib=$ac_cv_found_db_3_lib |
68 |
|
|
fi |
69 |
|
|
if test "$ac_cv_found_db_lib" = "yes" ; then |
70 |
|
|
ac_cv_db_where_lib=$i |
71 |
|
|
AC_MSG_RESULT(found) |
72 |
|
|
break |
73 |
|
|
else |
74 |
|
|
AC_MSG_RESULT(not found) |
75 |
|
|
fi |
76 |
|
|
done |
77 |
|
|
]) |
78 |
|
|
|
79 |
|
|
AC_DEFUN(CMU_USE_DB, [ |
80 |
|
|
AC_ARG_WITH(db, |
81 |
|
|
[ --with-db=PREFIX Compile with db support], |
82 |
|
|
[if test "X$with_db" = "X"; then |
83 |
|
|
with_db=yes |
84 |
|
|
fi]) |
85 |
|
|
AC_ARG_WITH(db-lib, |
86 |
|
|
[ --with-db-lib=dir use db libraries in dir], |
87 |
|
|
[if test "$withval" = "yes" -o "$withval" = "no"; then |
88 |
|
|
AC_MSG_ERROR([No argument for --with-db-lib]) |
89 |
|
|
fi]) |
90 |
|
|
AC_ARG_WITH(db-include, |
91 |
|
|
[ --with-db-include=dir use db headers in dir], |
92 |
|
|
[if test "$withval" = "yes" -o "$withval" = "no"; then |
93 |
|
|
AC_MSG_ERROR([No argument for --with-db-include]) |
94 |
|
|
fi]) |
95 |
|
|
AC_ARG_ENABLE(db4, |
96 |
|
|
[ --enable-db4 use db 4.x libraries]) |
97 |
|
|
|
98 |
|
|
if test "X$with_db" != "X"; then |
99 |
|
|
if test "$with_db" != "yes"; then |
100 |
|
|
ac_cv_db_where_lib=$with_db/lib |
101 |
|
|
ac_cv_db_where_inc=$with_db/include |
102 |
|
|
fi |
103 |
|
|
fi |
104 |
|
|
|
105 |
|
|
if test "X$with_db_lib" != "X"; then |
106 |
|
|
ac_cv_db_where_lib=$with_db_lib |
107 |
|
|
fi |
108 |
|
|
if test "X$ac_cv_db_where_lib" = "X"; then |
109 |
|
|
CMU_DB_LIB_WHERE(/usr/athena/lib /usr/lib /usr/local/lib) |
110 |
|
|
fi |
111 |
|
|
|
112 |
|
|
if test "X$with_db_include" != "X"; then |
113 |
|
|
ac_cv_db_where_inc=$with_db_include |
114 |
|
|
fi |
115 |
|
|
if test "X$ac_cv_db_where_inc" = "X"; then |
116 |
|
|
CMU_DB_INC_WHERE(/usr/athena/include /usr/local/include) |
117 |
|
|
fi |
118 |
|
|
|
119 |
|
|
AC_MSG_CHECKING(whether to include db) |
120 |
|
|
if test "X$ac_cv_db_where_lib" = "X" -o "X$ac_cv_db_where_inc" = "X"; then |
121 |
|
|
ac_cv_found_db=no |
122 |
|
|
AC_MSG_RESULT(no) |
123 |
|
|
else |
124 |
|
|
ac_cv_found_db=yes |
125 |
|
|
AC_MSG_RESULT(yes) |
126 |
|
|
DB_INC_DIR=$ac_cv_db_where_inc |
127 |
|
|
DB_LIB_DIR=$ac_cv_db_where_lib |
128 |
|
|
DB_INC_FLAGS="-I${DB_INC_DIR}" |
129 |
|
|
if test "$enable_db4" = "yes"; then |
130 |
|
|
DB_LIB_FLAGS="-L${DB_LIB_DIR} -ldb-4" |
131 |
|
|
else |
132 |
|
|
DB_LIB_FLAGS="-L${DB_LIB_DIR} -ldb-3" |
133 |
|
|
fi |
134 |
|
|
dnl Do not force configure.in to put these in CFLAGS and LIBS unconditionally |
135 |
|
|
dnl Allow makefile substitutions.... |
136 |
|
|
AC_SUBST(DB_INC_FLAGS) |
137 |
|
|
AC_SUBST(DB_LIB_FLAGS) |
138 |
|
|
if test "X$RPATH" = "X"; then |
139 |
|
|
RPATH="" |
140 |
|
|
fi |
141 |
|
|
case "${host}" in |
142 |
|
|
*-*-linux*) |
143 |
|
|
if test "X$RPATH" = "X"; then |
144 |
|
|
RPATH="-Wl,-rpath,${DB_LIB_DIR}" |
145 |
|
|
else |
146 |
|
|
RPATH="${RPATH}:${DB_LIB_DIR}" |
147 |
|
|
fi |
148 |
|
|
;; |
149 |
|
|
*-*-hpux*) |
150 |
|
|
if test "X$RPATH" = "X"; then |
151 |
|
|
RPATH="-Wl,+b${DB_LIB_DIR}" |
152 |
|
|
else |
153 |
|
|
RPATH="${RPATH}:${DB_LIB_DIR}" |
154 |
|
|
fi |
155 |
|
|
;; |
156 |
|
|
*-*-irix*) |
157 |
|
|
if test "X$RPATH" = "X"; then |
158 |
|
|
RPATH="-Wl,-rpath,${DB_LIB_DIR}" |
159 |
|
|
else |
160 |
|
|
RPATH="${RPATH}:${DB_LIB_DIR}" |
161 |
|
|
fi |
162 |
|
|
;; |
163 |
|
|
*-*-solaris2*) |
164 |
|
|
if test "$ac_cv_prog_gcc" = yes; then |
165 |
|
|
if test "X$RPATH" = "X"; then |
166 |
|
|
RPATH="-Wl,-R${DB_LIB_DIR}" |
167 |
|
|
else |
168 |
|
|
RPATH="${RPATH}:${DB_LIB_DIR}" |
169 |
|
|
fi |
170 |
|
|
else |
171 |
|
|
RPATH="${RPATH} -R${DB_LIB_DIR}" |
172 |
|
|
fi |
173 |
|
|
;; |
174 |
|
|
esac |
175 |
|
|
AC_SUBST(RPATH) |
176 |
|
|
fi |
177 |
|
|
]) |
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
dnl ---- CUT HERE --- |
182 |
|
|
|
183 |
|
|
dnl These are the Cyrus Berkeley DB macros. In an ideal world these would be |
184 |
|
|
dnl identical to the above. |
185 |
|
|
|
186 |
|
|
dnl They are here so that they can be shared between Cyrus IMAPd |
187 |
|
|
dnl and Cyrus SASL with relative ease. |
188 |
|
|
|
189 |
|
|
dnl The big difference between this and the ones above is that we don't assume |
190 |
|
|
dnl that we know the name of the library, and we try a lot of permutations |
191 |
|
|
dnl instead. We also assume that DB4 is acceptable. |
192 |
|
|
|
193 |
|
|
dnl When we're done, there will be a BDB_LIBADD and a BDB_INCADD which should |
194 |
|
|
dnl be used when necessary. We should probably be smarter about our RPATH |
195 |
|
|
dnl handling. |
196 |
|
|
|
197 |
|
|
dnl Call these with BERKELEY_DB_CHK. |
198 |
|
|
|
199 |
|
|
dnl We will also set $dblib to "berkeley" if we are successful, "no" otherwise. |
200 |
|
|
|
201 |
|
|
dnl this is unbelievably painful due to confusion over what db-3 should be |
202 |
|
|
dnl named and where the db-3 header file is located. arg. |
203 |
|
|
AC_DEFUN(CYRUS_BERKELEY_DB_CHK_LIB, |
204 |
|
|
[ |
205 |
|
|
BDB_SAVE_LIBS=$LIBS |
206 |
|
|
|
207 |
|
|
if test -d $with_bdb_lib; then |
208 |
|
|
CMU_ADD_LIBPATH_TO($with_bdb_lib, LIBS) |
209 |
|
|
CMU_ADD_LIBPATH_TO($with_bdb_lib, BDB_LIBADD) |
210 |
|
|
else |
211 |
|
|
BDB_LIBADD="" |
212 |
|
|
fi |
213 |
|
|
|
214 |
|
|
for dbname in db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db |
215 |
|
|
do |
216 |
|
|
AC_CHECK_LIB($dbname, db_create, BDB_LIBADD="$BDB_LIBADD -l$dbname"; |
217 |
|
|
dblib="berkeley"; break, dblib="no") |
218 |
|
|
done |
219 |
|
|
if test "$dblib" = "no"; then |
220 |
|
|
AC_CHECK_LIB(db, db_open, BDB_LIBADD="$BDB_LIBADD -ldb"; |
221 |
|
|
dblib="berkeley"; dbname=db, |
222 |
|
|
dblib="no") |
223 |
|
|
fi |
224 |
|
|
|
225 |
|
|
LIBS=$BDB_SAVE_LIBS |
226 |
|
|
]) |
227 |
|
|
|
228 |
|
|
AC_DEFUN(CYRUS_BERKELEY_DB_OPTS, |
229 |
|
|
[ |
230 |
|
|
AC_ARG_WITH(bdb-libdir, |
231 |
|
|
[ --with-bdb-libdir=DIR Berkeley DB lib files are in DIR], |
232 |
|
|
with_bdb_lib=$withval, |
233 |
|
|
[ test "${with_bdb_lib+set}" = set || with_bdb_lib=none]) |
234 |
|
|
AC_ARG_WITH(bdb-incdir, |
235 |
|
|
[ --with-bdb-incdir=DIR Berkeley DB include files are in DIR], |
236 |
|
|
with_bdb_inc=$withval, |
237 |
|
|
[ test "${with_bdb_inc+set}" = set || with_bdb_inc=none ]) |
238 |
|
|
]) |
239 |
|
|
|
240 |
|
|
AC_DEFUN(CYRUS_BERKELEY_DB_CHK, |
241 |
|
|
[ |
242 |
|
|
AC_REQUIRE([CYRUS_BERKELEY_DB_OPTS]) |
243 |
|
|
|
244 |
|
|
cmu_save_CPPFLAGS=$CPPFLAGS |
245 |
|
|
|
246 |
|
|
if test -d $with_bdb_inc; then |
247 |
|
|
CPPFLAGS="$CPPFLAGS -I$with_bdb_inc" |
248 |
|
|
BDB_INCADD="-I$with_bdb_inc" |
249 |
|
|
else |
250 |
|
|
BDB_INCADD="" |
251 |
|
|
fi |
252 |
|
|
|
253 |
|
|
dnl Note that FreeBSD puts it in a wierd place |
254 |
|
|
dnl (but they should use with-bdb-incdir) |
255 |
|
|
AC_CHECK_HEADER(db.h, |
256 |
|
|
CYRUS_BERKELEY_DB_CHK_LIB(), |
257 |
|
|
dblib="no") |
258 |
|
|
|
259 |
|
|
CPPFLAGS=$cmu_save_CPPFLAGS |
260 |
|
|
]) |