1
0

configure.in 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. dnl $Id: configure.in 1037 2004-12-03 23:51:38Z aturner $
  2. AC_INIT(tcpreplay.c)
  3. AC_CONFIG_HEADER(config.h)
  4. dnl Set version info here!
  5. MAJOR_VERSION=2
  6. MINOR_VERSION=3
  7. MICRO_VERSION=3
  8. TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
  9. dnl Release is only used for the RPM spec file
  10. TCPREPLAY_RELEASE=1
  11. AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION")
  12. AC_SUBST(TCPREPLAY_VERSION)
  13. AC_SUBST(TCPREPLAY_RELEASE)
  14. dnl Initialize prefix.
  15. if test "$prefix" = "NONE"; then
  16. prefix="/usr/local"
  17. fi
  18. dnl Determine OS
  19. AC_CANONICAL_BUILD
  20. AC_CANONICAL_HOST
  21. AC_CANONICAL_TARGET
  22. AC_SUBST(host)
  23. AC_SUBST(build)
  24. AC_SUBST(target)
  25. AC_C_BIGENDIAN
  26. dnl Checks for programs.
  27. AC_PROG_CC
  28. AC_PROG_CXX
  29. AC_PROG_CPP
  30. AC_PROG_LN_S
  31. AC_PROG_RANLIB
  32. AC_PROG_AWK
  33. AC_PROG_INSTALL
  34. AC_PROG_MAKE_SET
  35. AC_PATH_PROG(PRINTF, printf)
  36. AC_SUBST(PRINTF)
  37. dnl Checks for typedefs, structures, and compiler characteristics.
  38. AC_TYPE_SIZE_T
  39. AC_HEADER_TIME
  40. AC_C_CONST
  41. AC_C_INLINE
  42. AC_SYS_LARGEFILE
  43. dnl Check for functions
  44. AC_FUNC_FSEEKO
  45. dnl Enable debugging in code/compiler options
  46. debug=no
  47. AC_MSG_CHECKING(for debug enabled)
  48. AC_ARG_WITH(debug,
  49. [ --with-debug Enable debugging code and support for the -d option],
  50. [ debug=yes
  51. AC_DEFINE(DEBUG)
  52. AC_MSG_RESULT(yes)],
  53. AC_MSG_RESULT(no))
  54. dnl Use a debug flag during make test if debug is enabled
  55. if test $debug = yes ; then
  56. debug_flag="-d 3"
  57. AC_SUBST(debug_flag)
  58. fi
  59. dnl Enable Efense
  60. efence=no
  61. AC_MSG_CHECKING(for efence enabled)
  62. AC_ARG_WITH(efence,
  63. [ --with-efence Enable Electric Fence memory debugger],
  64. [ efence=yes
  65. AC_DEFINE(EFENCE)
  66. AC_MSG_RESULT(yes)],
  67. AC_MSG_RESULT(no)
  68. )
  69. dnl Enable Gprof
  70. gprof=no
  71. AC_MSG_CHECKING(for gprof enabled)
  72. AC_ARG_WITH(gprof,
  73. [ --with-gprof Enable GNU Profiler],
  74. [ gprof=yes
  75. AC_DEFINE(GPROF)
  76. AC_MSG_RESULT(yes)],
  77. AC_MSG_RESULT(no)
  78. )
  79. dnl Use these compiler flags if we have gcc.
  80. if test $ac_cv_prog_gcc = yes -a $debug = no ; then
  81. CCOPTS="-pipe -Wall -O3 -funroll-loops"
  82. CFLAGS="$CCOPTS"
  83. else
  84. CCOPTS="-pipe -Wall -ggdb -pedantic"
  85. CFLAGS="$CCOPTS"
  86. fi
  87. dnl Gprof requires -ggdb
  88. if test $gprof = yes -a $debug = yes ; then
  89. CCOPTS="$CCOPTS -pg"
  90. CFLAGS="$CCOPTS"
  91. elif test $gprof = yes -a $debug = no ; then
  92. CCOPTS="-pipe -Wall -pg -ggdb"
  93. CFLAGS="$CCOPTS"
  94. fi
  95. dnl Electric Fence
  96. if test $efence = yes ; then
  97. CCOPTS="$CCOPTS -lefence"
  98. CFLAGS="$CCOPTS"
  99. fi
  100. dnl gprof
  101. if test $gprof = yes ; then
  102. CCOPTS="$CCOPTS -fprofile-arcs"
  103. CFLAGS="$CCOPTS"
  104. fi
  105. dnl Check for types.
  106. AC_CHECK_TYPE(u_int8_t, uint8_t)
  107. AC_CHECK_TYPE(u_int16_t, uint16_t)
  108. AC_CHECK_TYPE(u_int32_t, uint32_t)
  109. AC_CHECK_TYPE(u_int64_t, uint64_t)
  110. dnl Check for other header files
  111. 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])
  112. dnl Checks for libraries.
  113. AC_CHECK_LIB(socket, socket)
  114. AC_CHECK_LIB(nsl, gethostbyname)
  115. AC_CHECK_LIB(rt, nanosleep)
  116. dnl Checks for library functions.
  117. AC_FUNC_MALLOC
  118. AC_FUNC_MEMCMP
  119. AC_TYPE_SIGNAL
  120. AC_FUNC_VPRINTF
  121. AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strerror strtol strncpy strtoull poll])
  122. dnl Check for inet_aton and inet_addr
  123. AC_CHECK_FUNC(inet_aton, AC_DEFINE(INET_ATON) inet_aton=yes, inet_aton=no)
  124. AC_CHECK_FUNC(inet_addr, AC_DEFINE(INET_ADDR) inet_addr=yes, inet_addr=no)
  125. if test $inet_aton = no -a $inet_addr = no ; then
  126. AC_MSG_ERROR("We need either inet_aton or inet_addr")
  127. fi
  128. dnl ##################################################
  129. dnl Checks for libnet (shamelessly horked from dsniff)
  130. dnl ##################################################
  131. foundnet=no
  132. trynetdir=/usr/local
  133. AC_MSG_CHECKING(for libnet)
  134. AC_ARG_WITH([libnet],
  135. AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
  136. [trynetdir=$withval])
  137. for testdir in $trynetdir /usr/local /usr ; do
  138. if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
  139. LNETINC="-I${testdir}/include"
  140. LNETINCDIR="$testdir/include"
  141. LNETLIB="-L${testdir}/lib -lnet"
  142. foundnet=$testdir
  143. fi
  144. done
  145. if test $foundnet = no ; then
  146. AC_MSG_RESULT(no)
  147. AC_ERROR(libnet not found)
  148. else
  149. AC_MSG_RESULT($foundnet)
  150. fi
  151. AC_SUBST(LNETINC)
  152. AC_SUBST(LNETLIB)
  153. OLDLIBS="$LIBS"
  154. LIBS="$LNETLIB"
  155. dnl Check to see what version of libnet
  156. dnl this code has been reduced a lot, but probably still could be
  157. dnl reduced quite a bit more if we chose too
  158. AC_MSG_CHECKING(for libnet version)
  159. AC_TRY_RUN([
  160. #include <string.h>
  161. #define LIBNET_LIL_ENDIAN 1
  162. #include "$LNETINCDIR/libnet.h"
  163. #define LIB_TEST "1.0"
  164. /*
  165. * simple proggy to test the version of libnet
  166. * returns zero if it's 1.0.x
  167. * or one otherwise
  168. */
  169. int
  170. main (int argc, char *argv[])
  171. {
  172. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  173. exit(0);
  174. exit(1);
  175. }],
  176. libnet_ver_10=yes
  177. AC_MSG_RESULT(1.0.x),
  178. libnet_ver_10=no,
  179. libnet_ver_10=no
  180. )
  181. AC_TRY_RUN([
  182. #include <string.h>
  183. #include "$LNETINCDIR/libnet.h"
  184. #define LIB_TEST "1.1"
  185. /*
  186. * simple proggy to test the version of libnet
  187. * returns zero if it's 1.0.x
  188. * or one otherwise
  189. */
  190. int
  191. main (int argc, char *argv[])
  192. {
  193. if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
  194. exit(0);
  195. exit(1);
  196. }],
  197. libnet_ver_11=yes
  198. AC_MSG_RESULT(1.1.x),
  199. libnet_ver_11=no,
  200. libnet_ver_11=no
  201. )
  202. if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
  203. AC_MSG_RESULT(unknown)
  204. AC_MSG_ERROR(Unable to determine version of libnet)
  205. fi
  206. if test $libnet_ver_10 = yes ; then
  207. AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
  208. Please upgrade to 1.1.0 or better)
  209. fi
  210. dnl restore LIBS
  211. LIBS="$OLDLIBS"
  212. dnl #####################################################
  213. dnl Checks for libpcap
  214. dnl #####################################################
  215. foundpcap=no
  216. trypcapdir=/usr/local
  217. AC_MSG_CHECKING(for libpcap)
  218. AC_ARG_WITH([libpcap],
  219. AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]),
  220. [trypcapdir=$withval])
  221. for testdir in $trypcapdir /usr/local /usr ; do
  222. if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then
  223. LPCAPINC="-I${testdir}/include"
  224. LPCAPINCDIR="${testdir}/include"
  225. LPCAPLIB="-L${testdir}/lib -lpcap"
  226. foundpcap=$testdir
  227. fi
  228. done
  229. if test $foundpcap = no ; then
  230. AC_MSG_RESULT(no)
  231. AC_ERROR(libpcap not found)
  232. else
  233. AC_MSG_RESULT($foundpcap)
  234. fi
  235. AC_SUBST(LPCAPINC)
  236. AC_SUBST(LPCAPLIB)
  237. dnl Checks to see what version of libpcap we've got
  238. OLDLIBS="$LIBS"
  239. LIBS="$LPCAPLIB"
  240. dnl Check to see what version of libpcap
  241. dnl this code has been reduced a lot, but probably still could be
  242. dnl reduced quite a bit more if we chose too
  243. AC_MSG_CHECKING(for libpcap version)
  244. AC_TRY_RUN([
  245. #include <string.h>
  246. #include "$LPCAPINCDIR/pcap.h"
  247. #define PCAP_TEST "0.6"
  248. /*
  249. * simple proggy to test the version of libpcap
  250. * returns zero if version >= 0.6
  251. * or one otherwise
  252. */
  253. extern char pcap_version[];
  254. int
  255. main (int argc, char *argv[])
  256. {
  257. if (strncmp(pcap_version, PCAP_TEST, 3) >= 0)
  258. exit(0);
  259. exit(1);
  260. }],
  261. libpcap_ver=yes
  262. AC_MSG_RESULT(>= 0.6),
  263. libpcap_ver=no
  264. AC_MSG_RESULT(< 0.6),
  265. libpcap_ver=no
  266. )
  267. if test $libpcap_ver = no ; then
  268. AC_MSG_ERROR(Libpcap versions < 0.6 are no longer supported.
  269. Please upgrade to version 0.6 or better)
  270. fi
  271. dnl Check to see if we've got pcap_datalink_val_to_name()
  272. AC_MSG_CHECKING(for pcap_datalink_val_to_description)
  273. AC_TRY_RUN([
  274. #include <stdio.h>
  275. #include "$LPCAPINCDIR/pcap.h"
  276. int
  277. main(int argc, char *argv[]) {
  278. char name[100];
  279. strncpy(name, pcap_datalink_val_to_description(1), 99);
  280. exit(0);
  281. }
  282. ],
  283. have_dlt_to_desc=yes
  284. AC_MSG_RESULT(yes),
  285. have_dlt_to_desc=no
  286. AC_MSG_RESULT(no),
  287. have_dlt_to_desc=no
  288. )
  289. if test $have_dlt_to_desc = yes ; then
  290. AC_DEFINE(HAVE_DLT_VAL_TO_DESC)
  291. fi
  292. dnl restore LIBS
  293. LIBS="$OLDLIBS"
  294. dnl ##################################################
  295. dnl # Check for pcapnav
  296. dnl ##################################################
  297. pcapnav_ver=no
  298. pcncfg=no
  299. AC_ARG_WITH(pcapnav-config,
  300. AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
  301. [pcncfg=$withval],
  302. [ AC_PATH_PROG(pcncfg,[pcapnav-config], [] ) ])
  303. if test $pcncfg = no ; then
  304. AC_MSG_RESULT(Cannot find pcapnav-config: Disabling offset jump feature.)
  305. else
  306. AC_MSG_RESULT($pcncfg)
  307. LNAVLIB=`$pcncfg --libs`
  308. LNAV_CFLAGS=`$pcncfg --cflags`
  309. PCAPNAV_VERSION=`$pcncfg --version`
  310. AC_SUBST(LNAVLIB)
  311. AC_SUBST(LNAV_CFLAGS)
  312. AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION")
  313. dnl Check to see what version of libpcapnav
  314. dnl this code has been reduced a lot, but probably still could be
  315. dnl reduced quite a bit more if we chose too
  316. AC_MSG_CHECKING(for libpcapnav version)
  317. AC_TRY_RUN([
  318. #include <string.h>
  319. #define PCAPNAV_TEST "0.4"
  320. /*
  321. * simple proggy to test the version of libpcapnav
  322. * returns zero if version >= 0.4
  323. * or one otherwise
  324. */
  325. int
  326. main (int argc, char *argv[])
  327. {
  328. if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
  329. exit(0);
  330. exit(1);
  331. }],
  332. libpcapnav_ver=yes
  333. AC_MSG_RESULT(>= 0.4),
  334. libpcapnav_ver=no
  335. AC_MSG_RESULT(< 0.4),
  336. libpcapnav_ver=no
  337. )
  338. if test $libpcapnav_ver = no ; then
  339. AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported.
  340. Please upgrade to version 0.4 or better.
  341. Disabling offset jump feature.])
  342. else
  343. AC_DEFINE(HAVE_PCAPNAV)
  344. fi
  345. fi # checking pcapnav version
  346. dnl (shamelessly ripped off from libpcap)
  347. dnl Checks to see if unaligned memory accesses fail
  348. dnl
  349. dnl FORCE_ALIGN (DEFINED)
  350. dnl
  351. AC_MSG_CHECKING(for requires strict byte alignment)
  352. AC_CACHE_VAL(unaligned_fail,
  353. [case "$host_cpu" in
  354. # XXX: should also check that they don't do weird things (like on arm)
  355. alpha*|arm*|hp*|mips*|sparc*|ia64)
  356. unaligned_fail=yes
  357. ;;
  358. *)
  359. cat >conftest.c <<EOF
  360. #include <sys/types.h>
  361. #include <sys/wait.h>
  362. #include <stdio.h>
  363. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  364. main() {
  365. unsigned int i;
  366. pid_t pid;
  367. int status;
  368. /* avoid "core dumped" message */
  369. pid = fork();
  370. if (pid < 0)
  371. exit(2);
  372. if (pid > 0) {
  373. /* parent */
  374. pid = waitpid(pid, &status, 0);
  375. if (pid < 0)
  376. exit(3);
  377. exit(!WIFEXITED(status));
  378. }
  379. /* child */
  380. i = *(unsigned int *)&a[[1]];
  381. printf("%d\n", i);
  382. exit(0);
  383. }
  384. EOF
  385. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  386. conftest.c $LIBS >/dev/null 2>&1
  387. if test ! -x conftest ; then
  388. dnl failed to compile for some reason
  389. unaligned_fail=yes
  390. else
  391. ./conftest >conftest.out
  392. if test ! -s conftest.out ; then
  393. unaligned_fail=yes
  394. else
  395. unaligned_fail=no
  396. fi
  397. fi
  398. rm -f conftest* core core.conftest
  399. ;;
  400. esac])
  401. AC_MSG_RESULT($unaligned_fail)
  402. if test $unaligned_fail = yes ; then
  403. AC_DEFINE(FORCE_ALIGN,1,[if unaligned access fails])
  404. fi
  405. dnl ##################################################
  406. dnl # Check for tcpdump.
  407. dnl ##################################################
  408. AC_ARG_WITH(tcpdump,
  409. AC_HELP_STRING([--with-tcpdump=FILE],[Path to tcpdump binary]),
  410. [td=$withval],
  411. [td=no])
  412. AC_PATH_PROG(td, tcpdump, "no",[$PATH:/usr/sbin:/sbin:/usr/local/sbin])
  413. if test $td = no ; then
  414. AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump.
  415. Disabling verbose reporting.])
  416. else
  417. AC_MSG_RESULT([Using tcpdump in $td.])
  418. AC_DEFINE(HAVE_TCPDUMP)
  419. AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$td", [The tcpdump binary initially used])
  420. fi
  421. dnl No 'make test' when cross compile
  422. AC_MSG_CHECKING( for 'make test' profile)
  423. if test "$host" != "$build" ; then
  424. AC_MSG_WARN(Unable to do tests when cross-compiling)
  425. fi
  426. dnl Allows user to choose which nic to use for testing purposes
  427. AC_ARG_WITH(testnic,
  428. AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
  429. [nic1=$withval
  430. nic2=$withval
  431. AC_MSG_RESULT([Using --with-testnic=$withval])],
  432. [
  433. dnl these need to be dynamic based on OS
  434. case $host in
  435. *-*-linux*)
  436. nic1=eth0
  437. nic2=eth0
  438. AC_MSG_RESULT(Linux)
  439. ;;
  440. *-*-solaris*)
  441. nic1=hme0
  442. nic2=hme0
  443. AC_MSG_RESULT(Solaris)
  444. ;;
  445. *-*-sunos*)
  446. nic1=hme0
  447. nic2=hme0
  448. AC_MSG_RESULT(SunOS)
  449. ;;
  450. powerpc-apple-darwin*)
  451. nic1=en0
  452. nic2=en0
  453. AC_MSG_RESULT(Apple OSX)
  454. ;;
  455. *-*-openbsd*)
  456. nic1=xl0
  457. nic2=xl0
  458. AC_MSG_RESULT(OpenBSD)
  459. ;;
  460. *)
  461. AC_MSG_RESULT([$host is unknown!
  462. Please use --with-nictest to select an interface for 'make test'])
  463. ;;
  464. esac])
  465. AC_ARG_WITH(testnic2,
  466. AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
  467. [nic2=$withval])
  468. AC_MSG_NOTICE(Using $nic1 for 1st test network interface card)
  469. AC_MSG_NOTICE(Using $nic2 for 2nd test network interface card)
  470. AC_SUBST(nic1)
  471. AC_SUBST(nic2)
  472. AC_OUTPUT(Makefile)
  473. AC_OUTPUT(test/Makefile)
  474. AC_OUTPUT(test/config)
  475. AC_OUTPUT(tcpreplay.spec)