Added a handler for SIGUSR1, which toggles off/on the enforcement calls to tc.
[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 == no
69 then
70     AC_MSG_WARN("mysql disabled.")
71 else
72 if test $withval != yes
73 then
74         dir=$withval
75 else
76         dir="/usr/local"
77 fi
78 mysqldir=""
79 AC_MSG_CHECKING(for MySQL files)
80 for d in $dir/bin /usr/bin /usr/local/bin /usr/local/mysql/bin /opt/mysql/bin /opt/packages/mysql/bin
81 do
82         if test -f $d/mysql_config
83         then
84                 AC_MSG_RESULT(found mysql_config in $d)
85                 mysqldir=$d
86                 break
87         fi
88 done
89
90 if test x$mysqldir = x
91 then
92         AC_MSG_WARN(MySQL backend not used)
93 else
94         AC_DEFINE(HAVE_MYSQL)
95         MYSQLINCLUDES=`$d/mysql_config --include`
96         MYSQLLIBS=`$d/mysql_config --libs`
97
98         DATABASE_DIR="${DATABASE_DIR} mysql"
99
100         MYSQL_LIB="${DATABASE_LIB} ${MYSQLLIBS} " 
101         # no change to DATABASE_LIB_DIR, since --libs already includes -L
102
103         DATABASE_DRIVERS="${DATABASE_DRIVERS} ../mysql/mysql_driver.o "
104
105         DB_DEF="${DB_DEF} -DHAVE_MYSQL "
106
107
108         AC_SUBST(MYSQLINCLUDES)
109         AC_SUBST(MYSQL_LIB)
110
111         dnl Here we check whether we have an old MySQL client library
112         dnl installed, which does not support the mysql_real_escape_string(),
113         dnl but the real_escape_string() function.
114         dnl Having a look in the libary itself should be more reliable than
115         dnl parsing the output of mysql --version.
116
117         AC_MSG_CHECKING(for mysql_real_escape_string support)
118
119         MYSQL_FUNCTION_TEST=`strings ${MYSQLLIBS}/libmysqlclient.so | grep mysql_real_escape_string`
120
121         if test "x$MYSQL_FUNCTION_TEST" = x
122         then
123                 EXTRA_MYSQL_DEF="-DOLD_MYSQL=1 "
124                 AC_MSG_RESULT(found old MySQL)
125         else
126                 AC_MSG_RESULT(found new MySQL)
127         fi
128
129 fi
130 fi
131 ])      
132
133
134 dnl
135 dnl Check whether the user wants log IP-addresses as strings rather
136 dnl than as unsigned long-integers to his MySQL-database. Since this
137 dnl feature is only used in ulogd_MYSQL.c, there are no checks in any
138 dnl way.
139 dnl
140
141 AC_ARG_WITH(mysql-log-ip-as-string,
142  --with-mysql-log-ip-as-string          log IPs as string rather than as
143                                         unsigned long-integer.
144 ,[
145    EXTRA_MYSQL_DEF="${EXTRA_MYSQL_DEF} -DIP_AS_STRING=1"
146    AC_MSG_WARN(the use of --with-mysql-log-ip-as-string is discouraged)
147 ])
148
149
150 dnl
151 dnl test for PostgreSQL
152 dnl
153 AC_ARG_WITH(pgsql,
154  --with-pgsql=<directory>               pgsql installed in <directory>,[
155 if test $withval != yes
156 then
157         dir=$withval
158 else
159         dir="/usr/local"
160 fi
161 pgsqldir=""
162 AC_MSG_CHECKING(for PGSQL files)
163 for d in $dir/bin /usr/bin /usr/local/bin /usr/local/pgsql/bin /opt/pgsql/bin /opt/packages/pgsql/bin
164 do
165         if test -x $d/pg_config
166         then
167                 AC_MSG_RESULT(found pg_config in $d)
168                 pgsqldir=$d
169                 break
170         fi
171 done
172
173 if test x$pgsqldir = x
174 then
175         AC_MSG_WARN(PGSQL backend not used)
176 else
177         AC_DEFINE(HAVE_PGSQL)
178         PGSQLINCLUDES=`$pgsqldir/pg_config --includedir`
179         PGSQLLIBS=`$pgsqldir/pg_config --libdir`
180
181         DATABASE_DIR="${DATABASE_DIR} pgsql"
182         PGSQL_LIB="${DATABASE_LIB} -lpq " 
183
184         DATABASE_LIB_DIR="${DATABASE_LIB_DIR} -L${PGSQLLIBS} "
185         DB_DEF="${DB_DEF} -DHAVE_PGSQL "
186
187         AC_SUBST(PGSQLINCLUDES)
188         AC_SUBST(PGSQL_LIB)
189
190 fi      
191 ])      
192
193 dnl
194 dnl Check whether the user wants to log IP-addresses as strings rather
195 dnl than integers to his pgsql-database.
196 dnl
197
198 AC_ARG_WITH(pgsql-log-ip-as-string,
199  --with-pgsql-log-ip-as-string          log IPs as string rather than as interger
200 ,[
201    EXTRA_PGSQL_DEF="-DIP_AS_STRING=1"
202 ])
203
204
205 dnl
206 dnl test for sqlite3
207 dnl
208 AC_ARG_WITH(sqlite3,
209  --with-sqlite3=<directory>             sqlite3 installed in <directory>,[
210 if test $withval != yes
211 then
212         dir=$withval
213 else
214         dir="/usr/local"
215 fi
216 mysqldir=""
217 AC_MSG_CHECKING(for sqlite3 files)
218 for d in $dir /usr /usr/local /usr/local/sqlite3
219 do
220         if test -f $d/lib/sqlite3/libsqlite3.so
221         then
222                 AC_MSG_RESULT(found sqlite3 in $d)
223                 sqlite3dir=$d
224                 sqlite3dir_suffix=/sqlite3
225                 break
226         elif test -f $d/lib64/sqlite3/libsqlite3.so
227         then
228                 AC_MSG_RESULT(found sqlite3 in $d)
229                 sqlite3dir=$d
230                 sqlite3dir_suffix=/sqlite3
231                 break
232         elif test -f $d/lib/libsqlite3.so
233         then
234                 AC_MSG_RESULT(found sqlite in $d)
235                 sqlite3dir=$d
236                 sqlite3dir_suffix=
237                 break
238         elif test -f $d/lib64/libsqlite3.so
239         then
240                 AC_MSG_RESULT(found sqlite in $d)
241                 sqlite3dir=$d
242                 sqlite3dir_suffix=
243                 break
244         fi
245 done
246
247 if test x$sqlite3dir = x
248 then
249         AC_MSG_WARN(sqlite3 backend not used)
250 else
251         AC_DEFINE(HAVE_SQLITE3)
252         SQLITE3INCLUDES=${sqlite3dir}/include${sqlite3dir_suffix}
253         SQLITE3LIBS=${sqlite3dir}/lib${sqlite3dir_suffix}
254
255         DATABASE_DIR="${DATABASE_DIR} sqlite3"
256
257         SQLITE3_LIB="${DATABASE_LIB} -lsqlite3 " 
258         DATABASE_LIB_DIR="${DATABASE_LIB_DIR} -L${SQLITE3LIBS} "
259
260 dnl     DATABASE_DRIVERS="${DATABASE_DRIVERS} ../sqlite3/mysql_driver.o "
261
262         DB_DEF="${DB_DEF} -DHAVE_SQLITE3 "
263
264
265         AC_SUBST(SQLITE3INCLUDES)
266         AC_SUBST(SQLITE3_LIB)
267
268 fi      
269 ])      
270
271
272 dnl
273 dnl Check whether the user wants log IP-addresses as strings rather
274 dnl than as unsigned long-integers to his sqlite3-database. Since this
275 dnl feature is only used in ulogd_SQLITE3.c, there are no checks in any
276 dnl way.
277 dnl
278
279 AC_ARG_WITH(sqlite3-log-ip-as-string,
280  --with-sqlite3-log-ip-as-string                log IPs as string rather than as
281                                                 unsigned long-integer.
282 ,[
283    EXTRA_SQLITE3_DEF="${EXTRA_SQLITE3_DEF} -DIP_AS_STRING=1"
284    AC_MSG_WARN(the use of --with-sqlite3-log-ip-as-string is discouraged)
285 ])
286
287
288 AC_SUBST(DATABASE_DIR)
289 AC_SUBST(DATABASE_LIB)
290 AC_SUBST(DATABASE_LIB_DIR)
291 AC_SUBST(DB_DEF)
292 AC_SUBST(EXTRA_MYSQL_DEF)
293 AC_SUBST(EXTRA_PGSQL_DEF)
294 AC_SUBST(EXTRA_SQLITE3_DEF)
295
296 AC_SUBST(DATABASE_DRIVERS)
297 AC_SUBST(HAVE_PCAP_H)
298
299 AM_CONDITIONAL(HAVE_MYSQL, test x$mysqldir != x)
300 AM_CONDITIONAL(HAVE_PGSQL, test x$pgsqldir != x)
301 AM_CONDITIONAL(HAVE_SQLITE3, test x$sqlite3dir != x)
302
303 AC_OUTPUT(extensions/Makefile doc/Makefile conffile/Makefile libipulog/Makefile mysql/Makefile pgsql/Makefile sqlite3/Makefile pcap/Makefile drl/Makefile Makefile Rules.make)