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