]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/tinycdb.m4
75a629da62a892bf98345d728a5a15fd71d4b840
[kerberos/krb5-strength.git] / m4 / tinycdb.m4
1 dnl Find the compiler and linker flags for libcdb.
2 dnl
3 dnl Finds the compiler and linker flags for linking with the libcdb library.
4 dnl Provides the --with-libcdb, --with-libcdb-lib, and --with-libcdb-include
5 dnl configure options to specify non-standard paths to libcdb libraries.
6 dnl
7 dnl Provides the macros RRA_LIB_CDB and RRA_LIB_CDB_OPTIONAL and sets the
8 dnl substitution variables CDB_CPPFLAGS, CDB_LDFLAGS, and CDB_LIBS.  Also
9 dnl provides RRA_LIB_CDB_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include
10 dnl the kadmin client libraries, saving the ecurrent values, and
11 dnl RRA_LIB_CDB_RESTORE to restore those settings to before the last
12 dnl RRA_LIB_CDB_SWITCH.  Defines HAVE_CDB and sets rra_use_CDB to true if the
13 dnl library is found.
14 dnl
15 dnl Depends on the lib-helper.m4 infrastructure.
16 dnl
17 dnl Written by Russ Allbery <eagle@eyrie.org>
18 dnl Copyright 2010, 2013
19 dnl     The Board of Trustees of the Leland Stanford Junior University
20 dnl
21 dnl This file is free software; the authors give unlimited permission to copy
22 dnl and/or distribute it, with or without modifications, as long as this
23 dnl notice is preserved.
24
25 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
26 dnl versions that include the kadmin client flags.  Used as a wrapper, with
27 dnl RRA_LIB_CDB_RESTORE, around tests.
28 AC_DEFUN([RRA_LIB_CDB_SWITCH], [RRA_LIB_HELPER_SWITCH([CDB])])
29
30 dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before
31 dnl RRA_LIB_CDB_SWITCH was called).
32 AC_DEFUN([RRA_LIB_CDB_RESTORE], [RRA_LIB_HELPER_RESTORE([CDB])])
33
34 dnl Checks if the libcdb library is present.  The single argument, if "true",
35 dnl says to fail if the libcdb library could not be found.
36 AC_DEFUN([_RRA_LIB_CDB_INTERNAL],
37 [RRA_LIB_HELPER_PATHS([CDB])
38  RRA_LIB_CDB_SWITCH
39  AC_CHECK_LIB([cdb], [cdb_init],
40     [CDB_LIBS=-lcdb
41      AC_DEFINE([HAVE_CDB], 1, [Define if libcdb is available.])
42      rra_use_CDB=true],
43     [AS_IF([test x"$1" = xtrue],
44         [AC_MSG_ERROR([cannot find usable TinyCDB library])])])
45  AC_CHECK_HEADERS([cdb.h])
46  RRA_LIB_CDB_RESTORE])
47
48 dnl The main macro for packages with mandatory kadmin client support.
49 AC_DEFUN([RRA_LIB_CDB],
50 [RRA_LIB_HELPER_VAR_INIT([CDB])
51  RRA_LIB_HELPER_WITH([tinycdb], [TinyCDB], [CDB])
52  _RRA_LIB_CDB_INTERNAL([true])])
53
54 dnl The main macro for packages with optional kadmin client support.
55 AC_DEFUN([RRA_LIB_CDB_OPTIONAL],
56 [RRA_LIB_HELPER_VAR_INIT([CDB])
57  RRA_LIB_HELPER_WITH_OPTIONAL([tinycdb], [TinyCDB], [CDB])
58  AS_IF([test x"$rra_use_CDB" != xfalse],
59     [AS_IF([test x"$rra_use_CDB" = xtrue],
60         [_RRA_LIB_CDB_INTERNAL([true])],
61         [_RRA_LIB_CDB_INTERNAL([false])])])])