]> git.ipfire.org Git - people/ms/suricata.git/blame - configure.ac
pool thread: undo CLS alignment
[people/ms/suricata.git] / configure.ac
CommitLineData
6899b3da 1#TODO A better place for default CFLAGS?
0ffa1c24 2
bab4b623 3
0cef0b88 4 AC_INIT(suricata, 2.0dev)
83014adc 5 AC_CONFIG_HEADERS([config.h])
7dbc97b0 6 AC_CONFIG_SRCDIR([src/suricata.c])
0cef0b88 7 AC_CONFIG_MACRO_DIR(m4)
7dbc97b0 8 AM_INIT_AUTOMAKE
a3510f20
WM
9
10 AC_LANG_C
ff6a2a01 11 AC_PROG_CC_C99
769022f4 12 AC_PROG_LIBTOOL
a3510f20
WM
13
14 AC_DEFUN([FAIL_MESSAGE],[
15 echo
16 echo
17 echo "**********************************************"
18 echo " ERROR: unable to find" $1
19 echo " checked in the following places"
20 for i in `echo $2`; do
21 echo " $i"
22 done
23 echo "**********************************************"
24 echo
25 exit 1
26 ])
27
3678dda1
WM
28 AC_DEFUN([LIBNET_FAIL_WARN],[
29 echo
30 echo "*************************************************************************"
31 echo " Warning! libnet version 1.1.x could not be found in " $1
32 echo " Reject keywords will not be supported."
149d2a07 33 echo " If you require reject support, please install libnet 1.1.x. "
3678dda1
WM
34 echo " If libnet is not installed in a non-standard location please use the"
35 echo " --with-libnet-includes and --with-libnet-libraries configure options"
36 echo "*************************************************************************"
37 echo
38 ])
39
1f94239d
EL
40 if test `basename $CC` = "clang"; then
41 CFLAGS="$CFLAGS -Wextra -Werror-implicit-function-declaration"
467f28e9
VJ
42 AC_MSG_CHECKING([clang __sync_bool_compare_and_swap])
43 AC_TRY_COMPILE([#include <stdio.h>],
44 [ unsigned int i = 0; (void)__sync_bool_compare_and_swap(&i, 1, 1);],
45 [
46 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1], [1], [Fake GCC atomic support])
47 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2], [1], [Fake GCC atomic support])
48 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4], [1], [Fake GCC atomic support])
49 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8], [1], [Fake GCC atomic support])
50 AC_MSG_RESULT([yes]) ],
51 [AC_MSG_RESULT([no])])
bda87024 52 fi
1f94239d
EL
53 if test `basename $CC` = "gcc"; then
54 dnl get gcc version
55 AC_MSG_CHECKING([gcc version])
56 gccver=$($CC -dumpversion)
57 gccvermajor=$(echo $gccver | cut -d . -f1)
58 gccverminor=$(echo $gccver | cut -d . -f2)
59 gccvernum=$(expr $gccvermajor "*" 100 + $gccverminor)
60 AC_MSG_RESULT($gccver)
61
62 if test "$gccvernum" -ge "400"; then
63 dnl gcc 4.0 or later
64 CFLAGS="$CFLAGS -Wextra -Werror-implicit-function-declaration"
042d0c6e
VJ
65 # remove optimization options that break our code
66 # VJ 2010/06/27: no-tree-pre added. It breaks ringbuffers code.
67 CFLAGS="$CFLAGS -fno-tree-pre"
1f94239d
EL
68 else
69 CFLAGS="$CFLAGS -W"
70 fi
1f94239d 71 fi
bc29684d 72 CFLAGS="$CFLAGS -Wall"
bda87024 73 CFLAGS="$CFLAGS -Wno-unused-parameter"
9f0bf35c 74 CFLAGS="$CFLAGS -std=gnu99"
0ffa1c24 75
89cee0ad 76 # Checks for programs.
fa5939ca
BR
77 AC_PROG_AWK
78 AC_PROG_CC
79 AC_PROG_CPP
80 AC_PROG_INSTALL
81 AC_PROG_LN_S
82 AC_PROG_MAKE_SET
fa5939ca 83
9f1d779a
WM
84 AC_PATH_PROG(HAVE_PKG_CONFIG, pkg-config, "no")
85 if test "$HAVE_PKG_CONFIG" = "no"; then
89cee0ad
VJ
86 echo
87 echo " ERROR! pkg-config not found, go get it "
88 echo " http://pkg-config.freedesktop.org/wiki/ "
89 echo " or install from your distribution "
90 echo
91 exit 1
9f1d779a
WM
92 fi
93
7c841e1d
EL
94 AC_PATH_PROG(HAVE_COCCINELLE_CONFIG, spatch, "no")
95 if test "$HAVE_COCCINELLE_CONFIG" = "no"; then
89cee0ad
VJ
96 echo
97 echo " Warning! spatch not found, you will not be "
98 echo " able to run code checking with coccinelle "
99 echo " get it from http://coccinelle.lip6.fr "
100 echo " or install from your distribution "
101 echo
7c841e1d
EL
102 fi
103 AM_CONDITIONAL([HAVE_COCCINELLE], [test "$HAVE_COCCINELLE_CONFIG" != "no"])
104
cd305c3a
EL
105 AC_PATH_PROG(HAVE_PYTHON_CONFIG, python, "no")
106 if test "$HAVE_PYTHON_CONFIG" = "no"; then
107 echo
108 echo " Warning! python not found, you will not be "
109 echo " able to install surictasc unix socket client "
110 echo
111 enable_python="no"
112 else
113 enable_python="yes"
114 fi
115 AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON_CONFIG" != "no"])
116
daa9dcb7
EL
117 AC_PATH_PROG(HAVE_WGET, wget, "no")
118 if test "$HAVE_WGET" = "no"; then
119 AC_PATH_PROG(HAVE_CURL, curl, "no")
120 if test "$HAVE_CURL" = "no"; then
121 echo
122 echo " Warning curl or wget not found, you won't be able to"
123 echo " download latest ruleset with 'make install-rules'"
124 fi
125 fi
126 AM_CONDITIONAL([HAVE_FETCH_COMMAND], [test "x$HAVE_WGET" != "xno" || test "x$HAVE_CURL" != "xno"])
127 AM_CONDITIONAL([HAVE_WGET_COMMAND], [test "x$HAVE_WGET" != "xno"])
7c841e1d 128
89cee0ad 129 # Checks for libraries.
7c841e1d 130
89cee0ad 131 # Checks for header files.
472e061c
VJ
132 AC_CHECK_HEADERS([arpa/inet.h assert.h ctype.h errno.h fcntl.h inttypes.h])
133 AC_CHECK_HEADERS([getopt.h])
134 AC_CHECK_HEADERS([limits.h netdb.h netinet/in.h poll.h sched.h signal.h])
135 AC_CHECK_HEADERS([stdarg.h stdint.h stdio.h stdlib.h string.h sys/ioctl.h])
136 AC_CHECK_HEADERS([syslog.h sys/prctl.h sys/socket.h sys/stat.h sys/syscall.h])
b63c2eda 137 AC_CHECK_HEADERS([sys/time.h time.h unistd.h])
472e061c 138 AC_CHECK_HEADERS([sys/ioctl.h linux/if_ether.h linux/if_packet.h linux/filter.h])
fcc87595 139 AC_CHECK_HEADERS([linux/ethtool.h linux/sockios.h])
472e061c
VJ
140
141 AC_CHECK_HEADERS([sys/socket.h net/if.h sys/mman.h linux/if_arp.h], [], [],
5656e344 142 [[#ifdef HAVE_SYS_SOCKET_H
472e061c
VJ
143 #include <sys/types.h>
144 #include <sys/socket.h>
145 #endif
5656e344
EL
146 ]])
147
b63c2eda
VJ
148 AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h], [], [],
149 [[#define _X86_
150 ]])
151 AC_CHECK_HEADERS([w32api/winbase.h], [], [],
152 [[#define _X86_
153 #include <windows.h>
154 ]])
fa5939ca 155
89cee0ad 156 # Checks for typedefs, structures, and compiler characteristics.
fa5939ca
BR
157 AC_C_INLINE
158 AC_TYPE_PID_T
159 AC_TYPE_SIZE_T
160 AC_TYPE_INT32_T
161 AC_TYPE_UINT16_T
162 AC_TYPE_UINT32_T
163 AC_TYPE_UINT64_T
164 AC_TYPE_UINT8_T
165 AC_HEADER_STDBOOL
166
89cee0ad 167 # Checks for library functions.
fa5939ca
BR
168 AC_FUNC_MALLOC
169 AC_FUNC_REALLOC
c8b71938 170 AC_CHECK_FUNCS([gettimeofday memset strcasecmp strchr strdup strerror strncasecmp strtol strtoul memchr memrchr])
fa5939ca 171
89cee0ad 172 # Add large file support
3b3f5816
WM
173 AC_SYS_LARGEFILE
174
89cee0ad 175 #check for os
769022f4
PR
176 AC_MSG_CHECKING([host os])
177
178 # If no host os was detected, try with uname
25804f5a 179 if test -z "$host" ; then
769022f4
PR
180 host="`uname`"
181 fi
a49bce63 182 echo -n "installation for $host OS... "
769022f4 183
e2bf0fab 184 e_magic_file="/usr/share/file/magic"
769022f4 185 case "$host" in
829238e4
VJ
186 *-*-*freebsd*)
187 CFLAGS="${CFLAGS} -DOS_FREEBSD"
188 CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/local/include/libnet11"
189 LDFLAGS="${LDFLAGS} -L/usr/local/lib -L/usr/local/lib/libnet11"
190 e_magic_file="/usr/share/misc/magic"
191 ;;
192 *-*-openbsd5.1)
193 CFLAGS="${CFLAGS} -D__OpenBSD__ -fgnu89-inline"
194 CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/local/include/libnet-1.1"
195 LDFLAGS="${LDFLAGS} -L/usr/local/lib -I/usr/local/lib/libnet-1.1"
196 e_magic_file="/usr/local/share/misc/magic.mgc"
197 ;;
198 *-*-openbsd5.2)
199 CFLAGS="${CFLAGS} -D__OpenBSD__"
200 CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/local/include/libnet-1.1"
201 LDFLAGS="${LDFLAGS} -L/usr/local/lib -I/usr/local/lib/libnet-1.1"
202 e_magic_file="/usr/local/share/misc/magic.mgc"
203 ;;
204 *-*-openbsd*)
205 CFLAGS="${CFLAGS} -D__OpenBSD__ -fgnu89-inline"
206 CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/local/include/libnet-1.1"
207 LDFLAGS="${LDFLAGS} -L/usr/local/lib -I/usr/local/lib/libnet-1.1"
208 e_magic_file="/usr/local/share/file/magic.mgc"
209 ;;
210 *darwin*|*Darwin*)
211 CFLAGS="${CFLAGS} -DOS_DARWIN"
212 CPPFLAGS="${CPPFLAGS} -I/opt/local/include"
213 LDFLAGS="${LDFLAGS} -L/opt/local/lib"
214 ;;
215 *-*-linux*)
216 #for now do nothing
217 ;;
218 *-*-mingw32*)
219 CFLAGS="${CFLAGS} -DOS_WIN32"
220 LDFLAGS="${LDFLAGS} -lws2_32"
221 WINDOWS_PATH="yes"
222 ;;
223 *-*-cygwin)
224 WINDOWS_PATH="yes"
225 ;;
226 *)
227 AC_MSG_WARN([unsupported OS this may or may not work])
228 ;;
769022f4
PR
229 esac
230 AC_MSG_RESULT(ok)
231
900918a5
VJ
232 # check if our target supports thread local storage
233 AC_MSG_CHECKING(for thread local storage __thread support)
234 AC_TRY_COMPILE([#include <stdlib.h>],
235 [ void somefunc (void) { static __thread int i; i = 1; i++; } ],
236 [AC_DEFINE([TLS], [1], [Thread local storage])
237 AC_MSG_RESULT([yes]) ],
238 [AC_MSG_RESULT([no])])
239
89cee0ad
VJ
240 #Enable support for gcc compile time security options. There is no great way to do detection of valid cflags that I have found
241 #AX_CFLAGS_GCC_OPTION don't seem to do a better job than the code below and are a pain because of extra m4 files etc.
242 #These flags seem to be supported on CentOS 5+, Ubuntu 8.04+, and FedoreCore 11+
243 #Options are taken from https://wiki.ubuntu.com/CompilerFlags
c49785fb 244 AC_ARG_ENABLE(gccprotect,
e07e9e16 245 AS_HELP_STRING([--enable-gccprotect], [Detect and use gcc hardening options]),,[enable_gccprotect=no])
c49785fb 246
e07e9e16 247 AS_IF([test "x$enable_gccprotect" = "xyes"], [
98b9009b
WM
248 #buffer overflow protection
249 AC_MSG_CHECKING(for -fstack-protector)
250 TMPCFLAGS="${CFLAGS}"
251 CFLAGS="${CFLAGS} -fstack-protector"
252 AC_TRY_LINK(,,SECCFLAGS="${SECCFLAGS} -fstack-protector"
253 AC_MSG_RESULT(yes),
254 AC_MSG_RESULT(no))
255 CFLAGS="${TMPCFLAGS}"
256
257 #compile-time best-practices errors for certain libc functions, provides checks of buffer lengths and memory regions
258 AC_MSG_CHECKING(for -D_FORTIFY_SOURCE=2)
259 TMPCFLAGS="${CFLAGS}"
260 CFLAGS="${CFLAGS} -D_FORTIFY_SOURCE=2"
261 AC_TRY_COMPILE(,,SECCFLAGS="${SECCFLAGS} -D_FORTIFY_SOURCE=2"
262 AC_MSG_RESULT(yes),
263 AC_MSG_RESULT(no))
264 CFLAGS="${TMPCFLAGS}"
265
266 #compile-time warnings about misuse of format strings
267 AC_MSG_CHECKING(for -Wformat -Wformat-security)
268 TMPCFLAGS="${CFLAGS}"
269 CFLAGS="${CFLAGS} -Wformat -Wformat-security"
270 AC_TRY_COMPILE(,,SECCFLAGS="${SECCFLAGS} -Wformat -Wformat-security"
271 AC_MSG_RESULT(yes),
272 AC_MSG_RESULT(no))
273 CFLAGS="${TMPCFLAGS}"
274
275 #provides a read-only relocation table area in the final ELF
276 AC_MSG_CHECKING(for -z relro)
277 TMPLDFLAGS="${LDFLAGS}"
278 LDFLAGS="${LDFLAGS} -z relro"
279 AC_TRY_LINK(,,SECLDFLAGS="${SECLDFLAGS} -z relro"
280 AC_MSG_RESULT(yes),
281 AC_MSG_RESULT(no))
282 LDFLAGS="${TMPLDFLAGS}"
283
284 #forces all relocations to be resolved at run-time
285 AC_MSG_CHECKING(for -z now)
286 TMPLDFLAGS="${LDFLAGS}"
287 LDFLAGS="${LDFLAGS} -z now"
288 AC_TRY_LINK(,,SECLDFLAGS="${SECLDFLAGS} -z now"
289 AC_MSG_RESULT(yes),
290 AC_MSG_RESULT(no))
291 LDFLAGS="${TMPLDFLAGS}"
292
293 CFLAGS="${CFLAGS} ${SECCFLAGS}"
294 LDFLAGS="${LDFLAGS} ${SECLDFLAGS}"
e07e9e16 295 ])
5bde1217 296
89cee0ad 297 #enable profile generation
5bde1217 298 AC_ARG_ENABLE(gccprofile,
e07e9e16
WM
299 AS_HELP_STRING([--enable-gccprofile], [Enable gcc profile info i.e -pg flag is set]),,[enable_gccprofile=no])
300 AS_IF([test "x$enable_gccprofile" = "xyes"], [
301 CFLAGS="${CFLAGS} -pg"
302 ])
5bde1217 303
89cee0ad 304 #enable gcc march=native gcc 4.2 or later
22f3e3d8 305 AC_ARG_ENABLE(gccmarch_native,
9f0bf35c 306 AS_HELP_STRING([--enable-gccmarch-native], [Enable gcc march=native gcc 4.2 and later only]),,[enable_gccmarch_native=yes])
e07e9e16 307 AS_IF([test "x$enable_gccmarch_native" = "xyes"], [
37b05b23
EL
308 OFLAGS="$CFLAGS"
309 CFLAGS="$CFLAGS -march=native"
310 AC_MSG_CHECKING([checking if $CC supports -march=native])
311 AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <stdlib.h>]])],
312 [
313 AC_MSG_RESULT([yes])
314 CFLAGS="$OFLAGS -march=native"
315 ],
316 [
317 AC_MSG_RESULT([no])
318 CFLAGS="$OFLAGS"
319 enable_gccmarch_native=no
320 ]
321 )
e07e9e16 322 ])
22f3e3d8 323
89cee0ad
VJ
324# options
325
326 # enable the running of unit tests
327 AC_ARG_ENABLE(unittests,
328 AS_HELP_STRING([--enable-unittests], [Enable compilation of the unit tests]),,[enable_unittests=no])
329 AS_IF([test "x$enable_unittests" = "xyes"], [
330 UT_ENABLED="yes"
331 CFLAGS="${CFLAGS} -DUNITTESTS"
332 ])
333
334 AM_CONDITIONAL([BUILD_UNITTESTS], [test "x$enable_unittests" = "xyes"])
335
336 # enable workaround for old barnyard2 for unified alert output
337 AC_ARG_ENABLE(old-barnyard2,
338 AS_HELP_STRING([--enable-old-barnyard2], [Use workaround for old barnyard2 in unified2 output]),,[enable_old_barnyard2=no])
339 AS_IF([test "x$enable_old_barnyard2" = "xyes"], [
340 CFLAGS="${CFLAGS} -DHAVE_OLD_BARNYARD2"
341 ])
342
343 # enable debug output
344 AC_ARG_ENABLE(debug,
345 AS_HELP_STRING([--enable-debug], [Enable debug output]),,[enable_debug=no])
346 AS_IF([test "x$enable_debug" = "xyes"], [
347 CFLAGS="${CFLAGS} -DDEBUG"
348 ])
349
350 # enable debug validation functions & macro's output
351 AC_ARG_ENABLE(debug-validation,
352 AS_HELP_STRING([--enable-debug-validation], [Enable (debug) validation code output]),,[enable_debug_validation=no])
353 AS_IF([test "x$enable_debug_validation" = "xyes"], [
354 CFLAGS="${CFLAGS} -DDEBUG_VALIDATION"
355 ])
356
357 # profiling support
358 AC_ARG_ENABLE(profiling,
359 AS_HELP_STRING([--enable-profiling], [Enable performance profiling]),,[enable_profiling=no])
360 AS_IF([test "x$enable_profiling" = "xyes"], [
ac5bab88
EL
361
362 case "$host" in
363 *-*-openbsd*)
364 AC_MSG_ERROR([profiling is not supported on OpenBSD])
365 ;;
366 *)
367 CFLAGS="${CFLAGS} -DPROFILING"
368 ;;
369 esac
89cee0ad
VJ
370 ])
371
d908e707
VJ
372 # profiling support, locking
373 AC_ARG_ENABLE(profiling-locks,
374 AS_HELP_STRING([--enable-profiling-locks], [Enable performance profiling for locks]),,[enable_profiling_locks=no])
375 AS_IF([test "x$enable_profiling_locks" = "xyes"], [
376 CFLAGS="${CFLAGS} -DPROFILING -DPROFILE_LOCKING"
377 ])
378
89cee0ad
VJ
379 # enable support for IPFW
380 AC_ARG_ENABLE(ipfw,
381 AS_HELP_STRING([--enable-ipfw], [Enable FreeBSD IPFW support for inline IDP]),,[enable_ipfw=no])
382 AS_IF([test "x$enable_ipfw" = "xyes"], [
383 CFLAGS="$CFLAGS -DIPFW"
384 ])
385
386# libraries
387
3db717db
KS
388 AC_MSG_CHECKING([for Mpipe])
389 AC_COMPILE_IFELSE(
390 [AC_LANG_PROGRAM([[#include <gxio/mpipe.h>]])],
391 [
392 AC_MSG_RESULT([yes])
393 AC_DEFINE([HAVE_MPIPE],[1],[mPIPE support is available])
394 LDFLAGS="$LDFLAGS -lgxio -ltmc"
395 ],
396 [AC_MSG_RESULT([no])])
397
89cee0ad 398 #libpcre
a3510f20
WM
399 AC_ARG_WITH(libpcre_includes,
400 [ --with-libpcre-includes=DIR libpcre include directory],
401 [with_libpcre_includes="$withval"],[with_libpcre_includes=no])
402 AC_ARG_WITH(libpcre_libraries,
403 [ --with-libpcre-libraries=DIR libpcre library directory],
404 [with_libpcre_libraries="$withval"],[with_libpcre_libraries="no"])
405
406 if test "$with_libpcre_includes" != "no"; then
89f83c2e 407 CPPFLAGS="${CPPFLAGS} -I${with_libpcre_includes}"
a3510f20 408 fi
a3510f20 409 AC_CHECK_HEADER(pcre.h,,[AC_ERROR(pcre.h not found ...)])
6899b3da 410
a3510f20 411 if test "$with_libpcre_libraries" != "no"; then
89f83c2e 412 LDFLAGS="${LDFLAGS} -L${with_libpcre_libraries}"
a3510f20 413 fi
a3510f20
WM
414 PCRE=""
415 AC_CHECK_LIB(pcre, pcre_get_substring,, PCRE="no")
89f83c2e
VJ
416 if test "$PCRE" = "no"; then
417 echo
418 echo " ERROR! pcre library not found, go get it"
419 echo " from www.pcre.org."
420 echo
421 exit 1
422 fi
6899b3da 423
89f83c2e
VJ
424 # To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
425 # see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
426 PCRE=""
427 TMPLIBS="${LIBS}"
428 AC_CHECK_LIB(pcre, pcre_dfa_exec,, PCRE="no")
a3510f20 429 if test "$PCRE" = "no"; then
89f83c2e
VJ
430 echo
431 echo " ERROR! pcre library was found but version was < 6.0"
432 echo " please upgrade to a newer version of pcre which you can get from"
433 echo " www.pcre.org."
434 echo
435 exit 1
a3510f20 436 fi
89f83c2e 437 LIBS="${TMPLIBS}"
6899b3da 438
89f83c2e
VJ
439 AC_TRY_COMPILE([ #include <pcre.h> ],
440 [ int eo = 0; eo |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; ],
441 [ pcre_match_limit_recursion_available=yes ], [:]
442 )
443 if test "$pcre_match_limit_recursion_available" != "yes"; then
444 CFLAGS="${CFLAGS} -DNO_PCRE_MATCH_RLIMIT"
445 echo
446 echo " Warning! pcre extra opt PCRE_EXTRA_MATCH_LIMIT_RECURSION not found"
447 echo " This could lead to potential DoS please upgrade to pcre >= 6.5"
448 echo " Continuing for now...."
449 echo " from www.pcre.org."
450 echo
451 fi
5bde1217 452
0bfba835
VJ
453 TMPCFLAGS="${CFLAGS}"
454 CFLAGS="-O0 -g -Werror -Wall"
455 AC_TRY_COMPILE([ #include <pcre.h> ],
456 [ pcre_extra *extra = NULL; pcre_free_study(extra); ],
457 [ AC_DEFINE([HAVE_PCRE_FREE_STUDY], [1], [Pcre pcre_free_study supported])], [:]
458 )
459 CFLAGS="${TMPCFLAGS}"
460
3d396e8b 461 #enable support for PCRE-jit available since pcre-8.20
3d558bf0
EL
462 AC_MSG_CHECKING(for PCRE JIT support)
463 AC_TRY_COMPILE([ #include <pcre.h> ],
464 [
465 int jit = 0;
466 pcre_config(PCRE_CONFIG_JIT, &jit);
467 ],
468 [ pcre_jit_available=yes ], [ pcre_jit_available=no ]
469 )
470
471 if test "x$pcre_jit_available" = "xyes"; then
472 AC_MSG_RESULT(yes)
473 AC_DEFINE([PCRE_HAVE_JIT], [1], [Pcre with JIT compiler support enabled])
474
475 AC_MSG_CHECKING(for PCRE JIT support usability)
476 AC_TRY_COMPILE([ #include <pcre.h> ],
477 [
478 const char* regexstr = "(a|b|c|d)";
479 pcre *re;
480 const char *error;
481 pcre_extra *extra;
482 int err_offset;
483 re = pcre_compile(regexstr,0, &error, &err_offset,NULL);
484 extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error);
485 if (extra == NULL)
486 exit(EXIT_FAILURE);
487 int jit = 0;
488 int ret = pcre_fullinfo(re, extra, PCRE_INFO_JIT, &jit);
489 if (ret != 0 || jit != 1)
490 exit(EXIT_FAILURE);
491 exit(EXIT_SUCCESS);
492 ],
493 [ pcre_jit_works=yes ], [:]
494 )
495 if test "x$pcre_jit_works" != "xyes"; then
496 AC_MSG_RESULT(no)
497 echo
498 echo " PCRE JIT support detection worked but testing it failed"
499 echo " something odd is going on, please file a bug report."
500 echo
501 exit 1
502 else
503 AC_MSG_RESULT(yes)
504 fi
5ea1b1d1 505 else
89f83c2e 506 AC_MSG_RESULT(no)
3d558bf0 507 fi
3d396e8b 508
89cee0ad 509 # libyaml
c91a4baa
JI
510 AC_ARG_WITH(libyaml_includes,
511 [ --with-libyaml-includes=DIR libyaml include directory],
512 [with_libyaml_includes="$withval"],[with_libyaml_includes=no])
513 AC_ARG_WITH(libyaml_libraries,
514 [ --with-libyaml-libraries=DIR libyaml library directory],
515 [with_libyaml_libraries="$withval"],[with_libyaml_libraries="no"])
516
517 if test "$with_libyaml_includes" != "no"; then
89f83c2e 518 CPPFLAGS="${CPPFLAGS} -I${with_libyaml_includes}"
c91a4baa
JI
519 fi
520
521 AC_CHECK_HEADER(yaml.h,,LIBYAML="no")
522
523 if test "$with_libyaml_libraries" != "no"; then
89f83c2e 524 LDFLAGS="${LDFLAGS} -L${with_libyaml_libraries}"
c91a4baa
JI
525 fi
526
527 LIBYAML=""
528 AC_CHECK_LIB(yaml,yaml_parser_initialize,,LIBYAML="no")
529
530 if test "$LIBYAML" = "no"; then
89cee0ad
VJ
531 echo
532 echo " ERROR! libyaml library not found, go get it"
533 echo " from http://pyyaml.org/wiki/LibYAML "
534 echo " or your distribution:"
535 echo
536 echo " Ubuntu: apt-get install libyaml-dev"
537 echo " Fedora: yum install libyaml-devel"
538 echo
539 exit 1
c91a4baa
JI
540 fi
541
89cee0ad 542 # libpthread
a3510f20
WM
543 AC_ARG_WITH(libpthread_includes,
544 [ --with-libpthread-includes=DIR libpthread include directory],
545 [with_libpthread_includes="$withval"],[with_libpthread_includes=no])
546 AC_ARG_WITH(libpthread_libraries,
547 [ --with-libpthread-libraries=DIR libpthread library directory],
548 [with_libpthread_libraries="$withval"],[with_libpthread_libraries="no"])
549
550 if test "$with_libpthread_includes" != "no"; then
89f83c2e 551 CPPFLAGS="${CPPFLAGS} -I${with_libpthread_includes}"
a3510f20 552 fi
6899b3da 553
fa5939ca 554 dnl AC_CHECK_HEADER(pthread.h,,[AC_ERROR(pthread.h not found ...)])
6899b3da 555
a3510f20 556 if test "$with_libpthread_libraries" != "no"; then
89f83c2e 557 LDFLAGS="${LDFLAGS} -L${with_libpthread_libraries}"
a3510f20 558 fi
6899b3da 559
a3510f20
WM
560 PTHREAD=""
561 AC_CHECK_LIB(pthread, pthread_create,, PTHREAD="no")
6899b3da 562
a3510f20 563 if test "$PTHREAD" = "no"; then
89f83c2e
VJ
564 echo
565 echo " ERROR! libpthread library not found, glibc problem?"
566 echo
567 exit 1
a3510f20
WM
568 fi
569
20a8b9db
EL
570 # libjansson
571 enable_jansson="no"
572 AC_ARG_WITH(libjansson_includes,
573 [ --with-libjansson-includes=DIR libjansson include directory],
574 [with_libjansson_includes="$withval"],[with_libjansson_includes=no])
575 AC_ARG_WITH(libjansson_libraries,
576 [ --with-libjansson-libraries=DIR libjansson library directory],
577 [with_libjansson_libraries="$withval"],[with_libjansson_libraries="no"])
578
579 if test "$with_libjansson_includes" != "no"; then
580 CPPFLAGS="${CPPFLAGS} -I${with_libjansson_includes}"
581 fi
582
583 enable_jansson="no"
584 enable_unixsocket="no"
7d706563
EL
585
586 AC_ARG_ENABLE(unix-socket,
587 AS_HELP_STRING([--enable-unix-socket], [Enable unix socket [default=test]]),[enable_unixsocket="$enableval"],[enable_unixsocket=test])
588
20a8b9db
EL
589 AC_CHECK_HEADER(jansson.h,JANSSON="yes",JANSSON="no")
590 if test "$JANSSON" = "yes"; then
591 if test "$with_libjansson_libraries" != "no"; then
592 LDFLAGS="${LDFLAGS} -L${with_libjansson_libraries}"
593 fi
594
0470c0f6 595 AC_CHECK_LIB(jansson, json_dump_callback,, JANSSON="no")
20a8b9db
EL
596 enable_jansson="yes"
597 if test "$JANSSON" = "no"; then
598 echo
0470c0f6 599 echo " Jansson >= 2.2 is required for features like unix socket"
ef45f7da 600 echo " Go get it from your distribution of from:"
7d706563 601 echo " http://www.digip.org/jansson/"
20a8b9db 602 echo
7d706563
EL
603 if test "x$enable_unixsocket" = "xyes"; then
604 exit 1
605 fi
20a8b9db
EL
606 enable_unixsocket="no"
607 enable_jansson="no"
608 else
609 case $host in
610 *-*-mingw32*)
611 ;;
612 *-*-cygwin)
613 ;;
614 *)
7d706563
EL
615 if test "x$enable_unixsocket" = "xtest"; then
616 enable_unixsocket="yes"
617 fi
20a8b9db
EL
618 ;;
619 esac
620 fi
7d706563
EL
621 else
622 if test "x$enable_unixsocket" = "xyes"; then
623 echo
624 echo " Jansson >= 2.2 is required for features like unix socket"
625 echo " Go get it from your distribution of from:"
626 echo " http://www.digip.org/jansson/"
627 echo
628 exit 1
629 fi
630 enable_unixsocket="no"
20a8b9db
EL
631 fi
632
633 AS_IF([test "x$enable_unixsocket" = "xyes"], [AC_DEFINE([BUILD_UNIX_SOCKET], [1], [Unix socket support enabled])])
634
89cee0ad 635 #enable support for NFQUEUE
a3510f20 636 AC_ARG_ENABLE(nfqueue,
e07e9e16
WM
637 AS_HELP_STRING([--enable-nfqueue], [Enable NFQUEUE support for inline IDP]),,[enable_nfqueue=no])
638 AS_IF([test "x$enable_nfqueue" = "xyes"], [
639 CFLAGS="$CFLAGS -DNFQ"
6899b3da 640
89cee0ad
VJ
641 # libnfnetlink
642 case $host in
643 *-*-mingw32*)
644 ;;
645 *)
646 AC_ARG_WITH(libnfnetlink_includes,
647 [ --with-libnfnetlink-includes=DIR libnfnetlink include directory],
648 [with_libnfnetlink_includes="$withval"],[with_libnfnetlink_includes=no])
649 AC_ARG_WITH(libnfnetlink_libraries,
650 [ --with-libnfnetlink-libraries=DIR libnfnetlink library directory],
651 [with_libnfnetlink_libraries="$withval"],[with_libnfnetlink_libraries="no"])
652
653 if test "$with_libnfnetlink_includes" != "no"; then
654 CPPFLAGS="${CPPFLAGS} -I${with_libnfnetlink_includes}"
655 fi
0ffa1c24 656
89cee0ad 657 AC_CHECK_HEADER(libnfnetlink/libnfnetlink.h,,[AC_ERROR(libnfnetlink.h not found ...)])
0ffa1c24 658
89cee0ad
VJ
659 if test "$with_libnfnetlink_libraries" != "no"; then
660 LDFLAGS="${LDFLAGS} -L${with_libnfnetlink_libraries}"
661 fi
0ffa1c24 662
89cee0ad
VJ
663 NFNL=""
664 AC_CHECK_LIB(nfnetlink, nfnl_fd,, NFNL="no")
0ffa1c24 665
89cee0ad
VJ
666 if test "$NFNL" = "no"; then
667 echo
668 echo " ERROR! nfnetlink library not found, go get it"
669 echo " from www.netfilter.org."
670 echo " we automatically append libnetfilter_queue/ when searching"
671 echo " for headers etc. when the --with-libnfnetlink-inlcudes directive"
672 echo " is used"
673 echo
674 exit 1
675 fi
676 ;;
677 esac
0ffa1c24 678
89cee0ad 679 #libnetfilter_queue
a3510f20
WM
680 AC_ARG_WITH(libnetfilter_queue_includes,
681 [ --with-libnetfilter_queue-includes=DIR libnetfilter_queue include directory],
682 [with_libnetfilter_queue_includes="$withval"],[with_libnetfilter_queue_includes=no])
683 AC_ARG_WITH(libnetfilter_queue_libraries,
684 [ --with-libnetfilter_queue-libraries=DIR libnetfilter_queue library directory],
685 [with_libnetfilter_queue_libraries="$withval"],[with_libnetfilter_queue_libraries="no"])
686
687 if test "$with_libnetfilter_queue_includes" != "no"; then
89cee0ad 688 CPPFLAGS="${CPPFLAGS} -I${with_libnetfilter_queue_includes}"
a3510f20 689 fi
0ffa1c24 690
a3510f20 691 AC_CHECK_HEADER(libnetfilter_queue/libnetfilter_queue.h,,[AC_ERROR(libnetfilter_queue/libnetfilter_queue.h not found ...)])
0ffa1c24 692
a3510f20 693 if test "$with_libnetfilter_queue_libraries" != "no"; then
89cee0ad 694 LDFLAGS="${LDFLAGS} -L${with_libnetfilter_queue_libraries}"
a3510f20 695 fi
0ffa1c24 696
89cee0ad 697 #LDFLAGS="${LDFLAGS} -lnetfilter_queue"
0ffa1c24 698
a3510f20 699 NFQ=""
89cee0ad
VJ
700 case $host in
701 *-*-mingw32*)
702 AC_CHECK_LIB(netfilter_queue, nfq_open,, NFQ="no",-lws2_32)
366671a8 703
89cee0ad 704 AC_ARG_WITH(netfilterforwin_includes,
366671a8
JJ
705 [ --with-netfilterforwin-includes=DIR netfilterforwin include directory],
706 [with_netfilterforwin_includes="$withval"],[with_netfilterforwin_includes=no])
707
89cee0ad
VJ
708 if test "$with_netfilterforwin_includes" != "no"; then
709 CPPFLAGS="${CPPFLAGS} -I${with_netfilterforwin_includes}"
710 else
711 CPPFLAGS="${CPPFLAGS} -I../../netfilterforwin"
712 fi
713 ;;
714 *)
715 AC_CHECK_LIB(netfilter_queue, nfq_open,, NFQ="no",)
716 AC_CHECK_LIB([netfilter_queue], [nfq_set_queue_maxlen],AC_DEFINE_UNQUOTED([HAVE_NFQ_MAXLEN],[1],[Found queue max length support in netfilter_queue]) ,,[-lnfnetlink])
717 AC_CHECK_LIB([netfilter_queue], [nfq_set_verdict2],AC_DEFINE_UNQUOTED([HAVE_NFQ_SET_VERDICT2],[1],[Found nfq_set_verdict2 function in netfilter_queue]) ,,[-lnfnetlink])
2c572759 718 AC_CHECK_LIB([netfilter_queue], [nfq_set_queue_flags],AC_DEFINE_UNQUOTED([HAVE_NFQ_SET_QUEUE_FLAGS],[1],[Found nfq_set_queue_flags function in netfilter_queue]) ,,[-lnfnetlink])
8da02115 719 AC_CHECK_LIB([netfilter_queue], [nfq_set_verdict_batch],AC_DEFINE_UNQUOTED([HAVE_NFQ_SET_VERDICT_BATCH],[1],[Found nfq_set_verdict_batch function in netfilter_queue]) ,,[-lnfnetlink])
89cee0ad
VJ
720
721 # check if the argument to nfq_get_payload is signed or unsigned
722 AC_MSG_CHECKING([for signed nfq_get_payload payload argument])
723 STORECFLAGS="${CFLAGS}"
adbf85c4
EL
724 if test `basename $CC` = "clang"; then
725 CFLAGS="${CFLAGS} -Werror=incompatible-pointer-types"
726 else
58bf4ea4 727 CFLAGS="${CFLAGS} -Werror"
adbf85c4 728 fi
89cee0ad 729 AC_COMPILE_IFELSE(
c9f9e3f9
VJ
730 [AC_LANG_PROGRAM(
731 [
b7c759fd 732 #include <stdio.h>
c9f9e3f9
VJ
733 #include <libnetfilter_queue/libnetfilter_queue.h>
734 ],
735 [
736 char *pktdata;
737 nfq_get_payload(NULL, &pktdata);
738 ])],
739 [libnetfilter_queue_nfq_get_payload_signed="yes"],
740 [libnetfilter_queue_nfq_get_payload_signed="no"])
89cee0ad
VJ
741 AC_MSG_RESULT($libnetfilter_queue_nfq_get_payload_signed)
742 if test "x$libnetfilter_queue_nfq_get_payload_signed" = "xyes"; then
adbf85c4 743 AC_DEFINE([NFQ_GET_PAYLOAD_SIGNED], [1], [For signed version of nfq_get_payload])
89cee0ad
VJ
744 fi
745 CFLAGS="${STORECFLAGS}"
746 ;;
747 esac
0ffa1c24 748
a3510f20 749 if test "$NFQ" = "no"; then
89cee0ad
VJ
750 echo
751 echo " ERROR! libnetfilter_queue library not found, go get it"
752 echo " from www.netfilter.org."
753 echo " we automatically append libnetfilter_queue/ when searching"
754 echo " for headers etc. when the --with-libnfq-includes directive"
755 echo " is used"
756 echo
e0ddcdd1 757 exit 1
a3510f20 758 fi
89cee0ad 759 ])
2b7b78f1 760
89cee0ad 761 # prelude
eb33dc16 762 AC_ARG_ENABLE(prelude,
e07e9e16 763 AS_HELP_STRING([--enable-prelude], [Enable Prelude support for alerts]),,[enable_prelude=no])
f0c785cc
KS
764 # Prelude doesn't work with -Werror
765 STORECFLAGS="${CFLAGS}"
766 CFLAGS="${CFLAGS} -Wno-error=unused-result"
767
4e84ffe2 768 AS_IF([test "x$enable_prelude" = "xyes"], [
eb33dc16
PC
769 CFLAGS="$CFLAGS -DPRELUDE"
770 AM_PATH_LIBPRELUDE(0.9.9, , AC_MSG_ERROR(Cannot find libprelude: Is libprelude-config in the path?), no)
771 if test "x${LIBPRELUDE_CFLAGS}" != "x"; then
772 CPPFLAGS="${CPPFLAGS} ${LIBPRELUDE_CFLAGS}"
773 fi
774
775 if test "x${LIBPRELUDE_LDFLAGS}" != "x"; then
776 LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LDFLAGS}"
777 fi
778
779 if test "x${LIBPRELUDE_LIBS}" != "x"; then
780 LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LIBS}"
781 fi
4e84ffe2 782 ])
f0c785cc
KS
783 CFLAGS="${STORECFLAGS}"
784
eb33dc16 785
89cee0ad 786 # libnet
a3510f20
WM
787 AC_ARG_WITH(libnet_includes,
788 [ --with-libnet-includes=DIR libnet include directory],
789 [with_libnet_includes="$withval"],[with_libnet_includes="no"])
790
791 AC_ARG_WITH(libnet_libraries,
792 [ --with-libnet-libraries=DIR libnet library directory],
793 [with_libnet_libraries="$withval"],[with_libnet_libraries="no"])
794
795 if test "x$with_libnet_includes" != "xno"; then
3678dda1
WM
796 CPPFLAGS="${CPPFLAGS} -I${with_libnet_includes}"
797 libnet_dir="${with_libnet_includes}"
f7111f38 798 else
829238e4 799 libnet_dir="/usr/include /usr/local/include /usr/local/include/libnet11 /opt/local/include /usr/local/include/libnet-1.1"
a3510f20 800 fi
0ffa1c24 801
a3510f20 802 if test "x$with_libnet_libraries" != "xno"; then
3678dda1 803 LDFLAGS="${LDFLAGS} -L${with_libnet_libraries}"
a3510f20
WM
804 fi
805
3678dda1 806 LIBNET_DETECT_FAIL="no"
a3510f20 807 LIBNET_INC_DIR=""
3678dda1 808
a3510f20
WM
809 for i in $libnet_dir; do
810 if test -r "$i/libnet.h"; then
3678dda1 811 LIBNET_INC_DIR="$i"
a3510f20
WM
812 fi
813 done
814
3678dda1 815 AC_MSG_CHECKING(for libnet.h version 1.1.x)
a3510f20 816 if test "$LIBNET_INC_DIR" != ""; then
64cd49da 817 if eval "grep LIBNET_VERSION $LIBNET_INC_DIR/libnet.h | grep -v '1.[[12]]' >/dev/null"; then
3678dda1
WM
818 AC_MSG_RESULT(no)
819 LIBNET_DETECT_FAIL="yes"
820 LIBNET_FAIL_WARN($libnet_dir)
821 else
822 AC_MSG_RESULT(yes)
823 fi
6e8c75ff 824
3678dda1
WM
825 #CentOS, Fedora, Ubuntu-LTS, Ubuntu all set defines to the same values. libnet-config seems
826 #to have been depreciated but all distro's seem to include it as part of the package.
827 if test "$LIBNET_DETECT_FAIL" = "no"; then
828 LLIBNET=""
829 AC_CHECK_LIB(net, libnet_write,, LLIBNET="no")
830 if test "$LLIBNET" != "no"; then
831 CFLAGS="${CFLAGS} -DHAVE_LIBNET11 -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H"
832 else
833 #if we displayed a warning already no reason to do it again.
834 if test "$LIBNET_DETECT_FAIL" = "no"; then
835 LIBNET_DETECT_FAIL="yes"
836 LIBNET_FAIL_WARN($libnet_dir)
837 fi
838 fi
839
840 # see if we have the patched libnet 1.1
841 # http://www.inliniac.net/blog/2007/10/16/libnet-11-ipv6-fixes-and-additions.html
842 #
843 # To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
844 # see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
845 if test "$LIBNET_DETECT_FAIL" = "no"; then
846 LLIBNET=""
847 TMPLIBS="${LIBS}"
848 AC_CHECK_LIB(net, libnet_build_icmpv6_unreach,, LLIBNET="no")
849 if test "$LLIBNET" != "no"; then
850 CFLAGS="$CFLAGS -DHAVE_LIBNET_ICMPV6_UNREACH"
851 fi
852 LIBS="${TMPLIBS}"
853 fi
854 fi
a3510f20 855 else
3678dda1
WM
856 LIBNET_DETECT_FAIL="yes"
857 LIBNET_FAIL_WARN($libnet_dir)
a3510f20 858 fi
89cee0ad
VJ
859 # libpfring (currently only supported for libpcap enabled pfring)
860 # Error on the side of caution. If libpfring enabled pcap is being used and we don't link against -lpfring compilation will fail.
04b0f177 861 AC_ARG_ENABLE(pfring,
e07e9e16
WM
862 AS_HELP_STRING([--enable-pfring], [Enable Native PF_RING support]),,[enable_pfring=no])
863 AS_IF([test "x$enable_pfring" = "xyes"], [
864 CFLAGS="$CFLAGS -DHAVE_PFRING"
ddf995da 865
89cee0ad 866 #We have to set CFLAGS for AC_TRY_COMPILE as it doesn't pay attention to CPPFLAGS
6408feba
W
867 AC_ARG_WITH(libpfring_includes,
868 [ --with-libpfring-includes=DIR libpfring include directory],
869 [with_libpfring_includes="$withval"],[with_libpfring_includes=no])
870 AC_ARG_WITH(libpfring_libraries,
871 [ --with-libpfring-libraries=DIR libpfring library directory],
872 [with_libpfring_libraries="$withval"],[with_libpfring_libraries="no"])
873
874 if test "$with_libpfring_includes" != "no"; then
89f83c2e 875 CPPFLAGS="${CPPFLAGS} -I${with_libpfring_includes}"
6408feba 876 fi
073d0421 877
6408feba 878 if test "$with_libpfring_libraries" != "no"; then
89f83c2e 879 LDFLAGS="${LDFLAGS} -L${with_libpfring_libraries}"
6408feba 880 fi
073d0421 881
6408feba 882 LIBPFRING=""
43ffd779 883 AC_CHECK_LIB(pfring, pfring_open,, LIBPFRING="no", [-lpcap])
6408feba 884 if test "$LIBPFRING" = "no"; then
a75911e0
EL
885 LIBPFRING=""
886 AC_CHECK_LIB(pfring, pfring_stats,, LIBPFRING="no", [-lpcap -lrt])
887 if test "$LIBPFRING" = "no"; then
888 if test "x$enable_pfring" = "xyes"; then
889 echo
890 echo " ERROR! --enable-pfring was passed but the library was not found or version is >4, go get it"
891 echo " from http://www.ntop.org/PF_RING.html"
892 echo
893 exit 1
894 fi
895 else
896 LIBS="${LIBS} -lrt"
6408feba 897 fi
04b0f177 898 fi
073d0421 899
6408feba 900 LIBPFRING_ENABLE_RING=""
43ffd779 901 AC_CHECK_LIB(pfring, pfring_enable_ring,, LIBPFRING_ENABLE_RING="no", [-lpcap])
6408feba
W
902 if test "$LIBPFRING_ENABLE_RING" != "no"; then
903 AC_DEFINE([HAVE_PFRING_ENABLE],[1],[PF_RING pfring_enable_ring is available])
904 fi
1099093e 905
0ac1cabf
EL
906 LIBPFRING_CLUSTER_TYPE=""
907 AC_CHECK_LIB(pfring, pfring_set_cluster,
43ffd779 908 , LIBPFRING_CLUSTER_TYPE="no", [-lpcap])
0ac1cabf 909 if test "$LIBPFRING_CLUSTER_TYPE" != "no"; then
6408feba 910 AC_DEFINE([HAVE_PFRING_CLUSTER_TYPE],[1],[PF_RING pfring_set_cluster is available])
6408feba
W
911 fi
912
0ac1cabf
EL
913 LIBPFRING_BPF_FILTER=""
914 AC_CHECK_LIB(pfring, pfring_set_bpf_filter,
43ffd779 915 , LIBPFRING_BPF_FILTER="no", [-lpcap])
2aa04add
CW
916 LIBPFRING_REMOVE_BPF_FILTER=""
917 AC_CHECK_LIB(pfring, pfring_remove_bpf_filter,
918 , LIBPFRING_REMOVE_BPF_FILTER="no", [-lpcap])
919 if test "$LIBPFRING_BPF_FILTER" != "no" -a "$LIBPFRING_REMOVE_BPF_FILTER" != "no"; then
d5e254d5 920 AC_DEFINE([HAVE_PFRING_SET_BPF_FILTER],[1],[PF_RING pfring_set_bpf_filter is available])
d5e254d5 921 fi
922
6408feba
W
923 STORE_CFLAGS="${CFLAGS}"
924 CFLAGS="${CFLAGS} -Werror"
925 AC_MSG_CHECKING([if pfring_recv expects u_char**])
926 AC_TRY_COMPILE([
927 #include <pfring.h>
928 ],
929 [
930 u_char *buffer;
dbf5d79e 931 pfring_recv(NULL, &buffer, 0, NULL, 1);
6408feba
W
932 ],
933 [ pfring_recv_uchar_buff=yes ], [:])
934
935 CFLAGS="${STORE_CFLAGS}"
936
6408feba
W
937 if test "$pfring_recv_uchar_buff" = "yes"; then
938 AC_DEFINE([HAVE_PFRING_RECV_UCHAR],[1],[PF_RING pfring_recv buffer is u_char**])
939 AC_MSG_RESULT(yes)
940 else
941 AC_MSG_RESULT(no)
942 fi
dbf5d79e
EL
943
944 # check if the argument to nfq_get_payload is signed or unsigned
945 AC_MSG_CHECKING([for post 5.4.0 pfring_open function])
946 STORECFLAGS="${CFLAGS}"
947 CFLAGS="${CFLAGS} -Werror"
948 AC_COMPILE_IFELSE(
949 [AC_LANG_PROGRAM(
950 [
951 #include <pfring.h>
952 ],
953 [
954 pfring_open(NULL, 0, 0);
955 ])],
956 [pfring_new_open="yes"],
957 [pfring_new_open="no"])
958 AC_MSG_RESULT($pfring_new_open)
959 if test "x$pfring_new_open" = "xyes"; then
960 AC_DEFINE([HAVE_PFRING_OPEN_NEW], [1], [For post 5.4.0 version of pfring_open])
961 fi
962 CFLAGS="${STORECFLAGS}"
963
6408feba 964 ])
ddf995da 965
c45d8985 966
89cee0ad 967 # libpcap
a3510f20
WM
968 AC_ARG_WITH(libpcap_includes,
969 [ --with-libpcap-includes=DIR libpcap include directory],
970 [with_libpcap_includes="$withval"],[with_libpcap_includes=no])
971 AC_ARG_WITH(libpcap_libraries,
972 [ --with-libpcap-libraries=DIR libpcap library directory],
973 [with_libpcap_libraries="$withval"],[with_libpcap_libraries="no"])
974
975 if test "$with_libpcap_includes" != "no"; then
89cee0ad 976 CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}"
a3510f20 977 fi
6899b3da 978
89cee0ad 979 AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)])
6899b3da 980
a3510f20 981 if test "$with_libpcap_libraries" != "no"; then
89cee0ad 982 LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}"
a3510f20 983 fi
472e061c 984 AC_CHECK_HEADERS([pcap.h pcap/pcap.h pcap/bpf.h])
6899b3da 985
a3510f20 986 LIBPCAP=""
ac092197 987 AC_CHECK_LIB(pcap, pcap_open_live,, LIBPCAP="no", [-lpthread])
a3510f20 988 if test "$LIBPCAP" = "no"; then
89cee0ad
VJ
989 echo
990 echo " ERROR! libpcap library not found, go get it"
991 echo " from http://www.tcpdump.org or your distribution:"
992 echo
993 echo " Ubuntu: apt-get install libpcap-dev"
994 echo " Fedora: yum install libpcap-devel"
995 echo
996 exit 1
a3510f20 997 fi
af992242 998
89cee0ad 999 # pcap_activate and pcap_create only exists in libpcap >= 1.0
a3510f20 1000 LIBPCAPVTEST=""
89cee0ad
VJ
1001 #To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
1002 #see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
6e8c75ff 1003 TMPLIBS="${LIBS}"
a3510f20 1004 AC_CHECK_LIB(pcap, pcap_activate,, LPCAPVTEST="no")
af992242 1005 if test "$LPCAPVTEST" != "no"; then
829238e4
VJ
1006 AC_PATH_PROG(HAVE_PCAP_CONFIG, pcap-config, "no")
1007 if test "$HAVE_PCAP_CONFIG" = "no"; then
1008 CFLAGS="${CFLAGS} -DLIBPCAP_VERSION_MAJOR=1"
1009 else
1010 CFLAGS="${CFLAGS} `pcap-config --defines` `pcap-config --cflags` -DLIBPCAP_VERSION_MAJOR=1"
1011 fi
af992242 1012 else
89cee0ad 1013 CFLAGS="${CFLAGS} -DLIBPCAP_VERSION_MAJOR=0"
a3510f20 1014 fi
6e8c75ff 1015 LIBS="${TMPLIBS}"
a3510f20 1016
89cee0ad 1017 #Appears as if pcap_set_buffer_size is linux only?
9ce1399d 1018 LIBPCAPSBUFF=""
89cee0ad
VJ
1019 #To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
1020 #see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
9ce1399d
WM
1021 TMPLIBS="${LIBS}"
1022 AC_CHECK_LIB(pcap, pcap_set_buffer_size,, LPCAPSBUFF="no")
1023 if test "$LPCAPSBUFF" != "no"; then
89cee0ad 1024 CFLAGS="${CFLAGS} -DHAVE_PCAP_SET_BUFF"
9ce1399d
WM
1025 fi
1026 LIBS="${TMPLIBS}"
1027
89cee0ad 1028 # AF_PACKET support
e80b30c0 1029 AC_ARG_ENABLE(af-packet,
b2ebd4a1
EL
1030 AS_HELP_STRING([--enable-af-packet], [Enable AF_PACKET support [default=yes]]),
1031 ,[enable_af_packet=yes])
e80b30c0 1032 AS_IF([test "x$enable_af_packet" = "xyes"], [
ac2d13d6 1033 AC_CHECK_DECL([TPACKET_V2],
e80b30c0 1034 AC_DEFINE([HAVE_AF_PACKET],[1],[AF_PACKET support is available]),
ac2d13d6
EL
1035 [enable_af_packet="no"],
1036 [[#include <sys/socket.h>
1037 #include <linux/if_packet.h>]])
e80b30c0
EL
1038 AC_CHECK_DECL([PACKET_FANOUT],
1039 AC_DEFINE([HAVE_PACKET_FANOUT],[1],[Packet fanout support is available]),
1040 [],
1041 [[#include <linux/if_packet.h>]])
e80b30c0
EL
1042 ])
1043
c45d8985 1044
89cee0ad 1045 # libhtp
e07e9e16
WM
1046 AC_ARG_ENABLE(non-bundled-htp,
1047 AS_HELP_STRING([--enable-non-bundled-htp], [Enable the use of an already installed version of htp]),,[enable_non_bundled_htp=no])
1048 AS_IF([test "x$enable_non_bundled_htp" = "xyes"], [
1049 AC_ARG_WITH(libhtp_includes,
1050 [ --with-libhtp-includes=DIR libhtp include directory],
1051 [with_libhtp_includes="$withval"],[with_libhtp_includes=no])
1052 AC_ARG_WITH(libhtp_libraries,
1053 [ --with-libhtp-libraries=DIR libhtp library directory],
1054 [with_libhtp_libraries="$withval"],[with_libhtp_libraries="no"])
1055
1056 if test "$with_libhtp_includes" != "no"; then
0c37f76f 1057 CPPFLAGS="-I${with_libhtp_includes} ${CPPFLAGS}"
e07e9e16 1058 fi
07f7ba55 1059
e07e9e16 1060 if test "$with_libhtp_libraries" != "no"; then
89cee0ad 1061 LDFLAGS="${LDFLAGS} -L${with_libhtp_libraries}"
e07e9e16 1062 fi
ed856de9 1063
e07e9e16 1064 AC_CHECK_HEADER(htp/htp.h,,[AC_ERROR(htp/htp.h not found ...)])
ed856de9 1065
e07e9e16
WM
1066 LIBHTP=""
1067 AC_CHECK_LIB(htp, htp_conn_create,, LIBHTP="no")
1068 if test "$LIBHTP" = "no"; then
89cee0ad
VJ
1069 echo
1070 echo " ERROR! libhtp library not found"
1071 echo
1072 exit 1
e07e9e16 1073 fi
f85a2dc8 1074 PKG_CHECK_MODULES(LIBHTPMINVERSION, [htp >= 0.5.5],[libhtp_minver_found="yes"],[libhtp_minver_found="no"])
e07e9e16 1075 if test "$libhtp_minver_found" = "no"; then
f85a2dc8
AS
1076 PKG_CHECK_MODULES(LIBHTPDEVVERSION, [htp = 0.5.X],[libhtp_devver_found="yes"],[libhtp_devver_found="no"])
1077 if test "$libhtp_devver_found" = "no"; then
1078 echo
1079 echo " ERROR! libhtp was found but it is neither >= 0.5.5, nor the dev 0.5.X"
1080 echo
1081 exit 1
1082 fi
d472d606
EL
1083 fi
1084
a3e2b355 1085 AC_CHECK_LIB([htp], [htp_config_register_request_uri_normalize],AC_DEFINE_UNQUOTED([HAVE_HTP_URI_NORMALIZE_HOOK],[1],[Found htp_config_register_request_uri_normalize function in libhtp]) ,,[-lhtp])
80fb33c6
VJ
1086 # check for htp_tx_get_response_headers_raw
1087 AC_CHECK_LIB([htp], [htp_tx_get_response_headers_raw],AC_DEFINE_UNQUOTED([HAVE_HTP_TX_GET_RESPONSE_HEADERS_RAW],[1],[Found htp_tx_get_response_headers_raw in libhtp]) ,,[-lhtp])
cc51eec5 1088 AC_CHECK_LIB([htp], [htp_decode_query_inplace],AC_DEFINE_UNQUOTED([HAVE_HTP_DECODE_QUERY_INPLACE],[1],[Found htp_decode_query_inplace function in libhtp]) ,,[-lhtp])
6d225378 1089 AC_EGREP_HEADER(htp_config_set_path_decode_u_encoding, htp/htp.h, AC_DEFINE_UNQUOTED([HAVE_HTP_SET_PATH_DECODE_U_ENCODING],[1],[Found usable htp_config_set_path_decode_u_encoding function in libhtp]) )
80fb33c6 1090 ])
4acd5a04 1091
aafc65c7
VJ
1092 if test "x$enable_non_bundled_htp" = "xno"; then
1093 # test if we have a bundled htp
1094 if test -d "$srcdir/libhtp"; then
1095 AC_CONFIG_SUBDIRS([libhtp])
1096 HTP_DIR="libhtp"
1097 AC_SUBST(HTP_DIR)
1098 HTP_LDADD="../libhtp/htp/libhtp.la"
1099 AC_SUBST(HTP_LDADD)
1100 # make sure libhtp is added to the includes
0c37f76f 1101 CPPFLAGS="-I${srcdir}/../libhtp/ ${CPPFLAGS}"
aafc65c7 1102
8060ef41 1103 AC_CHECK_HEADER(iconv.h,,[AC_ERROR(iconv.h not found ...)])
c0993495 1104 AC_CHECK_LIB(iconv, libiconv_close)
aafc65c7
VJ
1105 AC_DEFINE_UNQUOTED([HAVE_HTP_URI_NORMALIZE_HOOK],[1],[Assuming htp_config_register_request_uri_normalize function in bundled libhtp])
1106 AC_DEFINE_UNQUOTED([HAVE_HTP_TX_GET_RESPONSE_HEADERS_RAW],[1],[Assuming htp_tx_get_response_headers_raw function in bundled libhtp])
1107 AC_DEFINE_UNQUOTED([HAVE_HTP_DECODE_QUERY_INPLACE],[1],[Assuming htp_decode_query_inplace function in bundled libhtp])
1108 else
1109 echo
1bbbcf51
KS
1110 echo " ERROR: Libhtp is not bundled. Get libhtp by doing:"
1111 echo " git clone https://github.com/ironbee/libhtp"
1112 echo " Then re-run Suricata's autogen.sh and configure script."
1113 echo " Or, if libhtp is installed in a different location,"
1114 echo " pass --enable-non-bundled-htp to Suricata's configure script."
aafc65c7
VJ
1115 echo " Add --with-libhtp-includes=<dir> and --with-libhtp-libraries=<dir> if"
1116 echo " libhtp is not installed in the include and library paths."
1117 echo
1118 exit 1
1119 fi
1120 fi
36917c7d 1121
08328f9d 1122
89cee0ad 1123 # enable CUDA output
d281a6b8 1124 AC_ARG_ENABLE(cuda,
1fb11e93 1125 AS_HELP_STRING([--enable-cuda], [Enable experimental CUDA pattern matching]),,[enable_cuda=no])
e07e9e16
WM
1126 AS_IF([test "x$enable_cuda" = "xyes"], [
1127 AC_ARG_WITH(cuda_includes,
1128 [ --with-cuda-includes=DIR cuda include directory],
1129 [with_cuda_includes="$withval"],[with_cuda_includes=no])
1130 AC_ARG_WITH(cuda_libraries,
1131 [ --with-cuda-libraries=DIR cuda library directory],
1132 [with_cuda_libraries="$withval"],[with_cuda_libraries="no"])
49d66430
MB
1133 AC_ARG_WITH(cuda_nvcc,
1134 [ --with-cuda-nvcc=DIR cuda nvcc compiler directory],
1135 [with_cuda_nvcc="$withval"],[with_cuda_nvcc=no])
e07e9e16 1136
d281a6b8
VJ
1137 CFLAGS="${CFLAGS} -D__SC_CUDA_SUPPORT__"
1138
1139 if test "$with_cuda_includes" != "no"; then
1140 CPPFLAGS="${CPPFLAGS} -I${with_cuda_includes}"
1141 else
2f1262b4 1142 CPPFLAGS="${CPPFLAGS} -I/usr/local/cuda/include"
d281a6b8
VJ
1143 fi
1144
1145 if test "$with_cuda_libraries" != "no"; then
1146 LDFLAGS="${LDFLAGS} -L${with_cuda_libraries}"
1147 fi
1148
49d66430
MB
1149 if test "$with_cuda_nvcc" != "no"; then
1150 NVCC_DIR="${with_cuda_nvcc}"
1151 else
1152 NVCC_DIR="/usr/local/cuda/bin"
1153 fi
1154
d281a6b8
VJ
1155 AC_CHECK_HEADER(cuda.h,,[AC_ERROR(cuda.h not found ...)])
1156
1157 LIBCUDA=""
1158 AC_CHECK_LIB(cuda, cuArray3DCreate,, LIBCUDA="no")
1159 if test "$LIBCUDA" = "no"; then
1160 echo
1161 echo " ERROR! libcuda library not found"
1162 echo
1163 exit 1
1164 fi
49d66430 1165
2f1262b4
MB
1166 AC_PATH_PROG([NVCC], [nvcc], no, [$PATH:$NVCC_DIR])
1167 if test "x$NVCC" = "xno"; then
49d66430
MB
1168 echo
1169 echo " ERROR! CUDA nvcc compiler not found: use --with-cuda-nvcc=DIR"
1170 echo
1171 exit 1
1172 fi
1173
2f1262b4
MB
1174 AC_MSG_CHECKING(for nvcc version)
1175 NVCCVER=`$NVCC --version | grep "release" | sed 's/.*release \(@<:@0-9@:>@\)\.\(@<:@0-9@:>@\).*/\1\2/'`
1176 AC_MSG_RESULT($NVCCVER)
1177 if test "$NVCCVER" -lt 31; then
49d66430 1178 echo
2f1262b4
MB
1179 echo " Warning! Your CUDA nvcc version might be outdated."
1180 echo " If compilation fails try the latest CUDA toolkit from"
1181 echo " www.nvidia.com/object/cuda_develop.html"
1182 echo
1183 fi
1184
1185 AM_PATH_PYTHON(,, no)
1186 if test "x$PYTHON" = "xno"; then
1187 echo
1188 echo " ERROR! Compiling CUDA kernels requires python."
49d66430
MB
1189 echo
1190 exit 1
1191 fi
e07e9e16 1192 ])
2f1262b4 1193 AM_CONDITIONAL([BUILD_CUDA], [test "x$enable_cuda" = "xyes"])
d281a6b8 1194
070ed778 1195
89cee0ad 1196 # Check for libcap-ng
829238e4
VJ
1197 case $host in
1198 *-*-linux*)
070ed778
VJ
1199 AC_ARG_WITH(libcap_ng_includes,
1200 [ --with-libcap_ng-includes=DIR libcap_ng include directory],
1201 [with_libcap-ng_includes="$withval"],[with_libcap_ng_includes=no])
1202 AC_ARG_WITH(libcap_ng_libraries,
1203 [ --with-libcap_ng-libraries=DIR libcap_ng library directory],
1204 [with_libcap_ng_libraries="$withval"],[with_libcap_ng_libraries="no"])
1205
1206 if test "$with_libcap_ng_includes" != "no"; then
89cee0ad 1207 CPPFLAGS="${CPPFLAGS} -I${with_libcap_ng_includes}"
070ed778
VJ
1208 fi
1209
1210 if test "$with_libcap_ng_libraries" != "no"; then
89cee0ad 1211 LDFLAGS="${LDFLAGS} -L${with_libcap_ng_libraries}"
070ed778
VJ
1212 fi
1213
1214 AC_CHECK_HEADER(cap-ng.h,,LIBCAP_NG="no")
1215 if test "$LIBCAP_NG" != "no"; then
1216 LIBCAP_NG=""
1217 AC_CHECK_LIB(cap-ng,capng_clear,,LIBCAP_NG="no")
1218 fi
1219
1220 if test "$LIBCAP_NG" != "no"; then
1221 CFLAGS="${CFLAGS} -DHAVE_LIBCAP_NG"
1222 fi
1223
1224 if test "$LIBCAP_NG" = "no"; then
89cee0ad
VJ
1225 echo
1226 echo " WARNING! libcap-ng library not found, go get it"
1227 echo " from http://people.redhat.com/sgrubb/libcap-ng/"
1228 echo " or your distribution:"
1229 echo
1230 echo " Ubuntu: apt-get install libcap-ng-dev"
1231 echo " Fedora: yum install libcap-ng-devel"
1232 echo
1233 echo " Suricata will be built without support for dropping privs."
1234 echo
070ed778 1235 fi
829238e4
VJ
1236 ;;
1237 esac
835630ef 1238
89cee0ad 1239 # Check for DAG support.
835630ef 1240 AC_ARG_ENABLE(dag,
6913109b 1241 AS_HELP_STRING([--enable-dag],[Enable DAG capture]),
835630ef
JM
1242 [ enable_dag=yes ],
1243 [ enable_dag=no])
1244 AC_ARG_WITH(dag_includes,
1245 [ --with-dag-includes=DIR dagapi include directory],
1246 [with_dag_includes="$withval"],[with_dag_includes="no"])
1247 AC_ARG_WITH(dag_libraries,
1248 [ --with-dag-libraries=DIR dagapi library directory],
1249 [with_dag_libraries="$withval"],[with_dag_libraries="no"])
1250
1251 if test "$enable_dag" = "yes"; then
1252
c9cc137d 1253 if test "$with_dag_includes" != "no"; then
835630ef
JM
1254 CPPFLAGS="${CPPFLAGS} -I${with_dag_includes}"
1255 fi
1256
1257 if test "$with_dag_libraries" != "no"; then
573f31b2 1258 LDFLAGS="${LDFLAGS} -L${with_dag_libraries}"
835630ef
JM
1259 fi
1260
1261 AC_CHECK_HEADER(dagapi.h,DAG="yes",DAG="no")
1262 if test "$DAG" != "no"; then
1263 DAG=""
573f31b2 1264 AC_CHECK_LIB(dag,dag_open,,DAG="no",)
835630ef
JM
1265 fi
1266
1267 if test "$DAG" != "no"; then
1268 CFLAGS="${CFLAGS} -DHAVE_DAG"
1269 fi
1270
1271 if test "$DAG" = "no"; then
1272 echo
1273 echo " ERROR! libdag library not found"
1274 echo
1275 exit 1
1276 fi
1277 fi
1278
89cee0ad 1279 # libnspr
4a186bcf 1280 enable_nspr="no"
04d7d00d
VJ
1281
1282 # Try pkg-config first:
1283 PKG_CHECK_MODULES([libnspr], nspr,, [with_pkgconfig_nspr=no])
1284 if test "$with_pkgconfig_nspr" != "no"; then
1285 CPPFLAGS="${CPPFLAGS} ${libnspr_CFLAGS}"
1286 LIBS="${LIBS} ${libnspr_LIBS}"
1287 fi
1288
69b3df96
VJ
1289 AC_ARG_WITH(libnspr_includes,
1290 [ --with-libnspr-includes=DIR libnspr include directory],
1291 [with_libnspr_includes="$withval"],[with_libnspr_includes=no])
1292 AC_ARG_WITH(libnspr_libraries,
1293 [ --with-libnspr-libraries=DIR libnspr library directory],
1294 [with_libnspr_libraries="$withval"],[with_libnspr_libraries="no"])
1295
1296 if test "$with_libnspr_includes" != "no"; then
1297 CPPFLAGS="${CPPFLAGS} -I${with_libnspr_includes}"
1298 fi
1299
90422c9f 1300 AC_CHECK_HEADER(nspr.h,NSPR="yes",NSPR="no")
337f7861
VJ
1301 if test "$NSPR" = "yes"; then
1302 if test "$with_libnspr_libraries" != "no"; then
1303 LDFLAGS="${LDFLAGS} -L${with_libnspr_libraries}"
1304 fi
69b3df96 1305
337f7861 1306 AC_CHECK_LIB(nspr4, PR_GetCurrentThread,, NSPR="no")
69b3df96 1307
337f7861
VJ
1308 if test "$NSPR" = "no"; then
1309 echo
1310 echo " ERROR! libnspr library not found, go get it"
89cee0ad
VJ
1311 echo " from Mozilla or your distribution:"
1312 echo
1313 echo " Ubuntu: apt-get install libnspr4-dev"
1314 echo " Fedora: yum install nspr-devel"
337f7861
VJ
1315 echo
1316 exit 1
1317 fi
4a186bcf 1318 enable_nspr="yes"
69b3df96 1319 fi
337f7861 1320
89cee0ad 1321 # libnss
4a186bcf 1322 enable_nss="no"
cb8e5bc5
CK
1323
1324 # Try pkg-config first:
1325 PKG_CHECK_MODULES([libnss], nss,, [with_pkgconfig_nss=no])
1326 if test "$with_pkgconfig_nss" != "no"; then
1327 CPPFLAGS="${CPPFLAGS} ${libnss_CFLAGS}"
1328 LIBS="${LIBS} ${libnss_LIBS}"
1329 fi
1330
69b3df96
VJ
1331 AC_ARG_WITH(libnss_includes,
1332 [ --with-libnss-includes=DIR libnss include directory],
1333 [with_libnss_includes="$withval"],[with_libnss_includes=no])
1334 AC_ARG_WITH(libnss_libraries,
1335 [ --with-libnss-libraries=DIR libnss library directory],
1336 [with_libnss_libraries="$withval"],[with_libnss_libraries="no"])
1337
1338 if test "$with_libnss_includes" != "no"; then
1339 CPPFLAGS="${CPPFLAGS} -I${with_libnss_includes}"
1340 fi
1341
337f7861
VJ
1342 AC_CHECK_HEADER(sechash.h,NSS="yes",NSS="no")
1343 if test "$NSS" = "yes"; then
1344 if test "$with_libnss_libraries" != "no"; then
1345 LDFLAGS="${LDFLAGS} -L${with_libnss_libraries}"
1346 fi
69b3df96 1347
337f7861 1348 AC_CHECK_LIB(nss3, HASH_Begin,, NSS="no")
69b3df96 1349
337f7861
VJ
1350 if test "$NSS" = "no"; then
1351 echo
1352 echo " ERROR! libnss library not found, go get it"
89cee0ad
VJ
1353 echo " from Mozilla or your distribution:"
1354 echo
1355 echo " Ubuntu: apt-get install libnss3-dev"
1356 echo " Fedora: yum install nss-devel"
337f7861
VJ
1357 echo
1358 exit 1
1359 fi
69b3df96 1360
337f7861 1361 AC_DEFINE([HAVE_NSS],[1],[libnss available for md5])
4a186bcf 1362 enable_nss="yes"
69b3df96
VJ
1363 fi
1364
89cee0ad 1365 # libmagic
f4a6f4b2
VJ
1366 AC_ARG_WITH(libmagic_includes,
1367 [ --with-libmagic-includes=DIR libmagic include directory],
1368 [with_libmagic_includes="$withval"],[with_libmagic_includes=no])
1369 AC_ARG_WITH(libmagic_libraries,
1370 [ --with-libmagic-libraries=DIR libmagic library directory],
1371 [with_libmagic_libraries="$withval"],[with_libmagic_libraries="no"])
1372
1373 if test "$with_libmagic_includes" != "no"; then
1374 CPPFLAGS="${CPPFLAGS} -I${with_libmagic_includes}"
1375 fi
1376
1377 AC_CHECK_HEADER(magic.h,,[AC_ERROR(magic.h not found ...)])
1378
1379 if test "$with_libmagic_libraries" != "no"; then
1380 LDFLAGS="${LDFLAGS} -L${with_libmagic_libraries}"
1381 fi
1382
1383 MAGIC=""
1384 AC_CHECK_LIB(magic, magic_open,, MAGIC="no")
1385
1386 if test "$MAGIC" = "no"; then
1387 echo
1388 echo " ERROR! magic library not found, go get it"
89cee0ad
VJ
1389 echo " from http://www.darwinsys.com/file/ or your distribution:"
1390 echo
1391 echo " Ubuntu: apt-get install libmagic-dev"
1392 echo " Fedora: yum install file-devel"
f4a6f4b2
VJ
1393 echo
1394 exit 1
1395 fi
1396
37e3de84
MK
1397 # Napatech - Using the 3GD API
1398 AC_ARG_ENABLE(napatech,
6913109b 1399 AS_HELP_STRING([--enable-napatech],[Enabled Napatech Devices]),
37e3de84
MK
1400 [ enable_napatech=yes ],
1401 [ enable_napatech=no])
1402 AC_ARG_WITH(napatech_includes,
1403 [ --with-napatech-includes=DIR napatech include directory],
1404 [with_napatech_includes="$withval"],[with_napatech_includes="/opt/napatech3/include"])
1405 AC_ARG_WITH(napatech_libraries,
1406 [ --with-napatech-libraries=DIR napatech library directory],
1407 [with_napatech_libraries="$withval"],[with_napatech_libraries="/opt/napatech3/lib"])
1408
1409 if test "$enable_napatech" = "yes"; then
1410 CPPFLAGS="${CPPFLAGS} -I${with_napatech_includes}"
1411 LDFLAGS="${LDFLAGS} -L${with_napatech_libraries} -lntapi"
1412 AC_CHECK_HEADER(nt.h,NAPATECH="yes",NAPATECH="no")
1413 if test "$NAPATECH" != "no"; then
1414 NAPATECH=""
1415 AC_CHECK_LIB(ntapi, NT_Init,NAPATECH="yes",NAPATECH="no")
844e4dba
MK
1416 fi
1417
37e3de84
MK
1418 if test "$NAPATECH" != "no"; then
1419 CFLAGS="${CFLAGS} -DHAVE_NAPATECH"
844e4dba
MK
1420 fi
1421
37e3de84 1422 if test "$NAPATECH" = "no"; then
844e4dba
MK
1423 echo
1424 echo " ERROR! libntapi library not found"
1425 echo
1426 exit 1
1427 fi
1428 fi
1429
5b2fbfb1 1430 # libluajit
c9cc137d 1431 AC_ARG_ENABLE(luajit,
6913109b 1432 AS_HELP_STRING([--enable-luajit],[Enable Luajit support]),
c9cc137d
VJ
1433 [ enable_luajit="yes"],
1434 [ enable_luajit="no"])
5b2fbfb1
VJ
1435 AC_ARG_WITH(libluajit_includes,
1436 [ --with-libluajit-includes=DIR libluajit include directory],
c9cc137d 1437 [with_libluajit_includes="$withval"],[with_libluajit_includes="no"])
5b2fbfb1
VJ
1438 AC_ARG_WITH(libluajit_libraries,
1439 [ --with-libluajit-libraries=DIR libluajit library directory],
1440 [with_libluajit_libraries="$withval"],[with_libluajit_libraries="no"])
1441
c9cc137d
VJ
1442 if test "$enable_luajit" = "yes"; then
1443 if test "$with_libluajit_includes" != "no"; then
1444 CPPFLAGS="${CPPFLAGS} -I${with_libluajit_includes}"
819debdc 1445 else
344ea3fa 1446 PKG_CHECK_MODULES([LUAJIT], [luajit], , LUAJIT="no")
819debdc 1447 CPPFLAGS="${CPPFLAGS} ${LUAJIT_CFLAGS}"
5b2fbfb1
VJ
1448 fi
1449
c9cc137d
VJ
1450 AC_CHECK_HEADER(lualib.h,LUAJIT="yes",LUAJIT="no")
1451 if test "$LUAJIT" = "yes"; then
1452 if test "$with_libluajit_libraries" != "no"; then
1453 LDFLAGS="${LDFLAGS} -L${with_libluajit_libraries}"
819debdc
EL
1454 else
1455 PKG_CHECK_MODULES([LUAJIT], [luajit])
1456 LDFLAGS="${LDFLAGS} ${LUAJIT_LIBS}"
c9cc137d 1457 fi
5b2fbfb1 1458
c9cc137d 1459 AC_CHECK_LIB(luajit-5.1, luaL_openlibs,, LUAJIT="no")
5b2fbfb1 1460
c9cc137d
VJ
1461 if test "$LUAJIT" = "no"; then
1462 echo
1463 echo " ERROR! libluajit library not found, go get it"
1464 echo " from http://luajit.org/index.html or your distribution:"
1465 echo
1466 echo " Ubuntu: apt-get install libluajit-5.1-dev"
1467 echo
344ea3fa
EL
1468 echo " If you installed software in a non-standard prefix"
1469 echo " consider adjusting the PKG_CONFIG_PATH environment variable"
1470 echo " or use --with-libluajit-libraries configure option."
1471 echo
c9cc137d
VJ
1472 exit 1
1473 fi
1474
1475 AC_DEFINE([HAVE_LUAJIT],[1],[libluajit available])
1476 enable_luajit="yes"
e125869d
EL
1477 else
1478 echo
1479 echo " ERROR! libluajit headers not found, go get them"
1480 echo " from http://luajit.org/index.html or your distribution:"
1481 echo
1482 echo " Ubuntu: apt-get install libluajit-5.1-dev"
1483 echo
344ea3fa
EL
1484 echo " If you installed software in a non-standard prefix"
1485 echo " consider adjusting the PKG_CONFIG_PATH environment variable"
1486 echo " or use --with-libluajit-includes and --with-libluajit-libraries"
1487 echo " configure option."
1488 echo
e125869d 1489 exit 1
c9cc137d 1490 fi
5b2fbfb1
VJ
1491 fi
1492
d771e081
IS
1493 # libgeoip
1494 AC_ARG_ENABLE(geoip,
6913109b 1495 AS_HELP_STRING([--enable-geoip],[Enable GeoIP support]),
d771e081
IS
1496 [ enable_geoip="yes"],
1497 [ enable_geoip="no"])
1498 AC_ARG_WITH(libgeoip_includes,
1499 [ --with-libgeoip-includes=DIR libgeoip include directory],
1500 [with_libgeoip_includes="$withval"],[with_libgeoip_includes="no"])
1501 AC_ARG_WITH(libgeoip_libraries,
1502 [ --with-libgeoip-libraries=DIR libgeoip library directory],
1503 [with_libgeoip_libraries="$withval"],[with_libgeoip_libraries="no"])
1504
1505 if test "$enable_geoip" = "yes"; then
1506 if test "$with_libgeoip_includes" != "no"; then
1507 CPPFLAGS="${CPPFLAGS} -I${with_libgeoip_includes}"
1508 fi
1509
1510 AC_CHECK_HEADER(GeoIP.h,GEOIP="yes",GEOIP="no")
1511 if test "$GEOIP" = "yes"; then
1512 if test "$with_libgeoip_libraries" != "no"; then
1513 LDFLAGS="${LDFLAGS} -L${with_libgeoip_libraries}"
1514 fi
1515 AC_CHECK_LIB(GeoIP, GeoIP_country_code_by_ipnum,, GEOIP="no")
1516 fi
1517 if test "$GEOIP" = "no"; then
1518 echo
1519 echo " ERROR! libgeoip library not found, go get it"
1520 echo " from http://www.maxmind.com/en/geolite or your distribution:"
1521 echo
1522 echo " Ubuntu: apt-get install libgeoip-dev"
8f190249 1523 echo " Fedora: yum install GeoIP-devel"
d771e081
IS
1524 echo
1525 exit 1
1526 fi
1527 if test "$GEOIP" = "yes"; then
1528 AC_DEFINE([HAVE_GEOIP],[1],[libgeoip available])
1529 enable_geoip="yes"
1530 fi
1531 fi
1532
724ad9e8
VJ
1533# get cache line size
1534 AC_PATH_PROG(HAVE_GETCONF_CMD, getconf, "no")
1535 if test "$HAVE_GETCONF_CMD" != "no"; then
1536 CLS=$(getconf LEVEL1_DCACHE_LINESIZE)
fdc3b5ba 1537 if [test "$CLS" != "" && test "$CLS" != "0"]; then
0ddd57cb 1538 AC_DEFINE_UNQUOTED([CLS],[${CLS}],[L1 cache line size])
71c22ddf
VJ
1539 else
1540 AC_DEFINE_UNQUOTED([CLS],[64],[L1 cache line size])
0ddd57cb 1541 fi
71c22ddf
VJ
1542 else
1543 AC_DEFINE_UNQUOTED([CLS],[64],[L1 cache line size])
724ad9e8 1544 fi
d771e081 1545
e3bde3e9
VJ
1546# get revision
1547 if test -f ./revision; then
1548 REVISION=`cat ./revision`
1549 CFLAGS="${CFLAGS} -DREVISION=\"${REVISION}\""
1550 else
042d0c6e
VJ
1551 AC_PATH_PROG(HAVE_GIT_CMD, git, "no")
1552 if test "$HAVE_GIT_CMD" != "no"; then
5886ef82
VJ
1553 if [ test -d .git ]; then
1554 REVISION=`git rev-parse --short HEAD`
1555 CFLAGS="${CFLAGS} -DREVISION=\"${REVISION}\""
1556 fi
e3bde3e9
VJ
1557 fi
1558 fi
1559
0ffa1c24
WM
1560AC_SUBST(CFLAGS)
1561AC_SUBST(LDFLAGS)
1562AC_SUBST(CPPFLAGS)
1563
25804f5a
EL
1564define([EXPAND_VARIABLE],
1565[$2=[$]$1
1566if test $prefix = 'NONE'; then
1567 prefix="/usr/local"
1568fi
1569while true; do
1570 case "[$]$2" in
1571 *\[$]* ) eval "$2=[$]$2" ;;
1572 *) break ;;
1573 esac
1574done
1575eval "$2=[$]$2$3"
1576])dnl EXPAND_VARIABLE
1577
1578# suricata log dir
1579if test "$WINDOWS_PATH" = "yes"; then
d8356c5e
VJ
1580 systemtype="`systeminfo | grep \"based PC\"`"
1581 case "$systemtype" in
25804f5a 1582 *x64*)
d8356c5e 1583 e_winbase="C:\\\\Program Files (x86)\\\\Suricata"
25804f5a
EL
1584 ;;
1585 *)
d8356c5e 1586 e_winbase="C:\\\\Program Files\\\\Suricata"
25804f5a
EL
1587 ;;
1588 esac
d8356c5e
VJ
1589
1590 e_sysconfdir="$e_winbase\\\\"
1591 e_sysconfrulesdir="$e_winbase\\\\rules\\\\"
1592 e_magic_file="$e_winbase\\\\magic.mgc"
1593 e_logdir="$e_winbase\\\\log"
1594 e_logfilesdir="$e_logdir\\\\files"
55625d73 1595 e_logcertsdir="$e_logdir\\\\certs"
25804f5a 1596else
697e9e66 1597 EXPAND_VARIABLE(localstatedir, e_logdir, "/log/suricata/")
1c3546fe 1598 EXPAND_VARIABLE(localstatedir, e_rundir, "/run/")
d8356c5e 1599 EXPAND_VARIABLE(localstatedir, e_logfilesdir, "/log/suricata/files")
55625d73 1600 EXPAND_VARIABLE(localstatedir, e_logcertsdir, "/log/suricata/certs")
697e9e66 1601 EXPAND_VARIABLE(sysconfdir, e_sysconfdir, "/suricata/")
d8356c5e 1602 EXPAND_VARIABLE(sysconfdir, e_sysconfrulesdir, "/suricata/rules")
20a8b9db 1603 EXPAND_VARIABLE(localstatedir, e_localstatedir, "/run/suricata")
25804f5a
EL
1604fi
1605AC_SUBST(e_logdir)
1c3546fe 1606AC_SUBST(e_rundir)
d8356c5e 1607AC_SUBST(e_logfilesdir)
55625d73 1608AC_SUBST(e_logcertsdir)
25804f5a 1609AC_SUBST(e_sysconfdir)
d8356c5e 1610AC_SUBST(e_sysconfrulesdir)
20a8b9db 1611AC_SUBST(e_localstatedir)
d8356c5e 1612AC_DEFINE_UNQUOTED([CONFIG_DIR],["$e_sysconfdir"],[Our CONFIG_DIR])
25804f5a
EL
1613AC_SUBST(e_magic_file)
1614
0f42f0e8 1615AC_OUTPUT(Makefile src/Makefile qa/Makefile qa/coccinelle/Makefile rules/Makefile doc/Makefile contrib/Makefile contrib/file_processor/Makefile contrib/file_processor/Action/Makefile contrib/file_processor/Processor/Makefile suricata.yaml scripts/Makefile scripts/suricatasc/Makefile scripts/suricatasc/suricatasc)
a098e39b 1616
668113af 1617SURICATA_BUILD_CONF="Suricata Configuration:
73a1b972
VJ
1618 AF_PACKET support: ${enable_af_packet}
1619 PF_RING support: ${enable_pfring}
ef463457
EL
1620 NFQueue support: ${enable_nfqueue}
1621 IPFW support: ${enable_ipfw}
73a1b972 1622 DAG enabled: ${enable_dag}
37e3de84 1623 Napatech enabled: ${enable_napatech}
20a8b9db 1624 Unix socket enabled: ${enable_unixsocket}
73a1b972 1625
89cee0ad
VJ
1626 libnss support: ${enable_nss}
1627 libnspr support: ${enable_nspr}
20a8b9db 1628 libjansson support: ${enable_jansson}
ef463457 1629 Prelude support: ${enable_prelude}
73a1b972 1630 PCRE jit: ${pcre_jit_available}
5b2fbfb1 1631 libluajit: ${enable_luajit}
d771e081 1632 libgeoip: ${enable_geoip}
73a1b972
VJ
1633 Non-bundled htp: ${enable_non_bundled_htp}
1634 Old barnyard2 support: ${enable_old_barnyard2}
1635 CUDA enabled: ${enable_cuda}
1636
cd305c3a
EL
1637 Suricatasc install: ${enable_python}
1638
ef463457
EL
1639 Unit tests enabled: ${enable_unittests}
1640 Debug output enabled: ${enable_debug}
1641 Debug validation enabled: ${enable_debug_validation}
ef463457 1642 Profiling enabled: ${enable_profiling}
d908e707 1643 Profiling locks enabled: ${enable_profiling_locks}
ef463457
EL
1644
1645Generic build parameters:
1646 Installation prefix (--prefix): ${prefix}
1647 Configuration directory (--sysconfdir): ${e_sysconfdir}
1648 Log directory (--localstatedir) : ${e_logdir}
73a1b972 1649
ef463457
EL
1650 Host: ${host}
1651 GCC binary: ${CC}
1652 GCC Protect enabled: ${enable_gccprotect}
1653 GCC march native enabled: ${enable_gccmarch_native}
668113af
EL
1654 GCC Profile enabled: ${enable_gccprofile}"
1655
1656echo
1657echo "$SURICATA_BUILD_CONF"
4749420f
VJ
1658echo "printf(" >src/build-info.h
1659echo "$SURICATA_BUILD_CONF" | sed -e 's/^/"/' | sed -e 's/$/\\n"/' >>src/build-info.h
1660echo ");" >>src/build-info.h
25804f5a 1661
668113af 1662echo "
25804f5a 1663To build and install run 'make' and 'make install'.
73a1b972 1664
697e9e66
VJ
1665You can run 'make install-conf' if you want to install initial configuration
1666files to ${e_sysconfdir}. Running 'make install-full' will install configuration
1667and rules and provide you a ready-to-run suricata."
73a1b972
VJ
1668echo
1669echo "To install Suricata into /usr/bin/suricata, have the config in
1670/etc/suricata and use /var/log/suricata as log dir, use:
697e9e66
VJ
1671./configure --prefix=/usr/ --sysconfdir=/etc/ --localstatedir=/var/"
1672echo