summaryrefslogtreecommitdiffstats
path: root/src/modules/rlm_couchbase/configure.ac
blob: 453b92a8e56fcf45e9dd5636d563a785af3ec6f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
AC_PREREQ([2.69])
AC_INIT
AC_CONFIG_SRCDIR([rlm_couchbase.c])
AC_REVISION($Revision$)
FR_INIT_MODULE([rlm_couchbase])

FR_MODULE_START_TESTS

AC_PROG_CC
AC_PROG_CPP

dnl ############################################################
dnl # Check for json-c
dnl ############################################################

dnl extra argument: --with-jsonc-include-dir=DIR
jsonc_include_dir=
AC_ARG_WITH(jsonc-include-dir,
	[AS_HELP_STRING([--with-jsonc-include-dir=DIR],
		[Directory where the json-c includes may be found])],
	[case "$withval" in
	no)
		AC_MSG_ERROR(Need jsonc-include-dir)
		;;
	yes)
		;;
	*)
		jsonc_include_dir="$withval"
		;;
	esac])

dnl extra argument: --with-jsonc-lib-dir=DIR
jsonc_lib_dir=
AC_ARG_WITH(jsonc-lib-dir,
	[AS_HELP_STRING([--with-jsonc-lib-dir=DIR],
		[Directory where the json-c libraries may be found])],
	[case "$withval" in
	no)
		AC_MSG_ERROR(Need jsonc-lib-dir)
		;;
	yes)
		;;
	*)
		jsonc_lib_dir="$withval"
		;;
	esac])

dnl extra argument: --with-jsonc-dir=DIR
AC_ARG_WITH(jsonc-dir,
	[AS_HELP_STRING([--with-jsonc-dir=DIR],
		[Base directory where json-c is installed])],
	[case "$withval" in
	no)
		AC_MSG_ERROR(Need json-c-dir)
		;;
	yes)
		;;
	*)
		jsonc_lib_dir="$withval/lib"
		jsonc_include_dir="$withval/include"
		;;
	esac])

dnl ############################################################
dnl # Check for json-c header files
dnl ############################################################

have_json="yes"
smart_try_dir="$jsonc_include_dir"
FR_SMART_CHECK_INCLUDE([json/json.h])
if test "x$ac_cv_header_json_json_h" != "xyes"; then
	FR_SMART_CHECK_INCLUDE([json-c/json.h])
	if test "x$ac_cv_header_jsonmc_json_h" != "xyes"; then
		have_json="no"
		AC_MSG_WARN([json-c headers not found. Use --with-jsonc-include-dir=<path>.])
		FR_MODULE_FAIL([json.h])
	else
		AC_DEFINE([HAVE_JSONMC_JSON_H],[1],[json.h is at json-c/json.h relative to include dir])
	fi
else
	AC_DEFINE([HAVE_JSON_JSON_H],[1],[json.h is at json/json.h relative to include dir])
fi

dnl ############################################################
dnl # Check for json-c libraries
dnl ############################################################

smart_try_dir="$jsonc_lib_dir"
dnl # Use a json-c specific function which is only
dnl # available in newer versions.
FR_SMART_CHECK_LIB([json-c], [json_c_version])
if test "x$ac_cv_lib_json_c_json_c_version" != "xyes"; then
	dnl # Use a function which is included in legacy versions
	dnl # but which may be available in other json libraries
	FR_SMART_CHECK_LIB([json], [json_tokener_new])
	if test "x$ac_cv_lib_json_json_tokener_new" != "xyes"; then
		have_json="no"
		AC_MSG_WARN([json-c libraries not found. Use --with-jsonc-lib-dir=<path>.])
		FR_MODULE_FAIL([libjson-c])
	fi
fi

if test "x$have_json" = "xyes"; then
	dnl # Ensure we use the library we just found the rest of the checks
	LDFLAGS="$SMART_LIBS"

	dnl # Add any optional functions here
	AC_CHECK_FUNCS(\
		json_c_version \
		json_object_get_string_len \
		json_object_object_get_ex \
		json_object_new_int64 \
		json_tokener_error_desc \
		json_tokener_get_error
	)
else
	FR_MODULE_FAIL([json-c])
fi

dnl ############################################################
dnl # Check for libcouchbase
dnl ############################################################

dnl extra argument: --with-libcouchbase-include-dir=DIR
libcouchbase_include_dir=
AC_ARG_WITH(libcouchbase-include-dir,
	[AS_HELP_STRING([--with-libcouchbase-include-dir=DIR],
		[Directory where the libcouchbase includes may be found])],
	[case "$withval" in
	no)
			AC_MSG_ERROR(Need libcouchbase-include-dir)
		;;
	yes)
		;;
	*)
		libcouchbase_include_dir="$withval"
		;;
	esac])

dnl extra argument: --with-libcouchbase-lib-dir=DIR
libcouchbase_lib_dir=
AC_ARG_WITH(libcouchbase-lib-dir,
[AS_HELP_STRING([--with-libcouchbase-lib-dir=DIR],
		[Directory where the libcouchbase libraries may be found])],
	[case "$withval" in
	no)
		AC_MSG_ERROR(Need libcouchbase-lib-dir)
		;;
	yes)
		;;
	*)
		libcouchbase_lib_dir="$withval"
		;;
	esac])

dnl extra argument: --with-libcouchbase-dir=DIR
AC_ARG_WITH(libcouchbase-dir,
[AS_HELP_STRING([--with-libcouchbase-dir=DIR],
		[Base directory where libcouchbase is installed])],
	[case "$withval" in
	no)
		AC_MSG_ERROR(Need libcouchbase-dir)
		;;
	yes)
		;;
	*)
		libcouchbase_lib_dir="$withval/lib"
		libcouchbase_include_dir="$withval/include"
		;;
	esac])

dnl ############################################################
dnl # Check for libcouchbase header files
dnl ############################################################

smart_try_dir="$libcouchbase_include_dir"
FR_SMART_CHECK_INCLUDE([libcouchbase/couchbase.h])
if test "x$ac_cv_header_libcouchbase_couchbase_h" != "xyes"; then
	AC_MSG_WARN([libcouchbase headers not found. Use --with-libcouchbase-include-dir=<path>.])
	FR_MODULE_FAIL([couchbase.h])
fi

dnl ############################################################
dnl # Check for libcouchbase libraries
dnl ############################################################

smart_try_dir="$libcouchbase_lib_dir"
FR_SMART_CHECK_LIB([couchbase], [lcb_get_version])
if test "x$ac_cv_lib_couchbase_lcb_get_version" != "xyes"; then
	AC_MSG_WARN([libcouchbase libraries not found. Use --with-libcouchbase-lib-dir=<path>.])
	FR_MODULE_FAIL([libcouchbase])
fi

dnl ############################################################
dnl # Check for OpenSSL
dnl ############################################################

AC_MSG_CHECKING(for OpenSSL support)
if test "x$OPENSSL_LIBS" != "x"; then
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
	FR_MODULE_FAIL([OpenSSL])
fi

dnl ############################################################
dnl # Checks done - set targetname
dnl ############################################################

FR_MODULE_END_TESTS

mod_ldflags="${SMART_LIBS}"
mod_cflags="${SMART_CPPFLAGS}"

AC_SUBST(mod_cflags)
AC_SUBST(mod_ldflags)

AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([all.mk])
AC_OUTPUT