no need to check to kernel source (also fixes the nightly builds)
[distributedratelimiting.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(ulogd.c)
3
4 dnl Checks for programs.
5 AC_PROG_MAKE_SET
6 AC_PROG_CC
7 AC_CHECK_TOOL(LD, ld)
8 AC_PROG_INSTALL
9
10 dnl Checks for libraries.
11 AC_CHECK_LIB(dl, dlopen)
12 AC_CHECK_HEADER(pcap.h,HAVE_PCAP_H=true)
13
14 dnl Checks for header files.
15 AC_HEADER_DIRENT
16 AC_HEADER_STDC
17 AC_CHECK_HEADERS(fcntl.h unistd.h)
18
19 dnl Checks for typedefs, structures, and compiler characteristics.
20 AC_C_CONST
21 AC_TYPE_SIZE_T
22 AC_STRUCT_TM
23
24 dnl Checks for library functions.
25 AC_FUNC_VPRINTF
26 AC_CHECK_FUNCS(socket strerror)
27
28 dnl NetFlow prerequisites.
29 AC_ARG_WITH(proper,
30     --with-proper=<directory>           proper installed in <directory>,
31     [ CPPFLAGS="$CPPFLAGS -I$withval/include" ; LDFLAGS="$LDFLAGS -L$withval/.libs" ],
32 )
33 AC_CHECK_HEADER(prop.h, HAVE_PROP_H=true)
34 AC_CHECK_LIB(proper, prop_create_socket)
35 AC_CHECK_HEADER(pthread.h, HAVE_PTHREAD_H=true, AC_MSG_ERROR(NetFlow requires pthread))
36 AC_CHECK_LIB(pthread, pthread_create, [], AC_MSG_ERROR(NetFlow requires pthread))
37
38 DATABASE_DIR=""
39 DATABASE_LIB=""
40 DATABASE_LIB_DIR=""
41
42 DATABASE_DRIVERS=""
43
44 dnl
45 dnl test for MySQL
46 dnl
47 AC_ARG_WITH(mysql,
48  --with-mysql=<directory>               mysql installed in <directory>,[
49 if test $withval != yes
50 then
51         dir=$withval
52 else
53         dir="/usr/local"
54 fi
55 mysqldir=""
56 AC_MSG_CHECKING(for MySQL files)
57 for d in $dir/bin /usr/bin /usr/local/bin /usr/local/mysql/bin /opt/mysql/bin /opt/packages/mysql/bin
58 do
59         if test -f $d/mysql_config
60         then
61                 AC_MSG_RESULT(found mysql_config in $d)
62                 mysqldir=$d
63                 break
64         fi
65 done
66
67 if test x$mysqldir = x
68 then
69         AC_MSG_WARN(MySQL backend not used)
70 else
71         AC_DEFINE(HAVE_MYSQL)
72         MYSQLINCLUDES=`$d/mysql_config --include`
73         MYSQLLIBS=`$d/mysql_config --libs`
74
75         DATABASE_DIR="${DATABASE_DIR} mysql"
76
77         MYSQL_LIB="${DATABASE_LIB} ${MYSQLLIBS} " 
78         # no change to DATABASE_LIB_DIR, since --libs already includes -L
79
80         DATABASE_DRIVERS="${DATABASE_DRIVERS} ../mysql/mysql_driver.o "
81
82         DB_DEF="${DB_DEF} -DHAVE_MYSQL "
83
84
85         AC_SUBST(MYSQLINCLUDES)
86         AC_SUBST(MYSQL_LIB)
87
88         dnl Here we check whether we have an old MySQL client library
89         dnl installed, which does not support the mysql_real_escape_string(),
90         dnl but the real_escape_string() function.
91         dnl Having a look in the libary itself should be more reliable than
92         dnl parsing the output of mysql --version.
93
94         AC_MSG_CHECKING(for mysql_real_escape_string support)
95
96         MYSQL_FUNCTION_TEST=`strings ${MYSQLLIBS}/libmysqlclient.so | grep mysql_real_escape_string`
97
98         if test "x$MYSQL_FUNCTION_TEST" = x
99         then
100                 EXTRA_MYSQL_DEF="-DOLD_MYSQL=1 "
101                 AC_MSG_RESULT(found old MySQL)
102         else
103                 AC_MSG_RESULT(found new MySQL)
104         fi
105
106 fi      
107 ])      
108
109
110 dnl
111 dnl Check whether the user wants log IP-addresses as strings rather
112 dnl than as unsigned long-integers to his MySQL-database. Since this
113 dnl feature is only used in ulogd_MYSQL.c, there are no checks in any
114 dnl way.
115 dnl
116
117 AC_ARG_WITH(mysql-log-ip-as-string,
118  --with-mysql-log-ip-as-string          log IPs as string rather than as
119                                         unsigned long-integer.
120 ,[
121    EXTRA_MYSQL_DEF="${EXTRA_MYSQL_DEF} -DIP_AS_STRING=1"
122    AC_MSG_WARN(the use of --with-mysql-log-ip-as-string is discouraged)
123 ])
124
125 dnl
126 dnl test for libxml2
127 dnl
128 AC_ARG_WITH(libxml2, --with-libxml=<directory>          libxml2 installed in <directory>,[
129 if test $withval != yes
130 then
131         dir=$withval
132 else
133         dir="/usr/local"
134 fi])
135
136 libxmldir=""
137 AC_MSG_CHECKING(for LIBXML2 files)
138 for d in $dir/bin /usr/bin /usr/local/bin /usr/local/libxml2/bin /opt/libxml2/bin /opt/packages/libxml2/bin
139 do
140     if test -x $d/xml2-config
141     then
142         AC_MSG_RESULT(found xml2-config in $d)
143         libxmldir=$d
144         break
145     fi
146 done
147
148 if test x$libxmldir = x
149 then
150     AC_MSG_ERROR(xml2-config not found)
151 else
152     XMLINCLUDES=`$libxmldir/xml2-config --cflags`
153     AC_SUBST(XMLINCLUDES)
154
155     XMLLIBS=`$libxmldir/xml2-config --libs`
156     AC_SUBST(XMLLIBS)
157 fi
158
159 dnl
160 dnl check for zookeeper library
161 dnl
162 zkdir="/usr/local/lib"
163
164 AC_ARG_WITH(zookeeper, --with-zookeeperlib=<directory>          zookeeper shared object located in <directory>,[
165 if test $withval = no
166 then
167     zkdir=no
168     AC_MSG_WARN(Building without zookeeper support.)
169 else
170     zkdir=$withval
171 fi])
172
173 zklib=""
174 if test $zkdir != no
175 then
176     AC_MSG_CHECKING(for zookeeper libraries)
177     for d in $zkdir /usr/local/lib /lib /usr/lib
178     do
179         if test -f $d/libzookeeper_mt.so
180         then
181             AC_MSG_RESULT(found libzookeeper_mt.so in $d)
182             zklib=$d/libzookeeper_mt.so
183             break
184         fi
185     done
186
187     if test x$zklib = x
188     then
189         dnl no zklib
190         AC_MSG_WARN(Zookeeper libraries not found.)
191         ZKLIBS=""
192         AC_SUBST(ZKLIBS)
193
194         ZKFLAGS=""
195         AC_SUBST(ZKFLAGS)
196     else
197         dnl found it
198         ZKLIBS=$zklib
199         AC_SUBST(ZKLIBS)
200
201         ZKFLAGS="-DTHREADED -DBUILD_ZOOKEEPER"
202         AC_SUBST(ZKFLAGS)
203     fi
204 fi
205
206 dnl
207 dnl test for PostgreSQL
208 dnl
209 AC_ARG_WITH(pgsql,
210  --with-pgsql=<directory>               pgsql installed in <directory>,[
211 if test $withval != yes
212 then
213         dir=$withval
214 else
215         dir="/usr/local"
216 fi
217 pgsqldir=""
218 AC_MSG_CHECKING(for PGSQL files)
219 for d in $dir/bin /usr/bin /usr/local/bin /usr/local/pgsql/bin /opt/pgsql/bin /opt/packages/pgsql/bin
220 do
221         if test -x $d/pg_config
222         then
223                 AC_MSG_RESULT(found pg_config in $d)
224                 pgsqldir=$d
225                 break
226         fi
227 done
228
229 if test x$pgsqldir = x
230 then
231         AC_MSG_WARN(PGSQL backend not used)
232 else
233         AC_DEFINE(HAVE_PGSQL)
234         PGSQLINCLUDES=`$pgsqldir/pg_config --includedir`
235         PGSQLLIBS=`$pgsqldir/pg_config --libdir`
236
237         DATABASE_DIR="${DATABASE_DIR} pgsql"
238         PGSQL_LIB="${DATABASE_LIB} -lpq " 
239
240         DATABASE_LIB_DIR="${DATABASE_LIB_DIR} -L${PGSQLLIBS} "
241         DB_DEF="${DB_DEF} -DHAVE_PGSQL "
242
243         AC_SUBST(PGSQLINCLUDES)
244         AC_SUBST(PGSQL_LIB)
245
246 fi      
247 ])      
248
249 dnl
250 dnl Check whether the user wants to log IP-addresses as strings rather
251 dnl than integers to his pgsql-database.
252 dnl
253
254 AC_ARG_WITH(pgsql-log-ip-as-string,
255  --with-pgsql-log-ip-as-string          log IPs as string rather than as interger
256 ,[
257    EXTRA_PGSQL_DEF="-DIP_AS_STRING=1"
258 ])
259
260
261 dnl
262 dnl test for sqlite3
263 dnl
264 AC_ARG_WITH(sqlite3,
265  --with-sqlite3=<directory>             sqlite3 installed in <directory>,[
266 if test $withval != yes
267 then
268         dir=$withval
269 else
270         dir="/usr/local"
271 fi
272 mysqldir=""
273 AC_MSG_CHECKING(for sqlite3 files)
274 for d in $dir /usr /usr/local /usr/local/sqlite3
275 do
276         if test -f $d/lib/sqlite3/libsqlite3.so
277         then
278                 AC_MSG_RESULT(found sqlite3 in $d)
279                 sqlite3dir=$d
280                 sqlite3dir_suffix=/sqlite3
281                 break
282         elif test -f $d/lib64/sqlite3/libsqlite3.so
283         then
284                 AC_MSG_RESULT(found sqlite3 in $d)
285                 sqlite3dir=$d
286                 sqlite3dir_suffix=/sqlite3
287                 break
288         elif test -f $d/lib/libsqlite3.so
289         then
290                 AC_MSG_RESULT(found sqlite in $d)
291                 sqlite3dir=$d
292                 sqlite3dir_suffix=
293                 break
294         elif test -f $d/lib64/libsqlite3.so
295         then
296                 AC_MSG_RESULT(found sqlite in $d)
297                 sqlite3dir=$d
298                 sqlite3dir_suffix=
299                 break
300         fi
301 done
302
303 if test x$sqlite3dir = x
304 then
305         AC_MSG_WARN(sqlite3 backend not used)
306 else
307         AC_DEFINE(HAVE_SQLITE3)
308         SQLITE3INCLUDES=${sqlite3dir}/include${sqlite3dir_suffix}
309         SQLITE3LIBS=${sqlite3dir}/lib${sqlite3dir_suffix}
310
311         DATABASE_DIR="${DATABASE_DIR} sqlite3"
312
313         SQLITE3_LIB="${DATABASE_LIB} -lsqlite3 " 
314         DATABASE_LIB_DIR="${DATABASE_LIB_DIR} -L${SQLITE3LIBS} "
315
316 dnl     DATABASE_DRIVERS="${DATABASE_DRIVERS} ../sqlite3/mysql_driver.o "
317
318         DB_DEF="${DB_DEF} -DHAVE_SQLITE3 "
319
320
321         AC_SUBST(SQLITE3INCLUDES)
322         AC_SUBST(SQLITE3_LIB)
323
324 fi      
325 ])      
326
327
328 dnl
329 dnl Check whether the user wants log IP-addresses as strings rather
330 dnl than as unsigned long-integers to his sqlite3-database. Since this
331 dnl feature is only used in ulogd_SQLITE3.c, there are no checks in any
332 dnl way.
333 dnl
334
335 AC_ARG_WITH(sqlite3-log-ip-as-string,
336  --with-sqlite3-log-ip-as-string                log IPs as string rather than as
337                                                 unsigned long-integer.
338 ,[
339    EXTRA_SQLITE3_DEF="${EXTRA_SQLITE3_DEF} -DIP_AS_STRING=1"
340    AC_MSG_WARN(the use of --with-sqlite3-log-ip-as-string is discouraged)
341 ])
342
343
344 AC_SUBST(DATABASE_DIR)
345 AC_SUBST(DATABASE_LIB)
346 AC_SUBST(DATABASE_LIB_DIR)
347 AC_SUBST(DB_DEF)
348 AC_SUBST(EXTRA_MYSQL_DEF)
349 AC_SUBST(EXTRA_PGSQL_DEF)
350 AC_SUBST(EXTRA_SQLITE3_DEF)
351
352 AC_SUBST(DATABASE_DRIVERS)
353 AC_SUBST(HAVE_PCAP_H)
354
355 AM_CONDITIONAL(HAVE_MYSQL, test x$mysqldir != x)
356 AM_CONDITIONAL(HAVE_PGSQL, test x$pgsqldir != x)
357 AM_CONDITIONAL(HAVE_SQLITE3, test x$sqlite3dir != x)
358
359 AC_OUTPUT(extensions/Makefile doc/Makefile conffile/Makefile libipulog/Makefile mysql/Makefile pgsql/Makefile sqlite3/Makefile pcap/Makefile drl/Makefile Makefile Rules.make)