]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/sqlite.m4
Change CrackLib tests for system CrackLib
[kerberos/krb5-strength.git] / m4 / sqlite.m4
1 dnl Find the compiler and linker flags for SQLite.
2 dnl
3 dnl Finds the compiler and linker flags for linking with the SQLite library.
4 dnl Provides the --with-sqlite, --with-sqlite-lib, and --with-sqlite-include
5 dnl configure options to specify non-standard paths to the SQLite libraries or
6 dnl header files.  Currently, only SQLite 3 is considered sufficient.
7 dnl
8 dnl Provides the macros RRA_LIB_SQLITE and RRA_LIB_SQLITE_OPTIONAL and sets
9 dnl the substitution variables SQLITE_CPPFLAGS, SQLITE_LDFLAGS, and
10 dnl SQLITE_LIBS.  Also provides RRA_LIB_SQLITE_SWITCH to set CPPFLAGS,
11 dnl LDFLAGS, and LIBS to include the SQLite libraries, saving the current
12 dnl values first, and RRA_LIB_SQLITE_RESTORE to restore those settings to
13 dnl before the last RRA_LIB_SQLITE_SWITCH.  Defines HAVE_SQLITE and sets
14 dnl rra_use_SQLITE to true if libevent is found.  If it isn't found, the
15 dnl substitution variables will be empty.
16 dnl
17 dnl Depends on the lib-helper.m4 framework.
18 dnl
19 dnl The canonical version of this file is maintained in the rra-c-util
20 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
21 dnl
22 dnl Written by Russ Allbery <eagle@eyrie.org>
23 dnl Copyright 2014
24 dnl     The Board of Trustees of the Leland Stanford Junior University
25 dnl
26 dnl This file is free software; the authors give unlimited permission to copy
27 dnl and/or distribute it, with or without modifications, as long as this
28 dnl notice is preserved.
29
30 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
31 dnl versions that include the libevent flags.  Used as a wrapper, with
32 dnl RRA_LIB_SQLITE_RESTORE, around tests.
33 AC_DEFUN([RRA_LIB_SQLITE_SWITCH], [RRA_LIB_HELPER_SWITCH([SQLITE])])
34
35 dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values before
36 dnl RRA_LIB_SQLITE_SWITCH was called.
37 AC_DEFUN([RRA_LIB_SQLITE_RESTORE], [RRA_LIB_HELPER_RESTORE([SQLITE])])
38
39 dnl Checks if SQLite is present.  The single argument, if "true", says to fail
40 dnl if the SQLite library could not be found.  Prefer probing with pkg-config
41 dnl if available and the --with flags were not given.
42 AC_DEFUN([_RRA_LIB_SQLITE_INTERNAL],
43 [RRA_LIB_HELPER_PATHS([SQLITE])
44  AS_IF([test x"$SQLITE_CPPFLAGS" = x && test x"$SQLITE_LDFLAGS" = x],
45     [PKG_CHECK_EXISTS([sqlite3],
46         [PKG_CHECK_MODULES([SQLITE], [sqlite3])
47          SQLITE_CPPFLAGS="$SQLITE_CFLAGS"])])
48  AS_IF([test x"$SQLITE_LIBS" = x],
49     [RRA_LIB_SQLITE_SWITCH
50      LIBS=
51      AC_SEARCH_LIBS([sqlite3_open_v2], [sqlite3],
52         [SQLITE_LIBS="$LIBS"],
53         [AS_IF([test x"$1" = xtrue],
54             [AC_MSG_ERROR([cannot find usable SQLite library])])])
55      RRA_LIB_SQLITE_RESTORE])
56  RRA_LIB_SQLITE_SWITCH
57  AC_CHECK_HEADERS([sqlite3.h])
58  RRA_LIB_SQLITE_RESTORE])
59
60 dnl The main macro for packages with mandatory SQLite 3 support.
61 AC_DEFUN([RRA_LIB_SQLITE],
62 [RRA_LIB_HELPER_VAR_INIT([SQLITE])
63  RRA_LIB_HELPER_WITH([sqlite], [SQLite], [SQLITE])
64  _RRA_LIB_SQLITE_INTERNAL([true])
65  rra_use_SQLITE=true
66  AC_DEFINE([HAVE_SQLITE], 1, [Define if SQLite is available.])])
67
68 dnl The main macro for packages with optional SQLite support.
69 AC_DEFUN([RRA_LIB_SQLITE_OPTIONAL],
70 [RRA_LIB_HELPER_VAR_INIT([SQLITE])
71  RRA_LIB_HELPER_WITH_OPTIONAL([sqlite], [SQLite], [SQLITE])
72  AS_IF([test x"$rra_use_SQLITE" != xfalse],
73     [AS_IF([test x"$rra_use_SQLITE" = xtrue],
74         [_RRA_LIB_SQLITE_INTERNAL([true])],
75         [_RRA_LIB_SQLITE_INTERNAL([false])])])
76  AS_IF([test x"$SQLITE_LIBS" != x],
77     [rra_use_SQLITE=true
78      AC_DEFINE([HAVE_SQLITE], 1, [Define if SQLite is available.])])])