configure.ac 104 KB

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