From 9e64f8d5b7260bffa9fcfd1c1a408cfe1db65cf7 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 18 Mar 2016 17:14:43 +0100 Subject: [PATCH] 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. --- configure.ac | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3befb1577..b77160b61 100644 --- a/configure.ac +++ b/configure.ac @@ -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 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 + #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