]> git.ipfire.org Git - people/ms/suricata.git/blame - configure.ac
dns: remove as much C DNS code as possible
[people/ms/suricata.git] / configure.ac
CommitLineData
705d3b61 1 AC_INIT(suricata, 5.0.0-dev)
d258a11f 2 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])AM_SILENT_RULES([yes])
83014adc 3 AC_CONFIG_HEADERS([config.h])
7dbc97b0 4 AC_CONFIG_SRCDIR([src/suricata.c])
0cef0b88 5 AC_CONFIG_MACRO_DIR(m4)
7dbc97b0 6 AM_INIT_AUTOMAKE
a3510f20
WM
7
8 AC_LANG_C
ff6a2a01 9 AC_PROG_CC_C99
769022f4 10 AC_PROG_LIBTOOL
119115d3 11 PKG_PROG_PKG_CONFIG
a3510f20 12
ba81c4d2
VJ
13 dnl Taken from https://llvm.org/svn/llvm-project/llvm/trunk/autoconf/configure.ac
14 dnl check if we compile using clang or gcc. On some systems the gcc binary is
15 dnl is actually clang, so do a compile test.
16 AC_MSG_CHECKING([whether GCC or Clang is our compiler])
17 AC_LANG_PUSH([C])
18 compiler=unknown
19 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __clang__
20 #error
21 #endif
22 ]])],
23 compiler=clang,
24 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#if ! __GNUC__
25 #error
26 #endif
27 ]])],
28 compiler=gcc, [])])
29 AC_LANG_POP([C])
30 AC_MSG_RESULT([${compiler}])
31
32 case "$compiler" in
33 clang)
9858ae41 34 CLANG_CFLAGS="-Wextra -Werror-implicit-function-declaration -Wno-error=unused-command-line-argument"
ba81c4d2
VJ
35 AC_MSG_CHECKING([clang __sync_bool_compare_and_swap support])
36 AC_TRY_COMPILE([#include <stdio.h>],
467f28e9
VJ
37 [ unsigned int i = 0; (void)__sync_bool_compare_and_swap(&i, 1, 1);],
38 [
39 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1], [1], [Fake GCC atomic support])
40 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2], [1], [Fake GCC atomic support])
41 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4], [1], [Fake GCC atomic support])
42 AC_DEFINE([__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8], [1], [Fake GCC atomic support])
43 AC_MSG_RESULT([yes]) ],
44 [AC_MSG_RESULT([no])])
ba81c4d2
VJ
45 AC_SUBST(CLANG_CFLAGS)
46 ;;
47 gcc)
48 dnl get gcc version
49 AC_MSG_CHECKING([gcc version])
50 gccver=$($CC -dumpversion)
51 gccvermajor=$(echo $gccver | cut -d . -f1)
52 gccverminor=$(echo $gccver | cut -d . -f2)
53 gccvernum=$(expr $gccvermajor "*" 100 + $gccverminor)
54 AC_MSG_RESULT($gccver)
55
56 if test "$gccvernum" -ge "400"; then
1f94239d 57 dnl gcc 4.0 or later
ba81c4d2 58 GCC_CFLAGS="-Wextra -Werror-implicit-function-declaration"
ba81c4d2
VJ
59 else
60 GCC_CFLAGS="-W"
61 fi
62 AC_SUBST(GCC_CFLAGS)
63 ;;
64 *)
65 AC_MSG_WARN([unsupported/untested compiler, this may or may not work])
66 ;;
67 esac
0ffa1c24 68
89cee0ad 69 # Checks for programs.
fa5939ca
BR
70 AC_PROG_AWK
71 AC_PROG_CC
72 AC_PROG_CPP
73 AC_PROG_INSTALL
74 AC_PROG_LN_S
75 AC_PROG_MAKE_SET
91e1256b 76 AC_PROG_GREP
fa5939ca 77
24d6a164
VJ
78 AC_PATH_PROG(HAVE_CYGPATH, cygpath, "no")
79 AM_CONDITIONAL([HAVE_CYGPATH], [test "x$enable_cygpath" = "xyes"])
80
9f1d779a
WM
81 AC_PATH_PROG(HAVE_PKG_CONFIG, pkg-config, "no")
82 if test "$HAVE_PKG_CONFIG" = "no"; then
89cee0ad
VJ
83 echo
84 echo " ERROR! pkg-config not found, go get it "
85 echo " http://pkg-config.freedesktop.org/wiki/ "
86 echo " or install from your distribution "
87 echo
88 exit 1
9f1d779a
WM
89 fi
90
a228986c
JI
91 python_version="not set"
92 python_path="not set"
93
dc1bd5b6 94 AC_ARG_ENABLE(python,
a228986c
JI
95 AS_HELP_STRING([--enable-python], [Enable python]),
96 [enable_python=$enableval],[enable_python=yes])
97 if test "x$enable_python" != "xyes"; then
cd305c3a 98 enable_python="no"
a228986c
JI
99 else
100 AC_PATH_PROGS(HAVE_PYTHON, python3 python2.7 python2 python, "no")
101 if test "$HAVE_PYTHON" = "no"; then
102 echo
103 echo " Warning! python not found, you will not be "
104 echo " able to install suricatasc unix socket client "
105 echo
106 enable_python="no"
107 else
108 python_path="$HAVE_PYTHON"
109 python_version="$($HAVE_PYTHON --version)"
110 fi
cd305c3a 111 fi
dc1bd5b6 112 AM_CONDITIONAL([HAVE_PYTHON], [test "x$enable_python" = "xyes"])
cd305c3a 113
a69afd5c
JI
114 # Check for python-distutils (setup).
115 have_python_distutils="no"
116 if test "x$enable_python" = "xyes"; then
117 AC_MSG_CHECKING([for python-distutils])
118 if $HAVE_PYTHON -c "import distutils; from distutils.core import setup" 2>/dev/null; then
119 AC_MSG_RESULT([yes])
120 have_python_distutils="yes"
121 else
122 AC_MSG_RESULT([no])
123 fi
124 fi
125 AM_CONDITIONAL([HAVE_PYTHON_DISTUTILS],
126 [test "x$have_python_distutils" = "xyes"])
127 if test "$have_python_distutils" = "no"; then
128 echo ""
129 echo " Warning: Python distutils not found. Python tools will"
130 echo " not be installed."
131 echo ""
132 echo " Ubuntu/Debian: apt install `basename ${HAVE_PYTHON}`-distutils"
133 echo ""
134 fi
135
db367087
JI
136 # Check for python-yaml.
137 have_python_yaml="no"
138 if test "x$enable_python" = "xyes"; then
139 AC_MSG_CHECKING([for python-yaml])
140 if $HAVE_PYTHON -c "import yaml" 2>/dev/null; then
141 have_python_yaml="yes"
142 AC_MSG_RESULT([yes])
143 else
144 AC_MSG_RESULT([no])
145 fi
146 fi
147 AM_CONDITIONAL([HAVE_PYTHON_YAML], [test "x$have_python_yaml" = "xyes"])
148
daa9dcb7
EL
149 AC_PATH_PROG(HAVE_WGET, wget, "no")
150 if test "$HAVE_WGET" = "no"; then
151 AC_PATH_PROG(HAVE_CURL, curl, "no")
152 if test "$HAVE_CURL" = "no"; then
153 echo
154 echo " Warning curl or wget not found, you won't be able to"
155 echo " download latest ruleset with 'make install-rules'"
156 fi
157 fi
158 AM_CONDITIONAL([HAVE_FETCH_COMMAND], [test "x$HAVE_WGET" != "xno" || test "x$HAVE_CURL" != "xno"])
159 AM_CONDITIONAL([HAVE_WGET_COMMAND], [test "x$HAVE_WGET" != "xno"])
7c841e1d 160
89cee0ad 161 # Checks for libraries.
7c841e1d 162
89cee0ad 163 # Checks for header files.
4086938f 164 AC_CHECK_HEADERS([stddef.h])
472e061c
VJ
165 AC_CHECK_HEADERS([arpa/inet.h assert.h ctype.h errno.h fcntl.h inttypes.h])
166 AC_CHECK_HEADERS([getopt.h])
167 AC_CHECK_HEADERS([limits.h netdb.h netinet/in.h poll.h sched.h signal.h])
2c01985e 168 AC_CHECK_HEADERS([stdarg.h stdint.h stdio.h stdlib.h stdbool.h string.h strings.h sys/ioctl.h])
472e061c 169 AC_CHECK_HEADERS([syslog.h sys/prctl.h sys/socket.h sys/stat.h sys/syscall.h])
b63c2eda 170 AC_CHECK_HEADERS([sys/time.h time.h unistd.h])
472e061c 171 AC_CHECK_HEADERS([sys/ioctl.h linux/if_ether.h linux/if_packet.h linux/filter.h])
fcc87595 172 AC_CHECK_HEADERS([linux/ethtool.h linux/sockios.h])
2a237bdf 173 AC_CHECK_HEADERS([glob.h])
bbb93e48 174 AC_CHECK_HEADERS([dirent.h fnmatch.h])
c02739e5 175 AC_CHECK_HEADERS([sys/resource.h sys/types.h sys/un.h])
9b94679f 176 AC_CHECK_HEADERS([sys/random.h])
dbdac737 177 AC_CHECK_HEADERS([utime.h])
6ffa0507 178 AC_CHECK_HEADERS([libgen.h])
472e061c
VJ
179
180 AC_CHECK_HEADERS([sys/socket.h net/if.h sys/mman.h linux/if_arp.h], [], [],
5656e344 181 [[#ifdef HAVE_SYS_SOCKET_H
472e061c
VJ
182 #include <sys/types.h>
183 #include <sys/socket.h>
184 #endif
5656e344
EL
185 ]])
186
d1b6be99 187 AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h w32api/wtypes.h], [], [],
06f9b0ad
VJ
188 [[
189 #ifndef _X86_
190 #define _X86_
191 #endif
b63c2eda 192 ]])
d1b6be99 193 AC_CHECK_HEADERS([w32api/winbase.h wincrypt.h], [], [],
06f9b0ad
VJ
194 [[
195 #ifndef _X86_
196 #define _X86_
197 #endif
198 #include <windows.h>
b63c2eda 199 ]])
fa5939ca 200
89cee0ad 201 # Checks for typedefs, structures, and compiler characteristics.
fa5939ca
BR
202 AC_C_INLINE
203 AC_TYPE_PID_T
204 AC_TYPE_SIZE_T
205 AC_TYPE_INT32_T
206 AC_TYPE_UINT16_T
207 AC_TYPE_UINT32_T
208 AC_TYPE_UINT64_T
209 AC_TYPE_UINT8_T
210 AC_HEADER_STDBOOL
211
89cee0ad 212 # Checks for library functions.
fa5939ca
BR
213 AC_FUNC_MALLOC
214 AC_FUNC_REALLOC
dd70b3fd 215 AC_CHECK_FUNCS([gettimeofday memset strcasecmp strchr strdup strerror strncasecmp strtol strtoul memchr memrchr clock_gettime])
46cb00ec 216 AC_CHECK_FUNCS([strptime])
ba81c4d2 217
9b94679f
VJ
218 AC_CHECK_DECL([getrandom],
219 AC_DEFINE([HAVE_GETRANDOM], [1], [Use getrandom]),
220 [], [
221 #include <sys/random.h>
222 ])
223
dbdac737
JI
224 AC_CHECK_FUNCS([utime])
225
ba81c4d2
VJ
226 OCFLAGS=$CFLAGS
227 CFLAGS=""
8e946b92 228 AC_CHECK_FUNCS([strlcpy strlcat])
ba81c4d2 229 CFLAGS=$OCFLAGS
fa5939ca 230
89cee0ad 231 # Add large file support
3b3f5816
WM
232 AC_SYS_LARGEFILE
233
89cee0ad 234 #check for os
769022f4
PR
235 AC_MSG_CHECKING([host os])
236
7396237c
VJ
237 # lua pkg-config name differs per OS
238 LUA_PC_NAME="lua5.1"
239 LUA_LIB_NAME="lua5.1"
240
769022f4 241 # If no host os was detected, try with uname
25804f5a 242 if test -z "$host" ; then
769022f4
PR
243 host="`uname`"
244 fi
a49bce63 245 echo -n "installation for $host OS... "
769022f4 246
48566358
VJ
247 RUST_SURICATA_LIBNAME="libsuricata.a"
248
15c98c60
AH
249 e_magic_file=""
250 e_magic_file_comment="#"
d1e839ea 251 PCAP_LIB_NAME="pcap"
769022f4 252 case "$host" in
829238e4 253 *-*-*freebsd*)
7396237c
VJ
254 LUA_PC_NAME="lua-5.1"
255 LUA_LIB_NAME="lua-5.1"
829238e4
VJ
256 CFLAGS="${CFLAGS} -DOS_FREEBSD"
257 CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/local/include/libnet11"
258 LDFLAGS="${LDFLAGS} -L/usr/local/lib -L/usr/local/lib/libnet11"
48566358 259 RUST_LDADD="-lrt -lm"
829238e4 260 ;;
829238e4 261 *-*-openbsd*)
7396237c 262 LUA_PC_NAME="lua51"
ddf9b417 263 CFLAGS="${CFLAGS} -D__OpenBSD__"
829238e4
VJ
264 CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/local/include/libnet-1.1"
265 LDFLAGS="${LDFLAGS} -L/usr/local/lib -I/usr/local/lib/libnet-1.1"
829238e4
VJ
266 ;;
267 *darwin*|*Darwin*)
1177d489
VJ
268 LUA_PC_NAME="lua-5.1"
269 LUA_LIB_NAME="lua-5.1"
829238e4
VJ
270 CFLAGS="${CFLAGS} -DOS_DARWIN"
271 CPPFLAGS="${CPPFLAGS} -I/opt/local/include"
272 LDFLAGS="${LDFLAGS} -L/opt/local/lib"
273 ;;
274 *-*-linux*)
56d93f42 275 RUST_LDADD="-ldl -lrt -lm"
829238e4 276 ;;
bae83e61 277 *-*-mingw32*|*-*-msys)
829238e4 278 CFLAGS="${CFLAGS} -DOS_WIN32"
ec77632e 279 LDFLAGS="${LDFLAGS} -lws2_32 -liphlpapi -lwbemuuid -lOle32 -lOleAut32 -lUuid"
829238e4 280 WINDOWS_PATH="yes"
d1e839ea 281 PCAP_LIB_NAME="wpcap"
d8ddd3b5 282 AC_DEFINE([HAVE_NON_POSIX_MKDIR], [1], [mkdir is not POSIX compliant: single arg])
48566358
VJ
283 RUST_SURICATA_LIBNAME="suricata.lib"
284 RUST_LDADD="-luserenv -lshell32 -ladvapi32 -lgcc_eh"
829238e4
VJ
285 ;;
286 *-*-cygwin)
43c5b949
VJ
287 LUA_PC_NAME="lua"
288 LUA_LIB_NAME="lua"
829238e4 289 WINDOWS_PATH="yes"
d1e839ea 290 PCAP_LIB_NAME="wpcap"
829238e4 291 ;;
7847c4f8
VJ
292 *-*-solaris*)
293 AC_MSG_WARN([support for Solaris/Illumos/SunOS is experimental])
294 LDFLAGS="${LDFLAGS} -lsocket -lnsl"
295 ;;
829238e4
VJ
296 *)
297 AC_MSG_WARN([unsupported OS this may or may not work])
298 ;;
769022f4
PR
299 esac
300 AC_MSG_RESULT(ok)
301
faad6bd3
VJ
302 # enable modifications for AFL fuzzing
303 AC_ARG_ENABLE(afl,
304 AS_HELP_STRING([--enable-afl], Enable AFL fuzzing logic[])], [enable_afl="$enableval"],[enable_afl=no])
305
306 AS_IF([test "x$enable_afl" = "xyes"], [
307 AC_DEFINE([AFLFUZZ_NO_RANDOM], [1], [Disable all use of random functions])
308 AC_DEFINE([AFLFUZZ_DISABLE_MGTTHREADS], [1], [Disable all management threads])
309 AC_DEFINE([AFLFUZZ_PCAP_RUNMODE], [1], [Enable special AFL 'single' runmode])
310 AC_DEFINE([AFLFUZZ_CONF_TEST], [1], [Enable special --afl-parse-rules commandline option])
311 AC_DEFINE([AFLFUZZ_APPLAYER], [1], [Enable --afl-$proto-request commandline option])
312 AC_DEFINE([AFLFUZZ_MIME], [1], [Enable --afl-mime commandline option])
313 AC_DEFINE([AFLFUZZ_DECODER], [1], [Enable --afl-decoder-$proto commandline option])
314 AC_DEFINE([AFLFUZZ_DER], [1], [Enable --afl-der commandline option])
1c8775b3 315 AC_DEFINE([AFLFUZZ_RULES], [1], [Enable --afl-rules commandline option])
faad6bd3
VJ
316
317 # test for AFL PERSISTANT_MODE support
318 CFLAGS_ORIG=$CFLAGS
319 CFLAGS="-Werror"
320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[while (__AFL_LOOP(1000))]])],
321 [AC_DEFINE([AFLFUZZ_PERSISTANT_MODE], [1], [Enable AFL PERSISTANT_MODE])],
322 [])
323 CFLAGS=$CFLAGS_ORIG
324 ])
325
6fa8922c
VJ
326 # disable TLS on user request
327 AC_ARG_ENABLE(threading-tls,
2a17e3e8 328 AS_HELP_STRING([--disable-threading-tls], [Disable TLS (thread local storage)]), [enable_tls="$enableval"],[enable_tls=yes])
6fa8922c
VJ
329 AS_IF([test "x$enable_tls" = "xyes"], [
330 # check if our target supports thread local storage
331 AC_MSG_CHECKING(for thread local storage __thread support)
332 AC_TRY_COMPILE([#include <stdlib.h>],
333 [ static __thread int i; i = 1; i++; ],
334 [AC_DEFINE([TLS], [1], [Thread local storage])
335 AC_MSG_RESULT([yes]) ],
336 [AC_MSG_RESULT([no])])
337 ])
900918a5 338
89cee0ad
VJ
339 #Enable support for gcc compile time security options. There is no great way to do detection of valid cflags that I have found
340 #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.
341 #These flags seem to be supported on CentOS 5+, Ubuntu 8.04+, and FedoreCore 11+
342 #Options are taken from https://wiki.ubuntu.com/CompilerFlags
c49785fb 343 AC_ARG_ENABLE(gccprotect,
d01ce2e5 344 AS_HELP_STRING([--enable-gccprotect], [Detect and use gcc hardening options]),[enable_gccprotect=$enableval],[enable_gccprotect=no])
c49785fb 345
e07e9e16 346 AS_IF([test "x$enable_gccprotect" = "xyes"], [
98b9009b
WM
347 #buffer overflow protection
348 AC_MSG_CHECKING(for -fstack-protector)
349 TMPCFLAGS="${CFLAGS}"
350 CFLAGS="${CFLAGS} -fstack-protector"
ba81c4d2
VJ
351 AC_TRY_LINK(,,SECCFLAGS="-fstack-protector"
352 AC_MSG_RESULT(yes),
353 AC_MSG_RESULT(no))
98b9009b
WM
354 CFLAGS="${TMPCFLAGS}"
355
356 #compile-time best-practices errors for certain libc functions, provides checks of buffer lengths and memory regions
357 AC_MSG_CHECKING(for -D_FORTIFY_SOURCE=2)
358 TMPCFLAGS="${CFLAGS}"
359 CFLAGS="${CFLAGS} -D_FORTIFY_SOURCE=2"
360 AC_TRY_COMPILE(,,SECCFLAGS="${SECCFLAGS} -D_FORTIFY_SOURCE=2"
ba81c4d2
VJ
361 AC_MSG_RESULT(yes),
362 AC_MSG_RESULT(no))
98b9009b
WM
363 CFLAGS="${TMPCFLAGS}"
364
365 #compile-time warnings about misuse of format strings
366 AC_MSG_CHECKING(for -Wformat -Wformat-security)
367 TMPCFLAGS="${CFLAGS}"
368 CFLAGS="${CFLAGS} -Wformat -Wformat-security"
369 AC_TRY_COMPILE(,,SECCFLAGS="${SECCFLAGS} -Wformat -Wformat-security"
ba81c4d2
VJ
370 AC_MSG_RESULT(yes),
371 AC_MSG_RESULT(no))
98b9009b
WM
372 CFLAGS="${TMPCFLAGS}"
373
374 #provides a read-only relocation table area in the final ELF
375 AC_MSG_CHECKING(for -z relro)
376 TMPLDFLAGS="${LDFLAGS}"
377 LDFLAGS="${LDFLAGS} -z relro"
378 AC_TRY_LINK(,,SECLDFLAGS="${SECLDFLAGS} -z relro"
ba81c4d2
VJ
379 AC_MSG_RESULT(yes),
380 AC_MSG_RESULT(no))
98b9009b
WM
381 LDFLAGS="${TMPLDFLAGS}"
382
383 #forces all relocations to be resolved at run-time
384 AC_MSG_CHECKING(for -z now)
385 TMPLDFLAGS="${LDFLAGS}"
386 LDFLAGS="${LDFLAGS} -z now"
387 AC_TRY_LINK(,,SECLDFLAGS="${SECLDFLAGS} -z now"
ba81c4d2
VJ
388 AC_MSG_RESULT(yes),
389 AC_MSG_RESULT(no))
98b9009b
WM
390 LDFLAGS="${TMPLDFLAGS}"
391
ba81c4d2
VJ
392 AC_SUBST(SECCFLAGS)
393 AC_SUBST(SECLDFLAGS)
e07e9e16 394 ])
5bde1217 395
89cee0ad 396 #enable profile generation
5bde1217 397 AC_ARG_ENABLE(gccprofile,
d01ce2e5 398 AS_HELP_STRING([--enable-gccprofile], [Enable gcc profile info i.e -pg flag is set]),[enable_gccprofile=$enableval],[enable_gccprofile=no])
e07e9e16
WM
399 AS_IF([test "x$enable_gccprofile" = "xyes"], [
400 CFLAGS="${CFLAGS} -pg"
401 ])
5bde1217 402
89cee0ad 403 #enable gcc march=native gcc 4.2 or later
22f3e3d8 404 AC_ARG_ENABLE(gccmarch_native,
d01ce2e5 405 AS_HELP_STRING([--enable-gccmarch-native], [Enable gcc march=native gcc 4.2 and later only]),[enable_gccmarch_native=$enableval],[enable_gccmarch_native=yes])
e07e9e16 406 AS_IF([test "x$enable_gccmarch_native" = "xyes"], [
ffba26d0
VJ
407 case "$host" in
408 *powerpc*)
409 ;;
410 *)
37b05b23
EL
411 OFLAGS="$CFLAGS"
412 CFLAGS="$CFLAGS -march=native"
413 AC_MSG_CHECKING([checking if $CC supports -march=native])
414 AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <stdlib.h>]])],
415 [
416 AC_MSG_RESULT([yes])
ba81c4d2
VJ
417 OPTIMIZATION_CFLAGS="-march=native"
418 AC_SUBST(OPTIMIZATION_CFLAGS)
37b05b23
EL
419 ],
420 [
421 AC_MSG_RESULT([no])
422 CFLAGS="$OFLAGS"
423 enable_gccmarch_native=no
424 ]
425 )
ffba26d0
VJ
426 ;;
427 esac
e07e9e16 428 ])
22f3e3d8 429
89cee0ad
VJ
430# options
431
432 # enable the running of unit tests
433 AC_ARG_ENABLE(unittests,
d01ce2e5 434 AS_HELP_STRING([--enable-unittests], [Enable compilation of the unit tests]),[enable_unittests=$enableval],[enable_unittests=no])
89cee0ad 435 AS_IF([test "x$enable_unittests" = "xyes"], [
ba81c4d2 436 AC_DEFINE([UNITTESTS],[1],[Enable built-in unittests])
89cee0ad 437 ])
89cee0ad
VJ
438 AM_CONDITIONAL([BUILD_UNITTESTS], [test "x$enable_unittests" = "xyes"])
439
91e1256b
EL
440 # enable the building of ebpf files
441 AC_ARG_ENABLE(ebpf-build,
d01ce2e5 442 AS_HELP_STRING([--enable-ebpf-build], [Enable compilation of ebpf files]),[enable_ebpf_build=$enableval],[enable_ebpf_build=no])
91e1256b
EL
443 AM_CONDITIONAL([BUILD_EBPF], [test "x$enable_ebpf_build" = "xyes"])
444
445 if test "x$enable_ebpf_build" = "xyes"; then
446 if echo $CC | grep clang; then
027c903f 447 if test "x$CC" = "xclang"; then
750651a4
EL
448 AC_PATH_PROG(HAVE_LLC, llc, "no")
449 if test "$HAVE_LLC" != "no"; then
027c903f
EL
450 LLC="llc"
451 AC_SUBST(LLC)
452 else
027c903f
EL
453 llc_version_line=$($CC --version|$GREP version)
454 llc_version=$(echo $llc_version_line| cut -d '(' -f 1 | $GREP -E -o '@<:@0-9@:>@\.@<:@0-9@:>@')
750651a4
EL
455 AC_PATH_PROG(HAVE_LLC, "llc-$llc_version", "no")
456 if test "$HAVE_LLC" != "no"; then
457 LLC="llc-$llc_version"
458 AC_SUBST(LLC)
459 else
460 echo "unable to find llc needed to build ebpf files"
461 exit 1
462 fi
463 fi
464 else
465 llc_version=$(echo $CC | cut -d '-' -f 2)
466 AC_PATH_PROG(HAVE_LLC, "llc-$llc_version", "no")
467 if test "$HAVE_LLC" != "no"; then
027c903f
EL
468 LLC="llc-$llc_version"
469 AC_SUBST(LLC)
750651a4
EL
470 else
471 llc_version_line=$($CC --version|$GREP version)
472 llc_version=$(echo $llc_version_line| cut -d '(' -f 1 | $GREP -E -o '@<:@0-9@:>@\.@<:@0-9@:>@')
473 AC_PATH_PROG(HAVE_LLC, "llc-$llc_version", "no")
474 if test "$HAVE_LLC" != "no"; then
475 LLC="llc-$llc_version"
476 AC_SUBST(LLC)
477 else
478 echo "unable to find llc needed to build ebpf files"
479 exit 1
480 fi
027c903f 481 fi
027c903f 482 fi
91e1256b
EL
483 else
484 echo "clang needed to build ebpf files"
485 exit 1
486 fi
487 fi
488
89cee0ad
VJ
489 # enable workaround for old barnyard2 for unified alert output
490 AC_ARG_ENABLE(old-barnyard2,
d01ce2e5 491 AS_HELP_STRING([--enable-old-barnyard2], [Use workaround for old barnyard2 in unified2 output]),[enable_old_barnyard2=$enableval],[enable_old_barnyard2=no])
89cee0ad 492 AS_IF([test "x$enable_old_barnyard2" = "xyes"], [
ba81c4d2 493 AC_DEFINE([HAVE_OLD_BARNYARD2],[1],[Use workaround for old barnyard2 in unified2 output])
89cee0ad
VJ
494 ])
495
496 # enable debug output
497 AC_ARG_ENABLE(debug,
d01ce2e5 498 AS_HELP_STRING([--enable-debug], [Enable debug output]),[enable_debug=$enableval],[enable_debug=no])
89cee0ad 499 AS_IF([test "x$enable_debug" = "xyes"], [
ba81c4d2 500 AC_DEFINE([DEBUG],[1],[Enable debug output])
89cee0ad 501 ])
ba81c4d2 502 AM_CONDITIONAL([DEBUG], [test "x$enable_debug" = "xyes"])
89cee0ad
VJ
503
504 # enable debug validation functions & macro's output
505 AC_ARG_ENABLE(debug-validation,
d01ce2e5 506 AS_HELP_STRING([--enable-debug-validation], [Enable (debug) validation code output]),[enable_debug_validation=$enableval],[enable_debug_validation=no])
89cee0ad 507 AS_IF([test "x$enable_debug_validation" = "xyes"], [
a18af732
AH
508 if test "$enable_unittests" = "yes"; then
509 AC_MSG_ERROR([debug_validation can't be enabled with enabled unittests!])
510 else
511 AC_DEFINE([DEBUG_VALIDATION],[1],[Enable (debug) validation code output])
512 fi
89cee0ad
VJ
513 ])
514
515 # profiling support
516 AC_ARG_ENABLE(profiling,
d01ce2e5 517 AS_HELP_STRING([--enable-profiling], [Enable performance profiling]),[enable_profiling=$enableval],[enable_profiling=no])
89cee0ad 518 AS_IF([test "x$enable_profiling" = "xyes"], [
ba81c4d2
VJ
519 case "$host" in
520 *-*-openbsd*)
521 AC_MSG_ERROR([profiling is not supported on OpenBSD])
522 ;;
523 *)
524 AC_DEFINE([PROFILING],[1],[Enable performance profiling])
525 ;;
526 esac
89cee0ad
VJ
527 ])
528
d908e707
VJ
529 # profiling support, locking
530 AC_ARG_ENABLE(profiling-locks,
d01ce2e5 531 AS_HELP_STRING([--enable-profiling-locks], [Enable performance profiling for locks]),[enable_profiling_locks=$enableval],[enable_profiling_locks=no])
d908e707 532 AS_IF([test "x$enable_profiling_locks" = "xyes"], [
ba81c4d2
VJ
533 AC_DEFINE([PROFILING],[1],[Enable performance profiling])
534 AC_DEFINE([PROFILE_LOCKING],[1],[Enable performance profiling for locks])
d908e707
VJ
535 ])
536
89cee0ad
VJ
537 # enable support for IPFW
538 AC_ARG_ENABLE(ipfw,
d01ce2e5 539 AS_HELP_STRING([--enable-ipfw], [Enable FreeBSD IPFW support for inline IDP]),[enable_ipfw=$enableval],[enable_ipfw=no])
89cee0ad 540 AS_IF([test "x$enable_ipfw" = "xyes"], [
ba81c4d2 541 AC_DEFINE([IPFW],[1],[Enable FreeBSD IPFW support for inline IDP])
89cee0ad
VJ
542 ])
543
7fb860ac 544 AC_ARG_ENABLE(coccinelle,
20dd5939 545 AS_HELP_STRING([--disable-coccinelle], [Disable coccinelle QA steps during make check]),[enable_coccinelle="$enableval"],[enable_coccinelle=yes])
7fb860ac
VJ
546 AS_IF([test "x$enable_coccinelle" = "xyes"], [
547 AC_PATH_PROG(HAVE_COCCINELLE_CONFIG, spatch, "no")
548 if test "$HAVE_COCCINELLE_CONFIG" = "no"; then
e4b39a41 549 enable_coccinelle=no
7fb860ac
VJ
550 fi
551 ])
552 AM_CONDITIONAL([HAVE_COCCINELLE], [test "x$enable_coccinelle" != "xno"])
553
f4872a2f
VJ
554 # disable detection
555 AC_ARG_ENABLE(detection,
20dd5939 556 AS_HELP_STRING([--disable-detection], [Disable Detection Modules]), [enable_detection="$enableval"],[enable_detection=yes])
f4872a2f 557 AS_IF([test "x$enable_detection" = "xno"], [
65d8ae93 558 AC_DEFINE([HAVE_DETECT_DISABLED], [1], [Detection is disabled])
f4872a2f
VJ
559 ])
560
89cee0ad
VJ
561# libraries
562
b60065ca
GL
563 # zlib
564 AC_ARG_WITH(zlib_includes,
565 [ --with-zlib-includes=DIR zlib include directory],
566 [with_zlib_includes="$withval"],[with_zlib_includes=no])
567 AC_ARG_WITH(zlib_libraries,
568 [ --with-zlib-libraries=DIR zlib library directory],
569 [with_zlib_libraries="$withval"],[with_zlib_libraries="no"])
570
571 if test "$with_zlib_includes" != "no"; then
572 CPPFLAGS="${CPPFLAGS} -I${with_zlib_includes}"
573 fi
574
575 AC_CHECK_HEADER(zlib.h, ZLIB="yes",ZLIB="no")
576 if test "$ZLIB" = "yes"; then
577 if test "$with_zlib_libraries" != "no"; then
578 LDFLAGS="${LDFLAGS} -L${with_zlib_libraries}"
579 fi
580
581 # To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
582 # see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
583 ZLIB=""
584 TMPLIBS="${LIBS}"
585 AC_CHECK_LIB(z,inflate,,ZLIB="no")
586
587 if test "$ZLIB" = "no"; then
588 echo
589 echo " ERROR! zlib library not found, go get it"
b98c28a6 590 echo " Debian/Ubuntu: apt install zlib1g-dev"
591 echo " Fedora: dnf install zlib-devel"
592 echo " CentOS/RHEL: yum install zlib-devel"
b60065ca
GL
593 echo
594 exit 1
595 fi
596 LIBS="${TMPLIBS} -lz"
597 fi
598
599 # liblzma
600 enable_liblzma=no
601
602 AC_ARG_WITH(liblzma_includes,
603 [ --with-liblzma-includes=DIR liblzma include directory],
b98c28a6 604 [with_liblzma_includes="$withval"],[with_liblzma_includes="no"])
b60065ca
GL
605 AC_ARG_WITH(liblzma_libraries,
606 [ --with-liblzma-libraries=DIR liblzma library directory],
607 [with_liblzma_libraries="$withval"],[with_liblzma_libraries="no"])
608
609 if test "$with_liblzma_includes" != "no"; then
610 CPPFLAGS="${CPPFLAGS} -I${with_liblzma_includes}"
611 fi
b98c28a6 612 TMPLIBS="${LIBS}"
b60065ca 613
b98c28a6 614 AC_CHECK_HEADER(lzma.h,
615 AC_CHECK_LIB(lzma,lzma_code,[
616 AC_DEFINE([HAVE_LIBLZMA],[1],[liblzma available])
617 LIBLZMA="yes"
618 if test "$LIBLZMA" = "yes"; then
619 if test "$with_liblzma_libraries" != "no"; then
620 LDFLAGS="${LDFLAGS} -L${with_liblzma_libraries}"
621 LIBS="${TMPLIBS} -llzma"
622 else
623 LIBS="${TMPLIBS} -llzma"
624 fi
625 fi]),LIBLZMA="no")
b60065ca 626
b98c28a6 627 if test "$LIBLZMA" != "yes"; then
628 echo
629 echo " Warning! liblzma library not found, you will not be"
630 echo " able to decompress flash file compressed with lzma."
631 echo " Debian/Ubuntu: apt install liblzma-dev"
632 echo " Fedora: dnf install xz-devel"
633 echo " CentOS/RHEL: yum install xz-devel"
634 echo
635 enable_liblzma=no
636 else
637 enable_liblzma=yes
638 LIBS="${TMPLIBS} -llzma"
b60065ca
GL
639 fi
640
89cee0ad 641 #libpcre
a3510f20
WM
642 AC_ARG_WITH(libpcre_includes,
643 [ --with-libpcre-includes=DIR libpcre include directory],
b98c28a6 644 [with_libpcre_includes="$withval"],[with_libpcre_includes="no"])
a3510f20
WM
645 AC_ARG_WITH(libpcre_libraries,
646 [ --with-libpcre-libraries=DIR libpcre library directory],
647 [with_libpcre_libraries="$withval"],[with_libpcre_libraries="no"])
648
649 if test "$with_libpcre_includes" != "no"; then
89f83c2e 650 CPPFLAGS="${CPPFLAGS} -I${with_libpcre_includes}"
a3510f20 651 fi
a3510f20 652 AC_CHECK_HEADER(pcre.h,,[AC_ERROR(pcre.h not found ...)])
6899b3da 653
a3510f20 654 if test "$with_libpcre_libraries" != "no"; then
ba81c4d2 655 LDFLAGS="${LDFLAGS} -L${with_libpcre_libraries}"
a3510f20 656 fi
a3510f20 657 PCRE=""
b98c28a6 658 AC_CHECK_LIB(pcre, pcre_get_substring,,PCRE="no")
89f83c2e
VJ
659 if test "$PCRE" = "no"; then
660 echo
661 echo " ERROR! pcre library not found, go get it"
b98c28a6 662 echo " from www.pcre.org. Or from packages:"
663 echo " Debian/Ubuntu: apt install libpcre3-dev"
664 echo " Fedora: dnf install pcre-devel"
665 echo " CentOS/RHEL: yum install pcre-devel"
89f83c2e
VJ
666 echo
667 exit 1
668 fi
6899b3da 669
8c0e5750
AH
670 # libpcre 8.35 (especially on debian) has a known issue that results in segfaults
671 # see https://redmine.openinfosecfoundation.org/issues/1693
c8399e8c
AH
672 if test "$with_libpcre_libraries" = "no"; then
673 PKG_CHECK_MODULES(LIBPCREVERSION, [libpcre = 8.35],[libpcre_buggy_found="yes"],[libprce_buggy_found="no"])
674 if test "$libpcre_buggy_found" = "yes"; then
675 echo
676 echo " Warning! vulnerable libpcre version 8.35 found"
677 echo " This version has a known issue that could result in segfaults"
678 echo " please upgrade to a newer version of pcre which you can get from"
679 echo " www.pcre.org. For more information, see issue #1693"
680 echo
681 echo " Continuing for now with JIT disabled..."
682 echo
683 fi
8c0e5750
AH
684 fi
685
89f83c2e
VJ
686 # To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
687 # see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
688 PCRE=""
689 TMPLIBS="${LIBS}"
690 AC_CHECK_LIB(pcre, pcre_dfa_exec,, PCRE="no")
a3510f20 691 if test "$PCRE" = "no"; then
89f83c2e
VJ
692 echo
693 echo " ERROR! pcre library was found but version was < 6.0"
694 echo " please upgrade to a newer version of pcre which you can get from"
695 echo " www.pcre.org."
696 echo
697 exit 1
a3510f20 698 fi
89f83c2e 699 LIBS="${TMPLIBS}"
6899b3da 700
89f83c2e
VJ
701 AC_TRY_COMPILE([ #include <pcre.h> ],
702 [ int eo = 0; eo |= PCRE_EXTRA_MATCH_LIMIT_RECURSION; ],
703 [ pcre_match_limit_recursion_available=yes ], [:]
704 )
705 if test "$pcre_match_limit_recursion_available" != "yes"; then
89f83c2e
VJ
706 echo
707 echo " Warning! pcre extra opt PCRE_EXTRA_MATCH_LIMIT_RECURSION not found"
708 echo " This could lead to potential DoS please upgrade to pcre >= 6.5"
89f83c2e 709 echo " from www.pcre.org."
ba81c4d2 710 echo " Continuing for now...."
89f83c2e 711 echo
ba81c4d2 712 AC_DEFINE([NO_PCRE_MATCH_RLIMIT],[1],[Pcre PCRE_EXTRA_MATCH_LIMIT_RECURSION not available])
89f83c2e 713 fi
5bde1217 714
0bfba835
VJ
715 TMPCFLAGS="${CFLAGS}"
716 CFLAGS="-O0 -g -Werror -Wall"
717 AC_TRY_COMPILE([ #include <pcre.h> ],
718 [ pcre_extra *extra = NULL; pcre_free_study(extra); ],
719 [ AC_DEFINE([HAVE_PCRE_FREE_STUDY], [1], [Pcre pcre_free_study supported])], [:]
720 )
721 CFLAGS="${TMPCFLAGS}"
722
3d396e8b 723 #enable support for PCRE-jit available since pcre-8.20
3d558bf0
EL
724 AC_MSG_CHECKING(for PCRE JIT support)
725 AC_TRY_COMPILE([ #include <pcre.h> ],
726 [
727 int jit = 0;
728 pcre_config(PCRE_CONFIG_JIT, &jit);
729 ],
730 [ pcre_jit_available=yes ], [ pcre_jit_available=no ]
731 )
732
bc480fa8
VJ
733 case $host in
734 *powerpc64*)
cee5c9fa
VJ
735 PKG_CHECK_MODULES(LIBPCREVERSION, [libpcre = 8.39],[libpcre_ppc64_buggy_found1="yes"],[libprce_ppc64_buggy_found1="no"])
736 PKG_CHECK_MODULES(LIBPCREVERSION, [libpcre = 8.40],[libpcre_ppc64_buggy_found2="yes"],[libprce_ppc64_buggy_found2="no"])
737
738 if test "$libprce_ppc64_buggy_found1" = "yes" || test "$libprce_ppc64_buggy_found2"; then
739 # on powerpc64, both gcc and clang lead to SIGILL in
740 # unittests when jit is enabled.
741 pcre_jit_available="no, pcre 8.39/8.40 jit disabled for powerpc64"
742 fi
bc480fa8
VJ
743 ;;
744 *)
745 # bug 1693, libpcre 8.35 is broken and debian jessie is still using that
746 if test "$libpcre_buggy_found" = "yes"; then
747 pcre_jit_available="no, libpcre 8.35 blacklisted"
748 fi
749 ;;
750 esac
e51707be 751
3d558bf0
EL
752 if test "x$pcre_jit_available" = "xyes"; then
753 AC_MSG_RESULT(yes)
754 AC_DEFINE([PCRE_HAVE_JIT], [1], [Pcre with JIT compiler support enabled])
755
756 AC_MSG_CHECKING(for PCRE JIT support usability)
757 AC_TRY_COMPILE([ #include <pcre.h> ],
758 [
759 const char* regexstr = "(a|b|c|d)";
760 pcre *re;
761 const char *error;
762 pcre_extra *extra;
763 int err_offset;
764 re = pcre_compile(regexstr,0, &error, &err_offset,NULL);
765 extra = pcre_study(re, PCRE_STUDY_JIT_COMPILE, &error);
766 if (extra == NULL)
767 exit(EXIT_FAILURE);
768 int jit = 0;
769 int ret = pcre_fullinfo(re, extra, PCRE_INFO_JIT, &jit);
770 if (ret != 0 || jit != 1)
771 exit(EXIT_FAILURE);
772 exit(EXIT_SUCCESS);
773 ],
774 [ pcre_jit_works=yes ], [:]
775 )
776 if test "x$pcre_jit_works" != "xyes"; then
777 AC_MSG_RESULT(no)
778 echo
779 echo " PCRE JIT support detection worked but testing it failed"
780 echo " something odd is going on, please file a bug report."
781 echo
782 exit 1
783 else
784 AC_MSG_RESULT(yes)
785 fi
5ea1b1d1 786 else
89f83c2e 787 AC_MSG_RESULT(no)
3d558bf0 788 fi
3d396e8b 789
13b87f5a
JV
790 # libhs
791 enable_hyperscan="no"
792
793 # Try pkg-config first:
794 PKG_CHECK_MODULES([libhs], libhs,, [with_pkgconfig_libhs=no])
795 if test "$with_pkgconfig_libhs" != "no"; then
796 CPPFLAGS="${CPPFLAGS} ${libhs_CFLAGS}"
797 LIBS="${LIBS} ${libhs_LIBS}"
798 fi
799
800 AC_ARG_WITH(libhs_includes,
801 [ --with-libhs-includes=DIR libhs include directory],
802 [with_libhs_includes="$withval"],[with_libhs_includes=no])
803 AC_ARG_WITH(libhs_libraries,
804 [ --with-libhs-libraries=DIR libhs library directory],
805 [with_libhs_libraries="$withval"],[with_libhs_libraries="no"])
806
807 if test "$with_libhs_includes" != "no"; then
808 CPPFLAGS="${CPPFLAGS} -I${with_libhs_includes}"
809 fi
810 AC_CHECK_HEADER(hs.h,HYPERSCAN="yes",HYPERSCAN="no")
811 if test "$HYPERSCAN" = "yes"; then
812 if test "$with_libhs_libraries" != "no"; then
813 LDFLAGS="${LDFLAGS} -L${with_libhs_libraries}"
814 fi
815
816 AC_CHECK_LIB(hs,hs_compile,,HYPERSCAN="no")
e6044aaf 817 AC_CHECK_FUNCS(hs_valid_platform)
13b87f5a
JV
818 enable_hyperscan="yes"
819 if test "$HYPERSCAN" = "no"; then
820 echo
821 echo " Hyperscan headers are present, but link test failed."
822 echo " Check that you have a shared library and C++ linkage available."
823 echo
824 enable_hyperscan="no"
825 fi
826 fi
827 AS_IF([test "x$enable_hyperscan" = "xyes"], [AC_DEFINE([BUILD_HYPERSCAN], [1], [Intel Hyperscan support enabled])])
828
89cee0ad 829 # libyaml
c91a4baa
JI
830 AC_ARG_WITH(libyaml_includes,
831 [ --with-libyaml-includes=DIR libyaml include directory],
832 [with_libyaml_includes="$withval"],[with_libyaml_includes=no])
833 AC_ARG_WITH(libyaml_libraries,
834 [ --with-libyaml-libraries=DIR libyaml library directory],
835 [with_libyaml_libraries="$withval"],[with_libyaml_libraries="no"])
836
837 if test "$with_libyaml_includes" != "no"; then
89f83c2e 838 CPPFLAGS="${CPPFLAGS} -I${with_libyaml_includes}"
c91a4baa
JI
839 fi
840
841 AC_CHECK_HEADER(yaml.h,,LIBYAML="no")
842
843 if test "$with_libyaml_libraries" != "no"; then
ba81c4d2 844 LDFLAGS="${LDFLAGS} -L${with_libyaml_libraries}"
c91a4baa
JI
845 fi
846
847 LIBYAML=""
848 AC_CHECK_LIB(yaml,yaml_parser_initialize,,LIBYAML="no")
849
850 if test "$LIBYAML" = "no"; then
89cee0ad
VJ
851 echo
852 echo " ERROR! libyaml library not found, go get it"
853 echo " from http://pyyaml.org/wiki/LibYAML "
854 echo " or your distribution:"
855 echo
856 echo " Ubuntu: apt-get install libyaml-dev"
015cd930 857 echo " Fedora: dnf install libyaml-devel"
858 echo " CentOS/RHEL: yum install libyaml-devel"
89cee0ad
VJ
859 echo
860 exit 1
c91a4baa
JI
861 fi
862
89cee0ad 863 # libpthread
a3510f20
WM
864 AC_ARG_WITH(libpthread_includes,
865 [ --with-libpthread-includes=DIR libpthread include directory],
866 [with_libpthread_includes="$withval"],[with_libpthread_includes=no])
867 AC_ARG_WITH(libpthread_libraries,
868 [ --with-libpthread-libraries=DIR libpthread library directory],
869 [with_libpthread_libraries="$withval"],[with_libpthread_libraries="no"])
870
871 if test "$with_libpthread_includes" != "no"; then
89f83c2e 872 CPPFLAGS="${CPPFLAGS} -I${with_libpthread_includes}"
a3510f20 873 fi
6899b3da 874
fa5939ca 875 dnl AC_CHECK_HEADER(pthread.h,,[AC_ERROR(pthread.h not found ...)])
6899b3da 876
a3510f20 877 if test "$with_libpthread_libraries" != "no"; then
89f83c2e 878 LDFLAGS="${LDFLAGS} -L${with_libpthread_libraries}"
a3510f20 879 fi
6899b3da 880
a3510f20
WM
881 PTHREAD=""
882 AC_CHECK_LIB(pthread, pthread_create,, PTHREAD="no")
6899b3da 883
a3510f20 884 if test "$PTHREAD" = "no"; then
89f83c2e
VJ
885 echo
886 echo " ERROR! libpthread library not found, glibc problem?"
887 echo
888 exit 1
a3510f20
WM
889 fi
890
20a8b9db 891 # libjansson
20a8b9db
EL
892 AC_ARG_WITH(libjansson_includes,
893 [ --with-libjansson-includes=DIR libjansson include directory],
894 [with_libjansson_includes="$withval"],[with_libjansson_includes=no])
895 AC_ARG_WITH(libjansson_libraries,
896 [ --with-libjansson-libraries=DIR libjansson library directory],
897 [with_libjansson_libraries="$withval"],[with_libjansson_libraries="no"])
898
899 if test "$with_libjansson_includes" != "no"; then
900 CPPFLAGS="${CPPFLAGS} -I${with_libjansson_includes}"
901 fi
902
e49c4042
JI
903 if test "$with_libjansson_libraries" != "no"; then
904 LDFLAGS="${LDFLAGS} -L${with_libjansson_libraries}"
905 fi
906
907 AC_CHECK_HEADER(jansson.h,JANSSON="yes",JANSSON="no")
908 AC_CHECK_LIB(jansson, json_dump_callback,, JANSSON="no")
909
910 if test "$JANSSON" = "no"; then
911 echo ""
912 echo " ERROR: Jansson is now required."
913 echo ""
914 echo " Go get it from your distribution or from:"
915 echo " http://www.digip.org/jansson/"
916 echo ""
917 echo " Ubuntu/Debian: apt install libjansson-dev"
918 echo " CentOS: yum install jansson-devel"
919 echo " Fedora: dnf install jansson-devel"
920 echo ""
921 exit 1
922 fi
923
924 enable_jansson="yes"
20a8b9db 925 enable_unixsocket="no"
7d706563
EL
926
927 AC_ARG_ENABLE(unix-socket,
928 AS_HELP_STRING([--enable-unix-socket], [Enable unix socket [default=test]]),[enable_unixsocket="$enableval"],[enable_unixsocket=test])
929
20a8b9db 930 if test "$JANSSON" = "yes"; then
20a8b9db
EL
931 enable_jansson="yes"
932 if test "$JANSSON" = "no"; then
933 echo
0470c0f6 934 echo " Jansson >= 2.2 is required for features like unix socket"
42227e87 935 echo " Go get it from your distribution or from:"
b98c28a6 936 echo " http://www.digip.org/jansson/"
937 echo " Ubuntu: apt-get install libjansson-dev"
938 echo " Fedora: dnf install jansson-devel"
939 echo " CentOS/RHEL: yum install jansson-devel"
20a8b9db 940 echo
ba81c4d2 941 if test "x$enable_unixsocket" = "xyes"; then
7d706563
EL
942 exit 1
943 fi
20a8b9db
EL
944 enable_unixsocket="no"
945 enable_jansson="no"
946 else
947 case $host in
bae83e61 948 *-*-mingw32*|*-*-msys*|*-*-cygwin)
1261d30d 949 enable_unixsocket="no"
ba81c4d2 950 ;;
20a8b9db 951 *)
ba81c4d2
VJ
952 if test "x$enable_unixsocket" = "xtest"; then
953 enable_unixsocket="yes"
954 fi
955 ;;
20a8b9db
EL
956 esac
957 fi
7d706563
EL
958 else
959 if test "x$enable_unixsocket" = "xyes"; then
960 echo
961 echo " Jansson >= 2.2 is required for features like unix socket"
42227e87 962 echo " Go get it from your distribution or from:"
7d706563 963 echo " http://www.digip.org/jansson/"
b98c28a6 964 echo " Ubuntu: apt-get install libjansson-dev"
965 echo " Fedora: dnf install jansson-devel"
966 echo " CentOS/RHEL: yum install jansson-devel"
7d706563
EL
967 echo
968 exit 1
969 fi
970 enable_unixsocket="no"
20a8b9db
EL
971 fi
972
973 AS_IF([test "x$enable_unixsocket" = "xyes"], [AC_DEFINE([BUILD_UNIX_SOCKET], [1], [Unix socket support enabled])])
f55dbca5 974 e_enable_evelog=$enable_jansson
20a8b9db 975
5f4b745f
EL
976 AC_ARG_ENABLE(nflog,
977 AS_HELP_STRING([--enable-nflog],[Enable libnetfilter_log support]),
d01ce2e5 978 [ enable_nflog="$enableval"],
5f4b745f
EL
979 [ enable_nflog="no"])
980 AC_ARG_ENABLE(nfqueue,
d01ce2e5 981 AS_HELP_STRING([--enable-nfqueue], [Enable NFQUEUE support for inline IDP]),[enable_nfqueue=$enableval],[enable_nfqueue=no])
15766ce2
AH
982 if test "$enable_nfqueue" != "no"; then
983 PKG_CHECK_MODULES([libnetfilter_queue], [libnetfilter_queue], [enable_nfqueue=yes], [enable_nfqueue=no])
984 CPPFLAGS="${CPPFLAGS} ${libnetfilter_queue_CFLAGS}"
985 fi
0ffa1c24 986
5f4b745f
EL
987 if test "x$enable_nflog" = "xyes" || test "x$enable_nfqueue" = "xyes"; then
988 # libnfnetlink
989 case $host in
990 *-*-mingw32*)
991 ;;
992 *)
993 AC_ARG_WITH(libnfnetlink_includes,
994 [ --with-libnfnetlink-includes=DIR libnfnetlink include directory],
995 [with_libnfnetlink_includes="$withval"],[with_libnfnetlink_includes=no])
996 AC_ARG_WITH(libnfnetlink_libraries,
997 [ --with-libnfnetlink-libraries=DIR libnfnetlink library directory],
998 [with_libnfnetlink_libraries="$withval"],[with_libnfnetlink_libraries="no"])
999
1000 if test "$with_libnfnetlink_includes" != "no"; then
1001 CPPFLAGS="${CPPFLAGS} -I${with_libnfnetlink_includes}"
1002 fi
0ffa1c24 1003
5f4b745f
EL
1004 if test "$with_libnfnetlink_libraries" != "no"; then
1005 LDFLAGS="${LDFLAGS} -L${with_libnfnetlink_libraries}"
1006 fi
0ffa1c24 1007
5f4b745f
EL
1008 NFNL=""
1009 AC_CHECK_LIB(nfnetlink, nfnl_fd,, NFNL="no")
1010
1011 if test "$NFNL" = "no"; then
1012 echo
1013 echo " ERROR! nfnetlink library not found, go get it"
1014 echo " from www.netfilter.org."
1015 echo " we automatically append libnetfilter_queue/ when searching"
1016 echo " for headers etc. when the --with-libnfnetlink-includes directive"
1017 echo " is used"
b98c28a6 1018 echo " Ubuntu: apt-get install libnetfilter-queue-dev"
1019 echo " Fedora: dnf install libnetfilter_queue-devel"
1020 echo " CentOS/RHEL: yum install libnetfilter_queue-devel"
5f4b745f
EL
1021 echo
1022 fi
1023 ;;
1024 esac
1025 fi
0ffa1c24 1026
ba81c4d2 1027 # enable support for NFQUEUE
3ff5dc36 1028 if test "x$enable_nfqueue" = "xyes"; then
ba81c4d2 1029 AC_DEFINE_UNQUOTED([NFQ],[1],[Enable Linux Netfilter NFQUEUE support for inline IDP])
4851568a 1030
3ff5dc36
VJ
1031 #libnetfilter_queue
1032 AC_ARG_WITH(libnetfilter_queue_includes,
a3510f20
WM
1033 [ --with-libnetfilter_queue-includes=DIR libnetfilter_queue include directory],
1034 [with_libnetfilter_queue_includes="$withval"],[with_libnetfilter_queue_includes=no])
3ff5dc36 1035 AC_ARG_WITH(libnetfilter_queue_libraries,
a3510f20
WM
1036 [ --with-libnetfilter_queue-libraries=DIR libnetfilter_queue library directory],
1037 [with_libnetfilter_queue_libraries="$withval"],[with_libnetfilter_queue_libraries="no"])
1038
3ff5dc36
VJ
1039 if test "$with_libnetfilter_queue_includes" != "no"; then
1040 CPPFLAGS="${CPPFLAGS} -I${with_libnetfilter_queue_includes}"
1041 fi
366671a8 1042
3ff5dc36 1043 AC_CHECK_HEADER(libnetfilter_queue/libnetfilter_queue.h,,[AC_ERROR(libnetfilter_queue/libnetfilter_queue.h not found ...)])
366671a8 1044
3ff5dc36
VJ
1045 if test "$with_libnetfilter_queue_libraries" != "no"; then
1046 LDFLAGS="${LDFLAGS} -L${with_libnetfilter_queue_libraries}"
89cee0ad 1047 fi
3ff5dc36
VJ
1048
1049 NFQ=""
89cee0ad
VJ
1050 AC_CHECK_LIB(netfilter_queue, nfq_open,, NFQ="no",)
1051 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])
1052 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 1053 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 1054 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
1055
1056 # check if the argument to nfq_get_payload is signed or unsigned
1057 AC_MSG_CHECKING([for signed nfq_get_payload payload argument])
1058 STORECFLAGS="${CFLAGS}"
adbf85c4
EL
1059 if test `basename $CC` = "clang"; then
1060 CFLAGS="${CFLAGS} -Werror=incompatible-pointer-types"
1061 else
58bf4ea4 1062 CFLAGS="${CFLAGS} -Werror"
adbf85c4 1063 fi
89cee0ad 1064 AC_COMPILE_IFELSE(
c9f9e3f9
VJ
1065 [AC_LANG_PROGRAM(
1066 [
3ff5dc36
VJ
1067 #include <stdio.h>
1068 #include <libnetfilter_queue/libnetfilter_queue.h>
c9f9e3f9
VJ
1069 ],
1070 [
3ff5dc36
VJ
1071 char *pktdata;
1072 nfq_get_payload(NULL, &pktdata);
c9f9e3f9
VJ
1073 ])],
1074 [libnetfilter_queue_nfq_get_payload_signed="yes"],
1075 [libnetfilter_queue_nfq_get_payload_signed="no"])
89cee0ad
VJ
1076 AC_MSG_RESULT($libnetfilter_queue_nfq_get_payload_signed)
1077 if test "x$libnetfilter_queue_nfq_get_payload_signed" = "xyes"; then
adbf85c4 1078 AC_DEFINE([NFQ_GET_PAYLOAD_SIGNED], [1], [For signed version of nfq_get_payload])
89cee0ad
VJ
1079 fi
1080 CFLAGS="${STORECFLAGS}"
0ffa1c24 1081
3ff5dc36
VJ
1082 if test "$NFQ" = "no"; then
1083 echo
1084 echo " ERROR! libnetfilter_queue library not found, go get it"
1085 echo " from www.netfilter.org."
1086 echo " we automatically append libnetfilter_queue/ when searching"
1087 echo " for headers etc. when the --with-libnfq-includes directive"
1088 echo " is used"
b98c28a6 1089 echo " Ubuntu: apt-get install libnetfilter-queue-dev"
1090 echo " Fedora: dnf install libnetfilter_queue-devel"
1091 echo " CentOS/RHEL: yum install libnetfilter_queue-devel"
3ff5dc36
VJ
1092 echo
1093 exit 1
1094 fi
a3510f20 1095 fi
2b7b78f1 1096
4851568a 1097 # libnetfilter_log
4851568a
GL
1098 AC_ARG_WITH(libnetfilter_log_includes,
1099 [ --with-libnetfilter_log-includes=DIR libnetfilter_log include directory],
1100 [with_libnetfilter_log_includes="$withval"],[with_libnetfilter_log_includes="no"])
1101 AC_ARG_WITH(libnetfilter_log_libraries,
1102 [ --with-libnetfilter_log-libraries=DIR libnetfilter_log library directory],
1103 [with_libnetfilter_log_libraries="$withval"],[with_libnetfilter_log_libraries="no"])
1104
1105 if test "$enable_nflog" = "yes"; then
1106 if test "$with_libnetfilter_log_includes" != "no"; then
1107 CPPFLAGS="${CPPFLAGS} -I${with_libnetfilter_log_includes}"
1108 fi
1109
1110 AC_CHECK_HEADER(libnetfilter_log/libnetfilter_log.h,,[AC_ERROR(libnetfilter_log.h not found ...)])
1111
1112 if test "$with_libnetfilter_log_libraries" != "no"; then
1113 LDFLAGS="${LDFLAGS} -L${with_libnetfilter_log_libraries}"
1114 fi
1115
1116 NFLOG=""
1117 AC_CHECK_LIB(netfilter_log, nflog_open,, NFLOG="no")
1118
1119 if test "$NFLOG" = "no"; then
1120 echo
1121 echo " ERROR! libnetfilter_log library not found, go get it"
1122 echo " from http://www.netfilter.org."
1123 echo
1124 exit 1
1125 else
1126 AC_DEFINE([HAVE_NFLOG],[1],[nflog available])
1127 enable_nflog="yes"
1128 fi
1129 fi
1130
ec77632e
JMS
1131 # WinDivert support
1132 AC_ARG_ENABLE(windivert,
d01ce2e5 1133 AS_HELP_STRING([--enable-windivert],[Enable WinDivert support [default=no]]),[enable_windivert=$enableval],
ec77632e
JMS
1134 [enable_windivert="no"])
1135
1136 # WinDivert can only be enabled on Windows builds
1137 AC_CHECK_DECL([OS_WIN32],,[enable_windivert="no"])
1138
1139 if test "x$enable_windivert" = "xyes"; then
1140 # WinDivert requires Vista at a minimum. If the user has selected their own NTDDI_VERSION
1141 # then don't override it.
1142 AC_CHECK_DECL([NTDDI_VERSION],,
1143 [CFLAGS="${CFLAGS} -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA"])
1144
1145 AC_DEFINE_UNQUOTED([WINDIVERT],[1],[Enable Windows WinDivert support for inline IDP])
1146
1147 AC_ARG_WITH(windivert_include,
1148 [ --with-windivert-include=DIR WinDivert include path],
1149 [with_windivert_include="$withval"],[with_windivert_include="no"])
1150 AC_ARG_WITH(windivert_libraries,
1151 [ --with-windivert-libraries=DIR WinDivert library path],
1152 [with_windivert_libraries="$withval"],[with_windivert_libraries="no"])
1153
1154 if test "$with_windivert_include" != "no"; then
1155 CPPFLAGS="${CPPFLAGS} -I${with_windivert_include}"
1156 fi
1157
1158 if test "$with_windivert_libraries" != "no"; then
1159 LDFLAGS="${LDFLAGS} -L${with_windivert_libraries}"
1160 fi
1161
1162 AC_CHECK_HEADER(windivert.h,,WINDIVERT_INC="no")
1163 AC_CHECK_LIB(WinDivert, WinDivertOpen,, WINDIVERT_LIB="no")
1164
1165 if test "$WINDIVERT_LIB" = "no" || test "$WINDIVERT_INC" = "no"; then
1166 echo
1167 echo " ERROR! WinDivert not found, go get it from"
1168 echo " https://www.reqrypt.org/windivert.html"
1169 echo
1170 exit 1
1171 fi
1172 fi
1173 # /WinDivert
1174
89cee0ad 1175 # prelude
eb33dc16 1176 AC_ARG_ENABLE(prelude,
d01ce2e5 1177 AS_HELP_STRING([--enable-prelude], [Enable Prelude support for alerts]),[enable_prelude=$enableval],[enable_prelude=no])
f0c785cc
KS
1178 # Prelude doesn't work with -Werror
1179 STORECFLAGS="${CFLAGS}"
1180 CFLAGS="${CFLAGS} -Wno-error=unused-result"
1181
4e84ffe2 1182 AS_IF([test "x$enable_prelude" = "xyes"], [
eb33dc16
PC
1183 AM_PATH_LIBPRELUDE(0.9.9, , AC_MSG_ERROR(Cannot find libprelude: Is libprelude-config in the path?), no)
1184 if test "x${LIBPRELUDE_CFLAGS}" != "x"; then
1185 CPPFLAGS="${CPPFLAGS} ${LIBPRELUDE_CFLAGS}"
1186 fi
1187
1188 if test "x${LIBPRELUDE_LDFLAGS}" != "x"; then
1189 LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LDFLAGS}"
1190 fi
1191
1192 if test "x${LIBPRELUDE_LIBS}" != "x"; then
1193 LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LIBS}"
1194 fi
8623b8f9 1195 AC_DEFINE([PRELUDE], [1], [Libprelude support enabled])
4e84ffe2 1196 ])
f0c785cc
KS
1197 CFLAGS="${STORECFLAGS}"
1198
eb33dc16 1199
89cee0ad 1200 # libnet
a3510f20
WM
1201 AC_ARG_WITH(libnet_includes,
1202 [ --with-libnet-includes=DIR libnet include directory],
1203 [with_libnet_includes="$withval"],[with_libnet_includes="no"])
1204
1205 AC_ARG_WITH(libnet_libraries,
1206 [ --with-libnet-libraries=DIR libnet library directory],
1207 [with_libnet_libraries="$withval"],[with_libnet_libraries="no"])
1208
1209 if test "x$with_libnet_includes" != "xno"; then
3678dda1
WM
1210 CPPFLAGS="${CPPFLAGS} -I${with_libnet_includes}"
1211 libnet_dir="${with_libnet_includes}"
f7111f38 1212 else
829238e4 1213 libnet_dir="/usr/include /usr/local/include /usr/local/include/libnet11 /opt/local/include /usr/local/include/libnet-1.1"
a3510f20 1214 fi
0ffa1c24 1215
a3510f20 1216 if test "x$with_libnet_libraries" != "xno"; then
3678dda1 1217 LDFLAGS="${LDFLAGS} -L${with_libnet_libraries}"
a3510f20
WM
1218 fi
1219
3678dda1 1220 LIBNET_DETECT_FAIL="no"
a3510f20 1221 LIBNET_INC_DIR=""
3678dda1 1222
a3510f20
WM
1223 for i in $libnet_dir; do
1224 if test -r "$i/libnet.h"; then
3678dda1 1225 LIBNET_INC_DIR="$i"
a3510f20
WM
1226 fi
1227 done
1228
439b62fe 1229 enable_libnet="no"
3678dda1 1230 AC_MSG_CHECKING(for libnet.h version 1.1.x)
a3510f20 1231 if test "$LIBNET_INC_DIR" != ""; then
365015c2
AG
1232 LIBNET_VER=`grep LIBNET_VERSION $LIBNET_INC_DIR/libnet.h | grep '1.[[12]]' | sed 's/[[^"]]*"\([[^"]]*\).*/\1/'`
1233
1234 if test -z "$LIBNET_VER" ; then
3678dda1 1235 AC_MSG_RESULT(no)
3678dda1
WM
1236 else
1237 AC_MSG_RESULT(yes)
1238 fi
6e8c75ff 1239
3678dda1
WM
1240 #CentOS, Fedora, Ubuntu-LTS, Ubuntu all set defines to the same values. libnet-config seems
1241 #to have been depreciated but all distro's seem to include it as part of the package.
1242 if test "$LIBNET_DETECT_FAIL" = "no"; then
1243 LLIBNET=""
1244 AC_CHECK_LIB(net, libnet_write,, LLIBNET="no")
1245 if test "$LLIBNET" != "no"; then
ba81c4d2
VJ
1246 AC_DEFINE([HAVE_LIBNET11],[1],(libnet 1.1 available))
1247 AC_DEFINE([_DEFAULT_SOURCE],[1],(default source))
1248 AC_DEFINE([_BSD_SOURCE],[1],(bsd source))
1249 AC_DEFINE([__BSD_SOURCE],[1],(bsd source))
1250 AC_DEFINE([__FAVOR_BSD],[1],(favor bsd))
1251 AC_DEFINE([HAVE_NET_ETHERNET_H],[1],(ethernet.h))
439b62fe 1252 enable_libnet="yes"
3678dda1
WM
1253 fi
1254
1255 # see if we have the patched libnet 1.1
2e8678a5 1256 # https://www.inliniac.net/blog/2007/10/16/libnet-11-ipv6-fixes-and-additions.html
3678dda1
WM
1257 #
1258 # To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
1259 # see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
439b62fe 1260 if test "$enable_libnet" = "yes"; then
3678dda1
WM
1261 LLIBNET=""
1262 TMPLIBS="${LIBS}"
1263 AC_CHECK_LIB(net, libnet_build_icmpv6_unreach,, LLIBNET="no")
1264 if test "$LLIBNET" != "no"; then
ba81c4d2 1265 AC_DEFINE([HAVE_LIBNET_ICMPV6_UNREACH],[1],(libnet_build_icmpv6_unreach available))
3678dda1
WM
1266 fi
1267 LIBS="${TMPLIBS}"
1268 fi
365015c2
AG
1269
1270 # See if we have libnet 1.1.6 or newer - these versions handle capabilities correctly
1271 # Some patched 1.1.4 versions are also good, but it's not guaranteed for all distros.
1272 #
1273 # Details: https://bugzilla.redhat.com/show_bug.cgi?id=589770
1274 AS_VERSION_COMPARE([LIBNET_VER], [1.1.6],
1275 [],
1276 [AC_DEFINE([HAVE_LIBNET_CAPABILITIES],[1], (libnet_have_capabilities_patch))],
1277 [AC_DEFINE([HAVE_LIBNET_CAPABILITIES],[1], (libnet_have_capabilities_patch))])
66346e46
VJ
1278
1279
1280 # check if the argument to libnet_init is char* or const char*
1281 AC_MSG_CHECKING([libnet_init dev type])
1282 STORECFLAGS="${CFLAGS}"
1283 if test `basename $CC` = "clang"; then
1284 CFLAGS="${CFLAGS} -Werror=incompatible-pointer-types"
1285 else
1286 CFLAGS="${CFLAGS} -Werror"
1287 fi
1288 AC_COMPILE_IFELSE(
1289 [AC_LANG_PROGRAM(
1290 [
1291 #include <stdio.h>
1292 #include <libnet.h>
1293 ],
1294 [[
1295 const char dev[32] = "";
1296 char ebuf[LIBNET_ERRBUF_SIZE];
1297 (void)libnet_init(LIBNET_LINK, dev, ebuf);
1298 ]])],
1299 [libnet_init_const="yes"],
1300 [libnet_init_const="no"])
1301 AC_MSG_RESULT($libnet_init_const)
1302 if test "x$libnet_init_const" = "xyes"; then
1303 AC_DEFINE([HAVE_LIBNET_INIT_CONST], [1], [libnet_init takes const argument])
1304 fi
1305 CFLAGS="${STORECFLAGS}"
3678dda1 1306 fi
a3510f20 1307 else
439b62fe 1308 AC_MSG_RESULT(no)
a3510f20 1309 fi
0d15d4f6
MK
1310
1311 # libpcap
1312 AC_ARG_WITH(libpcap_includes,
1313 [ --with-libpcap-includes=DIR libpcap include directory],
1314 [with_libpcap_includes="$withval"],[with_libpcap_includes=no])
1315 AC_ARG_WITH(libpcap_libraries,
1316 [ --with-libpcap-libraries=DIR libpcap library directory],
1317 [with_libpcap_libraries="$withval"],[with_libpcap_libraries="no"])
1318
1319 if test "$with_libpcap_includes" != "no"; then
1320 CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}"
1321 fi
1322
1323 AC_CHECK_HEADER(pcap.h,,[AC_ERROR(pcap.h not found ...)])
1324
1325 if test "$with_libpcap_libraries" != "no"; then
1326 LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}"
1327 fi
1328 AC_CHECK_HEADERS([pcap.h pcap/pcap.h pcap/bpf.h])
1329
1330 LIBPCAP=""
d1e839ea 1331 AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_open_live,, LIBPCAP="no")
0d15d4f6
MK
1332 if test "$LIBPCAP" = "no"; then
1333 echo
1334 echo " ERROR! libpcap library not found, go get it"
1335 echo " from http://www.tcpdump.org or your distribution:"
1336 echo
1337 echo " Ubuntu: apt-get install libpcap-dev"
015cd930 1338 echo " Fedora: dnf install libpcap-devel"
1339 echo " CentOS/RHEL: yum install libpcap-devel"
0d15d4f6
MK
1340 echo
1341 exit 1
1342 fi
1343
1344 # pcap_activate and pcap_create only exists in libpcap >= 1.0
1345 LIBPCAPVTEST=""
1346 #To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
1347 #see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
1348 TMPLIBS="${LIBS}"
d1e839ea 1349 AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_activate,, LPCAPVTEST="no")
cda6e029
VJ
1350 if test "$LPCAPVTEST" = "no"; then
1351 echo
1352 echo " ERROR! libpcap library too old, need at least 1+, "
1353 echo " go get it from http://www.tcpdump.org or your distribution:"
1354 echo
1355 echo " Ubuntu: apt-get install libpcap-dev"
015cd930 1356 echo " Fedora: dnf install libpcap-devel"
1357 echo " CentOS/RHEL: yum install libpcap-devel"
cda6e029
VJ
1358 echo
1359 exit 1
1360 fi
1361 AC_PATH_PROG(HAVE_PCAP_CONFIG, pcap-config, "no")
1362 if test "$HAVE_PCAP_CONFIG" = "no" -o "$cross_compiling" = "yes"; then
1363 AC_MSG_RESULT(no pcap-config is use)
0d15d4f6 1364 else
cda6e029
VJ
1365 PCAP_CFLAGS="$(pcap-config --defines) $(pcap-config --cflags)"
1366 AC_SUBST(PCAP_CFLAGS)
0d15d4f6
MK
1367 fi
1368 LIBS="${TMPLIBS}"
1369
1370 #Appears as if pcap_set_buffer_size is linux only?
1371 LIBPCAPSBUFF=""
1372 #To prevent duping the lib link we reset LIBS after this check. Setting action-if-found to NULL doesn't seem to work
1373 #see: http://blog.flameeyes.eu/2008/04/29/i-consider-ac_check_lib-harmful
1374 TMPLIBS="${LIBS}"
d1e839ea 1375 AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_set_buffer_size,, LPCAPSBUFF="no")
0d15d4f6 1376 if test "$LPCAPSBUFF" != "no"; then
ba81c4d2 1377 AC_DEFINE([HAVE_PCAP_SET_BUFF],[1],(libpcap has pcap_set_buffer_size function))
0d15d4f6
MK
1378 fi
1379 LIBS="${TMPLIBS}"
1380
1381 # libpfring
89cee0ad
VJ
1382 # libpfring (currently only supported for libpcap enabled pfring)
1383 # Error on the side of caution. If libpfring enabled pcap is being used and we don't link against -lpfring compilation will fail.
04b0f177 1384 AC_ARG_ENABLE(pfring,
d01ce2e5 1385 AS_HELP_STRING([--enable-pfring], [Enable Native PF_RING support]),[enable_pfring=$enableval],[enable_pfring=no])
e07e9e16 1386 AS_IF([test "x$enable_pfring" = "xyes"], [
ba81c4d2 1387 AC_DEFINE([HAVE_PFRING],[1],(PF_RING support enabled))
ddf995da 1388
89cee0ad 1389 #We have to set CFLAGS for AC_TRY_COMPILE as it doesn't pay attention to CPPFLAGS
6408feba
W
1390 AC_ARG_WITH(libpfring_includes,
1391 [ --with-libpfring-includes=DIR libpfring include directory],
1392 [with_libpfring_includes="$withval"],[with_libpfring_includes=no])
1393 AC_ARG_WITH(libpfring_libraries,
1394 [ --with-libpfring-libraries=DIR libpfring library directory],
1395 [with_libpfring_libraries="$withval"],[with_libpfring_libraries="no"])
1396
1397 if test "$with_libpfring_includes" != "no"; then
89f83c2e 1398 CPPFLAGS="${CPPFLAGS} -I${with_libpfring_includes}"
6408feba 1399 fi
073d0421 1400
6408feba 1401 if test "$with_libpfring_libraries" != "no"; then
89f83c2e 1402 LDFLAGS="${LDFLAGS} -L${with_libpfring_libraries}"
6408feba 1403 fi
073d0421 1404
6408feba 1405 LIBPFRING=""
43ffd779 1406 AC_CHECK_LIB(pfring, pfring_open,, LIBPFRING="no", [-lpcap])
dde78e49
GL
1407 if test "$LIBPFRING" != "no"; then
1408 STORECFLAGS="${CFLAGS}"
1409 CFLAGS="${CFLAGS} -Werror"
1410 AC_COMPILE_IFELSE(
1411 [AC_LANG_PROGRAM(
1412 [
1413 #include <pfring.h>
1414 ],
1415 [
1416 pfring_recv_chunk(NULL, NULL, 0, 0);
1417 ])],
1418 [pfring_recv_chunk="yes"],
1419 [pfring_recv_chunk="no"])
1420 CFLAGS="${STORECFLAGS}"
1421 if test "x$pfring_recv_chunk" != "xyes"; then
a75911e0
EL
1422 if test "x$enable_pfring" = "xyes"; then
1423 echo
dde78e49
GL
1424 echo " ERROR! --enable-pfring was passed but the library version is < 6, go get it"
1425 echo " from http://www.ntop.org/products/pf_ring/"
a75911e0
EL
1426 echo
1427 exit 1
1428 fi
6408feba 1429 fi
b6baafb3
AC
1430 AC_COMPILE_IFELSE(
1431 [AC_LANG_SOURCE([[
1432 #include <pfring.h>
1433 #ifndef PF_RING_FLOW_OFFLOAD
1434 # error PF_RING_FLOW_OFFLOAD not defined
1435 #endif
1436 ]])],
1437 [
1438 AC_DEFINE([HAVE_PF_RING_FLOW_OFFLOAD], [1], [PF_RING bypass support enabled])
1439 ],
1440 [
1441 echo
1442 echo " Warning! Pfring hw bypass not supported by this library version < 7,"
1443 echo " please upgrade to a newer version to use this feature."
1444 echo
1445 echo " Continuing for now with hw bypass support disabled..."
1446 echo
1447 ])
6408feba 1448 else
dde78e49
GL
1449 if test "x$enable_pfring" = "xyes"; then
1450 echo
1451 echo " ERROR! --enable-pfring was passed but the library was not found, go get it"
1452 echo " from http://www.ntop.org/products/pf_ring/"
1453 echo
1454 exit 1
1455 fi
dbf5d79e 1456 fi
6408feba 1457 ])
ddf995da 1458
89cee0ad 1459 # AF_PACKET support
e80b30c0 1460 AC_ARG_ENABLE(af-packet,
b2ebd4a1 1461 AS_HELP_STRING([--enable-af-packet], [Enable AF_PACKET support [default=yes]]),
d01ce2e5 1462 [enable_af_packet=$enableval],[enable_af_packet=yes])
e80b30c0 1463 AS_IF([test "x$enable_af_packet" = "xyes"], [
ac2d13d6 1464 AC_CHECK_DECL([TPACKET_V2],
e80b30c0 1465 AC_DEFINE([HAVE_AF_PACKET],[1],[AF_PACKET support is available]),
ac2d13d6
EL
1466 [enable_af_packet="no"],
1467 [[#include <sys/socket.h>
1468 #include <linux/if_packet.h>]])
851fcef9
EL
1469 AC_CHECK_DECL([PACKET_FANOUT_QM],
1470 AC_DEFINE([HAVE_PACKET_FANOUT],[1],[Recent packet fanout support is available]),
e80b30c0
EL
1471 [],
1472 [[#include <linux/if_packet.h>]])
c2d0d938
EL
1473 AC_CHECK_DECL([TPACKET_V3],
1474 AC_DEFINE([HAVE_TPACKET_V3],[1],[AF_PACKET tpcket_v3 support is available]),
1475 [],
1476 [[#include <sys/socket.h>
1477 #include <linux/if_packet.h>]])
a40f08a2
EL
1478 AC_CHECK_DECL([SOF_TIMESTAMPING_RAW_HARDWARE],
1479 AC_DEFINE([HAVE_HW_TIMESTAMPING],[1],[Hardware timestamping support is available]),
1480 [],
f79f6409 1481 [[#include <linux/net_tstamp.h>]])
e80b30c0
EL
1482 ])
1483
10104066 1484 # Netmap support
1485 AC_ARG_ENABLE(netmap,
d01ce2e5 1486 AS_HELP_STRING([--enable-netmap], [Enable Netmap support]),[enable_netmap=$enableval],[enable_netmap=no])
10104066 1487 AC_ARG_WITH(netmap_includes,
1488 [ --with-netmap-includes=DIR netmap include directory],
1489 [with_netmap_includes="$withval"],[with_netmap_includes=no])
1490
1491 AS_IF([test "x$enable_netmap" = "xyes"], [
ba81c4d2 1492 AC_DEFINE([HAVE_NETMAP],[1],(NETMAP support enabled))
10104066 1493
1494 if test "$with_netmap_includes" != "no"; then
1495 CPPFLAGS="${CPPFLAGS} -I${with_netmap_includes}"
1496 fi
1497
1498 AC_CHECK_HEADER(net/netmap_user.h,,[AC_ERROR(net/netmap_user.h not found ...)],)
517b45ea
VJ
1499
1500 have_recent_netmap="no"
1501 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1502 #include <net/netmap_user.h>
1503 ],[
1504 #ifndef NETMAP_API
1505 #error "outdated netmap, need one with NETMAP_API"
1506 #endif
1507 #if NETMAP_API < 11
1508 #error "outdated netmap, need at least api version 11"
1509 #endif
1510 ])], [have_recent_netmap="yes"])
1511 if test "x$have_recent_netmap" != "xyes"; then
1512 echo "ERROR: outdated netmap"
1513 exit 1
1514 fi
1515 have_netmap_version="unknown"
1516 have_v11_netmap="no"
1517 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1518 #include <net/netmap_user.h>
1519 ],[
1520 #if NETMAP_API != 11
1521 #error "not 11"
1522 #endif
1523 ])], [have_v11_netmap="yes"])
1524 if test "x$have_v11_netmap" = "xyes"; then
1525 have_netmap_version="v11"
1526 fi
1527 have_v12_netmap="no"
1528 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1529 #include <net/netmap_user.h>
1530 ],[
1531 #if NETMAP_API != 12
1532 #error "not 12"
1533 #endif
1534 ])], [have_v12_netmap="yes"])
1535 if test "x$have_v12_netmap" = "xyes"; then
1536 have_netmap_version="v12"
1537 fi
1538 have_v13_netmap="no"
1539 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1540 #include <net/netmap_user.h>
1541 ],[
1542 #if NETMAP_API != 13
1543 #error "not 13"
1544 #endif
1545 ])], [have_v13_netmap="yes"])
1546 if test "x$have_v13_netmap" = "xyes"; then
1547 have_netmap_version="v13"
1548 fi
1549 have_gtv13_netmap="no"
1550 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1551 #include <net/netmap_user.h>
1552 ],[
1553 #if NETMAP_API <= 13
1554 #error "not gt 13"
1555 #endif
1556 ])], [have_gtv13_netmap="yes"])
1557 if test "x$have_gtv13_netmap" = "xyes"; then
1558 have_netmap_version="> v13"
1559 fi
10104066 1560 ])
c45d8985 1561
345ec58d
JI
1562 # Suricata-Update.
1563 AC_ARG_ENABLE([suricata-update], AS_HELP_STRING([--disable-suricata-update],
1564 [Disable suricata-update]), [enable_suricata_update=$enableval],
1565 [enable_suricata_update="yes"])
1566
1567 # Assume suircata-update will not be installed.
1568 have_suricata_update="no"
1569 ruledirprefix="$sysconfdir"
1570 no_suricata_update_comment="#"
1571 has_suricata_update_comment=""
1572 suricata_update_rule_files="suricata-update-rule-files"
1573
1574 if test "$enable_suricata_update" = "yes"; then
1575 AC_CHECK_FILE([$srcdir/suricata-update/setup.py], [
1576 have_suricata_update="yes"], [])
1577 fi
1578 AM_CONDITIONAL([HAVE_SURICATA_UPDATE],
1579 [test "x$have_suricata_update" != "xno"])
1580
345ec58d
JI
1581 if test "$have_suricata_update" = "yes"; then
1582 if test "$have_python_yaml" != "yes"; then
1583 echo ""
1584 echo " Warning: suricata-update will not be installed as the"
1585 echo " depedency python-yaml is not installed."
1586 echo ""
1587 echo " Debian/Ubuntu: apt install python-yaml"
1588 echo " Fedora: dnf install python-yaml"
1589 echo " CentOS/RHEL: yum install python-yaml"
b98c28a6 1590 echo
345ec58d 1591 else
345ec58d
JI
1592 SURICATA_UPDATE_DIR="suricata-update"
1593 AC_SUBST(SURICATA_UPDATE_DIR)
1594 AC_OUTPUT(suricata-update/Makefile)
1595 ruledirprefix="$localstatedir/lib"
1596 no_suricata_update_comment=""
1597 has_suricata_update_comment="#"
1598 fi
1599 fi
cbcbc0f6 1600
a69afd5c
JI
1601 # Test to see if suricatactl (and suricatasc) can be installed.
1602 if test "x$enable_python" != "xyes"; then
1603 install_suricatactl="requires python"
1604 elif test "x$have_python_distutils" != "xyes"; then
1605 install_suricatactl="requires distutils"
1606 else
1607 install_suricatactl="yes"
1608 fi
1609
1610 # Test to see if suricata-update can be installed.
1611 if test "x$have_suricata_update" != "xyes"; then
1612 install_suricata_update="not bundled"
1613 elif test "x$enable_python" != "xyes"; then
1614 install_suricata_update="requires python"
1615 elif test "x$have_python_distutils" != "xyes"; then
1616 install_suricata_update="requires distutils"
1617 elif test "x$have_python_yaml" != "xyes"; then
1618 install_suricata_update="requires pyyaml"
1619 else
1620 install_suricata_update="yes"
1621 fi
1622
89cee0ad 1623 # libhtp
e07e9e16 1624 AC_ARG_ENABLE(non-bundled-htp,
d01ce2e5 1625 AS_HELP_STRING([--enable-non-bundled-htp], [Enable the use of an already installed version of htp]),[enable_non_bundled_htp=$enableval],[enable_non_bundled_htp=no])
e07e9e16 1626 AS_IF([test "x$enable_non_bundled_htp" = "xyes"], [
f8b8b6f7
EL
1627 PKG_CHECK_MODULES([libhtp], htp,, [with_pkgconfig_htp=no])
1628 if test "$with_pkgconfig_htp" != "no"; then
1629 CPPFLAGS="${CPPFLAGS} ${libhtp_CFLAGS}"
1630 LIBS="${LIBS} ${libhtp_LIBS}"
1631 fi
1632
e07e9e16
WM
1633 AC_ARG_WITH(libhtp_includes,
1634 [ --with-libhtp-includes=DIR libhtp include directory],
1635 [with_libhtp_includes="$withval"],[with_libhtp_includes=no])
1636 AC_ARG_WITH(libhtp_libraries,
1637 [ --with-libhtp-libraries=DIR libhtp library directory],
1638 [with_libhtp_libraries="$withval"],[with_libhtp_libraries="no"])
1639
1640 if test "$with_libhtp_includes" != "no"; then
0c37f76f 1641 CPPFLAGS="-I${with_libhtp_includes} ${CPPFLAGS}"
e07e9e16 1642 fi
07f7ba55 1643
e07e9e16 1644 if test "$with_libhtp_libraries" != "no"; then
89cee0ad 1645 LDFLAGS="${LDFLAGS} -L${with_libhtp_libraries}"
e07e9e16 1646 fi
ed856de9 1647
e07e9e16 1648 AC_CHECK_HEADER(htp/htp.h,,[AC_ERROR(htp/htp.h not found ...)])
ed856de9 1649
e07e9e16
WM
1650 LIBHTP=""
1651 AC_CHECK_LIB(htp, htp_conn_create,, LIBHTP="no")
1652 if test "$LIBHTP" = "no"; then
89cee0ad
VJ
1653 echo
1654 echo " ERROR! libhtp library not found"
1655 echo
1656 exit 1
e07e9e16 1657 fi
37b10c13 1658 PKG_CHECK_MODULES(LIBHTPMINVERSION, [htp >= 0.5.20],[libhtp_minver_found="yes"],[libhtp_minver_found="no"])
e07e9e16 1659 if test "$libhtp_minver_found" = "no"; then
f85a2dc8
AS
1660 PKG_CHECK_MODULES(LIBHTPDEVVERSION, [htp = 0.5.X],[libhtp_devver_found="yes"],[libhtp_devver_found="no"])
1661 if test "$libhtp_devver_found" = "no"; then
1662 echo
37b10c13 1663 echo " ERROR! libhtp was found but it is neither >= 0.5.20, nor the dev 0.5.X"
f85a2dc8
AS
1664 echo
1665 exit 1
1666 fi
d472d606
EL
1667 fi
1668
a3e2b355 1669 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
1670 # check for htp_tx_get_response_headers_raw
1671 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 1672 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])
5ec885e4 1673 AC_CHECK_LIB([htp], [htp_config_set_response_decompression_layer_limit],AC_DEFINE_UNQUOTED([HAVE_HTP_CONFIG_SET_RESPONSE_DECOMPRESSION_LAYER_LIMIT],[1],[Found htp_config_set_response_decompression_layer_limit function in libhtp]) ,,[-lhtp])
6d225378 1674 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 1675 ])
4acd5a04 1676
aafc65c7
VJ
1677 if test "x$enable_non_bundled_htp" = "xno"; then
1678 # test if we have a bundled htp
1679 if test -d "$srcdir/libhtp"; then
1680 AC_CONFIG_SUBDIRS([libhtp])
1681 HTP_DIR="libhtp"
1682 AC_SUBST(HTP_DIR)
1683 HTP_LDADD="../libhtp/htp/libhtp.la"
1684 AC_SUBST(HTP_LDADD)
1685 # make sure libhtp is added to the includes
667e4e68 1686 CPPFLAGS="-I\${srcdir}/../libhtp/ ${CPPFLAGS}"
aafc65c7 1687
8060ef41 1688 AC_CHECK_HEADER(iconv.h,,[AC_ERROR(iconv.h not found ...)])
c0993495 1689 AC_CHECK_LIB(iconv, libiconv_close)
aafc65c7
VJ
1690 AC_DEFINE_UNQUOTED([HAVE_HTP_URI_NORMALIZE_HOOK],[1],[Assuming htp_config_register_request_uri_normalize function in bundled libhtp])
1691 AC_DEFINE_UNQUOTED([HAVE_HTP_TX_GET_RESPONSE_HEADERS_RAW],[1],[Assuming htp_tx_get_response_headers_raw function in bundled libhtp])
1692 AC_DEFINE_UNQUOTED([HAVE_HTP_DECODE_QUERY_INPLACE],[1],[Assuming htp_decode_query_inplace function in bundled libhtp])
5ec885e4
VJ
1693 # enable when libhtp has been updated
1694 AC_DEFINE_UNQUOTED([HAVE_HTP_CONFIG_SET_RESPONSE_DECOMPRESSION_LAYER_LIMIT],[1],[Assuming htp_config_set_response_decompression_layer_limit function in bundled libhtp])
aafc65c7
VJ
1695 else
1696 echo
1bbbcf51 1697 echo " ERROR: Libhtp is not bundled. Get libhtp by doing:"
5ec885e4 1698 echo " git clone https://github.com/OISF/libhtp"
1bbbcf51
KS
1699 echo " Then re-run Suricata's autogen.sh and configure script."
1700 echo " Or, if libhtp is installed in a different location,"
1701 echo " pass --enable-non-bundled-htp to Suricata's configure script."
aafc65c7
VJ
1702 echo " Add --with-libhtp-includes=<dir> and --with-libhtp-libraries=<dir> if"
1703 echo " libhtp is not installed in the include and library paths."
1704 echo
1705 exit 1
1706 fi
1707 fi
36917c7d 1708
08328f9d 1709
89cee0ad 1710 # Check for libcap-ng
829238e4
VJ
1711 case $host in
1712 *-*-linux*)
070ed778
VJ
1713 AC_ARG_WITH(libcap_ng_includes,
1714 [ --with-libcap_ng-includes=DIR libcap_ng include directory],
f01027e9 1715 [with_libcap_ng_includes="$withval"],[with_libcap_ng_includes=no])
070ed778
VJ
1716 AC_ARG_WITH(libcap_ng_libraries,
1717 [ --with-libcap_ng-libraries=DIR libcap_ng library directory],
1718 [with_libcap_ng_libraries="$withval"],[with_libcap_ng_libraries="no"])
1719
1720 if test "$with_libcap_ng_includes" != "no"; then
89cee0ad 1721 CPPFLAGS="${CPPFLAGS} -I${with_libcap_ng_includes}"
070ed778
VJ
1722 fi
1723
1724 if test "$with_libcap_ng_libraries" != "no"; then
89cee0ad 1725 LDFLAGS="${LDFLAGS} -L${with_libcap_ng_libraries}"
070ed778
VJ
1726 fi
1727
1728 AC_CHECK_HEADER(cap-ng.h,,LIBCAP_NG="no")
1729 if test "$LIBCAP_NG" != "no"; then
1730 LIBCAP_NG=""
1731 AC_CHECK_LIB(cap-ng,capng_clear,,LIBCAP_NG="no")
1732 fi
1733
1734 if test "$LIBCAP_NG" != "no"; then
ba81c4d2 1735 AC_DEFINE([HAVE_LIBCAP_NG],[1],[Libpcap-ng support])
070ed778
VJ
1736 fi
1737
1738 if test "$LIBCAP_NG" = "no"; then
89cee0ad
VJ
1739 echo
1740 echo " WARNING! libcap-ng library not found, go get it"
1741 echo " from http://people.redhat.com/sgrubb/libcap-ng/"
1742 echo " or your distribution:"
1743 echo
1744 echo " Ubuntu: apt-get install libcap-ng-dev"
015cd930 1745 echo " Fedora: dnf install libcap-ng-devel"
1746 echo " CentOS/RHEL: yum install libcap-ng-devel"
89cee0ad
VJ
1747 echo
1748 echo " Suricata will be built without support for dropping privs."
1749 echo
070ed778 1750 fi
829238e4
VJ
1751 ;;
1752 esac
835630ef 1753
91e1256b
EL
1754
1755 AC_ARG_ENABLE(ebpf,
1756 AS_HELP_STRING([--enable-ebpf],[Enable eBPF support]),
d01ce2e5 1757 [ enable_ebpf="$enableval"],
91e1256b
EL
1758 [ enable_ebpf="no"])
1759
731c2b2e 1760 have_xdp="no"
91e1256b
EL
1761 if test "$enable_ebpf" = "yes"; then
1762 AC_CHECK_LIB(elf,elf_begin,,LIBELF="no")
1763 if test "$LIBELF" = "no"; then
1764 echo
1765 echo " libelf library and development headers not found but"
1766 echo " but needed to use eBPF code"
1767 echo
1768 exit 1
1769 fi;
1770
1771 AC_CHECK_LIB(bpf,bpf_object__open,,LIBBPF="no")
1772 if test "$LIBBPF" = "no"; then
1773 echo
1774 echo " libbpf library and development headers not found but"
1775 echo " but needed to use eBPF code. It can be found in the"
1776 echo " Linux kernel tree under tools/lib/bpf"
1777 echo
1778 exit 1
1779 fi;
1780 AC_CHECK_DECL([PACKET_FANOUT_EBPF],
1781 AC_DEFINE([HAVE_PACKET_EBPF],[1],[Recent ebpf fanout support is available]),
1782 [],
1783 [[#include <linux/if_packet.h>]])
731c2b2e 1784 AC_CHECK_LIB(bpf, bpf_set_link_xdp_fd,have_xdp="yes")
8c880879
EL
1785 if test "$have_xdp" = "yes"; then
1786 AC_DEFINE([HAVE_PACKET_XDP],[1],[XDP support is available])
1787 fi
91e1256b
EL
1788 fi;
1789
89cee0ad 1790 # Check for DAG support.
835630ef 1791 AC_ARG_ENABLE(dag,
6913109b 1792 AS_HELP_STRING([--enable-dag],[Enable DAG capture]),
d01ce2e5 1793 [ enable_dag=$enableval ],
835630ef
JM
1794 [ enable_dag=no])
1795 AC_ARG_WITH(dag_includes,
1796 [ --with-dag-includes=DIR dagapi include directory],
1797 [with_dag_includes="$withval"],[with_dag_includes="no"])
1798 AC_ARG_WITH(dag_libraries,
1799 [ --with-dag-libraries=DIR dagapi library directory],
1800 [with_dag_libraries="$withval"],[with_dag_libraries="no"])
1801
1802 if test "$enable_dag" = "yes"; then
1803
c9cc137d 1804 if test "$with_dag_includes" != "no"; then
835630ef
JM
1805 CPPFLAGS="${CPPFLAGS} -I${with_dag_includes}"
1806 fi
1807
1808 if test "$with_dag_libraries" != "no"; then
573f31b2 1809 LDFLAGS="${LDFLAGS} -L${with_dag_libraries}"
835630ef
JM
1810 fi
1811
1812 AC_CHECK_HEADER(dagapi.h,DAG="yes",DAG="no")
1813 if test "$DAG" != "no"; then
1814 DAG=""
ba81c4d2 1815 AC_CHECK_LIB(dag,dag_open,,DAG="no",)
835630ef
JM
1816 fi
1817
1818 if test "$DAG" = "no"; then
1819 echo
1820 echo " ERROR! libdag library not found"
1821 echo
1822 exit 1
1823 fi
ba81c4d2
VJ
1824
1825 AC_DEFINE([HAVE_DAG],[1],(Endace DAG card support enabled))
835630ef
JM
1826 fi
1827
4ece6ba7 1828# libnspr
8f926fb7 1829 AC_ARG_ENABLE(nspr,
4ece6ba7
VJ
1830 AS_HELP_STRING([--disable-nspr],[Disable libnspr support]),
1831 [enable_nspr=$enableval],[enable_nspr="yes"])
69b3df96
VJ
1832 AC_ARG_WITH(libnspr_includes,
1833 [ --with-libnspr-includes=DIR libnspr include directory],
1834 [with_libnspr_includes="$withval"],[with_libnspr_includes=no])
1835 AC_ARG_WITH(libnspr_libraries,
1836 [ --with-libnspr-libraries=DIR libnspr library directory],
1837 [with_libnspr_libraries="$withval"],[with_libnspr_libraries="no"])
1838
8f926fb7 1839 if test "$enable_nspr" != "no"; then
4ece6ba7
VJ
1840 # Try pkg-config first:
1841 PKG_CHECK_MODULES([libnspr], nspr,, [with_pkgconfig_nspr=no])
1842 if test "$with_pkgconfig_nspr" != "no"; then
1843 CPPFLAGS="${CPPFLAGS} ${libnspr_CFLAGS}"
1844 LIBS="${LIBS} ${libnspr_LIBS}"
1845 fi
1846
1847 if test "$with_libnspr_includes" != "no"; then
1848 CPPFLAGS="${CPPFLAGS} -I${with_libnspr_includes}"
1849 fi
1850
1851 AC_CHECK_HEADER(nspr.h,NSPR="yes",NSPR="no")
1852 if test "$NSPR" = "yes"; then
1853 if test "$with_libnspr_libraries" != "no"; then
1854 LDFLAGS="${LDFLAGS} -L${with_libnspr_libraries}"
1855 fi
1856
1857 AC_CHECK_LIB(nspr4, PR_GetCurrentThread,, NSPR="no")
1858
1859 if test "$NSPR" = "no"; then
1860 echo
1861 echo " ERROR! libnspr library not found, go get it"
1862 echo " from Mozilla or your distribution:"
1863 echo
1864 echo " Ubuntu: apt-get install libnspr4-dev"
1865 echo " Fedora: dnf install nspr-devel"
1866 echo " CentOS/RHEL: yum install nspr-devel"
1867 echo
1868 exit 1
1869 fi
1870 else
1871 enable_nspr="no"
1872 fi
69b3df96 1873 fi
337f7861 1874
89cee0ad 1875 # libnss
8f926fb7 1876 AC_ARG_ENABLE(nss,
4ece6ba7
VJ
1877 AS_HELP_STRING([--disable-nss],[Disable libnss support]),
1878 [enable_nss=$enableval],[enable_nss="yes"])
69b3df96
VJ
1879 AC_ARG_WITH(libnss_includes,
1880 [ --with-libnss-includes=DIR libnss include directory],
4ece6ba7 1881 [with_libnss_includes="$withval"],[with_libnss_includes="no"])
69b3df96
VJ
1882 AC_ARG_WITH(libnss_libraries,
1883 [ --with-libnss-libraries=DIR libnss library directory],
1884 [with_libnss_libraries="$withval"],[with_libnss_libraries="no"])
1885
8f926fb7 1886 if test "$enable_nss" != "no"; then
4ece6ba7
VJ
1887 # Try pkg-config first:
1888 PKG_CHECK_MODULES([libnss], nss,, [with_pkgconfig_nss=no])
1889 if test "$with_pkgconfig_nss" != "no"; then
1890 CPPFLAGS="${CPPFLAGS} ${libnss_CFLAGS}"
1891 LIBS="${LIBS} ${libnss_LIBS}"
1892 fi
1893 if test "$with_libnss_includes" != "no"; then
1894 CPPFLAGS="${CPPFLAGS} -I${with_libnss_includes}"
1895 fi
1896
1897 AC_CHECK_HEADER(sechash.h,NSS="yes",NSS="no")
1898 if test "$NSS" = "yes"; then
1899 if test "$with_libnss_libraries" != "no"; then
1900 LDFLAGS="${LDFLAGS} -L${with_libnss_libraries}"
1901 fi
1902
1903 AC_CHECK_LIB(nss3, HASH_Begin,, NSS="no")
1904 if test "$NSS" = "no"; then
1905 echo
1906 echo " ERROR! libnss library not found, go get it"
1907 echo " from Mozilla or your distribution:"
1908 echo
1909 echo " Ubuntu: apt-get install libnss3-dev"
1910 echo " Fedora: dnf install nss-devel"
1911 echo " CentOS/RHEL: yum install nss-devel"
1912 echo
1913 exit 1
1914 fi
1915
1916 AC_DEFINE([HAVE_NSS],[1],[libnss available for md5/sha1/sha256])
1917 enable_nss="yes"
1918 else
1919 enable_nss="no"
1920 fi
69b3df96
VJ
1921 fi
1922
89cee0ad 1923 # libmagic
810e43f3
VJ
1924 enable_magic="no"
1925 AC_ARG_ENABLE(libmagic,
1926 AS_HELP_STRING([--enable-libmagic], [Enable libmagic support [default=yes]]),
d01ce2e5 1927 [enable_magic=$enableval],[enable_magic=yes])
810e43f3
VJ
1928 if test "$enable_magic" = "yes"; then
1929 AC_ARG_WITH(libmagic_includes,
1930 [ --with-libmagic-includes=DIR libmagic include directory],
1931 [with_libmagic_includes="$withval"],[with_libmagic_includes=no])
1932 AC_ARG_WITH(libmagic_libraries,
1933 [ --with-libmagic-libraries=DIR libmagic library directory],
1934 [with_libmagic_libraries="$withval"],[with_libmagic_libraries="no"])
1935
1936 if test "$with_libmagic_includes" != "no"; then
1937 CPPFLAGS="${CPPFLAGS} -I${with_libmagic_includes}"
1938 fi
f4a6f4b2 1939
810e43f3
VJ
1940 AC_CHECK_HEADER(magic.h,,MAGIC="no")
1941 if test "$MAGIC" != "no"; then
1942 MAGIC=""
1943 AC_CHECK_LIB(magic, magic_open,, MAGIC="no")
1944 fi
f4a6f4b2 1945
810e43f3
VJ
1946 if test "x$MAGIC" != "xno"; then
1947 if test "$with_libmagic_libraries" != "no"; then
1948 LDFLAGS="${LDFLAGS} -L${with_libmagic_libraries}"
1949 fi
1950 AC_DEFINE([HAVE_MAGIC],[1],(Libmagic for file handling))
1951 else
1952 echo
1953 echo " WARNING! magic library not found, go get it"
1954 echo " from http://www.darwinsys.com/file/ or your distribution:"
1955 echo
1956 echo " Ubuntu: apt-get install libmagic-dev"
015cd930 1957 echo " Fedora: dnf install file-devel"
1958 echo " CentOS/RHEL: yum install file-devel"
810e43f3
VJ
1959 echo
1960 enable_magic="no"
1961 fi
f4a6f4b2
VJ
1962 fi
1963
37e3de84
MK
1964 # Napatech - Using the 3GD API
1965 AC_ARG_ENABLE(napatech,
6913109b 1966 AS_HELP_STRING([--enable-napatech],[Enabled Napatech Devices]),
d01ce2e5 1967 [ enable_napatech=$enableval ],
37e3de84
MK
1968 [ enable_napatech=no])
1969 AC_ARG_WITH(napatech_includes,
1970 [ --with-napatech-includes=DIR napatech include directory],
1971 [with_napatech_includes="$withval"],[with_napatech_includes="/opt/napatech3/include"])
1972 AC_ARG_WITH(napatech_libraries,
1973 [ --with-napatech-libraries=DIR napatech library directory],
1974 [with_napatech_libraries="$withval"],[with_napatech_libraries="/opt/napatech3/lib"])
1975
1976 if test "$enable_napatech" = "yes"; then
1977 CPPFLAGS="${CPPFLAGS} -I${with_napatech_includes}"
1978 LDFLAGS="${LDFLAGS} -L${with_napatech_libraries} -lntapi"
1979 AC_CHECK_HEADER(nt.h,NAPATECH="yes",NAPATECH="no")
1980 if test "$NAPATECH" != "no"; then
1981 NAPATECH=""
1982 AC_CHECK_LIB(ntapi, NT_Init,NAPATECH="yes",NAPATECH="no")
844e4dba
MK
1983 fi
1984
37e3de84 1985 if test "$NAPATECH" = "no"; then
844e4dba
MK
1986 echo
1987 echo " ERROR! libntapi library not found"
1988 echo
1989 exit 1
05271bfb
PY
1990 else
1991 AC_CHECK_LIB(numa, numa_available,, LIBNUMA="no")
1992 if test "$LIBNUMA" = "no"; then
1993 echo
1994 echo " WARNING: libnuma is required to use Napatech auto-config"
1995 echo " libnuma is not found. Go get it"
1996 echo " from http://github.com/numactl/numactl or your distribution:"
1997 echo " Ubuntu: apt-get install libnuma-dev"
1998 echo " Fedora: dnf install numactl-devel"
1999 echo " CentOS/RHEL: yum install numactl-devel"
2000 echo
2001 exit 1
2002 fi
844e4dba 2003 fi
ba81c4d2
VJ
2004
2005 AC_DEFINE([HAVE_NAPATECH],[1],(Napatech capture card support))
844e4dba
MK
2006 fi
2007
e366c62c
VJ
2008 # liblua
2009 AC_ARG_ENABLE(lua,
2010 AS_HELP_STRING([--enable-lua],[Enable Lua support]),
d01ce2e5 2011 [ enable_lua="$enableval"],
e366c62c 2012 [ enable_lua="no"])
ba81c4d2
VJ
2013 AC_ARG_ENABLE(luajit,
2014 AS_HELP_STRING([--enable-luajit],[Enable Luajit support]),
d01ce2e5 2015 [ enable_luajit="$enableval"],
ba81c4d2
VJ
2016 [ enable_luajit="no"])
2017 if test "$enable_lua" = "yes"; then
2018 if test "$enable_luajit" = "yes"; then
2019 echo "ERROR: can't enable liblua and luajit at the same time."
2020 echo "For LuaJIT, just use --enable-luajit. For liblua (no jit)"
2021 echo "support, use just --enable-lua."
2022 echo "Both options will enable the Lua scripting capabilities"
2023 echo "in Suricata".
2024 echo
2025 exit 1
2026 fi
2027 fi
2028
e366c62c
VJ
2029 AC_ARG_WITH(liblua_includes,
2030 [ --with-liblua-includes=DIR liblua include directory],
2031 [with_liblua_includes="$withval"],[with_liblua_includes="no"])
2032 AC_ARG_WITH(liblua_libraries,
2033 [ --with-liblua-libraries=DIR liblua library directory],
2034 [with_liblua_libraries="$withval"],[with_liblua_libraries="no"])
2035
2036 if test "$enable_lua" = "yes"; then
2037 if test "$with_liblua_includes" != "no"; then
2038 CPPFLAGS="${CPPFLAGS} -I${with_liblua_includes}"
2039 else
da1fe759
VJ
2040 # lua lua51 lua5.1 lua-5.1
2041 PKG_CHECK_MODULES([LUA], [lua], [LUA="yes"], [
2042 PKG_CHECK_MODULES([LUA], [lua5.1], [LUA="yes"], [
2043 PKG_CHECK_MODULES([LUA], [lua-5.1], [LUA="yes"], [
2044 PKG_CHECK_MODULES([LUA], [lua51], [LUA="yes"], [
2045 LUA="no"
2046 ])
2047 ])
2048 ])
2049 ])
e366c62c
VJ
2050 CPPFLAGS="${CPPFLAGS} ${LUA_CFLAGS}"
2051 fi
2052
2053 AC_CHECK_HEADER(lualib.h,LUA="yes",LUA="no")
2054 if test "$LUA" = "yes"; then
2055 if test "$with_liblua_libraries" != "no"; then
2056 LDFLAGS="${LDFLAGS} -L${with_liblua_libraries}"
da1fe759
VJ
2057 AC_CHECK_LIB(${LUA_LIB_NAME}, luaL_openlibs,, LUA="no")
2058 if test "$LUA" = "no"; then
2059 echo
2060 echo " ERROR! liblua library not found, go get it"
2061 echo " from http://lua.org/index.html or your distribution:"
2062 echo
5db32204 2063 echo " Ubuntu: apt-get install liblua5.1-dev"
015cd930 2064 echo " Fedora: dnf install lua-devel"
2065 echo " CentOS/RHEL: yum install lua-devel"
da1fe759
VJ
2066 echo
2067 echo " If you installed software in a non-standard prefix"
2068 echo " consider adjusting the PKG_CONFIG_PATH environment variable"
2069 echo " or use --with-liblua-libraries configure option."
2070 echo
2071 exit 1
2072 fi
e366c62c 2073 else
da1fe759
VJ
2074 # lua lua51 lua5.1 lua-5.1
2075 PKG_CHECK_MODULES([LUA], [lua], [LUA="yes"], [
2076 PKG_CHECK_MODULES([LUA], [lua5.1], [LUA="yes"], [
2077 PKG_CHECK_MODULES([LUA], [lua-5.1], [LUA="yes"], [
2078 PKG_CHECK_MODULES([LUA], [lua51], [LUA="yes"], [
2079 LUA="no"
2080 ])
2081 ])
2082 ])
2083 ])
e366c62c
VJ
2084 LDFLAGS="${LDFLAGS} ${LUA_LIBS}"
2085 fi
2086
6228f5f6
VJ
2087 if test "$LUA" = "no"; then
2088 AC_CHECK_LIB(lua, luaL_openlibs,, LUA="no")
2089 fi
2090
2091 if test "$LUA" = "yes"; then
2092 AC_DEFINE([HAVE_LUA],[1],[liblua available])
2093 enable_lua="yes"
2094 fi
e366c62c
VJ
2095 else
2096 echo
2097 echo " ERROR! liblua headers not found, go get them"
2098 echo " from http://lua.org/index.html or your distribution:"
2099 echo
5db32204 2100 echo " Ubuntu: apt-get install liblua5.1-dev"
015cd930 2101 echo " Fedora: dnf install lua-devel"
2102 echo " CentOS/RHEL: yum install lua-devel"
e366c62c
VJ
2103 echo
2104 echo " If you installed software in a non-standard prefix"
2105 echo " consider adjusting the PKG_CONFIG_PATH environment variable"
2106 echo " or use --with-liblua-includes and --with-liblua-libraries"
2107 echo " configure option."
2108 echo
2109 exit 1
2110 fi
2111 fi
2112
5b2fbfb1 2113 # libluajit
5b2fbfb1
VJ
2114 AC_ARG_WITH(libluajit_includes,
2115 [ --with-libluajit-includes=DIR libluajit include directory],
c9cc137d 2116 [with_libluajit_includes="$withval"],[with_libluajit_includes="no"])
5b2fbfb1
VJ
2117 AC_ARG_WITH(libluajit_libraries,
2118 [ --with-libluajit-libraries=DIR libluajit library directory],
2119 [with_libluajit_libraries="$withval"],[with_libluajit_libraries="no"])
2120
c9cc137d
VJ
2121 if test "$enable_luajit" = "yes"; then
2122 if test "$with_libluajit_includes" != "no"; then
2123 CPPFLAGS="${CPPFLAGS} -I${with_libluajit_includes}"
819debdc 2124 else
344ea3fa 2125 PKG_CHECK_MODULES([LUAJIT], [luajit], , LUAJIT="no")
819debdc 2126 CPPFLAGS="${CPPFLAGS} ${LUAJIT_CFLAGS}"
5b2fbfb1
VJ
2127 fi
2128
c9cc137d
VJ
2129 AC_CHECK_HEADER(lualib.h,LUAJIT="yes",LUAJIT="no")
2130 if test "$LUAJIT" = "yes"; then
2131 if test "$with_libluajit_libraries" != "no"; then
2132 LDFLAGS="${LDFLAGS} -L${with_libluajit_libraries}"
819debdc
EL
2133 else
2134 PKG_CHECK_MODULES([LUAJIT], [luajit])
2135 LDFLAGS="${LDFLAGS} ${LUAJIT_LIBS}"
c9cc137d 2136 fi
5b2fbfb1 2137
c9cc137d 2138 AC_CHECK_LIB(luajit-5.1, luaL_openlibs,, LUAJIT="no")
5b2fbfb1 2139
c9cc137d
VJ
2140 if test "$LUAJIT" = "no"; then
2141 echo
2142 echo " ERROR! libluajit library not found, go get it"
2143 echo " from http://luajit.org/index.html or your distribution:"
2144 echo
2145 echo " Ubuntu: apt-get install libluajit-5.1-dev"
2146 echo
344ea3fa
EL
2147 echo " If you installed software in a non-standard prefix"
2148 echo " consider adjusting the PKG_CONFIG_PATH environment variable"
2149 echo " or use --with-libluajit-libraries configure option."
2150 echo
c9cc137d
VJ
2151 exit 1
2152 fi
2153
e366c62c 2154 AC_DEFINE([HAVE_LUA],[1],[lua support available])
c9cc137d 2155 AC_DEFINE([HAVE_LUAJIT],[1],[libluajit available])
ba81c4d2 2156 enable_lua="yes, through luajit"
c9cc137d 2157 enable_luajit="yes"
e125869d
EL
2158 else
2159 echo
2160 echo " ERROR! libluajit headers not found, go get them"
2161 echo " from http://luajit.org/index.html or your distribution:"
2162 echo
2163 echo " Ubuntu: apt-get install libluajit-5.1-dev"
2164 echo
344ea3fa
EL
2165 echo " If you installed software in a non-standard prefix"
2166 echo " consider adjusting the PKG_CONFIG_PATH environment variable"
2167 echo " or use --with-libluajit-includes and --with-libluajit-libraries"
2168 echo " configure option."
2169 echo
e125869d 2170 exit 1
c9cc137d 2171 fi
5b2fbfb1
VJ
2172 fi
2173
9d687025
JI
2174 AM_CONDITIONAL([HAVE_LUA], [test "x$enable_lua" != "xno"])
2175
d771e081
IS
2176 # libgeoip
2177 AC_ARG_ENABLE(geoip,
6913109b 2178 AS_HELP_STRING([--enable-geoip],[Enable GeoIP support]),
d01ce2e5 2179 [ enable_geoip="$enableval"],
d771e081
IS
2180 [ enable_geoip="no"])
2181 AC_ARG_WITH(libgeoip_includes,
2182 [ --with-libgeoip-includes=DIR libgeoip include directory],
2183 [with_libgeoip_includes="$withval"],[with_libgeoip_includes="no"])
2184 AC_ARG_WITH(libgeoip_libraries,
2185 [ --with-libgeoip-libraries=DIR libgeoip library directory],
2186 [with_libgeoip_libraries="$withval"],[with_libgeoip_libraries="no"])
2187
2188 if test "$enable_geoip" = "yes"; then
2189 if test "$with_libgeoip_includes" != "no"; then
2190 CPPFLAGS="${CPPFLAGS} -I${with_libgeoip_includes}"
2191 fi
2192
2193 AC_CHECK_HEADER(GeoIP.h,GEOIP="yes",GEOIP="no")
2194 if test "$GEOIP" = "yes"; then
2195 if test "$with_libgeoip_libraries" != "no"; then
ba81c4d2 2196 LDFLAGS="${LDFLAGS} -L${with_libgeoip_libraries}"
d771e081
IS
2197 fi
2198 AC_CHECK_LIB(GeoIP, GeoIP_country_code_by_ipnum,, GEOIP="no")
2199 fi
2200 if test "$GEOIP" = "no"; then
2201 echo
2202 echo " ERROR! libgeoip library not found, go get it"
2203 echo " from http://www.maxmind.com/en/geolite or your distribution:"
2204 echo
2205 echo " Ubuntu: apt-get install libgeoip-dev"
015cd930 2206 echo " Fedora: dnf install GeoIP-devel"
2207 echo " CentOS/RHEL: yum install GeoIP-devel"
d771e081
IS
2208 echo
2209 exit 1
2210 fi
ba81c4d2
VJ
2211
2212 AC_DEFINE([HAVE_GEOIP],[1],[libgeoip available])
2213 enable_geoip="yes"
d771e081
IS
2214 fi
2215
437fe406
AG
2216 # Position Independent Executable
2217 AC_ARG_ENABLE(pie,
2218 AS_HELP_STRING([--enable-pie],[Enable compiling as a position independent executable]),
d01ce2e5 2219 [ enable_pie="$enableval"],
437fe406
AG
2220 [ enable_pie="no"])
2221 if test "$enable_pie" = "yes"; then
2222 CPPFLAGS="${CPPFLAGS} -fPIC"
2223 LDFLAGS="${LDFLAGS} -pie"
2224 fi
2225
a64e5e77 2226#libevent includes and libraries
2227 AC_ARG_WITH(libevent_includes,
2228 [ --with-libevent-includes=DIR libevent include directory],
2229 [with_libevent_includes="$withval"],[with_libevent_includes="no"])
2230 AC_ARG_WITH(libevent_libraries,
2231 [ --with-libevent-libraries=DIR libevent library directory],
2232 [with_libevent_libraries="$withval"],[with_libevent_libraries="no"])
2233
eef5678e
EL
2234# libhiredis
2235 AC_ARG_ENABLE(hiredis,
2236 AS_HELP_STRING([--enable-hiredis],[Enable Redis support]),
d01ce2e5 2237 [ enable_hiredis="$enableval"],
eef5678e
EL
2238 [ enable_hiredis="no"])
2239 AC_ARG_WITH(libhiredis_includes,
2240 [ --with-libhiredis-includes=DIR libhiredis include directory],
2241 [with_libhiredis_includes="$withval"],[with_libhiredis_includes="no"])
2242 AC_ARG_WITH(libhiredis_libraries,
2243 [ --with-libhiredis-libraries=DIR libhiredis library directory],
2244 [with_libhiredis_libraries="$withval"],[with_libhiredis_libraries="no"])
2245
a64e5e77 2246 enable_hiredis_async="no"
eef5678e
EL
2247 if test "$enable_hiredis" = "yes"; then
2248 if test "$with_libhiredis_includes" != "no"; then
2249 CPPFLAGS="${CPPFLAGS} -I${with_libhiredis_includes}"
2250 fi
2251
2252 AC_CHECK_HEADER("hiredis/hiredis.h",HIREDIS="yes",HIREDIS="no")
2253 if test "$HIREDIS" = "yes"; then
2254 if test "$with_libhiredis_libraries" != "no"; then
2255 LDFLAGS="${LDFLAGS} -L${with_libhiredis_libraries}"
2256 fi
2257 AC_CHECK_LIB(hiredis, redisConnect,, HIREDIS="no")
2258 fi
2259 if test "$HIREDIS" = "no"; then
2260 echo
2261 echo " ERROR! libhiredis library not found, go get it"
2262 echo " from https://github.com/redis/hiredis or your distribution:"
2263 echo
2264 echo " Ubuntu: apt-get install libhiredis-dev"
80bd59ae 2265 echo " Fedora: dnf install hiredis-devel"
015cd930 2266 echo " CentOS/RHEL: yum install hiredis-devel"
eef5678e
EL
2267 echo
2268 exit 1
2269 fi
2270 if test "$HIREDIS" = "yes"; then
2271 AC_DEFINE([HAVE_LIBHIREDIS],[1],[libhiredis available])
2272 enable_hiredis="yes"
a64e5e77 2273 #
2274 # Check if async adapters and libevent is installed
2275 #
2276 AC_CHECK_HEADER("hiredis/adapters/libevent.h",HIREDIS_LIBEVENT_ADAPTER="yes",HIREDIS_LIBEVENT_ADAPTER="no")
2277 if test "$HIREDIS_LIBEVENT_ADAPTER" = "yes"; then
2278 #Look for libevent headers
2279 if test "$with_libevent_includes" != "no"; then
2280 CPPFLAGS="${CPPFLAGS} -I${with_libevent_includes}"
2281 fi
2282 AC_CHECK_HEADER("event.h",LIBEVENT="yes",LIBEVENT="no")
2283 if test "$LIBEVENT" = "yes"; then
2284 if test "$with_libevent_libraries" != "no"; then
2285 LDFLAGS="${LDFLAGS} -L${with_libevent_libraries}"
2286 fi
2287 AC_CHECK_LIB(event, event_base_free,, HAVE_LIBEVENT="no")
2288 AC_CHECK_LIB(event_pthreads, evthread_use_pthreads,, HAVE_LIBEVENT_PTHREADS="no")
2289 fi
7ea80b5c 2290 if [ test "$HAVE_LIBEVENT" = "no" ] && [ -o test "$HAVE_LIBEVENT_PTHREADS" = "no"]; then
a64e5e77 2291 if test "$HAVE_LIBEVENT" = "no"; then
2292 echo
2293 echo " Async mode for redis output will not be available."
2294 echo " To enable it install libevent"
2295 echo
2296 echo " Ubuntu: apt-get install libevent-dev"
0f41172c 2297 echo " Fedora: dnf install libevent-devel"
015cd930 2298 echo " CentOS/RHEL: yum install libevent-devel"
a64e5e77 2299 echo
2300 fi
2301 if test "$HAVE_LIBEVENT_PTHREADS" = "no"; then
2302 echo
2303 echo " Async mode for redis output will not be available."
2304 echo " To enable it install libevent with pthreads support"
2305 echo
2306 echo " Ubuntu: apt-get install libevent-pthreads-2.0-5"
2307 echo
2308 fi
2309 else
2310 AC_DEFINE([HAVE_LIBEVENT],[1],[libevent available])
2311 enable_hiredis_async="yes"
2312 fi
2313 fi
eef5678e
EL
2314 fi
2315 fi
2316
b85a0b18 2317# Check for lz4
58e92392
MF
2318enable_liblz4="yes"
2319AC_CHECK_LIB(lz4, LZ4F_createCompressionContext, , enable_liblz4="no")
2320
2321if test "$enable_liblz4" = "no"; then
2322 echo
2323 echo " Compressed pcap logging is not available without liblz4."
2324 echo " If you want to enable compression, you need to install it."
2325 echo
2326 echo " Ubuntu: apt-get install liblz4-dev"
2327 echo " Fedora: dnf install lz4-devel"
015cd930 2328 echo " CentOS/RHEL: yum install epel-release"
58e92392
MF
2329 echo " yum install lz4-devel"
2330 echo
2331fi
b85a0b18 2332
724ad9e8
VJ
2333# get cache line size
2334 AC_PATH_PROG(HAVE_GETCONF_CMD, getconf, "no")
2335 if test "$HAVE_GETCONF_CMD" != "no"; then
2336 CLS=$(getconf LEVEL1_DCACHE_LINESIZE)
fdc3b5ba 2337 if [test "$CLS" != "" && test "$CLS" != "0"]; then
0ddd57cb 2338 AC_DEFINE_UNQUOTED([CLS],[${CLS}],[L1 cache line size])
71c22ddf 2339 else
ba81c4d2 2340 AC_DEFINE([CLS],[64],[L1 cache line size])
0ddd57cb 2341 fi
71c22ddf 2342 else
ba81c4d2 2343 AC_DEFINE([CLS],[64],[L1 cache line size])
724ad9e8 2344 fi
d771e081 2345
6eedd006
JI
2346# sphinx for documentation
2347 AC_PATH_PROG(HAVE_SPHINXBUILD, sphinx-build, "no")
2348 if test "$HAVE_SPHINXBUILD" = "no"; then
2349 enable_sphinxbuild=no
7fa390de
JI
2350 if test -e "$srcdir/doc/userguide/suricata.1"; then
2351 have_suricata_man=yes
2352 fi
6eedd006
JI
2353 fi
2354 AM_CONDITIONAL([HAVE_SPHINXBUILD], [test "x$enable_sphinxbuild" != "xno"])
7fa390de 2355 AM_CONDITIONAL([HAVE_SURICATA_MAN], [test "x$have_suricata_man" = "xyes"])
6eedd006 2356
0792f809
JI
2357# pdflatex for the pdf version of the user manual
2358 AC_PATH_PROG(HAVE_PDFLATEX, pdflatex, "no")
2359 if test "$HAVE_PDFLATEX" = "no"; then
2360 enable_pdflatex=no
2361 fi
2362 AM_CONDITIONAL([HAVE_PDFLATEX], [test "x$enable_pdflatex" != "xno"])
2363
75429bbe
JI
2364# Cargo/Rust
2365 AC_PATH_PROG(RUSTC, rustc, "no")
2366 if test "$RUSTC" = "no"; then
2367 echo ""
2368 echo " ERROR: Suricata now requires Rust to build."
2369 echo ""
2370 echo " Ubuntu/Debian: apt install rustc cargo"
2371 echo " Fedora: dnf install rustc cargo"
2372 echo " CentOS: yum install rustc cargo (requires EPEL)"
2373 echo ""
2374 echo " Rustup works as well: https://rustup.rs/"
2375 echo ""
2376 exit 1
2377 fi
2378
2379 AC_PATH_PROG(CARGO, cargo, "no")
2380 if test "CARGO" = "no"; then
2381 AC_MSG_ERROR([cargo required])
2382 fi
2383
2384 AC_DEFINE([HAVE_RUST],[1],[Enable Rust language])
2385 AM_CONDITIONAL([HAVE_RUST],true)
2386 AC_SUBST([CARGO], [$CARGO])
2387
2388 enable_rust="yes"
2389 rust_compiler_version=$($RUSTC --version)
2390 rust_cargo_version=$($CARGO --version)
4fe9292e 2391
8f81792d
JI
2392 rust_vendor_comment="# "
2393 have_rust_vendor="no"
ed712768
VJ
2394 rust_compiler_version="not set"
2395 rust_cargo_version="not set"
8f81792d 2396
75429bbe
JI
2397 # We may require Python if the Rust header stubs are not already
2398 # generated.
2399 if test "x$enable_python" != "xyes" && test ! -f rust/gen/c-headers/rust-core-gen.h; then
699fd6cb
EL
2400 echo ""
2401 echo " ERROR! Rust support requires Python."
2402 echo
2403 echo " Ubuntu: apt install python"
b98c28a6 2404 echo
699fd6cb 2405 exit 1
75429bbe 2406 fi
9dab3ec7 2407
75429bbe
JI
2408 if test "x$enable_debug" = "xyes"; then
2409 RUST_SURICATA_LIB="../rust/target/debug/${RUST_SURICATA_LIBNAME}"
2410 else
2411 RUST_SURICATA_LIB="../rust/target/release/${RUST_SURICATA_LIBNAME}"
2412 fi
2413 RUST_LDADD="${RUST_SURICATA_LIB} ${RUST_LDADD}"
2414 CFLAGS="${CFLAGS} -I\${srcdir}/../rust/gen/c-headers"
2415 AC_SUBST(RUST_SURICATA_LIB)
2416 AC_SUBST(RUST_LDADD)
2417 if test "x$CARGO_HOME" = "x"; then
2418 AC_SUBST([CARGO_HOME], [~/.cargo])
2419 else
2420 AC_SUBST([CARGO_HOME], [$CARGO_HOME])
8f81792d 2421 fi
75429bbe
JI
2422 AC_CHECK_FILES([$srcdir/rust/vendor], [have_rust_vendor="yes"])
2423 if test "x$have_rust_vendor" = "xyes"; then
2424 rust_vendor_comment=""
2425 fi
2426
2427 rust_compiler_version=$(rustc --version)
2428 rust_cargo_version=$(cargo --version)
8f81792d 2429
8f81792d
JI
2430 AC_SUBST(rust_vendor_comment)
2431 AM_CONDITIONAL([HAVE_RUST_VENDOR], [test "x$have_rust_vendor" = "xyes"])
2432
ed712768 2433 if test "x$enable_rust" = "xyes" || test "x$enable_rust" = "xyes (default)"; then
8f81792d
JI
2434 AC_PATH_PROG(HAVE_CARGO_VENDOR, cargo-vendor, "no")
2435 if test "x$HAVE_CARGO_VENDOR" = "xno"; then
2436 echo " Warning: cargo-vendor not found, but it is only required"
2437 echo " for building the distribution"
2438 echo " To install: cargo install cargo-vendor"
2439 fi
2440 fi
2441 AM_CONDITIONAL([HAVE_CARGO_VENDOR], [test "x$HAVE_CARGO_VENDOR" != "xno"])
2442
6a4cefb7 2443 AC_ARG_ENABLE(rust_strict,
d01ce2e5 2444 AS_HELP_STRING([--enable-rust-strict], [Rust warnings as errors]),[enable_rust_strict=$enableval],[enable_rust_strict=no])
6a4cefb7
JI
2445 AS_IF([test "x$enable_rust_strict" = "xyes"], [
2446 RUST_FEATURES="strict"
2447 ])
2448 AC_SUBST(RUST_FEATURES)
2449
6c251b85 2450 AC_ARG_ENABLE(rust_debug,
d01ce2e5 2451 AS_HELP_STRING([--enable-rust-debug], [Rust not in --release mode]),[enable_rust_debug=$enableval],[enable_rust_debug=no])
6c251b85
VJ
2452 AM_CONDITIONAL([RUST_DEBUG], [test "x$enable_rust_debug" = "xyes"])
2453 AC_SUBST(RUST_DEBUG)
2454
e3bde3e9
VJ
2455# get revision
2456 if test -f ./revision; then
2457 REVISION=`cat ./revision`
ba81c4d2 2458 AC_DEFINE_UNQUOTED([REVISION],[${REVISION}],[Git revision])
e3bde3e9 2459 else
042d0c6e
VJ
2460 AC_PATH_PROG(HAVE_GIT_CMD, git, "no")
2461 if test "$HAVE_GIT_CMD" != "no"; then
5886ef82
VJ
2462 if [ test -d .git ]; then
2463 REVISION=`git rev-parse --short HEAD`
ba81c4d2 2464 AC_DEFINE_UNQUOTED([REVISION],[${REVISION}],[Git revision])
5886ef82 2465 fi
e3bde3e9
VJ
2466 fi
2467 fi
2468
0ffa1c24
WM
2469AC_SUBST(CFLAGS)
2470AC_SUBST(LDFLAGS)
2471AC_SUBST(CPPFLAGS)
2472
25804f5a
EL
2473define([EXPAND_VARIABLE],
2474[$2=[$]$1
2475if test $prefix = 'NONE'; then
2476 prefix="/usr/local"
2477fi
2478while true; do
2479 case "[$]$2" in
2480 *\[$]* ) eval "$2=[$]$2" ;;
2481 *) break ;;
2482 esac
2483done
2484eval "$2=[$]$2$3"
2485])dnl EXPAND_VARIABLE
2486
2487# suricata log dir
2488if test "$WINDOWS_PATH" = "yes"; then
6b751621
VJ
2489 case $host in
2490 x86_64-w64-mingw32)
2491 e_winbase="C:\\\\Program Files\\\\Suricata"
2492 ;;
2493 *)
2494 systemtype="`systeminfo | grep \"based PC\"`"
2495 case "$systemtype" in
2496 *x64*)
2497 e_winbase="C:\\\\Program Files (x86)\\\\Suricata"
2498 ;;
2499 *)
2500 e_winbase="C:\\\\Program Files\\\\Suricata"
2501 ;;
2502 esac
2503 esac
d8356c5e 2504
6b751621
VJ
2505 e_sysconfdir="${e_winbase}\\\\"
2506 e_sysconfrulesdir="$e_winbase\\\\rules\\\\"
e048a74e 2507 e_defaultruledir="$e_winbase\\\\rules\\\\"
6b751621
VJ
2508 e_magic_file="$e_winbase\\\\magic.mgc"
2509 e_logdir="$e_winbase\\\\log"
2510 e_logfilesdir="$e_logdir\\\\files"
2511 e_logcertsdir="$e_logdir\\\\certs"
7bf49006 2512 e_datarulesdir="$e_winbase\\\\rules\\\\"
24d6a164
VJ
2513 if test "$HAVE_CYGPATH" != "no"; then
2514 # turn srcdir into abs path and convert to the
2515 # mixed output (/c/Users/dev into c:/Users/dev)
2516 e_rustdir="$(cygpath -a -t mixed ${srcdir})/rust"
2517 else
2518 e_abs_srcdir=$(cd $srcdir && pwd)
2519 e_rustdir="$e_abs_srcdir/rust"
2520 fi
25804f5a 2521else
6b751621
VJ
2522 EXPAND_VARIABLE(localstatedir, e_logdir, "/log/suricata/")
2523 EXPAND_VARIABLE(localstatedir, e_rundir, "/run/")
2524 EXPAND_VARIABLE(localstatedir, e_logfilesdir, "/log/suricata/files")
2525 EXPAND_VARIABLE(localstatedir, e_logcertsdir, "/log/suricata/certs")
2526 EXPAND_VARIABLE(sysconfdir, e_sysconfdir, "/suricata/")
2527 EXPAND_VARIABLE(sysconfdir, e_sysconfrulesdir, "/suricata/rules")
2528 EXPAND_VARIABLE(localstatedir, e_localstatedir, "/run/suricata")
7bf49006 2529 EXPAND_VARIABLE(datadir, e_datarulesdir, "/suricata/rules")
e048a74e 2530 EXPAND_VARIABLE(ruledirprefix, e_defaultruledir, "/suricata/rules")
24d6a164
VJ
2531
2532 e_abs_srcdir=$(cd $srcdir && pwd)
2533 EXPAND_VARIABLE(e_abs_srcdir, e_rustdir, "/rust")
25804f5a
EL
2534fi
2535AC_SUBST(e_logdir)
1c3546fe 2536AC_SUBST(e_rundir)
d8356c5e 2537AC_SUBST(e_logfilesdir)
55625d73 2538AC_SUBST(e_logcertsdir)
25804f5a 2539AC_SUBST(e_sysconfdir)
d8356c5e 2540AC_SUBST(e_sysconfrulesdir)
20a8b9db 2541AC_SUBST(e_localstatedir)
d8356c5e 2542AC_DEFINE_UNQUOTED([CONFIG_DIR],["$e_sysconfdir"],[Our CONFIG_DIR])
25804f5a 2543AC_SUBST(e_magic_file)
15c98c60 2544AC_SUBST(e_magic_file_comment)
f55dbca5 2545AC_SUBST(e_enable_evelog)
7bf49006 2546AC_SUBST(e_datarulesdir)
e048a74e 2547AC_SUBST(e_defaultruledir)
24d6a164 2548AC_SUBST(e_rustdir)
64b6ff73
JI
2549AC_SUBST(has_suricata_update_comment)
2550AC_SUBST(no_suricata_update_comment)
25804f5a 2551
ba81c4d2
VJ
2552EXPAND_VARIABLE(prefix, CONFIGURE_PREFIX)
2553EXPAND_VARIABLE(sysconfdir, CONFIGURE_SYSCONDIR)
2554EXPAND_VARIABLE(localstatedir, CONFIGURE_LOCALSTATEDIR)
5eb7f0f7 2555EXPAND_VARIABLE(datadir, CONFIGURE_DATAROOTDIR)
ba81c4d2
VJ
2556AC_SUBST(CONFIGURE_PREFIX)
2557AC_SUBST(CONFIGURE_SYSCONDIR)
2558AC_SUBST(CONFIGURE_LOCALSTATEDIR)
5eb7f0f7 2559AC_SUBST(CONFIGURE_DATAROOTDIR)
8f81792d 2560AC_SUBST(PACKAGE_VERSION)
ba81c4d2 2561
6fcd2db0 2562AC_OUTPUT(Makefile src/Makefile rust/Makefile rust/Cargo.toml rust/.cargo/config qa/Makefile qa/coccinelle/Makefile rules/Makefile doc/Makefile doc/userguide/Makefile contrib/Makefile contrib/file_processor/Makefile contrib/file_processor/Action/Makefile contrib/file_processor/Processor/Makefile suricata.yaml etc/Makefile etc/suricata.logrotate etc/suricata.service python/Makefile python/suricata/config/defaults.py ebpf/Makefile)
a098e39b 2563
668113af 2564SURICATA_BUILD_CONF="Suricata Configuration:
73a1b972 2565 AF_PACKET support: ${enable_af_packet}
91e1256b 2566 eBPF support: ${enable_ebpf}
8c880879 2567 XDP support: ${have_xdp}
73a1b972 2568 PF_RING support: ${enable_pfring}
ef463457 2569 NFQueue support: ${enable_nfqueue}
4851568a 2570 NFLOG support: ${enable_nflog}
ef463457 2571 IPFW support: ${enable_ipfw}
517b45ea 2572 Netmap support: ${enable_netmap} ${have_netmap_version}
73a1b972 2573 DAG enabled: ${enable_dag}
37e3de84 2574 Napatech enabled: ${enable_napatech}
ec77632e 2575 WinDivert enabled: ${enable_windivert}
ba81c4d2 2576
20a8b9db 2577 Unix socket enabled: ${enable_unixsocket}
f4872a2f 2578 Detection enabled: ${enable_detection}
73a1b972 2579
810e43f3 2580 Libmagic support: ${enable_magic}
89cee0ad
VJ
2581 libnss support: ${enable_nss}
2582 libnspr support: ${enable_nspr}
20a8b9db 2583 libjansson support: ${enable_jansson}
b60065ca 2584 liblzma support: ${enable_liblzma}
eef5678e 2585 hiredis support: ${enable_hiredis}
a64e5e77 2586 hiredis async with libevent: ${enable_hiredis_async}
ef463457 2587 Prelude support: ${enable_prelude}
73a1b972 2588 PCRE jit: ${pcre_jit_available}
e366c62c 2589 LUA support: ${enable_lua}
5b2fbfb1 2590 libluajit: ${enable_luajit}
d771e081 2591 libgeoip: ${enable_geoip}
73a1b972
VJ
2592 Non-bundled htp: ${enable_non_bundled_htp}
2593 Old barnyard2 support: ${enable_old_barnyard2}
13b87f5a 2594 Hyperscan support: ${enable_hyperscan}
439b62fe 2595 Libnet support: ${enable_libnet}
58e92392 2596 liblz4 support: ${enable_liblz4}
73a1b972 2597
ed712768 2598 Rust support: ${enable_rust}
6a4cefb7 2599 Rust strict mode: ${enable_rust_strict}
6c251b85 2600 Rust debug mode: ${enable_rust_debug}
ed712768
VJ
2601 Rust compiler: ${rust_compiler_version}
2602 Rust cargo: ${rust_cargo_version}
8f81792d 2603
a228986c
JI
2604 Python support: ${enable_python}
2605 Python path: ${python_path}
2606 Python version: ${python_version}
a69afd5c
JI
2607 Python distutils ${have_python_distutils}
2608 Python yaml ${have_python_yaml}
2609 Install suricatactl: ${install_suricatactl}
2610 Install suricatasc: ${install_suricatactl}
345ec58d 2611 Install suricata-update: ${install_suricata_update}
cd305c3a 2612
ef463457 2613 Profiling enabled: ${enable_profiling}
d908e707 2614 Profiling locks enabled: ${enable_profiling_locks}
439b62fe
VJ
2615
2616Development settings:
7fb860ac 2617 Coccinelle / spatch: ${enable_coccinelle}
439b62fe
VJ
2618 Unit tests enabled: ${enable_unittests}
2619 Debug output enabled: ${enable_debug}
2620 Debug validation enabled: ${enable_debug_validation}
ef463457
EL
2621
2622Generic build parameters:
ba81c4d2
VJ
2623 Installation prefix: ${prefix}
2624 Configuration directory: ${e_sysconfdir}
2625 Log directory: ${e_logdir}
2626
2627 --prefix ${CONFIGURE_PREFIX}
2628 --sysconfdir ${CONFIGURE_SYSCONDIR}
2629 --localstatedir ${CONFIGURE_LOCALSTATEDIR}
5eb7f0f7 2630 --datarootdir ${CONFIGURE_DATAROOTDIR}
73a1b972 2631
ef463457 2632 Host: ${host}
ba81c4d2 2633 Compiler: ${CC} (exec name) / ${compiler} (real)
ef463457
EL
2634 GCC Protect enabled: ${enable_gccprotect}
2635 GCC march native enabled: ${enable_gccmarch_native}
ba81c4d2 2636 GCC Profile enabled: ${enable_gccprofile}
437fe406 2637 Position Independent Executable enabled: ${enable_pie}
ba81c4d2
VJ
2638 CFLAGS ${CFLAGS}
2639 PCAP_CFLAGS ${PCAP_CFLAGS}
2640 SECCFLAGS ${SECCFLAGS}"
668113af
EL
2641
2642echo
2643echo "$SURICATA_BUILD_CONF"
4749420f
VJ
2644echo "printf(" >src/build-info.h
2645echo "$SURICATA_BUILD_CONF" | sed -e 's/^/"/' | sed -e 's/$/\\n"/' >>src/build-info.h
2646echo ");" >>src/build-info.h
25804f5a 2647
668113af 2648echo "
25804f5a 2649To build and install run 'make' and 'make install'.
73a1b972 2650
697e9e66
VJ
2651You can run 'make install-conf' if you want to install initial configuration
2652files to ${e_sysconfdir}. Running 'make install-full' will install configuration
2653and rules and provide you a ready-to-run suricata."
73a1b972
VJ
2654echo
2655echo "To install Suricata into /usr/bin/suricata, have the config in
2656/etc/suricata and use /var/log/suricata as log dir, use:
697e9e66
VJ
2657./configure --prefix=/usr/ --sysconfdir=/etc/ --localstatedir=/var/"
2658echo