configure: Check common include subdirectories for bdb headers, and refuse to use any version other than 4.8 by default

This commit is contained in:
Luke Dashjr 2013-09-07 19:43:25 +00:00
parent b4d8d03b86
commit 941dba1783
5 changed files with 86 additions and 2 deletions

View file

@ -128,6 +128,7 @@ dnl Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXXCPP
AC_PROG_INSTALL
AC_PROG_OBJC
m4_ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX])
@ -334,8 +335,7 @@ AC_TRY_COMPILE([#include <sys/socket.h>],
)
dnl Check for libdb_cxx
AC_CHECK_HEADER([db_cxx.h],,AC_MSG_ERROR(libdb_cxx headers missing))
AC_CHECK_LIB([db_cxx], [main],, AC_MSG_ERROR(libdb_cxx missing))
BITCOIN_FIND_BDB48
dnl Check for libminiupnpc (optional)
if test x$use_upnp != xno; then

View file

@ -47,6 +47,9 @@ bitcoind_LDADD = libbitcoin.a leveldb/libleveldb.a leveldb/libmemenv.a \
bitcoind_SOURCES = bitcoind.cpp
#
AM_CPPFLAGS += $(BDB_CPPFLAGS)
bitcoind_LDADD += $(BDB_LIBS)
leveldb/libleveldb.a:
@echo "Building LevelDB ..." && cd leveldb && CXX="$(CXX)" CC="$(CC)" \
PLATFORM=$(TARGET_OS) AR="$(AR)" $(MAKE) $(LEVELDB_TARGET_FLAGS) OPT="$(CXXFLAGS) $(CPPFLAGS)" libleveldb.a

View file

@ -5,6 +5,9 @@ LIBLEVELDB=$(top_builddir)/src/leveldb/libleveldb.a
LIBMEMENV=$(top_builddir)/src/leveldb/libmemenv.a
LIBBITCOINQT=$(top_builddir)/src/qt/libbitcoinqt.a
INCLUDES += $(BDB_CPPFLAGS)
LIBBITCOIN += $(BDB_LIBS)
$(LIBBITCOIN):
$(MAKE) -C $(top_builddir)/src $(@F)

View file

@ -0,0 +1,66 @@
AC_DEFUN([BITCOIN_FIND_BDB48],[
AC_MSG_CHECKING([for Berkeley DB C++ headers])
BDB_CPPFLAGS=
BDB_LIBS=
bdbpath=X
bdb48path=X
bdbdirlist=
for _vn in 4.8 48 4 5 ''; do
for _pfx in b lib ''; do
bdbdirlist="$bdbdirlist ${_pfx}db${_vn}"
done
done
for searchpath in $bdbdirlist ''; do
test -n "${searchpath}" && searchpath="${searchpath}/"
AC_TRY_COMPILE([
#include <${searchpath}db_cxx.h>
],[
#if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4)
#error "failed to find bdb 4.8+"
#endif
],[
if test "x$bdbpath" = "xX"; then
bdbpath="${searchpath}"
fi
],[
continue
])
AC_TRY_COMPILE([
#include <${searchpath}db_cxx.h>
],[
#if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)
#error "failed to find bdb 4.8"
#endif
],[
bdb48path="${searchpath}"
break
])
done
if test "x$bdbpath" = "xX"; then
AC_MSG_RESULT([no])
AC_MSG_ERROR(libdb_cxx headers missing)
elif test "x$bdb48path" = "xX"; then
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx)
AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[
AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!])
],[
AC_MSG_ERROR([Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore)])
])
else
BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx)
bdbpath="${bdb48path}"
fi
AC_SUBST(BDB_CPPFLAGS)
# TODO: Ideally this could find the library version and make sure it matches the headers being used
for searchlib in db_cxx-4.8 db_cxx; do
AC_CHECK_LIB([$searchlib],[main],[
BDB_LIBS="-l${searchlib}"
break
])
done
if test "x$BDB_LIBS" = "x"; then
AC_MSG_ERROR(libdb_cxx missing)
fi
AC_SUBST(BDB_LIBS)
])

View file

@ -0,0 +1,12 @@
dnl BITCOIN_SUBDIR_TO_INCLUDE([CPPFLAGS-VARIABLE-NAME],[SUBDIRECTORY-NAME],[HEADER-FILE])
dnl SUBDIRECTORY-NAME must end with a path separator
AC_DEFUN([BITCOIN_SUBDIR_TO_INCLUDE],[
if test "x$2" = "x"; then
AC_MSG_RESULT([default])
else
echo "#include <$2$3.h>" >conftest.cpp
newinclpath=`${CXXCPP} -M conftest.cpp 2>/dev/null | [ tr -d '\\n\\r\\\\' | sed -e 's/^.*[[:space:]:]\(\/[^[:space:]]*\)]$3[\.h[[:space:]].*$/\1/' -e t -e d`]
AC_MSG_RESULT([${newinclpath}])
eval "$1=\"\$$1\"' -I${newinclpath}'"
fi
])