configure.ac 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971
  1. dnl $Id$
  2. AC_PREREQ([2.69])
  3. dnl Set version info here!
  4. AC_INIT([tcpreplay],[4.3.1],
  5. [https://github.com/appneta/tcpreplay/issues],
  6. [tcpreplay],
  7. [http://tcpreplay.sourceforge.net/])
  8. AC_CONFIG_SRCDIR([src/tcpreplay.c])
  9. AM_CONFIG_HEADER([src/config.h])
  10. AC_CONFIG_AUX_DIR(config)
  11. AM_MAINTAINER_MODE([enable])
  12. AM_WITH_DMALLOC
  13. dnl People building from GitHub need the same version of Autogen as I'm using
  14. dnl or specify --disable-local-libopts to force using the locally-installed
  15. dnl copy of libopts rather than the source in the `./liopts/` directory.
  16. MAINTAINER_AUTOGEN_VERSION=5.18.12
  17. AC_CONFIG_MACRO_DIR([m4])
  18. TCPREPLAY_VERSION=$PACKAGE_VERSION
  19. dnl Release is only used for the RPM spec file
  20. TCPREPLAY_RELEASE=1
  21. AC_SUBST(TCPREPLAY_VERSION)
  22. AC_SUBST(TCPREPLAY_RELEASE)
  23. dnl Determine OS
  24. AC_CANONICAL_BUILD
  25. AC_CANONICAL_HOST
  26. AC_CANONICAL_TARGET
  27. AC_SUBST(host)
  28. AC_SUBST(build)
  29. AC_SUBST(target)
  30. CROSS_ARCH=
  31. CROSS_LD=
  32. build_arch=$(echo $MACHTYPE | cut -d'-' -f1)
  33. if test "$cross_compiling" = "yes" ; then
  34. CROSS_ARCH="ARCH=$host_cpu"
  35. CROSS_LD="LD=$LD"
  36. fi
  37. AC_SUBST(CROSS_ARCH)
  38. AC_SUBST(CROSS_LD)
  39. dnl ============================================
  40. dnl Some libraries are in /usr/lib/i386-linux-gnu
  41. dnl but host is i686-linux-gnu
  42. dnl ============================================
  43. MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) 2> /dev/null || ${host_cpu}-${host_os}
  44. dnl ============================================
  45. dnl MacOSX build and runtime environment options
  46. dnl ============================================
  47. AC_ARG_WITH(macosx-sdk,
  48. AS_HELP_STRING([--with-macosx-sdk],
  49. [Use a specific SDK for building.])
  50. [
  51. Usage: --with-macosx-sdk=<version>
  52. e. g.: --with-macosx-sdk=10.8
  53. ],
  54. ,)
  55. dnl ===========================
  56. dnl Check OS X SDK and compiler
  57. dnl ===========================
  58. case "$host_os" in
  59. darwin*) # Mac OS X or iOS
  60. # If no --with-macosx-sdk option is given, look for one
  61. # The intent is that for "most" Mac-based developers, a suitable
  62. # SDK will be found automatically without any configure options.
  63. # For developers with a current Xcode, the lowest-numbered SDK
  64. # higher than or equal to the minimum required should be found.
  65. # To find a list of available version run `xcodebuild -showsdks`
  66. AC_MSG_CHECKING([what macOS compiler to use])
  67. for _macosx_sdk in $with_macosx_sdk 10.8 10.9 10.10 10.11 10.12 10.13 10.14 10.15 10.16.10.17 10.18 10.19 10.20 11.0 11.1 11.2 11.3 11.4 11.5; do
  68. MACOSX_SDK_PATH=$(xcrun --sdk macosx${_macosx_sdk} --show-sdk-path 2> /dev/null)
  69. if test -d "$MACOSX_SDK_PATH"; then
  70. with_macosx_sdk="${_macosx_sdk}"
  71. break
  72. else
  73. MACOSX_SDK_PATH="$(xcode-select -print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${_macosx_sdk}.sdk"
  74. if test -d "$MACOSX_SDK_PATH"; then
  75. with_macosx_sdk="${_macosx_sdk}"
  76. break
  77. fi
  78. fi
  79. done
  80. if test -d "$MACOSX_SDK_PATH"; then
  81. CC="$(xcrun -find clang) -m64 -isysroot $MACOSX_SDK_PATH"
  82. INSTALL_NAME_TOOL=$(xcrun -find install_name_tool)
  83. AR=$(xcrun -find ar)
  84. NM=$(xcrun -find nm)
  85. STRIP=$(xcrun -find strip)
  86. LIBTOOL=$(xcrun -find libtool)
  87. RANLIB=$(xcrun -find ranlib)
  88. AC_MSG_RESULT([$CC])
  89. else
  90. AC_MSG_RESULT([legacy])
  91. fi
  92. ;;
  93. esac
  94. AC_SUBST(MACOSX_SDK_PATH)
  95. AC_SUBST(LIBTOOL) # Note that the OS X libtool command is unrelated to GNU libtool
  96. dnl ============================================
  97. dnl PF_RING library option
  98. dnl ============================================
  99. AC_ARG_WITH(pfring-lib,
  100. AS_HELP_STRING([--with-pfring-lib],
  101. [Use a specific PF_RING static library when using PF_RING libpcap.])
  102. [
  103. Usage: --with-pfring-lib=<library>
  104. e. g.: --with-pfring-lib=/usr/lib/libpfring_zc_x86_64.a
  105. ],
  106. ,)
  107. have_cygwin=no
  108. AC_MSG_CHECKING([for cygwin development environment])
  109. if test $(echo $target | grep -c cygwin) -gt 0 ; then
  110. AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
  111. AC_MSG_RESULT(yes)
  112. have_cygwin=yes
  113. else
  114. AC_MSG_RESULT(no)
  115. fi
  116. AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Wno-override])
  117. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  118. dnl Checks for programs.
  119. AM_PROG_AR
  120. AC_PROG_INSTALL
  121. AC_PROG_LIBTOOL
  122. AC_PROG_CC
  123. AC_PROG_CC_STDC
  124. AC_PROG_CXX
  125. AC_PROG_CPP
  126. AC_PROG_LN_S
  127. LT_INIT
  128. AC_PROG_AWK
  129. AC_PROG_SED
  130. AC_PROG_MAKE_SET
  131. AC_EXEEXT
  132. AC_PATH_PROG(PRINTF, printf)
  133. AC_PATH_PROG(ECHO, echo)
  134. AC_PATH_PROG(CUT, cut)
  135. AC_PATH_PROG(AUTOGEN, autogen)
  136. AC_PATH_PROG(GROFF, groff)
  137. AC_PATH_PROG(depmod, depmod, /sbin/depmod, $PATH:/sbin)
  138. AC_PATH_PROG(insmod, insmod, /sbin/insmod, $PATH:/sbin)
  139. AC_PATH_PROG(rmmod, rmmod, /sbin/rmmod, $PATH:/sbin)
  140. dnl tcpreplay has (so far) been relying on leading-edge autogen.
  141. dnl Therefore, by default:
  142. dnl - use the version we ship with
  143. dnl - do not install it
  144. dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier)
  145. case "${enable_local_libopts+set}" in
  146. set) ;;
  147. *) enable_local_libopts=yes ;;
  148. esac
  149. case "${enable_libopts_install+set}" in
  150. set) ;;
  151. *) enable_libopts_install=no ;;
  152. esac
  153. dnl check autogen version
  154. AUTOGEN_VERSION="unknown - man pages will not be built"
  155. if test -n "${AUTOGEN}" ; then
  156. AC_MSG_CHECKING(for autogen version >= ${MAINTAINER_AUTOGEN_VERSION})
  157. AUTOGEN_VERSION=$(${AUTOGEN} -v | ${CUT} -d' ' -f 4)
  158. AUTOGEN_MAJOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1)
  159. AUTOGEN_MINOR=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2)
  160. AUTOGEN_BUILD=$(echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 3)
  161. if test -z "$AUTOGEN_BUILD"; then
  162. AUTOGEN_BUILD=0
  163. fi
  164. if (test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -eq 18 && test ${AUTOGEN_BUILD} -lt 4) ||
  165. (test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 18) ||
  166. test ${AUTOGEN_MAJOR} -lt 5 ; then
  167. AC_MSG_RESULT(no)
  168. if test "x$enable_local_libopts" == "xno"; then
  169. AC_MSG_ERROR([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from source code. Upgrade to 5.18.4 or higher])
  170. fi
  171. AUTOGEN_VERSION="${AUTOGEN_VERSION} - downlevel"
  172. else
  173. AC_MSG_RESULT(yes)
  174. fi
  175. dnl Compare the installed version with the maintainer version if building from GitHub and not using system libopts
  176. if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then
  177. if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
  178. AC_MSG_ERROR([Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION) Either install the correct version or specify --disable-local-libopts])
  179. fi
  180. fi
  181. else
  182. if test ! -f src/tcpreplay_opts.c ; then
  183. AC_MSG_ERROR([Please install GNU autogen $MAINTAINER_AUTOGEN_VERSION or higher if you are building from GitHub. To avoid this message download source from http://tcpreplay.appneta.com/wiki/installation.html])
  184. fi
  185. fi
  186. AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
  187. if test "x$enable_local_libopts" = "xyes" ; then
  188. AC_MSG_NOTICE([Using included libopts tearoff])
  189. else
  190. AC_MSG_NOTICE([Using system libopts])
  191. fi
  192. AC_HEADER_STDC
  193. AC_HEADER_MAJOR
  194. dnl Checks for typedefs, structures, and compiler characteristics.
  195. AC_CHECK_HEADER_STDBOOL
  196. AC_C_INLINE
  197. AC_TYPE_INT16_T
  198. AC_TYPE_INT32_T
  199. AC_TYPE_INT64_T
  200. AC_TYPE_INT8_T
  201. AC_TYPE_OFF_T
  202. AC_TYPE_PID_T
  203. AC_TYPE_SIZE_T
  204. AC_TYPE_SSIZE_T
  205. AC_TYPE_UINT16_T
  206. AC_TYPE_UINT32_T
  207. AC_TYPE_UINT64_T
  208. AC_TYPE_UINT8_T
  209. AC_HEADER_TIME
  210. AC_C_CONST
  211. AC_C_INLINE
  212. AC_SYS_LARGEFILE
  213. dnl Check for functions
  214. AC_FUNC_FSEEKO
  215. dnl Check for types.
  216. AC_CHECK_TYPE(u_int8_t, uint8_t)
  217. AC_CHECK_TYPE(u_int16_t, uint16_t)
  218. AC_CHECK_TYPE(u_int32_t, uint32_t)
  219. AC_CHECK_TYPE(u_int64_t, uint64_t)
  220. dnl OS X SDK 10.11 throws lots of unnecessary macro warnings
  221. wno_format=""
  222. wno_macro_redefined=""
  223. case $host in
  224. *-apple-darwin*)
  225. AC_MSG_CHECKING(for $CC -Wno-macro-redefined)
  226. OLD_CFLAGS=$CFLAGS
  227. CFLAGS="$CFLAGS -Wno-macro-redefined -Werror"
  228. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  229. int main(int argc, char *argv[]) { return(0); }]])],
  230. [ AC_MSG_RESULT(yes)
  231. wno_macro_redefined="-Wno-macro-redefined" ],
  232. [ AC_MSG_RESULT(no) ])
  233. CFLAGS="$OLD_CFLAGS $wno_macro_redefined"
  234. CFLAGS="$CFLAGS -Wno-format -Werror"
  235. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  236. int main(int argc, char *argv[]) { return(0); }]])],
  237. [ AC_MSG_RESULT(yes)
  238. wno_format="-Wno-format" ],
  239. [ AC_MSG_RESULT(no) ])
  240. CFLAGS="$OLD_CFLAGS $wno_format"
  241. ;;
  242. esac
  243. dnl Older versions of GCC don't support these options
  244. AC_MSG_CHECKING(for $CC -Wextra support)
  245. OLD_CFLAGS=$CFLAGS
  246. CFLAGS="$CFLAGS -Wextra -Werror"
  247. wextra=""
  248. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  249. int main(int argc, char *argv[]) { return(0); }]])],
  250. [ AC_MSG_RESULT(yes)
  251. wextra="-Wextra" ],
  252. [ AC_MSG_RESULT(no) ])
  253. CFLAGS="$OLD_CFLAGS $wextra"
  254. AC_MSG_CHECKING(for $CC -Wno-variadic-macros support)
  255. OLD_CFLAGS=$CFLAGS
  256. CFLAGS="$CFLAGS -Wno-variadic-macros -Werror"
  257. wno_variadic_macros=""
  258. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  259. int main(int argc, char *argv[]) { return(0); }]])],
  260. [ AC_MSG_RESULT(yes)
  261. wno_variadic_macros="-Wno-variadic-macros" ],
  262. [ AC_MSG_RESULT(no) ])
  263. CFLAGS="$OLD_CFLAGS $wno_variadic_macros"
  264. AC_MSG_CHECKING(for $CC -Wfatal-errors support)
  265. OLD_CFLAGS=$CFLAGS
  266. CFLAGS="$CFLAGS -Wfatal-errors -Werror"
  267. wfatal_errors=""
  268. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  269. int main(int argc, char *argv[]) { return(0); }]])],
  270. [ AC_MSG_RESULT(yes)
  271. wfatal_errors="-Wfatal-errors" ],
  272. [ AC_MSG_RESULT(no) ])
  273. CFLAGS="$OLD_CFLAGS $wfatal_errors"
  274. AC_MSG_CHECKING(for $CC -Wno-format-contains-nul support)
  275. OLD_CFLAGS=$CFLAGS
  276. CFLAGS="$CFLAGS -Wno-format-contains-nul -Werror"
  277. wno_format_contains_nul=""
  278. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
  279. int main(int argc, char *argv[]) { return(0); }]])],
  280. [ AC_MSG_RESULT(yes)
  281. wno_format_contains_nul="-Wno-format-contains-nul" ],
  282. [ AC_MSG_RESULT(no) ])
  283. CFLAGS="$OLD_CFLAGS $wno_format_contains_nul"
  284. dnl Check for other header files
  285. AC_CHECK_HEADERS([fcntl.h stddef.h sys/socket.h arpa/inet.h sys/time.h])
  286. AC_CHECK_HEADERS([signal.h string.h strings.h sys/types.h stdint.h sys/select.h])
  287. AC_CHECK_HEADERS([netinet/in.h netinet/in_systm.h poll.h sys/poll.h unistd.h sys/param.h])
  288. AC_CHECK_HEADERS([inttypes.h libintl.h sys/file.h sys/ioctl.h sys/systeminfo.h])
  289. AC_CHECK_HEADERS([sys/io.h architecture/i386/pio.h sched.h])
  290. AC_HEADER_STDBOOL
  291. dnl OpenBSD has special requirements
  292. AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [
  293. [#if HAVE_SYS_PARAM_H
  294. #include <sys/param.h>
  295. #endif
  296. #if HAVE_SYS_TYPES_H
  297. #include <sys/types.h>
  298. #endif
  299. #if HAVE_SYS_SOCKET_H
  300. #include <sys/socket.h>
  301. #endif
  302. ]])
  303. dnl Checks for libraries.
  304. AC_CHECK_LIB(socket, socket)
  305. AC_CHECK_LIB(nsl, gethostbyname)
  306. AC_CHECK_LIB(rt, nanosleep)
  307. AC_CHECK_LIB(resolv, resolv)
  308. dnl Checks for library functions.
  309. AC_FUNC_FORK
  310. AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
  311. AC_FUNC_MALLOC
  312. AC_FUNC_MEMCMP
  313. AC_TYPE_SIGNAL
  314. AC_FUNC_VPRINTF
  315. AC_FUNC_MKTIME
  316. AC_FUNC_MMAP
  317. AC_FUNC_REALLOC
  318. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  319. AC_CHECK_FUNCS([alarm atexit bzero dup2 gethostbyname getpagesize gettimeofday])
  320. AC_CHECK_FUNCS([ctime inet_ntoa memmove memset munmap pow putenv realpath])
  321. AC_CHECK_FUNCS([regcomp strdup select socket strcasecmp strchr strcspn strdup])
  322. AC_CHECK_FUNCS([strerror strtol strncpy strtoull poll ntohll mmap snprintf])
  323. AC_CHECK_FUNCS([vsnprintf strsignal strpbrk strrchr strspn strstr strtoul])
  324. AC_CHECK_FUNCS([ioperm])
  325. dnl Look for strlcpy since some BSD's have it
  326. AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
  327. AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
  328. AC_C_BIGENDIAN
  329. AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
  330. dnl Enable debugging in code/compiler options
  331. debug=no
  332. debug_flag=NDEBUG
  333. debug_run_time_flag=
  334. AC_ARG_ENABLE(debug,
  335. AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
  336. [ if test x$enableval = xyes; then
  337. debug=yes
  338. dnl replace '-0X' and add '-g' flags
  339. changequote({,})
  340. CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
  341. changequote([,])
  342. CFLAGS="${CFLAGS} -g -O0 -Wall $wextra $wfatal_errors $wno_variadic_macros $wno_format_contains_nul $wno_format"
  343. # We may also want to add:
  344. # -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
  345. debug_flag=DEBUG
  346. debug_run_time_flag=--dbug=1
  347. AC_DEFINE([DEBUG], [1], [Enable debugging code and support for the -d option])
  348. fi])
  349. AC_SUBST(debug_flag)
  350. AC_SUBST(debug_run_time_flag)
  351. dnl Enable extra debugging in code/compiler options - may slow down performance
  352. extra_debug=no
  353. extra_debug_flag=NEXTRA_DBUG
  354. AC_ARG_ENABLE(extra-debug,
  355. AC_HELP_STRING([--enable-extra-debug], [Enable additional debugging code (may affect performance)]),
  356. [ if test x$enableval = xyes; then
  357. extra_debug=yes
  358. extra_debug_flag=EXTRA_DEBUG
  359. AC_DEFINE([EXTRA_DEBUG], [1], [Enable additional debugging code (may affect performance)])
  360. fi])
  361. AC_SUBST(extra_debug_flag)
  362. dnl Enable timestamp_trace in code/compiler options
  363. timestamp_trace=no
  364. AC_ARG_ENABLE(timestamp-trace,
  365. AC_HELP_STRING([--timestamp-trace], [Enable dumping of trace timestamps at the end of a test]),
  366. [ if test x$enableval = xyes; then
  367. timestamp_trace=yes
  368. CFLAGS="${CFLAGS} -DTIMESTAMP_TRACE"
  369. AC_DEFINE([TIMESTAMP_TRACE], [1], [Enable dumping of trace timestamps at the end of a test])
  370. fi])
  371. AC_SUBST(timestamp_trace_flag)
  372. AC_ARG_ENABLE(dmalloc,
  373. AC_HELP_STRING([--enable-dmalloc], [Enable linking to dmalloc for better memory debugging]),
  374. [ if test x$enableval = xyes ; then
  375. dmalloc=yes
  376. AC_DEFINE([ENABLE_DMALLOC], [1], [Enable dmalloc])
  377. AC_DEFINE([DMALLOC_FUNC_CHECK], [1], [Enable dmalloc function arg checking])
  378. CFLAGS="${CFLAGS} -I/opt/local/include"
  379. DMALLOC_LIB="/opt/local/lib/libdmalloc.a"
  380. AC_SUBST(DMALLOC_LIB)
  381. fi])
  382. AC_ARG_ENABLE(pedantic,
  383. AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
  384. [ if test x$enableval = xyes; then
  385. CFLAGS="$CFLAGS -pedantic"
  386. fi ])
  387. dnl Enable Efense
  388. AC_ARG_ENABLE(efence,
  389. AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
  390. [ if test x$enableval = xyes; then
  391. CFLAGS="$CFLAGS -lefence"
  392. AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
  393. fi])
  394. dnl Enable Gprof
  395. AC_ARG_ENABLE(gprof,
  396. AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
  397. [ if test x$enableval = xyes; then
  398. if test $debug = yes; then
  399. CFLAGS="$CFLAGS -pg"
  400. else
  401. # GPROF requires gdb
  402. CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
  403. fi
  404. AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
  405. fi])
  406. dnl Enable libpcap auto discovery via pcap-config
  407. enable_pcap_config=no
  408. AC_ARG_ENABLE(pcapconfig,
  409. AC_HELP_STRING([--enable-pcapconfig], [Enable automatic libpcap config, reverting to system scanning]),
  410. [
  411. if test $enableval = yes; then
  412. enable_pcap_config=yes
  413. AC_MSG_NOTICE([Enabling libpcap discovery via pcap_config])
  414. else
  415. enable_pcap_config=no
  416. AC_MSG_NOTICE([Disabling libpcap discovery via pcap_config])
  417. fi
  418. ],
  419. [
  420. AC_MSG_NOTICE([Bypassing libpcap discovery via pcap_config])
  421. ])
  422. dnl Use 64bits for packet counters
  423. use64bit_counters=yes
  424. AC_ARG_ENABLE(64bits,
  425. AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]),
  426. [
  427. AC_MSG_NOTICE([Using u_int32_t for packet counters])
  428. ],
  429. [
  430. AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
  431. AC_MSG_NOTICE([Using u_int64_t for packet counters])
  432. ])
  433. # If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
  434. # so we can use _U_ to flag unused function arguments and not get warnings
  435. # about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
  436. # function argument will compile with non-GCC compilers.
  437. #
  438. if test "x$GCC" = "xyes" ; then
  439. CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
  440. else
  441. CFLAGS="-D_U_=\"\" $CFLAGS"
  442. fi
  443. AC_ARG_ENABLE(force-bpf,
  444. AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
  445. [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
  446. AC_ARG_ENABLE(force-pf,
  447. AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
  448. [ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
  449. AC_ARG_ENABLE(force-libdnet,
  450. AC_HELP_STRING([--enable-force-libdnet], [Force using libdnet for sending packets]),
  451. [ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
  452. AC_ARG_ENABLE(force-inject,
  453. AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
  454. [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
  455. AC_ARG_ENABLE(force-sendpacket,
  456. AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
  457. [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
  458. dnl Static link libraries
  459. static_link=no
  460. dynamic_link=yes
  461. AC_ARG_ENABLE(static-link,
  462. AC_HELP_STRING([--enable-static-link], [Use static libraries ( .a or .A.tbd ) - default no]),
  463. [
  464. if test $enableval = yes; then
  465. static_link=yes
  466. dynamic_link=no
  467. fi
  468. ])
  469. dnl Dynamic link libraries
  470. AC_ARG_ENABLE(dynamic-link,
  471. AC_HELP_STRING([--enable-dynamic-link], [Use shared libraries ( .so .dylib or .tbd ) - default yes]),
  472. [
  473. if test $enableval = no; then
  474. dynamic_link=no
  475. static_link=yes
  476. elif test $static_link = yes; then
  477. AC_MSG_ERROR([Cannot specify both --enable-dynamic-link and --enable-static-link])
  478. fi
  479. ])
  480. if test $static_link = yes; then
  481. AC_DEFINE([ENABLE_STATIC_LINK], [1], [Use static libraries ( .a or .A.tbd )])
  482. else
  483. AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Use shared libraries ( .so .dylib or .tbd )])
  484. fi
  485. dnl Check for inet_aton and inet_pton
  486. AC_CHECK_FUNC(inet_aton,
  487. AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
  488. inet_aton=yes,
  489. inet_aton=no)
  490. AC_CHECK_FUNC(inet_pton,
  491. AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
  492. inet_pton=yes,
  493. inet_pton=no)
  494. AC_CHECK_FUNC(inet_ntop,
  495. AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
  496. inet_ntop=yes,
  497. inet_ntop=no)
  498. if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
  499. AC_MSG_ERROR([We need either inet_ntop or inet_pton])
  500. fi
  501. AC_CHECK_FUNC(inet_addr,
  502. AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
  503. inet_addr=yes,
  504. inet_addr=no)
  505. if test x$inet_addr = no ; then
  506. AC_MSG_ERROR([We need inet_addr. See bug 26])
  507. fi
  508. dnl #####################################################
  509. dnl Checks for tuntap device support
  510. dnl #####################################################
  511. have_tuntap=no
  512. AC_ARG_ENABLE([tuntap],
  513. AS_HELP_STRING([--disable-tuntap], [Disable tuntap support]), [:],
  514. [case "$build_os" in
  515. linux*)
  516. AC_CHECK_HEADER([linux/if_tun.h], [have_tuntap=yes])
  517. ;;
  518. *)
  519. AC_CHECK_HEADER([net/if_tun.h], [have_tuntap=yes])
  520. ;;
  521. esac])
  522. if test $have_tuntap = yes ; then
  523. AC_DEFINE([HAVE_TUNTAP], [1],
  524. [Do we have TUNTAP device support?])
  525. fi
  526. dnl #####################################################
  527. dnl Checks for libpcap
  528. dnl #####################################################
  529. foundpcap=no
  530. pf_ring_found=no
  531. pf_ring_lib=${with_pfring_lib}
  532. using_pcap_config=no
  533. AC_MSG_CHECKING(for libpcap)
  534. AC_ARG_WITH(libpcap,
  535. AC_HELP_STRING([--with-libpcap=DIR],
  536. [Use libpcap in DIR]),
  537. [
  538. testdir=$withval
  539. for incl in ${testdir}/include/pcap.h ${testdir}/pcap.h ${testdir}/pcap/pcap.h; do
  540. if ! test -f "${incl}"; then
  541. continue
  542. fi
  543. LPCAPINC=${incl}
  544. LPCAPINCDIR=${testdir}
  545. if test $dynamic_link = yes; then
  546. for ext in .dylib .so .tbd ; do
  547. for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
  548. sharefile=$(ls ${testdir}/$dir/libpcap${ext}* 2> /dev/null | sort | head -n1)
  549. if test -n "${sharefile}"; then
  550. LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
  551. foundpcap=$testdir
  552. break
  553. fi
  554. done
  555. if ! test $foundpcap = no; then
  556. break
  557. fi
  558. done
  559. else
  560. dnl
  561. dnl If dynamic library not found, try static
  562. dnl
  563. for ext in ${libext} .a .A.tbd ; do
  564. for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
  565. staticfile=$(ls ${testdir}/$dir/libpcap${ext} 2> /dev/null | sort | head -n1)
  566. if test -n "${staticfile}"; then
  567. LPCAPLIB="${staticfile}"
  568. foundpcap=${testdir}
  569. break
  570. fi
  571. done
  572. if ! test $foundpcap = no; then
  573. ## could be PF_RING
  574. #
  575. # library is static and in PF_RING build tree
  576. #
  577. # Need access to libpfring library
  578. # and must find an associated libpfring.a
  579. if test -n "${with_pfring_lib}"; then
  580. if test -f ${with_pfring_lib}; then
  581. pf_ring_lib=${with_pfring_lib}
  582. pf_ring_found=yes
  583. else
  584. AC_MSG_ERROR(["Unable to find PF_RING library ${with_pfring_lib}"])
  585. fi
  586. else
  587. ## search locally for most likely PF_RING library
  588. for lib in ${foundpcap}/../lib/libs/libpfring_zc_${host_cpu}.a \
  589. ${foundpcap}/../lib/libs/libpfring_dna_${host_cpu}.a \
  590. ${foundpcap}/../lib/libs/libpfring_zero_${host_cpu}.a \
  591. ${foundpcap}/../lib/libs/libpfring_nt_${host_cpu}.a \
  592. ${foundpcap}/../lib/libpfring.a; do
  593. if test -f "${lib}"; then
  594. pf_ring_lib=${lib}
  595. pf_ring_found=yes
  596. break
  597. fi
  598. done
  599. fi
  600. break
  601. fi
  602. done
  603. fi
  604. if test $foundpcap = no; then
  605. AC_ERROR(["Unable to find matching library for header file in ${testdir}"])
  606. fi
  607. break
  608. done
  609. ],[
  610. #
  611. # Look for pcap-config.
  612. #
  613. # I wish this option could be the default, but it is only enabled with --enable-pcapconfig
  614. #
  615. # The issue is that libpcap is one of those libraries that is nearly impossible to set up
  616. # properly across all platforms. The 'pcap-config' script is shipped with new versions of libpcap,
  617. # and was created to address portability issues. Unfortunately, the script is not updated properly
  618. # outside of the base distribution. Examples: PF_RING requires 'pthreads', 'numa' and 'rt', but
  619. # this is not reflect that in the script. OS X Xcode 10.11 SDK creates its own very broken
  620. # 'pcap-config' script that only occasionally works for dynamic definitions, and defintely
  621. # does not work for static.
  622. #
  623. # The ability to enable this script exists for corner cases where libpcap distributions starts
  624. # using even more libraries than I am currently not aware of. Originally, you only had to worry
  625. # about 'nl', but now we have to be prepared to add 'nl-3', 'nl-genl-3' and 'dbus-1' to make
  626. # libpcap fucntional. In the future, there may be more.
  627. #
  628. # (sigh)
  629. #
  630. # So, in the future if libpcap changes and stops working, try setting --enable-pcapconfig. It
  631. # it may work for you.
  632. if test $enable_pcap_config = yes; then
  633. AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
  634. if test -n "$PCAP_CONFIG"; then
  635. #
  636. # Found - use it to get the include flags for
  637. # libpcap and the flags to link with libpcap.
  638. #
  639. # Please read section 11.6 "Shell Substitutions"
  640. # in the autoconf manual before doing anything
  641. # to this that involves quoting. Especially note
  642. # the statement "There is just no portable way to use
  643. # double-quoted strings inside double-quoted back-quoted
  644. # expressions (pfew!)."
  645. #
  646. if test $dynamic_link = yes; then
  647. LPCAPLIB=$($PCAP_CONFIG --libs)
  648. else
  649. LPCAPLIB=$($PCAP_CONFIG --libs --static)
  650. fi
  651. CFLAGS="$CFLAGS $($PCAP_CONFIG --cflags)"
  652. if test -n "$LPCAPLIB"; then
  653. foundpcap=yes
  654. using_pcap_config=yes
  655. else
  656. AC_WARN([Unable to find libpcap using pcap-config])
  657. fi
  658. fi
  659. fi
  660. if test ! $foundpcap = yes; then
  661. #
  662. # Not found; look for pcap.
  663. #
  664. for testdir in /usr/local /opt/local /usr /wpdpack $MACOSX_SDK_PATH/usr /usr/local/opt/libpcap ; do
  665. if test -f "${testdir}/include/pcap.h"; then
  666. LPCAPINC="${testdir}/include/pcap.h"
  667. LPCAPINCDIR="${testdir}/include"
  668. if test $dynamic_link = yes; then
  669. for ext in .dylib .so .tbd; do
  670. for dir in . lib lib64 ${host_cpu} lib/${host_cpu} ${host_cpu}-${host_os} lib/${host_cpu}-${host_os} ${MULTIARCH} lib/${MULTIARCH}; do
  671. sharefile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
  672. if test -n "${sharefile}"; then
  673. LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
  674. foundpcap=$testdir
  675. break
  676. fi
  677. done
  678. if ! test $foundpcap = no; then
  679. break
  680. fi
  681. done
  682. fi
  683. if test $foundpcap = no ; then
  684. dnl
  685. dnl If dynamic library not found, try static
  686. dnl
  687. for ext in ${libext} .a .A.tbd ; do
  688. for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
  689. staticfile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
  690. if test -n "${staticfile}"; then
  691. LPCAPLIB="${staticfile}"
  692. foundpcap=$testdir
  693. break
  694. fi
  695. done
  696. if ! test $foundpcap = no; then
  697. break
  698. fi
  699. done
  700. fi
  701. if test $foundpcap = no -a -f "${testdir}/lib/libwpcap.${libext}" ; then
  702. LPCAPLIB="${testdir}/lib/libwpcap.${libext}"
  703. AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
  704. foundpcap=$testdir
  705. fi
  706. fi
  707. if ! test $foundpcap = no; then
  708. break
  709. fi
  710. done
  711. fi
  712. ])
  713. if test $foundpcap = no ; then
  714. AC_MSG_RESULT(no)
  715. AC_ERROR(libpcap not found)
  716. else
  717. AC_MSG_RESULT($foundpcap)
  718. fi
  719. # libpcap can require libnl
  720. AC_SEARCH_LIBS([nl_handle_alloc], [nl],
  721. [AC_MSG_NOTICE([Unable to find nl library - may be needed by libpcap])])
  722. ##
  723. ## If not automatically configured,
  724. ## check for newer and full-featured libpcap's
  725. ##
  726. if ! test $using_pcap_config = yes; then
  727. ## newer libpcap requires dbus and latest nl (e.g. -lnl-genl-3 -lnl-3 -ldbus-1)
  728. AC_CHECK_LIB(nl, nl_cache_alloc, [nl_found=yes])
  729. AC_CHECK_LIB(nl-genl-3, genl_connect, [nl_genl_3_found=yes])
  730. AC_CHECK_LIB(nl-3, nl_cache_alloc, [nl_3_found=yes])
  731. AC_CHECK_LIB(dbus-1, dbus_malloc, [dbus_1_found=yes])
  732. if test "$nl_found" = "yes"; then
  733. LPCAPLIB="$LPCAPLIB -lnl"
  734. fi
  735. if test "$nl_genl_3_found" = "yes"; then
  736. LPCAPLIB="$LPCAPLIB -lnl-genl-3"
  737. fi
  738. if test "$nl_3_found" = "yes"; then
  739. LPCAPLIB="$LPCAPLIB -lnl-3"
  740. fi
  741. if test "$dbus_1_found" = "yes"; then
  742. LPCAPLIB="$LPCAPLIB -ldbus-1"
  743. fi
  744. ## See if prereqs for PF_RING exist
  745. AC_CHECK_LIB(numa, numa_available, [numa_found=yes])
  746. AC_CHECK_LIB(pthread, pthread_create, [pthread_found=yes])
  747. if test $pf_ring_found = yes; then
  748. if ! test "${numa_found}" = "yes"; then
  749. AC_MSG_ERROR([PF_RING requires libnuma and/or libnuma-dev])
  750. fi
  751. if ! test "${pthread_found}" = "yes"; then
  752. AC_MSG_ERROR([PF_RING requires libpthread])
  753. fi
  754. LPCAPLIB="$LPCAPLIB ${pf_ring_lib} -lnuma -lpthread -lrt"
  755. fi
  756. fi
  757. OLDLIBS="$LIBS"
  758. if test -n "$LPCAPINCDIR"; then
  759. OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
  760. CFLAGS="$CFLAGS -I$LPCAPINCDIR"
  761. else
  762. OLDCFLAGS="$CFLAGS"
  763. LPCAPINCDIR=$(echo $CFLAGS | sed -e 's/^\-I//')
  764. LPCAPINC="$LPCAPINCDIR/pcap.h"
  765. fi
  766. LIBS="$LPCAPLIB"
  767. AC_SEARCH_LIBS([pcap_get_pfring_id], [pcap], AC_DEFINE([HAVE_PF_RING_PCAP], [1], [Do we have PF_RING libpcap support?]))
  768. ## Does libpcap work with selected libraries?
  769. AC_SEARCH_LIBS([pcap_close], [pcap],
  770. , AC_ERROR([Unable to link libpcap in ${foundpcap}]),)
  771. AC_SUBST(LPCAPINC)
  772. AC_SUBST(LPCAPLIB)
  773. dnl Check to see what version of libpcap
  774. dnl this code has been reduced a lot, but probably still could be
  775. dnl reduced quite a bit more if we chose too
  776. AC_MSG_CHECKING(for libpcap version)
  777. dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
  778. dnl fix for OSX. See: http://tcpreplay.synfin.net/trac/ticket/167
  779. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  780. #include <string.h>
  781. #include <stdlib.h>
  782. #include <stdio.h>
  783. #include "$LPCAPINC"
  784. #define PCAP_TEST "0.9.6"
  785. ]], [[
  786. /*
  787. * simple proggy to test the version of libpcap
  788. * returns zero if version >= 0.9.6
  789. * or one otherwise
  790. */
  791. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  792. exit(0);
  793. if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0) {
  794. printf("%s ", pcap_lib_version());
  795. exit(0);
  796. }
  797. exit(1);
  798. ]])],
  799. [libpcap_version_096=yes],
  800. [libpcap_version_096=no],
  801. [libpcap_version_096=yes]
  802. )
  803. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  804. #include <string.h>
  805. #include <stdlib.h>
  806. #include <stdio.h>
  807. #include "$LPCAPINC"
  808. #define PCAP_TEST "0.8"
  809. ]], [[
  810. /*
  811. * simple proggy to test the version of libpcap
  812. * returns zero if version >= 0.8.0
  813. * or one otherwise
  814. */
  815. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  816. exit(0);
  817. /* winpcap? */
  818. if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
  819. exit(0);
  820. exit(1);
  821. ]])],
  822. [libpcap_ver8=yes],
  823. [libpcap_ver8=no],
  824. [libpcap_ver8=yes]
  825. )
  826. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  827. #include <string.h>
  828. #include <stdlib.h>
  829. #include <stdio.h>
  830. #include "$LPCAPINC"
  831. #define PCAP_TEST "0.7.2"
  832. extern const char pcap_version[[]]; /* double up since autoconf escapes things */
  833. ]], [[
  834. /*
  835. * simple proggy to test the version of libpcap
  836. * returns zero if version >= 0.7.2
  837. * or one otherwise
  838. */
  839. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  840. exit(0);
  841. if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
  842. exit(0);
  843. exit(1);
  844. ]])],
  845. [libpcap_ver7=yes],
  846. [libpcap_ver7=no],
  847. [libpcap_ver7=yes]
  848. )
  849. if test x$libpcap_ver8 = xyes ; then
  850. AC_MSG_RESULT(>= 0.8.0)
  851. elif test x$libpcap_ver7 = xyes ; then
  852. AC_MSG_RESULT(>= 0.7.2)
  853. else
  854. AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
  855. Please upgrade to version 0.7.2 or better])
  856. fi
  857. libpcap_version=unknown
  858. if test x$libpcap_version_096 = xyes ; then
  859. libpcap_version=">= 0.9.6"
  860. elif test x$libpcap_ver8 = xyes ; then
  861. libpcap_version=">= 0.8.0"
  862. elif test x$libcap_ver7 = xyes ; then
  863. libpcap_version=">= 0.7.0"
  864. fi
  865. dnl Check for pcap_setnonblock()
  866. AC_MSG_CHECKING(for pcap_setnonblock)
  867. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  868. #include <stdio.h>
  869. #include <stdlib.h>
  870. #include <string.h>
  871. #include "$LPCAPINC"
  872. ]],[[
  873. pcap_t *p;
  874. char *errbuf;
  875. pcap_setnonblock(p, 1, errbuf);
  876. exit(0);
  877. ]])], [
  878. have_pcap_setnonblock=yes
  879. AC_MSG_RESULT(yes)
  880. ], [
  881. have_pcap_setnonblock=no
  882. AC_MSG_RESULT(no)
  883. ])
  884. if test $have_pcap_setnonblock = yes ; then
  885. AC_DEFINE([HAVE_PCAP_SETNONBLOCK], [1],
  886. [Does libpcap have pcap_setnonblock?])
  887. fi
  888. dnl Check to see if we've got pcap_datalink_val_to_name()
  889. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  890. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  891. #include <stdio.h>
  892. #include <stdlib.h>
  893. #include <string.h>
  894. #include "$LPCAPINC"
  895. ]],[[
  896. if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0)
  897. exit(0);
  898. exit(1);
  899. ]])],[
  900. have_dlt_to_desc=yes
  901. AC_MSG_RESULT(yes)
  902. ], [
  903. have_dlt_to_desc=no
  904. AC_MSG_RESULT(no)
  905. ])
  906. if test $have_dlt_to_desc = yes ; then
  907. AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1],
  908. [Does libpcap have pcap_datalink_val_to_description?])
  909. fi
  910. dnl Check for pcap_get_selectable_fd()
  911. AC_MSG_CHECKING(for pcap_get_selectable_fd)
  912. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  913. #include <stdio.h>
  914. #include <stdlib.h>
  915. #include <string.h>
  916. #include "$LPCAPINC"
  917. ]], [[
  918. int f;
  919. pcap_t *p;
  920. f = pcap_get_selectable_fd(p);
  921. exit(0);
  922. ]])], [
  923. have_pcap_get_selectable_fd=yes
  924. AC_MSG_RESULT(yes)
  925. ], [
  926. have_pcap_get_selectable_fd=no
  927. AC_MSG_RESULT(no)
  928. ])
  929. if test x$have_pcap_get_selectable_fd = xyes ; then
  930. AC_DEFINE([HAVE_PCAP_GET_SELECTABLE_FD], [1],
  931. [Does libpcap have pcap_get_selectable_fd?])
  932. fi
  933. dnl Important: winpcap apparently defines functions in it's header files
  934. dnl which aren't actually in the library. Totally fucked up. Hence, we
  935. dnl must actually LINK the code, not just compile it.
  936. dnl Check to see if we've got pcap_dump_fopen()
  937. AC_MSG_CHECKING(for pcap_dump_fopen)
  938. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  939. #include <stdio.h>
  940. #include <stdlib.h>
  941. #include <string.h>
  942. #include "$LPCAPINC"
  943. ]],[[
  944. pcap_dumper_t *dump;
  945. pcap_t *pcap;
  946. FILE *foo;
  947. dump = pcap_dump_fopen(pcap, foo);
  948. ]])],[
  949. have_pcap_dump_fopen=yes
  950. AC_MSG_RESULT(yes)
  951. ], [
  952. have_pcap_dump_fopen=no
  953. AC_MSG_RESULT(no)
  954. ])
  955. if test $have_pcap_dump_fopen = yes ; then
  956. AC_DEFINE([HAVE_PCAP_DUMP_FOPEN], [1],
  957. [Does libpcap have pcap_dump_fopen?])
  958. else
  959. AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
  960. fi
  961. have_pcap_inject=no
  962. dnl Check to see if we've got pcap_inject()
  963. AC_MSG_CHECKING(for pcap_inject sending support)
  964. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  965. #include <stdio.h>
  966. #include <stdlib.h>
  967. #include <string.h>
  968. #include "$LPCAPINC"
  969. ]],[[
  970. pcap_t *pcap;
  971. char *buf;
  972. pcap_inject(pcap, (void *)buf, 0);
  973. ]])],[
  974. have_pcap_inject=yes
  975. AC_MSG_RESULT(yes)
  976. ], [
  977. have_pcap_inject=no
  978. AC_MSG_RESULT(no)
  979. ])
  980. if test $have_pcap_inject = yes ; then
  981. AC_DEFINE([HAVE_PCAP_INJECT], [1], [Does libpcap have pcap_inject?])
  982. fi
  983. have_pcap_sendpacket=no
  984. dnl Check to see if we've got pcap_sendpacket()
  985. AC_MSG_CHECKING(for pcap_sendpacket sending support)
  986. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  987. #include <stdio.h>
  988. #include <stdlib.h>
  989. #include <string.h>
  990. #include "$LPCAPINC"
  991. ]],[[
  992. pcap_t *pcap;
  993. u_char *buf;
  994. pcap_sendpacket(pcap, buf, 0);
  995. ]])],[
  996. have_pcap_sendpacket=yes
  997. AC_MSG_RESULT(yes)
  998. ], [
  999. have_pcap_sendpacket=no
  1000. AC_MSG_RESULT(no)
  1001. ])
  1002. if test $have_pcap_sendpacket = yes ; then
  1003. AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], [Does libpcap have pcap_sendpacket?])
  1004. fi
  1005. have_pcap_breakloop=no
  1006. AC_MSG_CHECKING(for pcap_breakloop)
  1007. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1008. #include <stdio.h>
  1009. #include <stdlib.h>
  1010. #include <string.h>
  1011. #include "$LPCAPINC"
  1012. ]],[[
  1013. pcap_t *pcap;
  1014. pcap_sendpacket(pcap);
  1015. ]])],[
  1016. have_pcap_breakloop=yes
  1017. AC_MSG_RESULT(yes)
  1018. ], [
  1019. have_pcap_breakloop=no
  1020. AC_MSG_RESULT(no)
  1021. ])
  1022. if test $have_pcap_breakloop = yes ; then
  1023. AC_DEFINE([HAVE_PCAP_BREAKLOOP], [1], [Does libpcap have pcap_breakloop?])
  1024. fi
  1025. have_pcap_version=no
  1026. dnl Check to see if we have pcap_version[]
  1027. AC_MSG_CHECKING(for pcap_version[])
  1028. AC_TRY_LINK([
  1029. #include <stdio.h>
  1030. #include <stdlib.h>
  1031. #include <string.h>
  1032. #include "$LPCAPINC"
  1033. extern char pcap_version[];
  1034. ],[
  1035. printf("%s", pcap_version);
  1036. ],[
  1037. AC_DEFINE([HAVE_PCAP_VERSION],[1], [Does libpcap have pcap_version[]])
  1038. AC_MSG_RESULT(yes)
  1039. ],[
  1040. AC_MSG_RESULT(no)
  1041. ])
  1042. have_pcap_snapshot=no
  1043. dnl Check for pcap_snapshot()
  1044. AC_MSG_CHECKING(for pcap_snapshot)
  1045. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1046. #include <stdio.h>
  1047. #include <stdlib.h>
  1048. #include <string.h>
  1049. #include "$LPCAPINC"
  1050. ]],[[
  1051. pcap_t *p;
  1052. int len;
  1053. len = pcap_snapshot(p);
  1054. exit(0);
  1055. ]])], [
  1056. have_pcap_snapshot=yes
  1057. AC_MSG_RESULT(yes)
  1058. ], [
  1059. have_pcap_snapshot=no
  1060. AC_MSG_RESULT(no)
  1061. ])
  1062. if test $have_pcap_snapshot = yes ; then
  1063. AC_DEFINE([HAVE_PCAP_SNAPSHOT], [1],
  1064. [Does libpcap have pcap_snapshot?])
  1065. fi
  1066. # Tcpbridge requires libpcap and pcap_sendpacket()
  1067. enable_tcpbridge=no
  1068. if test x$foundpcap != xno -a x$have_pcap_sendpacket = xyes ; then
  1069. # if we have pcap_sendpacket() then we can build tcpbridge on non-BPF systems
  1070. if test x$have_bpf = xno; then
  1071. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  1072. enable_tcpbridge=yes
  1073. AC_MSG_NOTICE([Building tcpbridge])
  1074. # BPF systems need to also have pcap_setnonblock()
  1075. elif test x$have_pcap_setnonblock = xyes ; then
  1076. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  1077. enable_tcpbridge=yes
  1078. AC_MSG_NOTICE([Building tcpbridge])
  1079. else
  1080. AC_MSG_WARN([Unable to build tcpbridge. Try installing latest libpcap!])
  1081. fi
  1082. fi
  1083. AM_CONDITIONAL(COMPILE_TCPBRIDGE, [test x$enable_tcpbridge = xyes ])
  1084. # tcpliveplay requires linux OS to function properly
  1085. enable_tcpliveplay=no
  1086. case $host in
  1087. *-*-linux*)
  1088. AC_DEFINE(ENABLE_TCPLIVEPLAY, [1], [Compile tcpliveplay])
  1089. enable_tcpliveplay=yes
  1090. AC_MSG_NOTICE([Building tcpliveplay])
  1091. ;;
  1092. *)
  1093. AC_MSG_WARN([Unable to build tcpliveplay. This tool is only enabled on linux environments.])
  1094. ;;
  1095. esac
  1096. AM_CONDITIONAL(COMPILE_TCPLIVEPLAY, [test x$enable_tcpliveplay = xyes ])
  1097. dnl #####################################################
  1098. dnl Check for netmap support
  1099. dnl #####################################################
  1100. have_netmap=no
  1101. enable_netmap=no
  1102. trynetmapdir=
  1103. AC_MSG_CHECKING(for netmap socket sending support)
  1104. AC_ARG_WITH(netmap,
  1105. AC_HELP_STRING([--with-netmap=DIR], [Use netmap in DIR]),
  1106. [trynetmapdir=$withval])
  1107. NETMAP_SEARCH_DIRS=
  1108. if test "$cross_compiling" = yes; then
  1109. if test "x$trynetmapdir" != "x"; then
  1110. NETMAP_SEARCH_DIRS=$trynetmapdir
  1111. fi
  1112. else
  1113. NETMAP_SEARCH_DIRS="$trynetmapdir /opt/netmap /usr/src/netmap-release /usr/src/netmap /usr/local/src/netmap-release /usr/local/src/netmap /usr/include"
  1114. fi
  1115. for testdir in $NETMAP_SEARCH_DIRS; do
  1116. if test -f "${testdir}/sys/net/netmap.h" ; then
  1117. NETMAPINC="${testdir}/sys/net/netmap.h"
  1118. NETMAPUSERINC="${testdir}/sys/net/netmap_user.h"
  1119. NETMAPINCDIR="${testdir}/sys"
  1120. have_netmap="yes $testdir"
  1121. enable_netmap=yes
  1122. else
  1123. if test -f "${testdir}/net/netmap.h" ; then
  1124. NETMAPINC="${testdir}/net/netmap.h"
  1125. NETMAPUSERINC="${testdir}/net/netmap_user.h"
  1126. NETMAPINCDIR="${testdir}"
  1127. have_netmap="yes $testdir"
  1128. enable_netmap=yes
  1129. fi
  1130. fi
  1131. if test "$have_netmap" != no ; then
  1132. NETMAPFLAGS="-DHAVE_NETMAP"
  1133. OLDCFLAGS="$CFLAGS -I$NETMAPINCDIR"
  1134. CFLAGS="$CFLAGS -DNETMAP_WITH_LIBS -DND -I$NETMAPINCDIR"
  1135. AC_SUBST(NETMAPINC)
  1136. AC_SUBST(NETMAPUSERINC)
  1137. AC_SUBST(NETMAPINCDIR)
  1138. AC_SUBST(NETMAPFLAGS)
  1139. AC_DEFINE([HAVE_NETMAP], [1],
  1140. [Do we have netmap support?])
  1141. have_netmap="yes $testdir"
  1142. enable_netmap=yes
  1143. break;
  1144. fi
  1145. done
  1146. AC_MSG_RESULT($have_netmap)
  1147. AM_CONDITIONAL(COMPILE_NETMAP, [test x$enable_netmap = xyes ])
  1148. dnl ###########################################################
  1149. dnl Check for nm_open() function available in netmap version 5
  1150. dnl Also check for other version-specific netmap definitions and structures
  1151. dnl ###########################################################
  1152. if test "x$NETMAPINCDIR" != "x"; then
  1153. OLDCPPFLAGS="$CPPFLAGS"
  1154. CPPFLAGS="$CPPFLAGS -DNETMAP_WITH_LIBS -DND -I$NETMAPINCDIR"
  1155. have_nm_open=no
  1156. have_nm_nr_reg_mask=no
  1157. have_nm_nr_flags=no
  1158. have_nmring_head_tail=no
  1159. if test "$have_netmap" != no ; then
  1160. dnl check for nm_open()
  1161. AC_CHECK_DECL([nm_open],[have_nm_open=yes], , [[
  1162. #include <stdio.h>
  1163. #include "${NETMAPUSERINC}"
  1164. ]])
  1165. dnl check for #define NR_REG_MASK
  1166. AC_MSG_CHECKING(for netmap NR_REG_MASK definition)
  1167. AC_COMPILE_IFELSE(
  1168. [AC_LANG_PROGRAM([[
  1169. #include <stdint.h>
  1170. #include <sys/socket.h>
  1171. #include <net/if.h>
  1172. #include <net/netmap.h>
  1173. ]],
  1174. [[
  1175. #ifdef NR_REG_MASK
  1176. /* OK */
  1177. #else
  1178. # error NR_REG_MASK not found
  1179. #endif
  1180. ]])
  1181. ],
  1182. [have_nm_nr_reg_mask=yes],
  1183. [])
  1184. AC_MSG_RESULT($have_nm_nr_reg_mask)
  1185. dnl check for nr_flags in struct nmreq
  1186. AC_MSG_CHECKING(for netmap nr_flags definition)
  1187. AC_COMPILE_IFELSE(
  1188. [AC_LANG_PROGRAM([[
  1189. #include <stdint.h>
  1190. #include <sys/socket.h>
  1191. #include <net/if.h>
  1192. #include <net/netmap.h>
  1193. ]],
  1194. [[
  1195. struct nmreq nmr;
  1196. nmr.nr_flags = 0;
  1197. ]])
  1198. ],
  1199. [have_nm_nr_flags=yes],
  1200. [])
  1201. AC_MSG_RESULT($have_nm_nr_flags)
  1202. dnl check for head/tail in struct netmap_ring
  1203. AC_MSG_CHECKING(for netmap ring head/tail definitions)
  1204. AC_COMPILE_IFELSE(
  1205. [AC_LANG_PROGRAM([[
  1206. #include <stdint.h>
  1207. #include <sys/socket.h>
  1208. #include <net/if.h>
  1209. #include <net/netmap.h>
  1210. ]],
  1211. [[
  1212. struct netmap_ring r;
  1213. r.head = r.tail = 0;
  1214. ]])
  1215. ],
  1216. [have_nmring_head_tail=yes],
  1217. [])
  1218. AC_MSG_RESULT($have_nmring_head_tail)
  1219. fi
  1220. if test "$have_nm_open" = yes ; then
  1221. AC_DEFINE([HAVE_NETMAP_NM_OPEN], [1], [Does netmap have nm_open function?])
  1222. fi
  1223. if test "$have_nm_nr_reg_mask" = yes ; then
  1224. AC_DEFINE([HAVE_NETMAP_NR_REG], [1], [Does netmap have NR_REG_MASK defined?])
  1225. fi
  1226. if test "$have_nm_nr_flags" = yes ; then
  1227. AC_DEFINE([HAVE_NETMAP_NR_FLAGS], [1], [Does netmap struct nmreq have nr_flags defined?])
  1228. fi
  1229. if test "$have_nmring_head_tail" = yes ; then
  1230. AC_DEFINE([HAVE_NETMAP_RING_HEAD_TAIL], [1], [Does structure netmap_ring have head/tail defined?])
  1231. fi
  1232. CPPFLAGS="$OLDCPPFLAGS"
  1233. fi
  1234. have_pf=no
  1235. dnl Check for linux PF_PACKET support
  1236. AC_MSG_CHECKING(for PF_PACKET socket sending support)
  1237. AC_TRY_COMPILE([
  1238. #include <sys/socket.h>
  1239. #include <netpacket/packet.h>
  1240. #include <net/ethernet.h> /* the L2 protocols */
  1241. #include <netinet/in.h> /* htons */
  1242. ],[
  1243. int pf_socket;
  1244. pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  1245. ],[
  1246. AC_DEFINE([HAVE_PF_PACKET], [1],
  1247. [Do we have Linux PF_PACKET socket support?])
  1248. AC_MSG_RESULT(yes)
  1249. have_pf=yes
  1250. ],[
  1251. AC_MSG_RESULT(no)
  1252. ])
  1253. have_tx_ring=no
  1254. dnl Check for older Linux TX_RING support
  1255. AC_MSG_CHECKING(for TX_RING socket sending support)
  1256. AC_TRY_COMPILE([
  1257. #include <sys/socket.h>
  1258. #include <netpacket/packet.h>
  1259. #include <net/ethernet.h> /* the L2 protocols */
  1260. #include <netinet/in.h> /* htons */
  1261. #include <linux/if_packet.h>
  1262. ],[
  1263. int test;
  1264. test = TP_STATUS_WRONG_FORMAT
  1265. ],[
  1266. AC_DEFINE([HAVE_TX_RING], [1],
  1267. [Do we have Linux TX_RING socket support?])
  1268. AC_MSG_RESULT(yes)
  1269. have_tx_ring=yes
  1270. ],[
  1271. AC_MSG_RESULT(no)
  1272. ])
  1273. AC_CHECK_HEADERS([net/bpf.h], [have_bpf=yes], [have_bpf=no])
  1274. if test $have_bpf = yes ; then
  1275. AC_DEFINE([HAVE_BPF], [1],
  1276. [Do we have BPF device support?])
  1277. fi
  1278. dnl ##################################################
  1279. dnl # Check for libdnet, but only if not Cygwin!
  1280. dnl #
  1281. dnl # if your version of libdnet doesn't compile, try
  1282. dnl # getting it from ...
  1283. dnl # http://libdnet.sourceforge.net/
  1284. dnl # ... or ...
  1285. dnl # https://github.com/jncornett/libdnet
  1286. dnl # ... or ...
  1287. dnl # on Linux try 'apt-get install libdumbnet-dev'
  1288. dnl ##################################################
  1289. founddnet=no
  1290. have_libdnet=no
  1291. libdnet_version=
  1292. enable_fragroute=no
  1293. trydnetdir=/usr/local
  1294. if test $have_cygwin = no ; then
  1295. AC_MSG_CHECKING(for libdnet)
  1296. AC_ARG_WITH(libdnet,
  1297. AC_HELP_STRING([--with-libdnet=DIR], [Use libdnet in DIR]),
  1298. [trydnetdir=$withval])
  1299. case "$build_os" in
  1300. linux*)
  1301. dnl # Debian/Ubuntu already have a package called libdnet
  1302. dnl # so you the package you want to install libdumbnet-dev
  1303. for testdir in $trydnetdir /usr/local /opt/local /usr ; do
  1304. if test -x ${testdir}/bin/dumbnet-config -a $founddnet = no ; then
  1305. LDNETINC="$($testdir/bin/dumbnet-config --cflags)"
  1306. LDNETLIB="$($testdir/bin/dumbnet-config --libs)"
  1307. libdnet_version="$($testdir/bin/dumbnet-config --version) (libdumbnet)"
  1308. founddnet=$testdir
  1309. fi
  1310. done
  1311. ;;
  1312. esac
  1313. if test $founddnet = no ; then
  1314. for testdir in $trydnetdir /usr/local /opt/local $MACOSX_SDK_PATH/usr /usr ; do
  1315. if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
  1316. LDNETINC="$($testdir/bin/dnet-config --cflags)"
  1317. LDNETLIB="$($testdir/bin/dnet-config --libs)"
  1318. libdnet_version="$($testdir/bin/dnet-config --version)"
  1319. founddnet=$testdir
  1320. fi
  1321. done
  1322. fi
  1323. if test $founddnet = no ; then
  1324. AC_MSG_RESULT(no)
  1325. AC_MSG_WARN([libdnet not found, disabling fragroute feature])
  1326. else
  1327. AC_MSG_RESULT($founddnet)
  1328. enable_fragroute=yes
  1329. have_libdnet=yes
  1330. AC_DEFINE([HAVE_LIBDNET], [1], [Do we have libdnet?])
  1331. dnl Debian uses dumbnet.h instead of dnet.h due to naming conflict
  1332. old_cflags=$CFLAGS
  1333. CFLAGS=$LDNETINC
  1334. AC_CHECK_HEADERS([dumbnet.h dnet.h])
  1335. CFLAGS=$old_cflags
  1336. fi
  1337. else
  1338. AC_MSG_NOTICE([Skipping libdnet check under Cygwin for compatibility reasons])
  1339. fi
  1340. AC_SUBST(LDNETINC)
  1341. AC_SUBST(LDNETLIB)
  1342. AC_DEFINE_UNQUOTED([LIBDNET_VERSION], "$libdnet_version", [Version of libdnet])
  1343. AM_CONDITIONAL(COMPILE_FRAGROUTE, [test x$founddnet != xno])
  1344. if test x$founddnet != xno ; then
  1345. AC_DEFINE(ENABLE_FRAGROUTE, [1], [Enable fragroute module])
  1346. fi
  1347. dnl Make sure we have a valid packet injection mechanisim
  1348. if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
  1349. -a $have_libdnet = no -a $have_pf = no ; then
  1350. AC_MSG_ERROR([Unable to find a supported method to send packets. Please upgrade your libpcap or enable libdnet])
  1351. fi
  1352. dnl Older versions of libpcap are missing some DLT types
  1353. dnl If doesn't exist, we'll define them in src/common/fakepcap.h
  1354. AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
  1355. AC_TRY_COMPILE([#include "$LPCAPINC"],
  1356. [ int foo;
  1357. foo = DLT_LINUX_SLL
  1358. ],
  1359. [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
  1360. [Does pcap.h include a header with DLT_LINUX_SLL?])
  1361. AC_MSG_RESULT(yes)
  1362. ],
  1363. [AC_MSG_RESULT(no)]
  1364. )
  1365. AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
  1366. AC_TRY_COMPILE([#include "$LPCAPINC"],
  1367. [ int foo;
  1368. foo = DLT_C_HDLC ],
  1369. [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
  1370. [Does pcap.h include a header with DLT_C_HDLC?])
  1371. AC_MSG_RESULT(yes)
  1372. ],
  1373. AC_MSG_RESULT(no)
  1374. )
  1375. PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
  1376. AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
  1377. AC_TRY_COMPILE([#include <sys/types.h>
  1378. #include <sys/time.h>
  1379. #include <stdint.h>
  1380. #include "$PCAP_BPF_H_FILE"],
  1381. [ int foo;
  1382. foo = BPF_MAJOR_VERSION; ],
  1383. [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  1384. [What is the path (if any) to the pcap-bpf.h
  1385. header?])
  1386. AC_MSG_RESULT(yes)
  1387. AC_SUBST(PCAP_BPF_H_FILE)
  1388. ],
  1389. AC_MSG_RESULT(no)
  1390. )
  1391. foundbpfheader=no
  1392. AC_MSG_CHECKING(for libpcap bpf header)
  1393. for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do
  1394. if test -f "${testfile}" -a $foundbpfheader = no ; then
  1395. AC_TRY_COMPILE([
  1396. #include <sys/types.h>
  1397. #include <sys/time.h>
  1398. #include <stdint.h>
  1399. #include "$testfile"],
  1400. [
  1401. int foo;
  1402. foo = BPF_MAJOR_VERSION;
  1403. ],
  1404. [
  1405. foundbpfheader=yes
  1406. PCAP_BPF_H_FILE=$testfile
  1407. AC_SUBST(PCAP_BPF_H_FILE)
  1408. AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  1409. [What is the path (if any) to the libpcap bpf header file?])
  1410. ]
  1411. )
  1412. fi
  1413. done
  1414. if test $foundbpfheader != no; then
  1415. AC_MSG_RESULT($testfile)
  1416. else
  1417. AC_MSG_RESULT(no)
  1418. fi
  1419. dnl ## Test for netmap-libpcap
  1420. have_pcap_netmap=no
  1421. if test $foundpcap != no ; then
  1422. AC_MSG_CHECKING(for netmap libpcap)
  1423. PCAP_NETMAP_C_FILE="$LPCAPINCDIR/pcap-netmap.c"
  1424. if test -f "${PCAP_NETMAP_C_FILE}" ; then
  1425. AC_DEFINE([HAVE_LIBPCAP_NETMAP], [1],
  1426. [Does this version of libpcap support netmap?])
  1427. have_pcap_netmap=yes
  1428. AC_MSG_RESULT(yes)
  1429. else
  1430. AC_MSG_RESULT(no)
  1431. fi
  1432. fi
  1433. dnl restore LIBS & CFLAGS
  1434. LIBS="$OLDLIBS"
  1435. CFLAGS="$OLDCFLAGS"
  1436. dnl ##################################################
  1437. dnl # Check for pcapnav
  1438. dnl ##################################################
  1439. pcapnav_ver=no
  1440. pcncfg=no
  1441. AC_ARG_WITH(pcapnav-config,
  1442. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  1443. [ AC_MSG_CHECKING(for pcapnav-config)
  1444. if test -x $withval ; then
  1445. pcncfg=$withval
  1446. AC_MSG_RESULT($pcncfg)
  1447. elif test x$withval = xno ; then
  1448. AC_MSG_RESULT(no)
  1449. else
  1450. AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
  1451. fi ],
  1452. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
  1453. )
  1454. if test $pcncfg != no ; then
  1455. LNAVLIB=$($pcncfg --libs)
  1456. LNAV_CFLAGS=$($pcncfg --cflags)
  1457. PCAPNAV_VERSION=$($pcncfg --version)
  1458. AC_SUBST(LNAVLIB)
  1459. AC_SUBST(LNAV_CFLAGS)
  1460. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
  1461. [libpcapnav's version?])
  1462. dnl Check to see what version of libpcapnav
  1463. dnl this code has been reduced a lot, but probably still could be
  1464. dnl reduced quite a bit more if we chose too
  1465. AC_MSG_CHECKING(for libpcapnav version)
  1466. AC_TRY_RUN([
  1467. #include <string.h>
  1468. #define PCAPNAV_TEST "0.4"
  1469. /*
  1470. * simple proggy to test the version of libpcapnav
  1471. * returns zero if version >= 0.4
  1472. * or one otherwise
  1473. */
  1474. int
  1475. main (int argc, char *argv[])
  1476. {
  1477. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  1478. exit(0);
  1479. exit(1);
  1480. } ],
  1481. libpcapnav_ver=yes
  1482. AC_MSG_RESULT(>= 0.4),
  1483. libpcapnav_ver=no
  1484. AC_MSG_RESULT(< 0.4),
  1485. libpcapnav_ver=no
  1486. )
  1487. if test x$libpcapnav_ver = xno ; then
  1488. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  1489. Please upgrade to version 0.4 or better.
  1490. Disabling offset jump feature.])
  1491. else
  1492. AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
  1493. fi
  1494. fi # checking pcapnav version
  1495. dnl (shamelessly ripped off from libpcap)
  1496. dnl Checks to see if unaligned memory accesses fail
  1497. dnl
  1498. dnl FORCE_ALIGN (DEFINED)
  1499. dnl
  1500. AC_MSG_CHECKING(for requires strict byte alignment)
  1501. AC_CACHE_VAL(unaligned_cv_fail,
  1502. [case "$host_cpu" in
  1503. # XXX: should also check that they don't do weird things (like on arm)
  1504. alpha*|arm*|hp*|mips*|sparc*|ia64)
  1505. unaligned_cv_fail=yes
  1506. ;;
  1507. *)
  1508. cat >conftest.c <<EOF
  1509. #include <sys/types.h>
  1510. #include <sys/wait.h>
  1511. #include <stdio.h>
  1512. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  1513. main() {
  1514. unsigned int i;
  1515. pid_t pid;
  1516. int status;
  1517. /* avoid "core dumped" message */
  1518. pid = fork();
  1519. if (pid < 0)
  1520. exit(2);
  1521. if (pid > 0) {
  1522. /* parent */
  1523. pid = waitpid(pid, &status, 0);
  1524. if (pid < 0)
  1525. exit(3);
  1526. exit(!WIFEXITED(status));
  1527. }
  1528. /* child */
  1529. i = *(unsigned int *)&a[[1]];
  1530. printf("%d\n", i);
  1531. exit(0);
  1532. }
  1533. EOF
  1534. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  1535. conftest.c $LIBS >/dev/null 2>&1
  1536. if test ! -x conftest ; then
  1537. dnl failed to compile for some reason
  1538. unaligned_cv_fail=yes
  1539. else
  1540. ./conftest >conftest.out
  1541. if test ! -s conftest.out ; then
  1542. unaligned_cv_fail=yes
  1543. else
  1544. unaligned_cv_fail=no
  1545. fi
  1546. fi
  1547. rm -f conftest* core core.conftest
  1548. ;;
  1549. esac
  1550. ])
  1551. AC_MSG_RESULT($unaligned_cv_fail)
  1552. if test $unaligned_cv_fail = yes ; then
  1553. AC_DEFINE([FORCE_ALIGN], [1], [Are we strictly aligned?])
  1554. fi
  1555. dnl ##################################################
  1556. dnl # Check for tcpdump.
  1557. dnl ##################################################
  1558. tcpdump_path=no
  1559. AC_ARG_WITH(tcpdump,
  1560. AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
  1561. [ if test -x $withval ; then
  1562. tcpdump_path=$withval
  1563. AC_MSG_RESULT([Using tcpdump in $tcpdump_path])
  1564. else
  1565. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  1566. fi ],
  1567. [ AC_PATH_PROG(tcpdump_path, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
  1568. if test "$tcpdump_path" = "no"; then
  1569. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  1570. Disabling --verbose])
  1571. else
  1572. AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
  1573. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$tcpdump_path", [The tcpdump binary initially used])
  1574. fi
  1575. AM_CONDITIONAL([ENABLE_TCPDUMP], test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes)
  1576. if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then
  1577. AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?])
  1578. else
  1579. AC_MSG_WARN([Your version of libpcap does not support --verbose])
  1580. fi
  1581. dnl No 'make test' when cross compile
  1582. AC_MSG_CHECKING(for 'make test' profile)
  1583. if test "$host" != "$build" ; then
  1584. AC_MSG_WARN(Unable to do tests when cross-compiling)
  1585. fi
  1586. dnl Allows user to choose which nic to use for testing purposes
  1587. AC_ARG_WITH(testnic,
  1588. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  1589. [ nic1=$withval
  1590. nic2=$withval
  1591. AC_MSG_RESULT([Using --with-testnic=$withval])],
  1592. [
  1593. case $host in
  1594. *-*-linux*)
  1595. nic1=eth0
  1596. nic2=eth0
  1597. ;;
  1598. *-*-solaris*)
  1599. nic1=hme0
  1600. nic2=hme0
  1601. ;;
  1602. *-*-sunos*)
  1603. nic1=hme0
  1604. nic2=hme0
  1605. ;;
  1606. *-apple-darwin*)
  1607. nic1=en0
  1608. nic2=en0
  1609. ;;
  1610. *-*-openbsd*)
  1611. nic1=xl0
  1612. nic2=xl0
  1613. ;;
  1614. *-*-freebsd*)
  1615. nic1=em0
  1616. nic2=em0
  1617. ;;
  1618. *-*-cygwin)
  1619. nic1=%0
  1620. nic2=%0
  1621. ;;
  1622. *)
  1623. AC_MSG_RESULT([$host is unknown! Using first non-loopback interface])
  1624. nic1=%0
  1625. nic2=%0
  1626. ;;
  1627. esac])
  1628. dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC to disassociate
  1629. dnl so under OSX we disable the interface list feature
  1630. disable_pcap_findalldevs=no
  1631. osx_frameworks=no
  1632. dnl these need to be dynamic based on OS
  1633. case $host in
  1634. *-*-linux*)
  1635. AC_DEFINE([HAVE_LINUX], [1], [Building Linux])
  1636. AC_MSG_RESULT(Linux)
  1637. ;;
  1638. *-*-solaris*)
  1639. AC_DEFINE([HAVE_SOLARIS], [1], [Building Solaris])
  1640. AC_MSG_RESULT(Solaris)
  1641. ;;
  1642. *-*-sunos*)
  1643. AC_DEFINE([HAVE_SUNOS], [1], [Building SunOS])
  1644. AC_MSG_RESULT(SunOS)
  1645. ;;
  1646. *-apple-darwin*)
  1647. if test x$libpcap_version_096 = xno ; then
  1648. disable_pcap_findalldevs=yes
  1649. fi
  1650. osx_frameworks=yes
  1651. AC_DEFINE([HAVE_DARWIN], [1], [Building Apple/Darwin])
  1652. AC_MSG_RESULT(Apple OS X)
  1653. ;;
  1654. *-*-openbsd*)
  1655. AC_DEFINE([HAVE_OPENBSD], [1], [Building Open BSD])
  1656. AC_MSG_RESULT(OpenBSD)
  1657. ;;
  1658. *-*-freebsd*)
  1659. AC_DEFINE([HAVE_FREEBSD], [1], [Building Free BSD])
  1660. AC_MSG_RESULT(FreeBSD)
  1661. ;;
  1662. *-*-cygwin)
  1663. AC_MSG_RESULT(Win32/Cygwin)
  1664. AC_DEFINE([HAVE_CYGWIN], [1], [Building Cygwin])
  1665. ;;
  1666. *)
  1667. AC_MSG_RESULT([$host is unknown!])
  1668. ;;
  1669. esac
  1670. AM_CONDITIONAL([ENABLE_OSX_FRAMEWORKS], test "$osx_frameworks" = "yes")
  1671. AC_ARG_WITH(testnic2,
  1672. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  1673. [ nic2=$withval ])
  1674. AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
  1675. AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
  1676. AC_SUBST(nic1)
  1677. AC_SUBST(nic2)
  1678. AC_MSG_CHECKING([if it's ok to use pcap_findalldevs()])
  1679. if test x$disable_pcap_findalldevs = xno ; then
  1680. AC_DEFINE([ENABLE_PCAP_FINDALLDEVS], [1], [Enable use of pcap_findalldevs()])
  1681. AC_MSG_RESULT(yes)
  1682. else
  1683. AC_MSG_RESULT(no)
  1684. fi
  1685. LIBOPTS_CHECK(libopts)
  1686. AC_CONFIG_FILES([Makefile
  1687. doxygen.cfg
  1688. lib/Makefile
  1689. docs/Makefile
  1690. src/Makefile
  1691. src/tcpedit/Makefile
  1692. src/fragroute/Makefile
  1693. src/common/Makefile
  1694. src/defines.h
  1695. test/Makefile
  1696. test/config
  1697. scripts/Makefile])
  1698. AC_OUTPUT
  1699. # Configuration results
  1700. AC_MSG_RESULT([
  1701. ##########################################################################
  1702. TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
  1703. ##########################################################################
  1704. libpcap: ${foundpcap} (${libpcap_version})
  1705. PF_RING libpcap ${pf_ring_found} ${pf_ring_lib}
  1706. libdnet: ${founddnet} ${libdnet_version}
  1707. autogen: ${AUTOGEN} (${AUTOGEN_VERSION})
  1708. Use libopts tearoff: ${enable_local_libopts}
  1709. 64bit counter support: ${use64bit_counters}
  1710. tcpdump binary path: ${tcpdump_path}
  1711. fragroute support: ${enable_fragroute}
  1712. tcpbridge support: ${enable_tcpbridge}
  1713. tcpliveplay support: ${enable_tcpliveplay}
  1714. Supported Packet Injection Methods (*):
  1715. Linux TX_RING: ${have_tx_ring}
  1716. Linux PF_PACKET: ${have_pf}
  1717. BSD BPF: ${have_bpf}
  1718. libdnet: ${have_libdnet}
  1719. pcap_inject: ${have_pcap_inject}
  1720. pcap_sendpacket: ${have_pcap_sendpacket} **
  1721. pcap_netmap ${have_pcap_netmap}
  1722. Linux/BSD netmap: ${have_netmap}
  1723. Tuntap device support: ${have_tuntap}
  1724. * In order of preference; see configure --help to override
  1725. ** Required for tcpbridge
  1726. ])
  1727. case $host in
  1728. *-apple-darwin*)
  1729. AC_MSG_WARN([Apple OS X versions prior to 10.5 (Leopard) have a serious problem!
  1730. Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details])
  1731. ;;
  1732. *-*-cygwin)
  1733. AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.
  1734. Please report any bugs! https://github.com/appneta/tcpreplay/issues])
  1735. ;;
  1736. esac