2 AC_INIT([onak],[0.4.0],[noodles-onak@earth.li])
3 AC_CONFIG_SRCDIR(onak.c)
4 AC_CONFIG_HEADER(config.h)
11 m4_include([m4/ax_lib_nettle.m4])
15 dnl We should always have these backends available.
16 backends="file fs keyd"
18 AC_CHECK_LIB(pq, PQsetdbLogin,[have_libpq="yes" backends="$backends pg"],have_libpq="no")
20 AC_CHECK_HEADER(db.h, have_db_h="yes", have_db_h="no")
21 AC_MSG_CHECKING(for libdb version in db.h)
22 printf "#include <db.h>\nDB_VERSION_MAJOR DB_VERSION_MINOR\n" >conftest.c
23 set `eval $ac_cpp conftest.c | egrep '^ *[[0-9]] *'`; v="$1"; vv="$2"
25 if test "$v" -ge 4; then
26 for db in "db-$v.$vv" "db$v.$vv" "db-$v" "db$v" "db"; do
27 AC_MSG_CHECKING(for db_create in lib$db)
31 AC_TRY_LINK([#include <db.h>], db_create(0, 0, 0),
32 have_libdb="yes", have_libdb="no")
33 AC_MSG_RESULT($have_libdb)
35 if test "$have_libdb" != "no"; then break; fi
38 if test "$have_libdb" = "yes" -a "$have_db_h" = "yes"; then
39 AC_DEFINE(HAVE_LIBDB4, 1, [libdb found])
40 backends="$backends db4"
43 AC_MSG_CHECKING(available backends)
44 AC_MSG_RESULT($backends)
46 AC_ARG_ENABLE(backend,AC_HELP_STRING([--enable-backend=<backend>],[Choose the backend database to use. Defaults to dynamic.]), [], [enable_backend="dynamic"])
48 AC_ARG_ENABLE(keyd,AC_HELP_STRING([--enable-keyd],[Use keyd as the DB backend.]), [], [])
50 AC_MSG_CHECKING([which key database backend to use])
51 AC_MSG_RESULT([$enable_backend])
52 AC_CHECK_FILE([$srcdir/keydb_$enable_backend.c], ,AC_MSG_ERROR([non existent key database backend $enable_backend]))
54 if test "x$enable_backend" = "xdb4"
56 if test "$have_libdb" = "no" -o "$have_db_h" = "no"; then
57 AC_MSG_ERROR(libdb not found.)
60 else if test "x$enable_backend" = "xpg"
62 if test "$have_libpq" = "no"; then
63 AC_MSG_ERROR(libpq not found.)
69 dnl If we are explicitly told which backend to use, only build that one.
70 if test "x$enable_backend" = "xdb4"
72 backend="$enable_backend"
75 AC_SUBST(DBTYPE, $enable_backend)
76 AC_SUBST(DB4LIBS, $db4libs)
77 AC_SUBST(KEYD, $enable_keyd)
78 AC_SUBST(BACKENDS, $backends)
80 AC_CONFIG_FILES(Makefile)