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