7dad0779b873a1cf05ab00b7dc9dbc4871f25593
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_sqlite / configure.ac
1 AC_PREREQ([2.59])
2 AC_INIT(rlm_sql_sqlite.c)
3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_sql_sqlite])
5
6 fail=
7 SMART_LIBS=
8 SMART_CLFAGS=
9 if test x$with_[]modname != xno; then
10
11     dnl ############################################################
12     dnl # Check for command line options
13     dnl ############################################################
14
15     dnl extra argument: --with-sqlite-include-dir=DIR
16     sqlite_include_dir=
17     AC_ARG_WITH(sqlite-include-dir,
18         [AS_HELP_STRING([--with-sqlite-include-dir=DIR],
19                 [Directory where the sqlite includes may be found])],
20         [case "$withval" in
21             no)
22                 AC_MSG_ERROR(Need sqlite-include-dir)
23                 ;;
24             yes)
25                 ;;
26             *)
27                 sqlite_include_dir="$withval"
28                 ;;
29         esac])
30
31     dnl extra argument: --with-sqlite-lib-dir=DIR
32     sqlite_lib_dir=
33     AC_ARG_WITH(sqlite-lib-dir,
34         [AS_HELP_STRING([--with-sqlite-lib-dir=DIR],
35                 [Directory where the sqlite libraries may be found])],
36         [case "$withval" in
37             no)
38                 AC_MSG_ERROR(Need sqlite-lib-dir)
39                 ;;
40             yes)
41                 ;;
42             *)
43                 sqlite_lib_dir="$withval"
44                 ;;
45         esac])
46
47     dnl extra argument: --with-sqlite-dir=DIR
48     AC_ARG_WITH(sqlite-dir,
49         [AS_HELP_STRING([--with-sqlite-dir=DIR],
50                 [Base directory where sqlite is installed])],
51         [case "$withval" in
52             no)
53                 AC_MSG_ERROR(Need sqlite-dir)
54                 ;;
55             yes)
56                 ;;
57             *)
58                 sqlite_lib_dir="$withval/lib"
59                 sqlite_include_dir="$withval/include"
60                 ;;
61         esac])
62
63     dnl ############################################################
64     dnl # Check for programs
65     dnl ############################################################
66
67     AC_PROG_CC
68
69     dnl ############################################################
70     dnl # Check for libraries
71     dnl ############################################################
72
73     dnl try to link to libsqlite3
74     smart_try_dir="$sqlite_lib_dir"
75     FR_SMART_CHECK_LIB(sqlite3, sqlite3_open)
76     dnl # Ensure we use the library we just found the rest of the checks
77     LDFLAGS="$SMART_LIBS"
78     if test "x$ac_cv_lib_sqlite3_sqlite3_open" != "xyes"
79     then
80         AC_MSG_WARN([Sqlite libraries not found. Use --with-sqlite-lib-dir=<path>.])
81         fail="$fail libsqlite3"
82     else
83         dnl # Add any v2 variants here
84         AC_CHECK_FUNCS(\
85                 sqlite3_prepare_v2 \
86                 sqlite3_open_v2 \
87                 sqlite3_create_function_v2 \
88                 sqlite3_errstr \
89                 sqlite3_extended_result_codes \
90         )
91     fi
92
93     dnl ############################################################
94     dnl # Check for header files
95     dnl ############################################################
96
97     smart_try_dir="$sqlite_include_dir"
98     FR_SMART_CHECK_INCLUDE(sqlite3.h)
99     if test "x$ac_cv_header_sqlite3_h" != "xyes"; then
100         AC_MSG_WARN([Sqlite headers not found. Use --with-sqlite-include-dir=<path>.])
101         fail="$fail sqlite.h"
102     fi
103     CFLAGS="$SMART_CPPFLAGS"
104     AC_CHECK_TYPES([sqlite3_int64], [], [], [[#include <sqlite3.h>]])
105
106     targetname=modname
107 else
108     targetname=
109     echo \*\*\* module modname is disabled.
110 fi
111
112 dnl Don't change this section.
113 if test "x$fail" != x; then
114         if test "x${enable_strict_dependencies}" = xyes; then
115                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
116         else
117                 AC_MSG_WARN([silently not building ]modname[.])
118                 AC_MSG_WARN([FAILURE: ]modname[ requires:$fail.]);
119                 targetname=
120         fi
121 fi
122
123 mod_ldflags="$SMART_LIBS"
124 mod_cflags="$SMART_CFLAGS"
125 AC_SUBST(mod_ldflags)
126 AC_SUBST(mod_cflags)
127
128 AC_CONFIG_HEADER(config.h)
129
130 AC_SUBST(targetname)
131 AC_OUTPUT(all.mk)