1
0

configure.ac 60 KB

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