Commit 4b260414 authored by Bernhard Link's avatar Bernhard Link

rework detection of libdb version available

parent 980041d2
......@@ -12,4 +12,30 @@ AC_CACHE_CHECK([for $1 in $2], check_Enum,
[AS_VAR_SET(check_Enum, no)])])
AS_IF([test AS_VAR_GET(check_Enum) = yes], [$3], [$4])[]dnl
AS_VAR_POPDEF([check_Enum])dnl
])#
])dnl
# extract the value of a #define from a header
m4_define([GET_DEFINE],
[AC_LANG_PREPROC_REQUIRE()dnl
AS_VAR_PUSHDEF(get_Define, [cv_get_define_$1])dnl
AC_CACHE_CHECK([for $1], get_Define,
[dnl
m4_ifvaln([$2],[dnl
echo "#include <$2>" > conftest.$ac_ext
echo "$1" >> conftest.$ac_ext
],[dnl
echo "$1" > conftest.$ac_ext
])
if _AC_EVAL_STDERR([$ac_cpp conftest.$ac_ext >conftest.out]) >/dev/null; then
if test -s conftest.err; then
AS_VAR_SET(get_Define, $1)
else
AS_VAR_SET(get_Define, "$(tail -1 conftest.out)")
fi
else
AS_VAR_SET(get_Define, $1)
fi
rm -f conftest.err conftest.out conftest.$ac_ext
])
AS_IF([test AS_VAR_GET(get_Define) = $1], [$3], [$1=AS_VAR_GET(get_Define)])[]dnl
AS_VAR_POPDEF([get_Define])dnl
])dnl GET_DEFINE
......@@ -12,68 +12,102 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_SYS_LARGEFILE
AC_CHECK_LIB(z,gzopen,,[AC_MSG_ERROR(["no zlib found"])],)
AC_CHECK_LIB(gpgme,gpgme_check_version,,[AC_MSG_ERROR(["no libgpgme found"])],)
AC_CHECK_HEADER(gpgme.h,,[AC_MSG_ERROR(["no gpgme.h found"])])
AH_TEMPLATE([HASGPGMEGOODEXP],[Defined if libgpgme contains GPGME_SIG_STAT_GOOD_EXP])
CHECK_ENUM(GPGME_SIG_STAT_GOOD_EXP,[gpgme.h],[AC_DEFINE_UNQUOTED(AS_TR_CPP(HASGPGMEGOODEXP))],[],)
DBLIBS=""
DBCPPFLAGS=""
AH_TEMPLATE([LIBDB_VERSION],[variant of libdb used])
AC_ARG_WITH(libdb,
[ --with-libdb=path|4.4|4.3|3 Give prefix of libdb-4.4 or older version to use],[dnl
[ --with-libdb=path|4.4|4.3|3 Give prefix of libdb-4.3 or older version to use],[dnl
case "$withval" in
no)
AC_MSG_ERROR(["Cannot compile without libdb"]);
;;
3)
AC_CHECK_LIB(db3,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),3)
DBLIBS="-ldb3"
],[AC_MSG_ERROR(["no libdb3 found"])],)
DB_WANT_VERSION=3
;;
4.3)
AC_CHECK_LIB(db-4.3,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),43)
DBLIBS="-ldb-4.3"
],[AC_MSG_ERROR(["no libdb-4.3 found"])],)
yes|4.3)
DB_WANT_VERSION=4.3
;;
yes|4.4)
AC_CHECK_LIB(db-4.4,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),44)
DBLIBS="-ldb-4.4"
],[AC_MSG_ERROR(["no libdb-4.4 found"])],)
4.4)
DB_WANT_VERSION=4.4
;;
?|?.?)
AC_MSG_ERROR([Unknown --with-libdb argument $withval])
;;
*)
AC_CHECK_LIB(db-4.4,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),44)
DBLIBS="-ldb-4.4 -L$withval/lib"
DBCPPFLAGS="-I$withval/include"
],[AC_MSG_ERROR(["no libdb-4.4 found in $withval/lib"])],[-L$withval/lib])
DB_WANT_VERSION=any
DBLIBS="-L$withval/lib"
DBCPPFLAGS="-I$withval/include"
;;
esac
],[dnl without --with-libdb-4.4 we look for first for libdb-4.4 then for libdb3
AC_CHECK_LIB(db-4.4,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),44)
DBLIBS="-ldb-4.4"
],[AC_CHECK_LIB(db-4.3,db_create,[dnl
AC_MSG_WARN([using libdb3 instead of libdb-4.3])
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),43)
DBLIBS="-ldb-4.3"
],[AC_CHECK_LIB(db3,db_create,[dnl
AC_MSG_WARN([using libdb3 instead of libdb-4.4])
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),3)
DBLIBS="-ldb3"
],[AC_MSG_ERROR(["no libdb-4.4 or libdb3 found"])],)],)],)
])
],[DB_WANT_VERSION=any])
# the only way to find out which is compileable is to look into db.h:
mysave_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $DBCPPFLAGS"
AC_CHECK_HEADER(db.h,,[AC_MSG_ERROR(["no db.h found"])])
GET_DEFINE(DB_VERSION_MAJOR,db.h,[AC_MSG_ERROR("Unable to retrieve DB_VERSION_MAJOR from db.h")])
GET_DEFINE(DB_VERSION_MINOR,db.h,[AC_MSG_ERROR("Unable to retrieve DB_VERSION_MINOR from db.h")])
CPPFLAGS="$mysave_CPPFLAGS"
# now make sure what we found is what we want
if test "x$DB_VERSION_MAJOR" = "x3" ; then
if test "$DB_WANT_VERSION" = "any" ; then
DB_WANT_VERSION=3
elif test "$DB_WANT_VERSION" != "3" ; then
AC_MSG_ERROR([Found libdb major version $DB_VERSION_MAJOR.$DB_VERSION_MINOR, need $DB_WANT_VERSION])
fi
elif test "x$DB_VERSION_MAJOR" = "x4" -a "x$DB_VERSION_MINOR" = "x3" ; then
if test "$DB_WANT_VERSION" = "any" ; then
DB_WANT_VERSION=4.3
elif test "$DB_WANT_VERSION" != "4.3" ; then
AC_MSG_ERROR([Found libdb version $DB_VERSION_MAJOR.$DB_VERSION_MINOR, need $DB_WANT_VERSION])
fi
elif test "x$DB_VERSION_MAJOR" = "x4" -a "x$DB_VERSION_MINOR" = "x4" ; then
if test "$DB_WANT_VERSION" = "any" ; then
DB_WANT_VERSION=4.4
elif test "$DB_WANT_VERSION" != "4.4" ; then
AC_MSG_ERROR([Found libdb major version $DB_VERSION_MAJOR.$DB_VERSION_MINOR, need $DB_WANT_VERSION])
fi
else
AC_MSG_ERROR([Unsupported libdb major $DB_VERSION_MAJOR minor $DB_VERSION_MINOR
Only 4.3 (stronly recommended) or 3.2 or 4.4 are supported])
fi
# now we have a header with the expected version, check for the library:
case "$DB_WANT_VERSION" in
4.4)
AC_CHECK_LIB(db-4.4,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),44)
DBLIBS="-ldb-4.4 $DBLIBS"
],[AC_MSG_ERROR(["no libdb-4.4 found"])],[$DBLIBS])
;;
4.3)
AC_CHECK_LIB(db-4.3,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),43)
DBLIBS="-ldb-4.3 $DBLIBS"
],[AC_MSG_ERROR(["no libdb-4.3 found"])],[$DBLIBS])
;;
3)
AC_CHECK_LIB(db3,db_create,[dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(LIBDB_VERSION),3)
DBLIBS="-ldb3 $DBLIBS"
],[AC_MSG_ERROR(["no libdb3 found"])],[$DBLIBS])
;;
*)
AC_MSG_ERROR([Internal error: DB_WANT_VERSION=$DB_WANT_VERSION])
esac
AC_SUBST([DBLIBS])
AC_SUBST([DBCPPFLAGS])
AC_CHECK_LIB(z,gzopen,,[AC_MSG_ERROR(["no zlib found"])],)
AC_CHECK_LIB(gpgme,gpgme_check_version,,[AC_MSG_ERROR(["no libgpgme found"])],)
AC_CHECK_HEADER(gpgme.h,,[AC_MSG_ERROR(["no gpgme.h found"])])
AH_TEMPLATE([HASGPGMEGOODEXP],[Defined if libgpgme contains GPGME_SIG_STAT_GOOD_EXP])
CHECK_ENUM(GPGME_SIG_STAT_GOOD_EXP,[gpgme.h],[AC_DEFINE_UNQUOTED(AS_TR_CPP(HASGPGMEGOODEXP))],[],)
AC_ARG_WITH(libbz2,
[ --with-libbz2=path|yes|no Give path to prefix libbz2 was installed with],[dnl
case "$withval" in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment