+AC_ARG_WITH(gdbm, [ --with-gdbm[=DIR] use GDBM [DIR=/usr/local]])
+AC_ARG_WITH(db, [ --with-db[=DIR] use Sleepycat DB 3.1 [DIR=/usr/local/BerkeleyDB.3.1]])
+
+if test "x$with_gdbm" != xno -a "x$with_gdbm" != xyeso -a "$with_gdbm"; then
+ db_dir="$with_gdbm"
+ with_gdbm=yes
+else
+ test -f /usr/local/lib/libgdbm.a -o -f /usr/local/lib/libgdbm.so && db_dir=/usr/local
+fi
+
+if test "x$with_db" != xno -a "x$with_db" != xyes -a "$with_db"; then
+ db_dir="$with_db"
+ with_db=yes
+else
+ test -d /usr/local/BerkeleyDB.3.1 && db_dir=/usr/local/BerkeleyDB.3.1
+fi
+
+if test "x$with_gdbm" = xyes -a "x$with_db" = xyes; then
+ AC_MSG_ERROR(can't enable both gdbm and db)
+fi