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