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