]> eyrie.org Git - kerberos/krb5-strength.git/blob - m4/sqlite3.m4
New upstream version 3.3
[kerberos/krb5-strength.git] / m4 / sqlite3.m4
1 # serial 1
2
3 dnl Find the compiler and linker flags for SQLite v3.
4 dnl
5 dnl Finds the compiler and linker flags for linking with the SQLite library.
6 dnl Provides the --with-sqlite3, --with-sqlite3-lib, and
7 dnl --with-sqlite3-include configure options to specify non-standard paths to
8 dnl the SQLite v3 libraries or header files.
9 dnl
10 dnl Provides the macro RRA_LIB_SQLITE3 and sets the substitution variables
11 dnl SQLITE3_CPPFLAGS, SQLITE3_LDFLAGS, and SQLITE3_LIBS.  Also provides
12 dnl RRA_LIB_SQLITE3_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the
13 dnl SQLite library, saving the current values first, and
14 dnl RRA_LIB_SQLITE3_RESTORE to restore those settings to before the last
15 dnl RRA_LIB_SQLITE3_SWITCH.  Defines HAVE_SQLITE3 and sets rra_use_SQLITE3 to
16 dnl true.
17 dnl
18 dnl Provides the RRA_LIB_SQLITE3_OPTIONAL macro, which should be used if
19 dnl SQLite support is optional.  This macro will still always set the
20 dnl substitution variables, but they'll be empty if the SQLite library is not
21 dnl found or if --without-sqlite3 is given.  Defines HAVE_SQLITE3 and sets
22 dnl rra_use_SQLITE3 to true if the SQLite library is found and
23 dnl --without-sqlite3 is not given.
24 dnl
25 dnl Depends on the lib-helper.m4 framework and the Autoconf macros that come
26 dnl with pkg-config.
27 dnl
28 dnl The canonical version of this file is maintained in the rra-c-util
29 dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
30 dnl
31 dnl Written by Russ Allbery <eagle@eyrie.org>
32 dnl Copyright 2020, 2022 Russ Allbery <eagle@eyrie.org>
33 dnl Copyright 2014
34 dnl     The Board of Trustees of the Leland Stanford Junior University
35 dnl
36 dnl This file is free software; the authors give unlimited permission to copy
37 dnl and/or distribute it, with or without modifications, as long as this
38 dnl notice is preserved.
39 dnl
40 dnl SPDX-License-Identifier: FSFULLR
41
42 dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
43 dnl versions that include the SQLite 3 flags.  Used as a wrapper, with
44 dnl RRA_LIB_SQLITE3_RESTORE, around tests.
45 AC_DEFUN([RRA_LIB_SQLITE3_SWITCH], [RRA_LIB_HELPER_SWITCH([SQLITE3])])
46
47 dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values before
48 dnl RRA_LIB_SQLITE3_SWITCH was called.
49 AC_DEFUN([RRA_LIB_SQLITE3_RESTORE], [RRA_LIB_HELPER_RESTORE([SQLITE3])])
50
51 dnl Checks if SQLite v3 is present.  The single argument, if "true", says to
52 dnl fail if the SQLite library could not be found.  Prefer probing with
53 dnl pkg-config if available and the --with flags were not given.
54 AC_DEFUN([_RRA_LIB_SQLITE3_INTERNAL],
55 [RRA_LIB_HELPER_PATHS([SQLITE3])
56  AS_IF([test x"$SQLITE3_CPPFLAGS" = x && test x"$SQLITE3_LDFLAGS" = x],
57     [PKG_CHECK_EXISTS([sqlite3],
58         [PKG_CHECK_MODULES([SQLITE3], [sqlite3])
59          SQLITE3_CPPFLAGS="$SQLITE3_CFLAGS"])])
60  AS_IF([test x"$SQLITE3_LIBS" = x],
61     [RRA_LIB_SQLITE3_SWITCH
62      LIBS=
63      AC_SEARCH_LIBS([sqlite3_open_v2], [sqlite3],
64         [SQLITE3_LIBS="$LIBS"],
65         [AS_IF([test x"$1" = xtrue],
66             [AC_MSG_ERROR([cannot find usable libsqlite3 library])])])
67      RRA_LIB_SQLITE3_RESTORE])
68  RRA_LIB_SQLITE3_SWITCH
69  AC_CHECK_HEADERS([sqlite3.h])
70  RRA_LIB_SQLITE3_RESTORE])
71
72 dnl The main macro for packages with mandatory SQLite v3 support.
73 AC_DEFUN([RRA_LIB_SQLITE3],
74 [RRA_LIB_HELPER_VAR_INIT([SQLITE3])
75  RRA_LIB_HELPER_WITH([sqlite3], [SQLite v3], [SQLITE3])
76  _RRA_LIB_SQLITE3_INTERNAL([true])
77  rra_use_SQLITE3=true
78  AC_DEFINE([HAVE_SQLITE3], 1, [Define if libsqlite3 is available.])])
79
80 dnl The main macro for packages with optional SQLite v3 support.
81 AC_DEFUN([RRA_LIB_SQLITE3_OPTIONAL],
82 [RRA_LIB_HELPER_VAR_INIT([SQLITE3])
83  RRA_LIB_HELPER_WITH_OPTIONAL([sqlite3], [SQLite v3], [SQLITE3])
84  AS_IF([test x"$rra_use_SQLITE3" != xfalse],
85     [AS_IF([test x"$rra_use_SQLITE3" = xtrue],
86         [_RRA_LIB_SQLITE3_INTERNAL([true])],
87         [_RRA_LIB_SQLITE3_INTERNAL([false])])])
88  AS_IF([test x"$SQLITE3_LIBS" = x],
89     [RRA_LIB_HELPER_VAR_CLEAR([SQLITE3])],
90     [rra_use_SQLITE3=true
91      AC_DEFINE([HAVE_SQLITE3], 1, [Define if libsqlite3 is available.])])])