]> git.sommitrealweird.co.uk Git - onak.git/blob - configure.ac
f2bdfd1cb28e097b8417854f58e956aa6d7a26c0
[onak.git] / configure.ac
1 AC_PREREQ(2.50)
2 AC_INIT([onak],[0.4.0],[noodles-onak@earth.li])
3 AC_CONFIG_SRCDIR(onak.c)
4 AC_CONFIG_HEADER(config.h)
5
6 AC_PROG_CC
7
8 AC_C_BIGENDIAN
9
10 m4_include([m4/ax_lib_nettle.m4])
11
12 AX_LIB_NETTLE(auto)
13
14 dnl We should always have these backends available.
15 backends="file fs keyd"
16
17 AC_CHECK_LIB(pq, PQsetdbLogin,[have_libpq="yes" backends="$backends pg"],have_libpq="no")
18
19 AC_CHECK_HEADER(db.h, have_db_h="yes", have_db_h="no")
20 AC_MSG_CHECKING(for libdb version in db.h)
21 printf "#include <db.h>\nDB_VERSION_MAJOR DB_VERSION_MINOR\n" >conftest.c
22 set `eval $ac_cpp conftest.c | egrep '^ *[[0-9]] *'`; v="$1"; vv="$2"
23 AC_MSG_RESULT($v.$vv)
24 if test "$v" -ge 4; then
25         for db in "db-$v.$vv" "db$v.$vv" "db-$v" "db$v" "db"; do
26                 AC_MSG_CHECKING(for db_create in lib$db)
27                 oldLIBS="$LIBS"
28                 LIBS="$LIBS -l$db"
29                 db4libs="-l$db"
30                 AC_TRY_LINK([#include <db.h>], db_create(0, 0, 0),
31                         have_libdb="yes", have_libdb="no")
32                 AC_MSG_RESULT($have_libdb)
33                 LIBS="$oldLIBS"
34                 if test "$have_libdb" != "no"; then break; fi
35         done
36 fi
37 if test "$have_libdb" = "yes" -a "$have_db_h" = "yes"; then
38         AC_DEFINE(HAVE_LIBDB4, 1, [libdb found])
39         backends="$backends db4"
40 fi
41
42 AC_MSG_CHECKING(available backends)
43 AC_MSG_RESULT($backends)
44
45 AC_ARG_ENABLE(backend,AC_HELP_STRING([--enable-backend=<backend>],[Choose the backend database to use. Defaults to dynamic.]), [], [enable_backend="dynamic"])
46
47 AC_ARG_ENABLE(keyd,AC_HELP_STRING([--enable-keyd],[Use keyd as the DB backend.]), [], [])
48
49 AC_MSG_CHECKING([which key database backend to use])
50 AC_MSG_RESULT([$enable_backend])
51 AC_CHECK_FILE([$srcdir/keydb_$enable_backend.c], ,AC_MSG_ERROR([non existent key database backend $enable_backend]))
52
53 if test "x$enable_backend" = "xdb4"
54 then
55         if test "$have_libdb" = "no" -o "$have_db_h" = "no"; then
56                 AC_MSG_ERROR(libdb not found.)
57         fi
58         LIBS="$LIBS $db4libs"
59 else if test "x$enable_backend" = "xpg"
60 then
61         if test "$have_libpq" = "no"; then
62                 AC_MSG_ERROR(libpq not found.)
63         fi
64         LIBS="$LIBS -lpq"
65 fi
66 fi
67
68 dnl If we are explicitly told which backend to use, only build that one.
69 if test "x$enable_backend" = "xdb4"
70 then
71         backend="$enable_backend"
72 fi
73
74 AC_SUBST(DBTYPE, $enable_backend)
75 AC_SUBST(DB4LIBS, $db4libs)
76 AC_SUBST(KEYD, $enable_keyd)
77 AC_SUBST(BACKENDS, $backends)
78
79 AC_CONFIG_FILES(Makefile)
80
81 AC_OUTPUT