configure.in 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. dnl $Id: configure.in 1380 2005-06-30 05:54:26Z 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. AC_PROG_LIBTOOL
  9. dnl Set version info here!
  10. MAJOR_VERSION=3
  11. MINOR_VERSION=0
  12. MICRO_VERSION=beta7
  13. TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
  14. dnl Release is only used for the RPM spec file
  15. TCPREPLAY_RELEASE=1
  16. AC_DEFINE(PACKAGE, [tcpreplay], [This is our package name])
  17. AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?])
  18. AC_SUBST(TCPREPLAY_VERSION)
  19. AC_SUBST(TCPREPLAY_RELEASE)
  20. CFLAGS="$CFLAGS -Wall -O2 -funroll-loops" # -std=c99 -Wno-variadic-macros"
  21. dnl Determine OS
  22. AC_CANONICAL_BUILD
  23. AC_CANONICAL_HOST
  24. AC_CANONICAL_TARGET
  25. AC_SUBST(host)
  26. AC_SUBST(build)
  27. AC_SUBST(target)
  28. AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine)
  29. dnl Checks for programs.
  30. AC_PROG_INSTALL
  31. AC_PROG_LIBTOOL
  32. AC_PROG_CC
  33. AC_PROG_CC_STDC
  34. AC_PROG_CXX
  35. AC_PROG_CPP
  36. AC_PROG_LN_S
  37. AC_PROG_RANLIB
  38. AC_PROG_AWK
  39. AC_PROG_MAKE_SET
  40. AC_EXEEXT
  41. AC_PATH_PROG(PRINTF, printf)
  42. AC_PATH_PROG(FIG2DEV, fig2dev)
  43. dnl Look for lyx in the normal locations
  44. dnl The OS X installer puts Lyx at /Applications/Lyx.app/Contents/MacOS/LyX
  45. AC_ARG_WITH(lyx,
  46. AC_HELP_STRING([--with-lyx=FILE], [Path to Lyx binary]),
  47. [ AC_MSG_CHECKING(for lyx)
  48. if test -x $withval ; then
  49. td=$withval
  50. AC_MSG_RESULT($td)
  51. else
  52. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  53. fi ],
  54. [
  55. case $host in
  56. powerpc-apple-darwin*)
  57. lyx=/Applications/Lyx.app/Contents/MacOS/LyX
  58. if test -x $lyx ; then
  59. AC_MSG_CHECKING(for lyx)
  60. AC_SUBST(LYX, $lyx)
  61. AC_MSG_RESULT($lyx)
  62. else
  63. AC_PATH_PROG(LYX, lyx)
  64. fi
  65. ;;
  66. *)
  67. AC_PATH_PROG(LYX, lyx)
  68. ;;
  69. esac
  70. ])
  71. AC_PATH_PROG(DVIPS, dvips)
  72. AC_PATH_PROG(TEXI2DVI, texi2dvi)
  73. AC_PATH_PROG(LATEX2HTML, latex2html)
  74. AC_PATH_PROG(DVIPDFM, dvipdfm)
  75. AC_PATH_PROG(AUTOGEN, autogen)
  76. AC_HEADER_STDC
  77. AC_HEADER_MAJOR
  78. dnl Checks for typedefs, structures, and compiler characteristics.
  79. AC_TYPE_SIZE_T
  80. AC_HEADER_TIME
  81. AC_C_CONST
  82. AC_C_INLINE
  83. AC_SYS_LARGEFILE
  84. dnl Check for functions
  85. AC_FUNC_FSEEKO
  86. dnl Check for types.
  87. AC_CHECK_TYPE(u_int8_t, uint8_t)
  88. AC_CHECK_TYPE(u_int16_t, uint16_t)
  89. AC_CHECK_TYPE(u_int32_t, uint32_t)
  90. AC_CHECK_TYPE(u_int64_t, uint64_t)
  91. dnl Check for other header files
  92. 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 sys/select.h netinet/in.h poll.h sys/poll.h unistd.h])
  93. dnl Checks for libraries.
  94. AC_CHECK_LIB(socket, socket)
  95. AC_CHECK_LIB(nsl, gethostbyname)
  96. AC_CHECK_LIB(rt, nanosleep)
  97. dnl Checks for library functions.
  98. AC_FUNC_MALLOC
  99. AC_FUNC_MEMCMP
  100. AC_TYPE_SIGNAL
  101. AC_FUNC_VPRINTF
  102. AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strerror strtol strncpy strtoull poll ntohll mmap])
  103. dnl Look for strlcpy since some BSD's have it
  104. AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
  105. AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue])
  106. AC_CHECK_MEMBERS([struct timeval.tv_sec])
  107. AC_C_BIGENDIAN
  108. doctools=no
  109. if test -n "$FIG2DEV" -a -n "$LYX" -a -n "$DVIPS" -a -n "$TEXI2DVI" \
  110. -a -n "$LATEX2HTML" -a -n "$DVIPDFM" ; then
  111. doctools=yes
  112. fi
  113. AM_CONDITIONAL(HAVE_DOCTOOLS, test $doctools = yes)
  114. dnl Enable debugging in code/compiler options
  115. debug=no
  116. AC_ARG_ENABLE(debug,
  117. AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
  118. [ if test x$enableval = xyes; then
  119. debug=yes
  120. CFLAGS="-ggdb -Wall -pedantic"
  121. AC_SUBST(debug_flag)
  122. AC_DEFINE([DEBUG], [], [Enable debuggin code and support for the -d option])
  123. fi])
  124. dnl Enable Efense
  125. AC_ARG_ENABLE(efence,
  126. AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
  127. [ if test x$enableval = xyes; then
  128. CFLAGS="$CFLAGS -lefence"
  129. AC_DEFINE([EFENCE], [], [Enable Electric Fence memory debugger])
  130. fi])
  131. dnl Enable Gprof
  132. AC_ARG_ENABLE(gprof,
  133. AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
  134. [ if test x$enableval = xyes; then
  135. if test $debug = yes; then
  136. CFLAGS="$CFLAGS -pg"
  137. else
  138. # GPROF requires gdb
  139. CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
  140. fi
  141. AC_DEFINE([GPROF], [], [Enable GNU Profiler])
  142. fi])
  143. dnl Use 64bits for packet counters
  144. AC_ARG_ENABLE(64bits,
  145. AC_HELP_STRING([--enable-64bits], [Use 64bit packet counters]),
  146. [ if test x$enableval = xyes; then
  147. AC_DEFINE([ENABLE_64BITS], [], [Use 64bit packet counters])
  148. AC_MSG_NOTICE([Using u_int64_t for packet counters])
  149. else
  150. AC_MSG_NOTICE([Using u_int32_t for packet counters])
  151. fi
  152. ])
  153. dnl Dynamic link libraries
  154. dynamic_link=no
  155. AC_ARG_ENABLE(dynamic-link,
  156. AC_HELP_STRING([--enable-dynamic-link], [Dynamically link libraries]),
  157. [ if test x$enableval = xyes; then
  158. AC_DEFINE([ENABLE_DYNAMIC_LINK], [], [Enable dynamically linking libs])
  159. dynamic_link=yes
  160. fi
  161. ])
  162. dnl Check for inet_aton and inet_addr
  163. AC_CHECK_FUNC(inet_aton,
  164. AC_DEFINE([INET_ATON], [], [Do we have inet_aton?])
  165. inet_aton=yes,
  166. inet_aton=no)
  167. AC_CHECK_FUNC(inet_addr,
  168. AC_DEFINE([INET_ADDR], [], [Do we have inet_addr?])
  169. inet_addr=yes,
  170. inet_addr=no)
  171. if test $inet_aton = no -a $inet_addr = no ; then
  172. AC_MSG_ERROR("We need either inet_aton or inet_addr")
  173. fi
  174. dnl ##################################################
  175. dnl Checks for libnet (shamelessly horked from dsniff)
  176. dnl ##################################################
  177. foundnet=no
  178. trynetdir=/usr/local
  179. AC_MSG_CHECKING(for libnet)
  180. AC_ARG_WITH(libnet,
  181. AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
  182. [trynetdir=$withval])
  183. for testdir in $trynetdir /usr/local /usr ; do
  184. if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
  185. LNETINC="${testdir}/include/libnet.h"
  186. LNETINCDIR="$testdir/include"
  187. if test $dynamic_link = yes; then
  188. LNETLIB="-L${testdir}/lib -lnet"
  189. elif test -f "${testdir}/lib64/libnet.a" ; then
  190. LNETLIB="${testdir}/lib64/libnet.a"
  191. else
  192. LNETLIB="${testdir}/lib/libnet.a"
  193. fi
  194. foundnet=$testdir
  195. fi
  196. done
  197. if test $foundnet = no ; then
  198. AC_MSG_RESULT(no)
  199. AC_ERROR(libnet not found)
  200. else
  201. AC_MSG_RESULT($foundnet)
  202. fi
  203. AC_SUBST(LNETINC)
  204. AC_SUBST(LNETLIB)
  205. OLDLIBS="$LIBS"
  206. OLDCFLAGS="$CFLAGS"
  207. LIBS="$LNETLIB"
  208. CFLAGS="$CFLAGS -I$LNETINCDIR"
  209. dnl Check to see what version of libnet
  210. dnl this code has been reduced a lot, but probably still could be
  211. dnl reduced quite a bit more if we chose too
  212. AC_MSG_CHECKING(for libnet version)
  213. AC_TRY_RUN([
  214. #include <string.h>
  215. #define LIBNET_LIL_ENDIAN 1
  216. #include "$LNETINC"
  217. #define LIB_TEST "1.0"
  218. /*
  219. * simple proggy to test the version of libnet
  220. * returns zero if it's 1.0.x
  221. * or one otherwise
  222. */
  223. int
  224. main (int argc, char *argv[])
  225. {
  226. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  227. exit(0);
  228. exit(1);
  229. }],
  230. libnet_ver_10=yes
  231. AC_MSG_RESULT(1.0.x),
  232. libnet_ver_10=no,
  233. libnet_ver_10=no
  234. )
  235. AC_TRY_RUN([
  236. #include <string.h>
  237. #include "$LNETINC"
  238. #define LIB_TEST "1.1"
  239. /*
  240. * simple proggy to test the version of libnet
  241. * returns zero if it's 1.0.x
  242. * or one otherwise
  243. */
  244. int
  245. main (int argc, char *argv[])
  246. {
  247. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  248. exit(0);
  249. exit(1);
  250. }],
  251. libnet_ver_11=yes
  252. AC_MSG_RESULT(1.1.x),
  253. libnet_ver_11=no,
  254. libnet_ver_11=no
  255. )
  256. if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
  257. AC_MSG_RESULT(unknown)
  258. AC_MSG_ERROR(Unable to determine version of libnet)
  259. fi
  260. if test $libnet_ver_10 = yes ; then
  261. AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
  262. Please upgrade to 1.1.0 or better)
  263. fi
  264. AC_MSG_CHECKING([for working libnet_checksum()])
  265. AC_TRY_RUN([
  266. #include <string.h>
  267. #include "$LNETINC"
  268. #define LIB_TEST "1.1.3"
  269. /*
  270. * simple proggy to test the version of libnet
  271. * returns zero if it's < 1.1.3 which has the checksum fix
  272. * or one otherwise
  273. */
  274. int
  275. main (int argc, char *argv[])
  276. {
  277. if (strncmp(LIB_TEST, LIBNET_VERSION, 5) <= 0)
  278. exit(0);
  279. exit(1);
  280. }],
  281. libnet_ver_113=yes,
  282. libnet_ver_113=no,
  283. libnet_ver_113=no
  284. )
  285. if test $libnet_ver_113 = no ; then
  286. AC_MSG_RESULT(no)
  287. AC_MSG_WARN([You should upgrade to libnet 1.1.3 or better if you
  288. want to modify packets])
  289. else
  290. AC_MSG_RESULT(yes)
  291. fi
  292. dnl restore LIBS & CFLAGS
  293. LIBS="$OLDLIBS"
  294. CFLAGS="$OLDCFLAGS"
  295. dnl #####################################################
  296. dnl Checks for libpcap
  297. dnl #####################################################
  298. foundpcap=no
  299. trypcapdir=/usr/local
  300. AC_MSG_CHECKING(for libpcap)
  301. AC_ARG_WITH(libpcap,
  302. AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]),
  303. [trypcapdir=$withval])
  304. for testdir in $trypcapdir /usr/local /usr ; do
  305. if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then
  306. LPCAPINC="${testdir}/include/pcap.h"
  307. LPCAPINCDIR="${testdir}/include"
  308. if test $dynamic_link = yes; then
  309. LPCAPLIB="-L${testdir}/lib -lpcap"
  310. elif test -f "${testdir}/lib64/libpcap.a" ; then
  311. LPCAPLIB="${testdir}/lib64/libpcap.a"
  312. else
  313. LPCAPLIB="${testdir}/lib/libpcap.a"
  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. AC_SUBST(LPCAPINC)
  325. AC_SUBST(LPCAPLIB)
  326. dnl Checks to see what version of libpcap we've got
  327. OLDLIBS="$LIBS"
  328. OLDCFLAGS="$CFLAGS"
  329. LIBS="$LPCAPLIB"
  330. CFLAGS="$CFLAGS -I$LPCAPINCDIR"
  331. dnl Check to see what version of libpcap
  332. dnl this code has been reduced a lot, but probably still could be
  333. dnl reduced quite a bit more if we chose too
  334. AC_MSG_CHECKING(for libpcap version)
  335. AC_TRY_RUN([
  336. #include <string.h>
  337. #include <stdlib.h>
  338. #include <stdio.h>
  339. #include "$LPCAPINC"
  340. #define PCAP_TEST "0.5"
  341. /*
  342. * simple proggy to test the version of libpcap
  343. * returns zero if version >= 0.5
  344. * or one otherwise
  345. */
  346. extern char pcap_version[];
  347. int
  348. main (int argc, char *argv[])
  349. {
  350. if (strncmp(pcap_version, PCAP_TEST, 3) >= 0)
  351. exit(0);
  352. exit(1);
  353. }],
  354. libpcap_ver=yes
  355. AC_MSG_RESULT(>= 0.5),
  356. libpcap_ver=no
  357. AC_MSG_RESULT(< 0.5),
  358. libpcap_ver=no
  359. )
  360. if test $libpcap_ver = no ; then
  361. AC_MSG_ERROR(Libpcap versions < 0.5 are not supported.
  362. Please upgrade to version 0.5 or better)
  363. fi
  364. dnl Check to see if we've got pcap_datalink_val_to_name()
  365. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  366. AC_TRY_RUN([
  367. #include <stdio.h>
  368. #include <stdlib.h>
  369. #include <string.h>
  370. #include "$LPCAPINC"
  371. int
  372. main(int argc, char *argv[]) {
  373. pcap_datalink_val_to_description(1);
  374. exit(0);
  375. }
  376. ],
  377. have_dlt_to_desc=yes
  378. AC_MSG_RESULT(yes),
  379. have_dlt_to_desc=no
  380. AC_MSG_RESULT(no),
  381. have_dlt_to_desc=no
  382. )
  383. if test $have_dlt_to_desc = yes ; then
  384. AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [],
  385. [Does libpcap have dlt_val_to_desc?])
  386. fi
  387. dnl Older versions of libpcap are missing some DLT types
  388. dnl If doesn't exist, we'll define them in src/common/fakepcap.h
  389. AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
  390. AC_TRY_COMPILE([#include "$LPCAPINC"],
  391. [ int foo;
  392. foo = DLT_LINUX_SLL ],
  393. [ AC_DEFINE([HAVE_DLT_LINUX_SLL],
  394. [], [Does pcap.h include a header with DLT_LINUX_SLL?])
  395. AC_MSG_RESULT(yes)
  396. ],
  397. AC_MSG_RESULT(no)
  398. )
  399. AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
  400. AC_TRY_COMPILE([#include "$LPCAPINC"],
  401. [ int foo;
  402. foo = DLT_C_HDLC ],
  403. [ AC_DEFINE([HAVE_DLT_C_HDLC],
  404. [], [Does pcap.h include a header with DLT_C_HDLC?])
  405. AC_MSG_RESULT(yes)
  406. ],
  407. AC_MSG_RESULT(no)
  408. )
  409. PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
  410. AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
  411. AC_TRY_COMPILE([#include <sys/types.h>
  412. #include <sys/time.h>
  413. #include "$PCAP_BPF_H_FILE"],
  414. [ int foo;
  415. foo = BPF_MAJOR_VERSION; ],
  416. [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [],
  417. [What is the path (if any) to the pcap-bpf.h
  418. header?])
  419. AC_MSG_RESULT(yes)
  420. AC_SUBST(PCAP_BPF_H_FILE)
  421. ],
  422. AC_MSG_RESULT(no)
  423. )
  424. dnl restore LIBS & CFLAGS
  425. LIBS="$OLDLIBS"
  426. CFLAGS="$OLDCFLAGS"
  427. dnl ##################################################
  428. dnl # Check for pcapnav
  429. dnl ##################################################
  430. pcapnav_ver=no
  431. pcncfg=no
  432. AC_ARG_WITH(pcapnav-config,
  433. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  434. [ AC_MSG_CHECKING(for pcapnav-config)
  435. if test -x $withval ; then
  436. pcncfg=$withval
  437. AC_MSG_RESULT($pcncfg)
  438. else
  439. AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
  440. fi ],
  441. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
  442. )
  443. if test $pcncfg != no ; then
  444. LNAVLIB=`$pcncfg --libs`
  445. LNAV_CFLAGS=`$pcncfg --cflags`
  446. PCAPNAV_VERSION=`$pcncfg --version`
  447. AC_SUBST(LNAVLIB)
  448. AC_SUBST(LNAV_CFLAGS)
  449. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION",
  450. [libpcapnav's version?])
  451. dnl Check to see what version of libpcapnav
  452. dnl this code has been reduced a lot, but probably still could be
  453. dnl reduced quite a bit more if we chose too
  454. AC_MSG_CHECKING(for libpcapnav version)
  455. AC_TRY_RUN([
  456. #include <string.h>
  457. #define PCAPNAV_TEST "0.4"
  458. /*
  459. * simple proggy to test the version of libpcapnav
  460. * returns zero if version >= 0.4
  461. * or one otherwise
  462. */
  463. int
  464. main (int argc, char *argv[])
  465. {
  466. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  467. exit(0);
  468. exit(1);
  469. }],
  470. libpcapnav_ver=yes
  471. AC_MSG_RESULT(>= 0.4),
  472. libpcapnav_ver=no
  473. AC_MSG_RESULT(< 0.4),
  474. libpcapnav_ver=no
  475. )
  476. if test x$libpcapnav_ver = xno ; then
  477. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  478. Please upgrade to version 0.4 or better.
  479. Disabling offset jump feature.])
  480. else
  481. AC_DEFINE([HAVE_PCAPNAV], [], [Do we have libpcapnav?])
  482. fi
  483. fi # checking pcapnav version
  484. dnl #####################################################
  485. dnl Checks for libnids
  486. dnl #####################################################
  487. foundnids=no
  488. trynidsdir=/usr/local
  489. AC_MSG_CHECKING(for libnids)
  490. AC_ARG_WITH(libnids,
  491. AC_HELP_STRING([--with-libnids=DIR], [Use libnids in DIR]),
  492. [trynidsdir=$withval])
  493. for testdir in $trynidsdir /usr/local /usr ; do
  494. if test -f "${testdir}/include/nids.h" -a $foundnids = no ; then
  495. LNIDSINC="${testdir}/include/nids.h"
  496. LNIDSINCDIR="${testdir}/include"
  497. dnl Libnids by default doesn't build a dynamic library and due to a
  498. dnl bug, won't build one for OS X, so we link to the static
  499. dnl LNIDSLIB="${testdir}/lib -lnids"
  500. LNIDSLIB="${testdir}/lib/libnids.a"
  501. foundnids=$testdir
  502. fi
  503. done
  504. if test $foundnids = no ; then
  505. AC_MSG_RESULT(no)
  506. AC_MSG_WARN(libnids not found. We won't build flowreplay.)
  507. else
  508. AC_MSG_RESULT($foundnids)
  509. AC_DEFINE([HAVE_LIBNIDS], [], [Do we have libnids?])
  510. fi
  511. AC_SUBST(LNIDSINC)
  512. AC_SUBST(LNIDSLIB)
  513. AM_CONDITIONAL([HAVE_LIBNIDS], [ test ${foundnids} != no ])
  514. dnl (shamelessly ripped off from libpcap)
  515. dnl Checks to see if unaligned memory accesses fail
  516. dnl
  517. dnl FORCE_ALIGN (DEFINED)
  518. dnl
  519. AC_MSG_CHECKING(for requires strict byte alignment)
  520. AC_CACHE_VAL(unaligned_fail,
  521. [case "$host_cpu" in
  522. # XXX: should also check that they don't do weird things (like on arm)
  523. alpha*|arm*|hp*|mips*|sparc*|ia64)
  524. unaligned_fail=yes
  525. ;;
  526. *)
  527. cat >conftest.c <<EOF
  528. #include <sys/types.h>
  529. #include <sys/wait.h>
  530. #include <stdio.h>
  531. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  532. main() {
  533. unsigned int i;
  534. pid_t pid;
  535. int status;
  536. /* avoid "core dumped" message */
  537. pid = fork();
  538. if (pid < 0)
  539. exit(2);
  540. if (pid > 0) {
  541. /* parent */
  542. pid = waitpid(pid, &status, 0);
  543. if (pid < 0)
  544. exit(3);
  545. exit(!WIFEXITED(status));
  546. }
  547. /* child */
  548. i = *(unsigned int *)&a[[1]];
  549. printf("%d\n", i);
  550. exit(0);
  551. }
  552. EOF
  553. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  554. conftest.c $LIBS >/dev/null 2>&1
  555. if test ! -x conftest ; then
  556. dnl failed to compile for some reason
  557. unaligned_fail=yes
  558. else
  559. ./conftest >conftest.out
  560. if test ! -s conftest.out ; then
  561. unaligned_fail=yes
  562. else
  563. unaligned_fail=no
  564. fi
  565. fi
  566. rm -f conftest* core core.conftest
  567. ;;
  568. esac])
  569. AC_MSG_RESULT($unaligned_fail)
  570. if test $unaligned_fail = yes ; then
  571. AC_DEFINE([FORCE_ALIGN],1,[Are we strictly aligned?])
  572. fi
  573. dnl ##################################################
  574. dnl # Check for tcpdump.
  575. dnl ##################################################
  576. td=no
  577. AC_ARG_WITH(tcpdump,
  578. AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
  579. [ if test -x $withval ; then
  580. td=$withval
  581. AC_MSG_RESULT([Using tcpdump in $td])
  582. else
  583. AC_MSG_RESULT([Error: $withval does not exist or is not executable])
  584. fi ],
  585. [ AC_PATH_PROG(td, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
  586. if test "$td" = "no"; then
  587. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  588. Disabling verbose reporting.])
  589. else
  590. AC_DEFINE([HAVE_TCPDUMP], [], [Do we have tcpdump?])
  591. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$td", [The tcpdump binary initially used])
  592. fi
  593. dnl No 'make test' when cross compile
  594. AC_MSG_CHECKING( for 'make test' profile)
  595. if test "$host" != "$build" ; then
  596. AC_MSG_WARN(Unable to do tests when cross-compiling)
  597. fi
  598. dnl Allows user to choose which nic to use for testing purposes
  599. AC_ARG_WITH(testnic,
  600. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  601. [ nic1=$withval
  602. nic2=$withval
  603. AC_MSG_RESULT([Using --with-testnic=$withval])],
  604. [
  605. dnl these need to be dynamic based on OS
  606. case $host in
  607. *-*-linux*)
  608. nic1=eth0
  609. nic2=eth0
  610. AC_MSG_RESULT(Linux)
  611. ;;
  612. *-*-solaris*)
  613. nic1=hme0
  614. nic2=hme0
  615. AC_MSG_RESULT(Solaris)
  616. ;;
  617. *-*-sunos*)
  618. nic1=hme0
  619. nic2=hme0
  620. AC_MSG_RESULT(SunOS)
  621. ;;
  622. powerpc-apple-darwin*)
  623. nic1=en0
  624. nic2=en0
  625. AC_MSG_RESULT(Apple OS X)
  626. ;;
  627. *-*-openbsd*)
  628. nic1=xl0
  629. nic2=xl0
  630. AC_MSG_RESULT(OpenBSD)
  631. ;;
  632. *)
  633. AC_MSG_RESULT([$host is unknown!
  634. Please use --with-nictest to select an interface for 'make test'])
  635. ;;
  636. esac])
  637. AC_ARG_WITH(testnic2,
  638. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  639. [ nic2=$withval ])
  640. AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])
  641. AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
  642. AC_SUBST(nic1)
  643. AC_SUBST(nic2)
  644. LIBOPTS_CHECK
  645. AC_OUTPUT([Makefile
  646. doxygen.cfg
  647. lib/Makefile
  648. docs/Makefile
  649. src/Makefile
  650. src/common/Makefile
  651. src/defines.h
  652. test/Makefile
  653. test/config
  654. scripts/Makefile
  655. tcpreplay.spec])