configure --with-external-db should fall back to external if unspecified.

configure.ac implies that there is a fall back to the internal db if
no external one is specified or found. But that doesn't work since
with_external_db defaults to no when not --with[out]-external-db isn't
given. Fix that by defaulting to "maybe" and then after the check for an
internal db fails fall back to the external db.h if available.

This keeps the current behavior of defaulting to --without-external-db (no)
if nothing is specified, but falls back to trying with the external one if
there is no in tree internal db. Giving an explicit --with-external-db or
--without-external-db doesn't change and produces an error if no external
or no internal db is found.
This commit is contained in:
Mark Wielaard 2016-03-18 17:14:43 +01:00 committed by Florian Festi
parent 64b6cbbb44
commit 9e64f8d5b7
1 changed files with 25 additions and 3 deletions

View File

@ -374,7 +374,7 @@ AC_ARG_WITH(external_db, [AS_HELP_STRING([--with-external-db],[build against an
yes|no) ;;
*) AC_MSG_ERROR([invalid argument to --with-external-db]) ;;
esac],
[with_external_db=no])
[with_external_db=maybe])
case "$with_external_db" in
yes )
@ -393,11 +393,33 @@ yes )
AC_MSG_ERROR([missing required header db.h])
])
;;
* ) # Fall back to internal db if available
no|maybe )
# Try internal database first, then fall back to external
# unless --without-external-db (no) was explicitly given.
if [ test -x db/dist/configure ]; then
AC_DEFINE(HAVE_DB_H, 1, [Define if you have the <db3/db.h> header file])
else
AC_MSG_ERROR([internal Berkeley DB directory not present, see INSTALL])
case "$with_external_db" in
maybe)
AC_CHECK_HEADERS([db.h],[
AC_PREPROC_IFELSE([
AC_LANG_SOURCE([
#include <db.h>
#if ((DB_VERSION_MAJOR < 4) || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 5))
#error Berkeley DB too old
#endif
])
],[ WITH_DB_LIB=-ldb ],
[ AC_MSG_ERROR([Berkeley DB version >= 4.5 required])
])
],[
AC_MSG_ERROR([missing required header db.h])
])
;;
no)
AC_MSG_ERROR([internal Berkeley DB directory not present, see INSTALL])
;;
esac
fi
;;
esac