configure.ac 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. dnl $Id: configure.ac 2446 2010-03-30 04:58:36Z aturner $
  2. AC_INIT(tcpreplay)
  3. AC_CONFIG_SRCDIR(src/tcpreplay.c)
  4. AM_CONFIG_HEADER(src/config.h)
  5. AC_CONFIG_AUX_DIR(config)
  6. AM_MAINTAINER_MODE
  7. AM_WITH_DMALLOC
  8. dnl People building from SVN need the same version of Autogen as I'm using
  9. dnl or specify --disable-local-libopts
  10. MAINTAINER_AUTOGEN_VERSION=5.9.7
  11. AC_CONFIG_MACRO_DIR([m4])
  12. dnl Set version info here!
  13. MAJOR_VERSION=3
  14. MINOR_VERSION=4
  15. MICRO_VERSION=4
  16. TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
  17. PACKAGE_URL=http://tcpreplay.synfin.net/
  18. dnl Release is only used for the RPM spec file
  19. TCPREPLAY_RELEASE=1
  20. AC_DEFINE(PACKAGE, [tcpreplay], [This is our package name])
  21. AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?])
  22. AC_SUBST(TCPREPLAY_VERSION)
  23. AC_SUBST(TCPREPLAY_RELEASE)
  24. USER_CFLAGS=$CFLAGS
  25. CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99"
  26. dnl Determine OS
  27. AC_CANONICAL_BUILD
  28. AC_CANONICAL_HOST
  29. AC_CANONICAL_TARGET
  30. AC_SUBST(host)
  31. AC_SUBST(build)
  32. AC_SUBST(target)
  33. have_cygwin=no
  34. AC_MSG_CHECKING([for cygwin development environment])
  35. if test `echo $target | grep -c cygwin` -gt 0 ; then
  36. AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin])
  37. AC_MSG_RESULT(yes)
  38. have_cygwin=yes
  39. else
  40. AC_MSG_RESULT(no)
  41. fi
  42. AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine)
  43. dnl Checks for programs.
  44. AC_PROG_INSTALL
  45. AC_PROG_LIBTOOL
  46. AM_PROG_CC_C_O
  47. AC_PROG_CC_STDC
  48. AC_PROG_CXX
  49. AC_PROG_CPP
  50. AC_PROG_LN_S
  51. LT_INIT
  52. AC_PROG_AWK
  53. AC_PROG_SED
  54. AC_PROG_MAKE_SET
  55. AC_EXEEXT
  56. AC_PATH_PROG(PRINTF, printf)
  57. AC_PATH_PROG(ECHO, echo)
  58. AC_PATH_PROG(CUT, cut)
  59. AC_PATH_PROG(AUTOGEN, autogen)
  60. AC_PATH_PROG(GROFF, groff)
  61. dnl check autogen version
  62. AUTOGEN_VERSION=unknown
  63. if test -n "${AUTOGEN}" ; then
  64. AC_MSG_CHECKING(for autogen version >= 5.9.x)
  65. ${AUTOGEN} -v >autogen.version
  66. AUTOGEN_VERSION=`cat autogen.version | ${SED} 's|.*\([[0-9\.]]\{5,\}\).*|\1|'`
  67. AUTOGEN_MAJOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1`
  68. AUTOGEN_MINOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2`
  69. if ( test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 9 ) || test ${AUTOGEN_MAJOR} -lt 5 ; then
  70. AC_MSG_RESULT(no)
  71. AC_MSG_WARN([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from SVN. Please upgrade to 5.9.x)])
  72. else
  73. AC_MSG_RESULT(yes)
  74. fi
  75. rm -f autogen.version
  76. dnl Compare the installed version with the maintainer version if building from SVN and not using system libopts
  77. if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then
  78. if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then
  79. 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])
  80. fi
  81. fi
  82. else
  83. if test ! -f src/tcpreplay_opts.c ; then
  84. AC_MSG_ERROR([Please install GNU autogen >= 5.9.x if you are building from SVN])
  85. fi
  86. fi
  87. AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
  88. if test "x$enable_local_libopts" = "xyes" ; then
  89. AC_MSG_NOTICE([Using included libopts tearoff])
  90. else
  91. AC_MSG_NOTICE([Using system libopts])
  92. fi
  93. AC_HEADER_STDC
  94. AC_HEADER_MAJOR
  95. dnl Checks for typedefs, structures, and compiler characteristics.
  96. AC_TYPE_SIZE_T
  97. AC_HEADER_TIME
  98. AC_C_CONST
  99. AC_C_INLINE
  100. AC_SYS_LARGEFILE
  101. dnl Check for functions
  102. AC_FUNC_FSEEKO
  103. dnl Check for types.
  104. AC_CHECK_TYPE(u_int8_t, uint8_t)
  105. AC_CHECK_TYPE(u_int16_t, uint16_t)
  106. AC_CHECK_TYPE(u_int32_t, uint32_t)
  107. AC_CHECK_TYPE(u_int64_t, uint64_t)
  108. dnl Older versions of GCC don't support these options
  109. AC_MSG_CHECKING(for $CC -Wextra support)
  110. OLD_CFLAGS=$CFLAGS
  111. CFLAGS="$CFLAGS -Wextra"
  112. wextra=""
  113. AC_COMPILE_IFELSE([#include <stdlib.h>
  114. int main(int argc, char *argv[]) { return(0); }],
  115. [ AC_MSG_RESULT(yes)
  116. wextra="-Wextra" ],
  117. [ AC_MSG_RESULT(no) ])
  118. CFLAGS="$OLD_CFLAGS $wextra"
  119. AC_MSG_CHECKING(for $CC -Wno-variadic-macros support)
  120. OLD_CFLAGS=$CFLAGS
  121. CFLAGS="$CFLAGS -Wno-variadic-macros"
  122. wno_variadic_macros=""
  123. AC_COMPILE_IFELSE([#include <stdlib.h>
  124. int main(int argc, char *argv[]) { return(0); }],
  125. [ AC_MSG_RESULT(yes)
  126. wno_variadic_macros="-Wno-variadic-macros" ],
  127. [ AC_MSG_RESULT(no) ])
  128. CFLAGS="$OLD_CFLAGS $wno_variadic_macros"
  129. AC_MSG_CHECKING(for $CC -Wfatal-errors support)
  130. OLD_CFLAGS=$CFLAGS
  131. CFLAGS="$CFLAGS -Wfatal-errors"
  132. wfatal_errors=""
  133. AC_COMPILE_IFELSE([#include <stdlib.h>
  134. int main(int argc, char *argv[]) { return(0); }],
  135. [ AC_MSG_RESULT(yes)
  136. wfatal_errors="-Wfatal-errors" ],
  137. [ AC_MSG_RESULT(no) ])
  138. CFLAGS="$OLD_CFLAGS $wfatal_errors"
  139. dnl Check for other header files
  140. AC_CHECK_HEADERS([fcntl.h stddef.h sys/socket.h arpa/inet.h sys/time.h signal.h string.h strings.h sys/types.h stdint.h sys/select.h netinet/in.h poll.h sys/poll.h unistd.h sys/param.h])
  141. dnl OpenBSD has special requirements
  142. AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [
  143. [#if HAVE_SYS_PARAM_H
  144. #include <sys/param.h>
  145. #endif
  146. #if HAVE_SYS_TYPES_H
  147. #include <sys/types.h>
  148. #endif
  149. #if HAVE_SYS_SOCKET_H
  150. #include <sys/socket.h>
  151. #endif
  152. ]])
  153. dnl Checks for libraries.
  154. AC_CHECK_LIB(socket, socket)
  155. AC_CHECK_LIB(nsl, gethostbyname)
  156. AC_CHECK_LIB(rt, nanosleep)
  157. AC_CHECK_LIB(resolv, resolv)
  158. dnl Checks for library functions.
  159. AC_FUNC_MALLOC
  160. AC_FUNC_MEMCMP
  161. AC_TYPE_SIGNAL
  162. AC_FUNC_VPRINTF
  163. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  164. AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strchr strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf strsignal])
  165. dnl Look for strlcpy since some BSD's have it
  166. AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
  167. AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
  168. AC_C_BIGENDIAN
  169. AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
  170. dnl Enable debugging in code/compiler options
  171. debug=no
  172. AC_ARG_ENABLE(debug,
  173. AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
  174. [ if test x$enableval = xyes; then
  175. debug=yes
  176. CFLAGS="${USER_CFLAGS} -ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros"
  177. # We may also want to add:
  178. # -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
  179. AC_SUBST(debug_flag)
  180. AC_DEFINE([DEBUG], [1], [Enable debuging code and support for the -d option])
  181. fi])
  182. AC_ARG_ENABLE(dmalloc,
  183. AC_HELP_STRING([--enable-dmalloc], [Enable linking to dmalloc for better memory debugging]),
  184. [ if test x$enableval = xyes ; then
  185. dmalloc=yes
  186. AC_DEFINE([ENABLE_DMALLOC], [1], [Enable dmalloc])
  187. AC_DEFINE([DMALLOC_FUNC_CHECK], [1], [Enable dmalloc function arg checking])
  188. CFLAGS="${CFLAGS} -I/opt/local/include"
  189. DMALLOC_LIB="/opt/local/lib/libdmalloc.a"
  190. AC_SUBST(DMALLOC_LIB)
  191. fi])
  192. AC_ARG_ENABLE(pedantic,
  193. AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
  194. [ if test x$enableval = xyes; then
  195. CFLAGS="$CFLAGS -pedantic"
  196. fi ])
  197. dnl Enable Efense
  198. AC_ARG_ENABLE(efence,
  199. AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
  200. [ if test x$enableval = xyes; then
  201. CFLAGS="$CFLAGS -lefence"
  202. AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
  203. fi])
  204. dnl Enable Gprof
  205. AC_ARG_ENABLE(gprof,
  206. AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
  207. [ if test x$enableval = xyes; then
  208. if test $debug = yes; then
  209. CFLAGS="$CFLAGS -pg"
  210. else
  211. # GPROF requires gdb
  212. CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
  213. fi
  214. AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
  215. fi])
  216. dnl Use 64bits for packet counters
  217. use64bit_counters=yes
  218. AC_ARG_ENABLE(64bits,
  219. AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]),
  220. [
  221. AC_MSG_NOTICE([Using u_int32_t for packet counters])
  222. ],
  223. [
  224. AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
  225. AC_MSG_NOTICE([Using u_int64_t for packet counters])
  226. ])
  227. # If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
  228. # so we can use _U_ to flag unused function arguments and not get warnings
  229. # about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
  230. # function argument will compile with non-GCC compilers.
  231. #
  232. if test "x$GCC" = "xyes" ; then
  233. CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
  234. else
  235. CFLAGS="-D_U_=\"\" $CFLAGS"
  236. fi
  237. AC_ARG_ENABLE(force-bpf,
  238. AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
  239. [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
  240. AC_ARG_ENABLE(force-pf,
  241. AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
  242. [ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
  243. AC_ARG_ENABLE(force-libdnet,
  244. AC_HELP_STRING([--enable-force-libdnet], [Force using libdnet for sending packets]),
  245. [ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
  246. AC_ARG_ENABLE(force-inject,
  247. AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
  248. [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
  249. AC_ARG_ENABLE(force-sendpacket,
  250. AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
  251. [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
  252. dnl Dynamic link libraries
  253. dynamic_link=no
  254. AC_ARG_ENABLE(dynamic-link,
  255. AC_HELP_STRING([--enable-dynamic-link], [Dynamically link libraries]),
  256. [ if test x$enableval = xyes; then
  257. AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Enable dynamically linking libs])
  258. dynamic_link=yes
  259. fi
  260. ])
  261. dnl Check for inet_aton and inet_pton
  262. AC_CHECK_FUNC(inet_aton,
  263. AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
  264. inet_aton=yes,
  265. inet_aton=no)
  266. AC_CHECK_FUNC(inet_pton,
  267. AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
  268. inet_pton=yes,
  269. inet_pton=no)
  270. AC_CHECK_FUNC(inet_ntop,
  271. AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
  272. inet_ntop=yes,
  273. inet_ntop=no)
  274. if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
  275. AC_MSG_ERROR([We need either inet_ntop or inet_pton])
  276. fi
  277. AC_CHECK_FUNC(inet_addr,
  278. AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
  279. inet_addr=yes,
  280. inet_addr=no)
  281. if test x$inet_addr = no ; then
  282. AC_MSG_ERROR([We need inet_addr. See bug 26])
  283. fi
  284. dnl #####################################################
  285. dnl Checks for libpcap
  286. dnl #####################################################
  287. foundpcap=no
  288. trypcapdir=/usr/local
  289. AC_MSG_CHECKING(for libpcap)
  290. AC_ARG_WITH(libpcap,
  291. AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]),
  292. [trypcapdir=$withval])
  293. for testdir in $trypcapdir /usr/local /opt/local /usr /wpdpack ; do
  294. if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then
  295. LPCAPINC="${testdir}/include/pcap.h"
  296. LPCAPINCDIR="${testdir}/include"
  297. if test $dynamic_link = yes; then
  298. if test -f "${testdir}/lib64/libpcap${shrext_cmds}" ; then
  299. LPCAPLIB="-L${testdir}/lib64 -lpcap"
  300. elif test -f "${testdir}/lib/libpcap${shrext_cmds}" ; then
  301. LPCAPLIB="-L${testdir}/lib -lpcap"
  302. else
  303. AC_ERROR([Unable to find libpcap in ${testdir}])
  304. fi
  305. elif test -f "${testdir}/lib64/libpcap.${libext}" ; then
  306. LPCAPLIB="${testdir}/lib64/libpcap.${libext}"
  307. elif test -f "${testdir}/lib/libpcap.${libext}" ; then
  308. LPCAPLIB="${testdir}/lib/libpcap.${libext}"
  309. elif test -f "${testdir}/lib/libwpcap.${libext}" ; then
  310. LPCAPLIB="${testdir}/lib/libwpcap.${libext}"
  311. AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
  312. else
  313. AC_ERROR([Unable to find matching library for header file in ${testdir}])
  314. fi
  315. foundpcap=$testdir
  316. fi
  317. done
  318. if test $foundpcap = no ; then
  319. AC_MSG_RESULT(no)
  320. AC_ERROR(libpcap not found)
  321. else
  322. AC_MSG_RESULT($foundpcap)
  323. fi
  324. dnl Checks to see what version of libpcap we've got
  325. OLDLIBS="$LIBS"
  326. OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR"
  327. LIBS="$LPCAPLIB"
  328. CFLAGS="$CFLAGS -I$LPCAPINCDIR"
  329. # Does libpcap require libnl?
  330. AC_SEARCH_LIBS([pcap_close], [pcap],
  331. LPCAPLIB="$LIBS",
  332. AC_ERROR([Unable to link libpcap in ${foundpcap}]),
  333. -lnl)
  334. AC_SUBST(LPCAPINC)
  335. AC_SUBST(LPCAPLIB)
  336. dnl Check to see what version of libpcap
  337. dnl this code has been reduced a lot, but probably still could be
  338. dnl reduced quite a bit more if we chose too
  339. AC_MSG_CHECKING(for libpcap version)
  340. dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
  341. dnl fix for OSX. See: http://tcpreplay.synfin.net/trac/ticket/167
  342. libpcap_version_096=no
  343. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  344. #include <string.h>
  345. #include <stdlib.h>
  346. #include <stdio.h>
  347. #include "$LPCAPINC"
  348. #define PCAP_TEST "0.9.6"
  349. ]], [[
  350. /*
  351. * simple proggy to test the version of libpcap
  352. * returns zero if version >= 0.9.6
  353. * or one otherwise
  354. */
  355. if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0)
  356. exit(0);
  357. exit(1);
  358. ]]), [
  359. libpcap_version_096=yes
  360. ])
  361. libpcap_ver8=no
  362. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  363. #include <string.h>
  364. #include <stdlib.h>
  365. #include <stdio.h>
  366. #include "$LPCAPINC"
  367. #define PCAP_TEST "0.8"
  368. ]], [[
  369. /*
  370. * simple proggy to test the version of libpcap
  371. * returns zero if version >= 0.8.0
  372. * or one otherwise
  373. */
  374. if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
  375. exit(0);
  376. /* winpcap? */
  377. if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
  378. exit(0);
  379. exit(1);
  380. ]]), [
  381. libpcap_ver8=yes
  382. ], [
  383. libpcap_ver8=no
  384. ])
  385. libpcap_ver7=no
  386. AC_RUN_IFELSE(AC_LANG_PROGRAM([[
  387. #include <string.h>
  388. #include <stdlib.h>
  389. #include <stdio.h>
  390. #include "$LPCAPINC"
  391. #define PCAP_TEST "0.7.2"
  392. extern const char pcap_version[[]]; /* double up since autoconf escapes things */
  393. ]], [[
  394. /*
  395. * simple proggy to test the version of libpcap
  396. * returns zero if version >= 0.7.2
  397. * or one otherwise
  398. */
  399. if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
  400. exit(0);
  401. exit(1);
  402. ]]), [
  403. libpcap_ver7=yes
  404. ], [
  405. libpcap_ver7=no
  406. ])
  407. if test x$libpcap_ver8 = xyes ; then
  408. AC_MSG_RESULT(>= 0.8.0)
  409. elif test x$libpcap_ver7 = xyes ; then
  410. AC_MSG_RESULT(>= 0.7.2)
  411. else
  412. AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
  413. Please upgrade to version 0.7.2 or better])
  414. fi
  415. libpcap_version=unknown
  416. if test x$libpcap_version_096 = xyes ; then
  417. libpcap_version=">= 0.9.6"
  418. elif test x$libpcap_ver8 = xyes ; then
  419. libpcap_version=">= 0.8.0"
  420. elif test x$libcap_ver7 = xyes ; then
  421. libpcap_version=">= 0.7.0"
  422. fi
  423. dnl Check for pcap_setnonblock()
  424. AC_MSG_CHECKING(for pcap_setnonblock)
  425. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  426. #include <stdio.h>
  427. #include <stdlib.h>
  428. #include <string.h>
  429. #include "$LPCAPINC"
  430. ]],[[
  431. pcap_t *p;
  432. char *errbuf;
  433. pcap_setnonblock(p, 1, errbuf);
  434. exit(0);
  435. ]]), [
  436. have_pcap_setnonblock=yes
  437. AC_MSG_RESULT(yes)
  438. ], [
  439. have_pcap_setnonblock=no
  440. AC_MSG_RESULT(no)
  441. ])
  442. if test $have_pcap_setnonblock = yes ; then
  443. AC_DEFINE([HAVE_PCAP_SETNONBLOCK], [1],
  444. [Does libpcap have pcap_setnonblock?])
  445. fi
  446. dnl Check to see if we've got pcap_datalink_val_to_name()
  447. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  448. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  449. #include <stdio.h>
  450. #include <stdlib.h>
  451. #include <string.h>
  452. #include "$LPCAPINC"
  453. ]],[[
  454. if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0)
  455. exit(0);
  456. exit(1);
  457. ]]),[
  458. have_dlt_to_desc=yes
  459. AC_MSG_RESULT(yes)
  460. ], [
  461. have_dlt_to_desc=no
  462. AC_MSG_RESULT(no)
  463. ])
  464. if test $have_dlt_to_desc = yes ; then
  465. AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1],
  466. [Does libpcap have pcap_datalink_val_to_description?])
  467. fi
  468. dnl Check for pcap_get_selectable_fd()
  469. AC_MSG_CHECKING(for pcap_get_selectable_fd)
  470. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  471. #include <stdio.h>
  472. #include <stdlib.h>
  473. #include <string.h>
  474. #include "$LPCAPINC"
  475. ]], [[
  476. int f;
  477. pcap_t *p;
  478. f = pcap_get_selectable_fd(p);
  479. exit(0);
  480. ]]), [
  481. have_pcap_get_selectable_fd=yes
  482. AC_MSG_RESULT(yes)
  483. ], [
  484. have_pcap_get_selectable_fd=no
  485. AC_MSG_RESULT(no)
  486. ])
  487. if test x$have_pcap_get_selectable_fd = xyes ; then
  488. AC_DEFINE([HAVE_PCAP_GET_SELECTABLE_FD], [1],
  489. [Does libpcap have pcap_get_selectable_fd?])
  490. fi
  491. dnl Important: winpcap apparently defines functions in it's header files
  492. dnl which aren't actually in the library. Totally fucked up. Hence, we
  493. dnl must actually LINK the code, not just compile it.
  494. dnl Check to see if we've got pcap_dump_fopen()
  495. AC_MSG_CHECKING(for pcap_dump_fopen)
  496. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  497. #include <stdio.h>
  498. #include <stdlib.h>
  499. #include <string.h>
  500. #include "$LPCAPINC"
  501. ]],[[
  502. pcap_dumper_t *dump;
  503. pcap_t *pcap;
  504. FILE *foo;
  505. dump = pcap_dump_fopen(pcap, foo);
  506. ]]),[
  507. have_pcap_dump_fopen=yes
  508. AC_MSG_RESULT(yes)
  509. ], [
  510. have_pcap_dump_fopen=no
  511. AC_MSG_RESULT(no)
  512. ])
  513. if test $have_pcap_dump_fopen = yes ; then
  514. AC_DEFINE([HAVE_PCAP_DUMP_FOPEN], [1],
  515. [Does libpcap have pcap_dump_fopen?])
  516. else
  517. AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
  518. fi
  519. have_pcap_inject=no
  520. dnl Check to see if we've got pcap_inject()
  521. AC_MSG_CHECKING(for pcap_inject sending support)
  522. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  523. #include <stdio.h>
  524. #include <stdlib.h>
  525. #include <string.h>
  526. #include "$LPCAPINC"
  527. ]],[[
  528. pcap_t *pcap;
  529. char *buf;
  530. pcap_inject(pcap, (void *)buf, 0);
  531. ]]),[
  532. have_pcap_inject=yes
  533. AC_MSG_RESULT(yes)
  534. ], [
  535. have_pcap_inject=no
  536. AC_MSG_RESULT(no)
  537. ])
  538. if test $have_pcap_inject = yes ; then
  539. AC_DEFINE([HAVE_PCAP_INJECT], [1], [Does libpcap have pcap_inject?])
  540. fi
  541. have_pcap_sendpacket=no
  542. dnl Check to see if we've got pcap_sendpacket()
  543. AC_MSG_CHECKING(for pcap_sendpacket sending support)
  544. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  545. #include <stdio.h>
  546. #include <stdlib.h>
  547. #include <string.h>
  548. #include "$LPCAPINC"
  549. ]],[[
  550. pcap_t *pcap;
  551. u_char *buf;
  552. pcap_sendpacket(pcap, buf, 0);
  553. ]]),[
  554. have_pcap_sendpacket=yes
  555. AC_MSG_RESULT(yes)
  556. ], [
  557. have_pcap_sendpacket=no
  558. AC_MSG_RESULT(no)
  559. ])
  560. if test $have_pcap_sendpacket = yes ; then
  561. AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], [Does libpcap have pcap_sendpacket?])
  562. fi
  563. have_pcap_breakloop=no
  564. AC_MSG_CHECKING(for pcap_breakloop)
  565. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  566. #include <stdio.h>
  567. #include <stdlib.h>
  568. #include <string.h>
  569. #include "$LPCAPINC"
  570. ]],[[
  571. pcap_t *pcap;
  572. pcap_sendpacket(pcap);
  573. ]]),[
  574. have_pcap_breakloop=yes
  575. AC_MSG_RESULT(yes)
  576. ], [
  577. have_pcap_breakloop=no
  578. AC_MSG_RESULT(no)
  579. ])
  580. if test $have_pcap_breakloop = yes ; then
  581. AC_DEFINE([HAVE_PCAP_BREAKLOOP], [1], [Does libpcap have pcap_breakloop?])
  582. fi
  583. have_pcap_version=no
  584. dnl Check to see if we have pcap_version[]
  585. AC_MSG_CHECKING(for pcap_version[])
  586. AC_TRY_COMPILE([
  587. #include <stdio.h>
  588. #include <stdlib.h>
  589. #include <string.h>
  590. #include "$LPCAPINC"
  591. extern char pcap_version[];
  592. ],[
  593. printf("%s", pcap_version);
  594. ],[
  595. AC_DEFINE([HAVE_PCAP_VERSION],[1], [Does libpcap have pcap_version[]])
  596. AC_MSG_RESULT(yes)
  597. ],[
  598. AC_MSG_RESULT(no)
  599. ])
  600. have_pcap_snapshot=no
  601. dnl Check for pcap_snapshot()
  602. AC_MSG_CHECKING(for pcap_snapshot)
  603. AC_LINK_IFELSE(AC_LANG_PROGRAM([[
  604. #include <stdio.h>
  605. #include <stdlib.h>
  606. #include <string.h>
  607. #include "$LPCAPINC"
  608. ]],[[
  609. pcap_t *p;
  610. int len;
  611. len = pcap_snapshot(p);
  612. exit(0);
  613. ]]), [
  614. have_pcap_snapshot=yes
  615. AC_MSG_RESULT(yes)
  616. ], [
  617. have_pcap_snapshot=no
  618. AC_MSG_RESULT(no)
  619. ])
  620. if test $have_pcap_snapshot = yes ; then
  621. AC_DEFINE([HAVE_PCAP_SNAPSHOT], [1],
  622. [Does libpcap have pcap_snapshot?])
  623. fi
  624. # Tcpbridge requires libpcap and pcap_sendpacket()
  625. enable_tcpbridge=no
  626. if test x$foundpcap != xno -a x$have_pcap_sendpacket = xyes ; then
  627. # if we have pcap_sendpacket() then we can build tcpbridge on non-BPF systems
  628. if test x$have_bpf = xno; then
  629. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  630. enable_tcpbridge=yes
  631. AC_MSG_NOTICE([Building tcpbridge])
  632. # BPF systems need to also have pcap_setnonblock()
  633. elif test x$have_pcap_setnonblock = xyes ; then
  634. AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge])
  635. enable_tcpbridge=yes
  636. AC_MSG_NOTICE([Building tcpbridge])
  637. else
  638. AC_MSG_WARN([Unable to build tcpbridge. Try installing latest libpcap!])
  639. fi
  640. fi
  641. AM_CONDITIONAL(COMPILE_TCPBRIDGE, [test x$enable_tcpbridge = xyes ])
  642. have_pf=no
  643. dnl Check for linux PF_PACKET support
  644. AC_MSG_CHECKING(for PF_PACKET socket sending support)
  645. AC_TRY_COMPILE([
  646. #include <sys/socket.h>
  647. #include <netpacket/packet.h>
  648. #include <net/ethernet.h> /* the L2 protocols */
  649. #include <netinet/in.h> /* htons */
  650. ],[
  651. int pf_socket;
  652. pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  653. ],[
  654. AC_DEFINE([HAVE_PF_PACKET], [1],
  655. [Do we have Linux PF_PACKET socket support?])
  656. AC_MSG_RESULT(yes)
  657. have_pf=yes
  658. ],[
  659. AC_MSG_RESULT(no)
  660. ])
  661. have_bpf=no
  662. dnl Check for BSD's BPF
  663. AC_MSG_CHECKING(for BPF device sending support)
  664. AC_TRY_RUN([
  665. #include <stdio.h>
  666. #include <stdlib.h>
  667. #include <sys/types.h>
  668. #include <sys/socket.h>
  669. #include <fcntl.h>
  670. #include <sys/time.h>
  671. #include <sys/ioctl.h>
  672. #include <stdint.h>
  673. #include <net/bpf.h>
  674. #include <errno.h>
  675. int
  676. main(int argc, char *argv[]) {
  677. int fd;
  678. fd = open("/dev/bpf0", O_RDONLY, 0);
  679. /* if we opened it, we're good */
  680. if (fd > 1)
  681. exit(0);
  682. /* if we got EBUSY or permission denied it exists, so we're good */
  683. if (fd < 0 && (errno == EBUSY || errno == 13))
  684. exit(0);
  685. /* else suck, no good */
  686. exit(-1);
  687. }],
  688. [
  689. AC_DEFINE([HAVE_BPF], [1],
  690. [Do we have BPF device support?])
  691. AC_MSG_RESULT(yes)
  692. have_bpf=yes
  693. ],[
  694. AC_MSG_RESULT(no)
  695. ])
  696. dnl ##################################################
  697. dnl # Check for libdnet, but only if not Cygwin!
  698. dnl ##################################################
  699. founddnet=no
  700. have_libdnet=no
  701. libdnet_version=
  702. enable_fragroute=no
  703. trydnetdir=/usr/local
  704. if test $have_cygwin == no ; then
  705. AC_MSG_CHECKING(for libdnet)
  706. AC_ARG_WITH(libdnet,
  707. AC_HELP_STRING([--with-libdnet=DIR], [Use libdnet in DIR]),
  708. [trydnetdir=$withval])
  709. for testdir in $trydnetdir /usr/local /opt/local /usr ; do
  710. if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
  711. LDNETINC="`$testdir/bin/dnet-config --cflags`"
  712. LDNETLIB="`$testdir/bin/dnet-config --libs`"
  713. libdnet_version="`$testdir/bin/dnet-config --version`"
  714. founddnet=$testdir
  715. fi
  716. done
  717. if test $founddnet = no ; then
  718. AC_MSG_RESULT(no)
  719. AC_MSG_WARN([libdnet not found, disabling fragroute feature])
  720. else
  721. AC_MSG_RESULT($founddnet)
  722. enable_fragroute=yes
  723. have_libdnet=yes
  724. AC_DEFINE([HAVE_LIBDNET], [1], [Do we have libdnet?])
  725. fi
  726. else
  727. AC_MSG_NOTICE([Skipping libdnet check under Cygwin for compatibility reasons])
  728. fi
  729. AC_SUBST(LDNETINC)
  730. AC_SUBST(LDNETLIB)
  731. AC_DEFINE_UNQUOTED([LIBDNET_VERSION], "$libdnet_version", [Version of libdnet])
  732. AM_CONDITIONAL(COMPILE_FRAGROUTE, [test x$founddnet != xno])
  733. if test x$founddnet != xno ; then
  734. AC_DEFINE(ENABLE_FRAGROUTE, [1], [Enable fragroute module])
  735. fi
  736. dnl Make sure we have a valid packet injection mechanisim
  737. if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
  738. -a $have_libdnet = no -a $have_pf = no ; then
  739. AC_MSG_ERROR([Unable to find a supported method to send packets. Please upgrade your libpcap or enable libdnet])
  740. fi
  741. dnl Older versions of libpcap are missing some DLT types
  742. dnl If doesn't exist, we'll define them in src/common/fakepcap.h
  743. AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
  744. AC_TRY_COMPILE([#include "$LPCAPINC"],
  745. [ int foo;
  746. foo = DLT_LINUX_SLL ],
  747. [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
  748. [Does pcap.h include a header with DLT_LINUX_SLL?])
  749. AC_MSG_RESULT(yes)
  750. ],
  751. AC_MSG_RESULT(no)
  752. )
  753. AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
  754. AC_TRY_COMPILE([#include "$LPCAPINC"],
  755. [ int foo;
  756. foo = DLT_C_HDLC ],
  757. [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
  758. [Does pcap.h include a header with DLT_C_HDLC?])
  759. AC_MSG_RESULT(yes)
  760. ],
  761. AC_MSG_RESULT(no)
  762. )
  763. PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
  764. AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
  765. AC_TRY_COMPILE([#include <sys/types.h>
  766. #include <sys/time.h>
  767. #include <stdint.h>
  768. #include "$PCAP_BPF_H_FILE"],
  769. [ int foo;
  770. foo = BPF_MAJOR_VERSION; ],
  771. [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  772. [What is the path (if any) to the pcap-bpf.h
  773. header?])
  774. AC_MSG_RESULT(yes)
  775. AC_SUBST(PCAP_BPF_H_FILE)
  776. ],
  777. AC_MSG_RESULT(no)
  778. )
  779. foundbpfheader=no
  780. AC_MSG_CHECKING(for libpcap bpf header)
  781. for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do
  782. if test -f "${testfile}" -a $foundbpfheader = no ; then
  783. AC_TRY_COMPILE([
  784. #include <sys/types.h>
  785. #include <sys/time.h>
  786. #include <stdint.h>
  787. #include "$testfile"],
  788. [
  789. int foo;
  790. foo = BPF_MAJOR_VERSION;
  791. ],
  792. [
  793. foundbpfheader=yes
  794. PCAP_BPF_H_FILE=$testfile
  795. AC_SUBST(PCAP_BPF_H_FILE)
  796. AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
  797. [What is the path (if any) to the libpcap bpf header file?])
  798. AC_MSG_RESULT($testfile)
  799. ],
  800. AC_MSG_RESULT(no)
  801. )
  802. fi
  803. done
  804. dnl restore LIBS & CFLAGS
  805. LIBS="$OLDLIBS"
  806. CFLAGS="$OLDCFLAGS"
  807. dnl ##################################################
  808. dnl # Check for pcapnav
  809. dnl ##################################################
  810. pcapnav_ver=no
  811. pcncfg=no
  812. AC_ARG_WITH(pcapnav-config,
  813. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  814. [ AC_MSG_CHECKING(for pcapnav-config)
  815. if test -x $withval ; then
  816. pcncfg=$withval
  817. AC_MSG_RESULT($pcncfg)
  818. elif test x$withval = xno ; then
  819. AC_MSG_RESULT(no)
  820. else
  821. AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
  822. fi ],
  823. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
  824. )
  825. if test $pcncfg != no ; then
  826. LNAVLIB=`$pcncfg --libs`
  827. LNAV_CFLAGS=`$pcncfg --cflags`
  828. PCAPNAV_VERSION=`$pcncfg --version`
  829. AC_SUBST(LNAVLIB)
  830. AC_SUBST(LNAV_CFLAGS)
  831. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
  832. [libpcapnav's version?])
  833. dnl Check to see what version of libpcapnav
  834. dnl this code has been reduced a lot, but probably still could be
  835. dnl reduced quite a bit more if we chose too
  836. AC_MSG_CHECKING(for libpcapnav version)
  837. AC_TRY_RUN([
  838. #include <string.h>
  839. #define PCAPNAV_TEST "0.4"
  840. /*
  841. * simple proggy to test the version of libpcapnav
  842. * returns zero if version >= 0.4
  843. * or one otherwise
  844. */
  845. int
  846. main (int argc, char *argv[])
  847. {
  848. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  849. exit(0);
  850. exit(1);
  851. } ],
  852. libpcapnav_ver=yes
  853. AC_MSG_RESULT(>= 0.4),
  854. libpcapnav_ver=no
  855. AC_MSG_RESULT(< 0.4),
  856. libpcapnav_ver=no
  857. )
  858. if test x$libpcapnav_ver = xno ; then
  859. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  860. Please upgrade to version 0.4 or better.
  861. Disabling offset jump feature.])
  862. else
  863. AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
  864. fi
  865. fi # checking pcapnav version
  866. dnl (shamelessly ripped off from libpcap)
  867. dnl Checks to see if unaligned memory accesses fail
  868. dnl
  869. dnl FORCE_ALIGN (DEFINED)
  870. dnl
  871. AC_MSG_CHECKING(for requires strict byte alignment)
  872. AC_CACHE_VAL(unaligned_cv_fail,
  873. [case "$host_cpu" in
  874. # XXX: should also check that they don't do weird things (like on arm)
  875. alpha*|arm*|hp*|mips*|sparc*|ia64)
  876. unaligned_cv_fail=yes
  877. ;;
  878. *)
  879. cat >conftest.c <<EOF
  880. #include <sys/types.h>
  881. #include <sys/wait.h>
  882. #include <stdio.h>
  883. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  884. main() {
  885. unsigned int i;
  886. pid_t pid;
  887. int status;
  888. /* avoid "core dumped" message */
  889. pid = fork();
  890. if (pid < 0)
  891. exit(2);
  892. if (pid > 0) {
  893. /* parent */
  894. pid = waitpid(pid, &status, 0);
  895. if (pid < 0)
  896. exit(3);
  897. exit(!WIFEXITED(status));
  898. }
  899. /* child */
  900. i = *(unsigned int *)&a[[1]];
  901. printf("%d\n", i);
  902. exit(0);
  903. }
  904. EOF
  905. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  906. conftest.c $LIBS >/dev/null 2>&1
  907. if test ! -x conftest ; then
  908. dnl failed to compile for some reason
  909. unaligned_cv_fail=yes
  910. else
  911. ./conftest >conftest.out
  912. if test ! -s conftest.out ; then
  913. unaligned_cv_fail=yes
  914. else
  915. unaligned_cv_fail=no
  916. fi
  917. fi
  918. rm -f conftest* core core.conftest
  919. ;;
  920. esac
  921. ])
  922. AC_MSG_RESULT($unaligned_cv_fail)
  923. if test $unaligned_cv_fail = yes ; then
  924. AC_DEFINE([FORCE_ALIGN], [1], [Are we strictly aligned?])
  925. fi
  926. dnl ##################################################
  927. dnl # Check for tcpdump.
  928. dnl ##################################################
  929. tcpdump_path=no
  930. AC_ARG_WITH(tcpdump,
  931. AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
  932. [ if test -x $withval ; then
  933. tcpdump_path=$withval
  934. AC_MSG_RESULT([Using tcpdump in $tcpdump_path])
  935. else
  936. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  937. fi ],
  938. [ AC_PATH_PROG(tcpdump_path, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
  939. if test "$tcpdump_path" = "no"; then
  940. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  941. Disabling --verbose])
  942. else
  943. AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
  944. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$tcpdump_path", [The tcpdump binary initially used])
  945. fi
  946. AM_CONDITIONAL([ENABLE_TCPDUMP], test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes)
  947. if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then
  948. AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?])
  949. else
  950. AC_MSG_WARN([Your version of libpcap is too old for --verbose support])
  951. fi
  952. dnl No 'make test' when cross compile
  953. AC_MSG_CHECKING(for 'make test' profile)
  954. if test "$host" != "$build" ; then
  955. AC_MSG_WARN(Unable to do tests when cross-compiling)
  956. fi
  957. dnl Allows user to choose which nic to use for testing purposes
  958. AC_ARG_WITH(testnic,
  959. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  960. [ nic1=$withval
  961. nic2=$withval
  962. AC_MSG_RESULT([Using --with-testnic=$withval])],
  963. [
  964. dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC to disassociate
  965. dnl so under OSX we disable the interface list feature
  966. disable_pcap_findalldevs=no
  967. osx_frameworks=no
  968. dnl these need to be dynamic based on OS
  969. case $host in
  970. *-*-linux*)
  971. nic1=eth0
  972. nic2=eth0
  973. AC_MSG_RESULT(Linux)
  974. ;;
  975. *-*-solaris*)
  976. nic1=hme0
  977. nic2=hme0
  978. AC_MSG_RESULT(Solaris)
  979. ;;
  980. *-*-sunos*)
  981. nic1=hme0
  982. nic2=hme0
  983. AC_MSG_RESULT(SunOS)
  984. ;;
  985. *-apple-darwin*)
  986. nic1=en0
  987. nic2=en0
  988. if test x$libpcap_version_096 = xno ; then
  989. disable_pcap_findalldevs=yes
  990. fi
  991. AC_DEFINE([HAVE_ABSOLUTE_TIME], [1], [Have OS X UpTime()/AbsoluteTime high-precision timing])
  992. osx_frameworks=yes
  993. AC_DEFINE([HAVE_DARWIN], [1], [Building Apple/Darwin])
  994. AC_MSG_RESULT(Apple OS X)
  995. ;;
  996. *-*-openbsd*)
  997. nic1=xl0
  998. nic2=xl0
  999. AC_MSG_RESULT(OpenBSD)
  1000. ;;
  1001. *-*-cygwin)
  1002. AC_MSG_RESULT(Win32/Cygwin)
  1003. nic1=%0
  1004. nic2=%0
  1005. ;;
  1006. *)
  1007. AC_MSG_RESULT([$host is unknown! Using first non-loopback interface])
  1008. nic1=%0
  1009. nic2=%0
  1010. ;;
  1011. esac])
  1012. AM_CONDITIONAL([ENABLE_OSX_FRAMEWORKS], test "$osx_frameworks" == "yes")
  1013. AC_ARG_WITH(testnic2,
  1014. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  1015. [ nic2=$withval ])
  1016. AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
  1017. AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
  1018. AC_SUBST(nic1)
  1019. AC_SUBST(nic2)
  1020. AC_MSG_CHECKING([if it's ok to use pcap_findalldevs()])
  1021. if test x$disable_pcap_findalldevs = xno ; then
  1022. AC_DEFINE([ENABLE_PCAP_FINDALLDEVS], [1], [Enable use of pcap_findalldevs()])
  1023. AC_MSG_RESULT(yes)
  1024. else
  1025. AC_MSG_RESULT(no)
  1026. fi
  1027. dnl tcpreplay has (so far) been relying on leading-edge autogen.
  1028. dnl Therefore, by default:
  1029. dnl - use the version we ship with
  1030. dnl - do not install it
  1031. dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier)
  1032. case "${enable_local_libopts+set}" in
  1033. set) ;;
  1034. *) enable_local_libopts=yes ;;
  1035. esac
  1036. case "${enable_libopts_install+set}" in
  1037. set) ;;
  1038. *) enable_libopts_install=no ;;
  1039. esac
  1040. LIBOPTS_CHECK(libopts)
  1041. AC_OUTPUT([Makefile
  1042. doxygen.cfg
  1043. lib/Makefile
  1044. docs/Makefile
  1045. src/Makefile
  1046. src/common/Makefile
  1047. src/tcpedit/Makefile
  1048. src/fragroute/Makefile
  1049. src/defines.h
  1050. test/Makefile
  1051. test/config
  1052. scripts/Makefile])
  1053. # Configuration results
  1054. AC_MSG_RESULT(
  1055. ##########################################################################
  1056. TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
  1057. ##########################################################################
  1058. libpcap: ${foundpcap} (${libpcap_version})
  1059. libdnet: ${founddnet} (${libdnet_version})
  1060. autogen: ${AUTOGEN} (${AUTOGEN_VERSION})
  1061. Use libopts tearoff: ${enable_local_libopts}
  1062. 64bit counter support: ${use64bit_counters}
  1063. tcpdump binary path: ${tcpdump_path}
  1064. tcpreplay edit support: ${tcpreplay_edit}
  1065. fragroute support: ${enable_fragroute}
  1066. tcpbridge support: ${enable_tcpbridge}
  1067. Supported Packet Injection Methods (*):
  1068. Linux PF_PACKET: ${have_pf}
  1069. BSD BPF: ${have_bpf}
  1070. libdnet: ${have_libdnet}
  1071. pcap_inject: ${have_pcap_inject}
  1072. pcap_sendpacket: ${have_pcap_sendpacket} **
  1073. * In order of preference; see configure --help to override
  1074. ** Required for tcpbridge
  1075. )
  1076. case $host in
  1077. *-apple-darwin*)
  1078. AC_MSG_WARN([Apple OS X versions prior to 10.5 (Leopard) has a serious problem!
  1079. Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details])
  1080. ;;
  1081. *-*-cygwin)
  1082. AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.
  1083. Please report any bugs! http://tcpreplay.synfin.net/trac/newticket])
  1084. ;;
  1085. esac