summaryrefslogtreecommitdiffstats
path: root/src/modules/rlm_sql/drivers/rlm_sql_mongo/configure.ac
blob: b9756a99be295768610c9d5a4d089d1ee90331b8 (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
AC_PREREQ([2.69])
AC_INIT
AC_CONFIG_SRCDIR([rlm_sql_mongo.c])
AC_REVISION($Revision: 1.10 $)
FR_INIT_MODULE([rlm_sql_mongo])

mongoc_ldflags=
mongoc_cflags=

FR_MODULE_START_TESTS

AC_ARG_WITH(mongoc_lib_dir,
	[AS_HELP_STRING([--with-mongoc-lib-dir],
		[Path of libmongoc libraries])],
	[ mongoc_lib_dir="$withval" ],
	[ mongoc_lib_dir="" ])

AC_ARG_WITH(mongoc_include_dir,
	[AS_HELP_STRING([--with-mongoc-include-dir],
		[Path of libmongoc includes])],
	[ mongoc_include_dir="$withval" ],
	[ mongoc_include_dir="" ])

AC_ARG_WITH(bson_lib_dir,
	[AS_HELP_STRING([--with-bson-lib-dir],
		[Path of libbson libraries])],
	[ bson_lib_dir="$withval" ],
	[ bson_lib_dir="" ])

AC_ARG_WITH(bson_include_dir,
	[AS_HELP_STRING([--with-bson-include-dir],
		[Path of libbson includes])],
	[ bson_include_dir="$withval" ],
	[ bson_include_dir="" ])

dnl ######################################################
dnl # Check for header files of Bson Libraries
dnl ######################################################

CFLAGS_PRE="$CFLAGS"
if test x$bson_include_dir != x ; then
	bson_cflags="-isystem ${bson_include_dir}"
else
	bson_cflags="-isystem /usr/include/libbson-1.0"
fi
CFLAGS="$CFLAGS ${bson_cflags}"

AC_CHECK_HEADER([bson/bson.h], [], [], [#include <bson/bson.h>])
CFLAGS="$CFLAGS_PRE"

if test "x$ac_cv_header_bson_bson_h" != "xyes"; then
	FR_MODULE_FAIL([bson/bson.h])
fi

dnl ######################################################
dnl # Check for libraries of Bson
dnl ######################################################

LDFLAGS_PRE="$LDFLAGS"
if test x$bson_lib_dir != x ; then
	bson_ldflags="-L${bson_lib_dir} -lbson-1.0"
else
	bson_ldflags="-L/usr/lib -lbson-1.0"
fi
LDFLAGS="$LDFLAGS ${bson_ldflags}"

AC_CHECK_LIB(bson-1.0, [ bson_iter_init_find ], [], [])
LDFLAGS="$LDFLAGS_PRE"

if test "x$ac_cv_lib_bson_1_0__bson_iter_init_find_" != "xyes"; then
	FR_MODULE_FAIL([libbson])
fi

dnl ######################################################
dnl # Check for header files of MongoC Libraries
dnl ######################################################

CFLAGS_PRE="$CFLAGS"
if test x$mongoc_include_dir != x ; then
	mongoc_cflags="-isystem ${mongoc_include_dir} ${bson_cflags}"
else
	mongoc_cflags="-isystem /usr/include/libmongoc-1.0 ${bson_cflags}"
fi
CFLAGS="$CFLAGS ${mongoc_cflags}"

AC_CHECK_HEADER([mongoc.h], [], [], [#include <mongoc.h>])
CFLAGS="$CFLAGS_PRE"

if test "x$ac_cv_header_mongoc_h" != "xyes"; then
	FR_MODULE_FAIL([mongoc.h])
fi

dnl ######################################################
dnl # Check for libraries of MongoC
dnl ######################################################

LDFLAGS_PRE="$LDFLAGS"
if test x$mongoc_lib_dir != x ; then
	mongoc_ldflags="-L${mongoc_lib_dir} -lmongoc-1.0 ${bson_ldflags}"
else
	mongoc_ldflags="-L/usr/lib -lmongoc-1.0 ${bson_ldflags}"
fi
LDFLAGS="$LDFLAGS ${mongoc_ldflags}"

AC_CHECK_LIB(mongoc-1.0, [ mongoc_init ], [], [])
LDFLAGS="$LDFLAGS_PRE"

if test "x$ac_cv_lib_mongoc_1_0__mongoc_init_" != "xyes"; then
	FR_MODULE_FAIL([libmongoc-1.0])
fi

FR_MODULE_END_TESTS

AC_SUBST(mongoc_cflags)
AC_SUBST(mongoc_ldflags)

AC_CONFIG_FILES([all.mk])
AC_OUTPUT