]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/tinycdb.m4
Merge branch 'debian' into squeeze
[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 TinyCDB libraries, saving the current values, and RRA_LIB_CDB_RESTORE
11 dnl to restore those settings to before the last RRA_LIB_CDB_SWITCH.  Defines
12 dnl HAVE_CDB and sets rra_use_CDB to true if the library is found.
13 dnl
14 dnl Depends on the lib-helper.m4 framework.
15 dnl
16 dnl The canonical version of this file is maintained in the rra-c-util
17 dnl package, available at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
18 dnl
19 dnl Written by Russ Allbery <eagle@eyrie.org>
20 dnl Copyright 2013
21 dnl     The Board of Trustees of the Leland Stanford Junior University
22 dnl
23 dnl This file is free software; the authors give unlimited permission to copy
24 dnl and/or distribute it, with or without modifications, as long as this
25 dnl notice is preserved.
26
27 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
28 dnl versions that include the TinyCDB flags.  Used as a wrapper, with
29 dnl RRA_LIB_CDB_RESTORE, around tests.
30 AC_DEFUN([RRA_LIB_CDB_SWITCH], [RRA_LIB_HELPER_SWITCH([CDB])])
31
32 dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before
33 dnl RRA_LIB_CDB_SWITCH was called).
34 AC_DEFUN([RRA_LIB_CDB_RESTORE], [RRA_LIB_HELPER_RESTORE([CDB])])
35
36 dnl Checks if the libcdb library is present.  The single argument, if "true",
37 dnl says to fail if the libcdb library could not be found.
38 AC_DEFUN([_RRA_LIB_CDB_INTERNAL],
39 [RRA_LIB_HELPER_PATHS([CDB])
40  RRA_LIB_CDB_SWITCH
41  AC_CHECK_LIB([cdb], [cdb_init], [CDB_LIBS=-lcdb],
42     [AS_IF([test x"$1" = xtrue],
43         [AC_MSG_ERROR([cannot find usable TinyCDB library])])])
44  AC_CHECK_HEADERS([cdb.h])
45  RRA_LIB_CDB_RESTORE])
46
47 dnl The main macro for packages with mandatory TinyCDB support.
48 AC_DEFUN([RRA_LIB_CDB],
49 [RRA_LIB_HELPER_VAR_INIT([CDB])
50  RRA_LIB_HELPER_WITH([tinycdb], [TinyCDB], [CDB])
51  _RRA_LIB_CDB_INTERNAL([true])
52  rra_use_CDB=true
53  AC_DEFINE([HAVE_CDB], 1, [Define if libcdb is available.])])
54
55 dnl The main macro for packages with optional TinyCDB support.
56 AC_DEFUN([RRA_LIB_CDB_OPTIONAL],
57 [RRA_LIB_HELPER_VAR_INIT([CDB])
58  RRA_LIB_HELPER_WITH_OPTIONAL([tinycdb], [TinyCDB], [CDB])
59  AS_IF([test x"$rra_use_CDB" != xfalse],
60     [AS_IF([test x"$rra_use_CDB" = xtrue],
61         [_RRA_LIB_CDB_INTERNAL([true])],
62         [_RRA_LIB_CDB_INTERNAL([false])])])
63  AS_IF([test x"$CDB_LIBS" != x],
64     [rra_use_CDB=true
65      AC_DEFINE([HAVE_CDB], 1, [Define if libcdb is available.])])])