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