summaryrefslogtreecommitdiffstats
path: root/m4/pdns_check_lmdb.m4
blob: 5a54f0739107814737ded63bc99a49edda09c89e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
dnl invoking this makes lmdb a requirement
AC_DEFUN([PDNS_CHECK_LMDB], [
  AC_MSG_CHECKING([where to find the lmdb library and headers])
  AC_ARG_WITH([lmdb],
    AS_HELP_STRING([--with-lmdb], [lmdb library to use @<:@default=auto@:>@]),[
    with_lmdb=$withval
    ],[
    with_lmdb=auto
  ])
  AC_MSG_RESULT([$with_lmdb])

  AS_IF([test "$with_lmdb" != "no"], [
    AS_IF([test "x$with_lmdb" = "xyes" -o "x$with_lmdb" = "xauto"], [
      PKG_CHECK_MODULES([LMDB], [lmdb], [
        AC_DEFINE([HAVE_LMDB], [1], [Define to 1 if you have LMDB])
        [HAVE_LMDB=1]
        ], [ : ]
      )
    ], [
      save_CPPFLAGS=$CPPFLAGS
      save_LIBS=$LIBS
      AS_IF([test -d "$with_lmdb/include"], [
        LMDB_CFLAGS="-I$with_lmdb/include"
        LMDB_LIBS="-L$with_lmdb/lib"
      ],[
        LMDB_CFLAGS="-I$with_lmdb"
        LMDB_LIBS="-L$with_lmdb"
      ])
      CPPFLAGS="$LMDB_CFLAGS"
      LIBS="$LMDB_LIBS"

      AC_SEARCH_LIBS([mdb_env_open], [lmdb], [
        AC_CHECK_HEADERS([lmdb.h], [
          dnl ac_cv_search_mdb_env_open contains '-llmdb'
          LMDB_LIBS="$LMDB_LIBS $ac_cv_search_mdb_env_open"
          AC_DEFINE([HAVE_LMDB], [1], [Define to 1 if you have LMDB])
          [HAVE_LMDB=1]
        ], [
          AC_MSG_ERROR([lmdb headers not found in $with_lmdb])
        ])
        CPPFLAGS="$save_CPPFLAGS"
        LIBS="$save_LIBS"
        AC_SUBST([LMDB_CFLAGS])
        AC_SUBST([LMDB_LIBS])
      ])
    ])
  ])
  AM_CONDITIONAL([HAVE_LMDB], [test "x$LMDB_LIBS" != "x"])
])