dnl $Id: configure.in 1037 2004-12-03 23:51:38Z aturner $ AC_INIT(tcpreplay.c) AC_CONFIG_HEADER(config.h) dnl Set version info here! MAJOR_VERSION=2 MINOR_VERSION=3 MICRO_VERSION=3 TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION dnl Release is only used for the RPM spec file TCPREPLAY_RELEASE=1 AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION") AC_SUBST(TCPREPLAY_VERSION) AC_SUBST(TCPREPLAY_RELEASE) dnl Initialize prefix. if test "$prefix" = "NONE"; then prefix="/usr/local" fi dnl Determine OS AC_CANONICAL_BUILD AC_CANONICAL_HOST AC_CANONICAL_TARGET AC_SUBST(host) AC_SUBST(build) AC_SUBST(target) AC_C_BIGENDIAN dnl Checks for programs. AC_PROG_CC AC_PROG_CXX AC_PROG_CPP AC_PROG_LN_S AC_PROG_RANLIB AC_PROG_AWK AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PATH_PROG(PRINTF, printf) AC_SUBST(PRINTF) dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T AC_HEADER_TIME AC_C_CONST AC_C_INLINE AC_SYS_LARGEFILE dnl Check for functions AC_FUNC_FSEEKO dnl Enable debugging in code/compiler options debug=no AC_MSG_CHECKING(for debug enabled) AC_ARG_WITH(debug, [ --with-debug Enable debugging code and support for the -d option], [ debug=yes AC_DEFINE(DEBUG) AC_MSG_RESULT(yes)], AC_MSG_RESULT(no)) dnl Use a debug flag during make test if debug is enabled if test $debug = yes ; then debug_flag="-d 3" AC_SUBST(debug_flag) fi dnl Enable Efense efence=no AC_MSG_CHECKING(for efence enabled) AC_ARG_WITH(efence, [ --with-efence Enable Electric Fence memory debugger], [ efence=yes AC_DEFINE(EFENCE) AC_MSG_RESULT(yes)], AC_MSG_RESULT(no) ) dnl Enable Gprof gprof=no AC_MSG_CHECKING(for gprof enabled) AC_ARG_WITH(gprof, [ --with-gprof Enable GNU Profiler], [ gprof=yes AC_DEFINE(GPROF) AC_MSG_RESULT(yes)], AC_MSG_RESULT(no) ) dnl Use these compiler flags if we have gcc. if test $ac_cv_prog_gcc = yes -a $debug = no ; then CCOPTS="-pipe -Wall -O3 -funroll-loops" CFLAGS="$CCOPTS" else CCOPTS="-pipe -Wall -ggdb -pedantic" CFLAGS="$CCOPTS" fi dnl Gprof requires -ggdb if test $gprof = yes -a $debug = yes ; then CCOPTS="$CCOPTS -pg" CFLAGS="$CCOPTS" elif test $gprof = yes -a $debug = no ; then CCOPTS="-pipe -Wall -pg -ggdb" CFLAGS="$CCOPTS" fi dnl Electric Fence if test $efence = yes ; then CCOPTS="$CCOPTS -lefence" CFLAGS="$CCOPTS" fi dnl gprof if test $gprof = yes ; then CCOPTS="$CCOPTS -fprofile-arcs" CFLAGS="$CCOPTS" fi dnl Check for types. AC_CHECK_TYPE(u_int8_t, uint8_t) AC_CHECK_TYPE(u_int16_t, uint16_t) AC_CHECK_TYPE(u_int32_t, uint32_t) AC_CHECK_TYPE(u_int64_t, uint64_t) dnl Check for other header files 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]) dnl Checks for libraries. AC_CHECK_LIB(socket, socket) AC_CHECK_LIB(nsl, gethostbyname) AC_CHECK_LIB(rt, nanosleep) dnl Checks for library functions. AC_FUNC_MALLOC AC_FUNC_MEMCMP AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strerror strtol strncpy strtoull poll]) dnl Check for inet_aton and inet_addr AC_CHECK_FUNC(inet_aton, AC_DEFINE(INET_ATON) inet_aton=yes, inet_aton=no) AC_CHECK_FUNC(inet_addr, AC_DEFINE(INET_ADDR) inet_addr=yes, inet_addr=no) if test $inet_aton = no -a $inet_addr = no ; then AC_MSG_ERROR("We need either inet_aton or inet_addr") fi dnl ################################################## dnl Checks for libnet (shamelessly horked from dsniff) dnl ################################################## foundnet=no trynetdir=/usr/local AC_MSG_CHECKING(for libnet) AC_ARG_WITH([libnet], AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]), [trynetdir=$withval]) for testdir in $trynetdir /usr/local /usr ; do if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then LNETINC="-I${testdir}/include" LNETINCDIR="$testdir/include" LNETLIB="-L${testdir}/lib -lnet" foundnet=$testdir fi done if test $foundnet = no ; then AC_MSG_RESULT(no) AC_ERROR(libnet not found) else AC_MSG_RESULT($foundnet) fi AC_SUBST(LNETINC) AC_SUBST(LNETLIB) OLDLIBS="$LIBS" LIBS="$LNETLIB" dnl Check to see what version of libnet dnl this code has been reduced a lot, but probably still could be dnl reduced quite a bit more if we chose too AC_MSG_CHECKING(for libnet version) AC_TRY_RUN([ #include #define LIBNET_LIL_ENDIAN 1 #include "$LNETINCDIR/libnet.h" #define LIB_TEST "1.0" /* * simple proggy to test the version of libnet * returns zero if it's 1.0.x * or one otherwise */ int main (int argc, char *argv[]) { if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0) exit(0); exit(1); }], libnet_ver_10=yes AC_MSG_RESULT(1.0.x), libnet_ver_10=no, libnet_ver_10=no ) AC_TRY_RUN([ #include #include "$LNETINCDIR/libnet.h" #define LIB_TEST "1.1" /* * simple proggy to test the version of libnet * returns zero if it's 1.0.x * or one otherwise */ int main (int argc, char *argv[]) { if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0) exit(0); exit(1); }], libnet_ver_11=yes AC_MSG_RESULT(1.1.x), libnet_ver_11=no, libnet_ver_11=no ) if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then AC_MSG_RESULT(unknown) AC_MSG_ERROR(Unable to determine version of libnet) fi if test $libnet_ver_10 = yes ; then AC_MSG_ERROR(Libnet version 1.0.x is no longer supported. Please upgrade to 1.1.0 or better) fi dnl restore LIBS LIBS="$OLDLIBS" dnl ##################################################### dnl Checks for libpcap dnl ##################################################### foundpcap=no trypcapdir=/usr/local AC_MSG_CHECKING(for libpcap) AC_ARG_WITH([libpcap], AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]), [trypcapdir=$withval]) for testdir in $trypcapdir /usr/local /usr ; do if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then LPCAPINC="-I${testdir}/include" LPCAPINCDIR="${testdir}/include" LPCAPLIB="-L${testdir}/lib -lpcap" foundpcap=$testdir fi done if test $foundpcap = no ; then AC_MSG_RESULT(no) AC_ERROR(libpcap not found) else AC_MSG_RESULT($foundpcap) fi AC_SUBST(LPCAPINC) AC_SUBST(LPCAPLIB) dnl Checks to see what version of libpcap we've got OLDLIBS="$LIBS" LIBS="$LPCAPLIB" dnl Check to see what version of libpcap dnl this code has been reduced a lot, but probably still could be dnl reduced quite a bit more if we chose too AC_MSG_CHECKING(for libpcap version) AC_TRY_RUN([ #include #include "$LPCAPINCDIR/pcap.h" #define PCAP_TEST "0.6" /* * simple proggy to test the version of libpcap * returns zero if version >= 0.6 * or one otherwise */ extern char pcap_version[]; int main (int argc, char *argv[]) { if (strncmp(pcap_version, PCAP_TEST, 3) >= 0) exit(0); exit(1); }], libpcap_ver=yes AC_MSG_RESULT(>= 0.6), libpcap_ver=no AC_MSG_RESULT(< 0.6), libpcap_ver=no ) if test $libpcap_ver = no ; then AC_MSG_ERROR(Libpcap versions < 0.6 are no longer supported. Please upgrade to version 0.6 or better) fi dnl Check to see if we've got pcap_datalink_val_to_name() AC_MSG_CHECKING(for pcap_datalink_val_to_description) AC_TRY_RUN([ #include #include "$LPCAPINCDIR/pcap.h" int main(int argc, char *argv[]) { char name[100]; strncpy(name, pcap_datalink_val_to_description(1), 99); exit(0); } ], have_dlt_to_desc=yes AC_MSG_RESULT(yes), have_dlt_to_desc=no AC_MSG_RESULT(no), have_dlt_to_desc=no ) if test $have_dlt_to_desc = yes ; then AC_DEFINE(HAVE_DLT_VAL_TO_DESC) fi dnl restore LIBS LIBS="$OLDLIBS" dnl ################################################## dnl # Check for pcapnav dnl ################################################## pcapnav_ver=no pcncfg=no AC_ARG_WITH(pcapnav-config, AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]), [pcncfg=$withval], [ AC_PATH_PROG(pcncfg,[pcapnav-config], [] ) ]) if test $pcncfg = no ; then AC_MSG_RESULT(Cannot find pcapnav-config: Disabling offset jump feature.) else AC_MSG_RESULT($pcncfg) LNAVLIB=`$pcncfg --libs` LNAV_CFLAGS=`$pcncfg --cflags` PCAPNAV_VERSION=`$pcncfg --version` AC_SUBST(LNAVLIB) AC_SUBST(LNAV_CFLAGS) AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION") dnl Check to see what version of libpcapnav dnl this code has been reduced a lot, but probably still could be dnl reduced quite a bit more if we chose too AC_MSG_CHECKING(for libpcapnav version) AC_TRY_RUN([ #include #define PCAPNAV_TEST "0.4" /* * simple proggy to test the version of libpcapnav * returns zero if version >= 0.4 * or one otherwise */ int main (int argc, char *argv[]) { if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0) exit(0); exit(1); }], libpcapnav_ver=yes AC_MSG_RESULT(>= 0.4), libpcapnav_ver=no AC_MSG_RESULT(< 0.4), libpcapnav_ver=no ) if test $libpcapnav_ver = no ; then AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported. Please upgrade to version 0.4 or better. Disabling offset jump feature.]) else AC_DEFINE(HAVE_PCAPNAV) fi fi # checking pcapnav version dnl (shamelessly ripped off from libpcap) dnl Checks to see if unaligned memory accesses fail dnl dnl FORCE_ALIGN (DEFINED) dnl AC_MSG_CHECKING(for requires strict byte alignment) AC_CACHE_VAL(unaligned_fail, [case "$host_cpu" in # XXX: should also check that they don't do weird things (like on arm) alpha*|arm*|hp*|mips*|sparc*|ia64) unaligned_fail=yes ;; *) cat >conftest.c < #include #include unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; main() { unsigned int i; pid_t pid; int status; /* avoid "core dumped" message */ pid = fork(); if (pid < 0) exit(2); if (pid > 0) { /* parent */ pid = waitpid(pid, &status, 0); if (pid < 0) exit(3); exit(!WIFEXITED(status)); } /* child */ i = *(unsigned int *)&a[[1]]; printf("%d\n", i); exit(0); } EOF ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ conftest.c $LIBS >/dev/null 2>&1 if test ! -x conftest ; then dnl failed to compile for some reason unaligned_fail=yes else ./conftest >conftest.out if test ! -s conftest.out ; then unaligned_fail=yes else unaligned_fail=no fi fi rm -f conftest* core core.conftest ;; esac]) AC_MSG_RESULT($unaligned_fail) if test $unaligned_fail = yes ; then AC_DEFINE(FORCE_ALIGN,1,[if unaligned access fails]) fi dnl ################################################## dnl # Check for tcpdump. dnl ################################################## AC_ARG_WITH(tcpdump, AC_HELP_STRING([--with-tcpdump=FILE],[Path to tcpdump binary]), [td=$withval], [td=no]) AC_PATH_PROG(td, tcpdump, "no",[$PATH:/usr/sbin:/sbin:/usr/local/sbin]) if test $td = no ; then AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump. Disabling verbose reporting.]) else AC_MSG_RESULT([Using tcpdump in $td.]) AC_DEFINE(HAVE_TCPDUMP) AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$td", [The tcpdump binary initially used]) fi dnl No 'make test' when cross compile AC_MSG_CHECKING( for 'make test' profile) if test "$host" != "$build" ; then AC_MSG_WARN(Unable to do tests when cross-compiling) fi dnl Allows user to choose which nic to use for testing purposes AC_ARG_WITH(testnic, AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]), [nic1=$withval nic2=$withval AC_MSG_RESULT([Using --with-testnic=$withval])], [ dnl these need to be dynamic based on OS case $host in *-*-linux*) nic1=eth0 nic2=eth0 AC_MSG_RESULT(Linux) ;; *-*-solaris*) nic1=hme0 nic2=hme0 AC_MSG_RESULT(Solaris) ;; *-*-sunos*) nic1=hme0 nic2=hme0 AC_MSG_RESULT(SunOS) ;; powerpc-apple-darwin*) nic1=en0 nic2=en0 AC_MSG_RESULT(Apple OSX) ;; *-*-openbsd*) nic1=xl0 nic2=xl0 AC_MSG_RESULT(OpenBSD) ;; *) AC_MSG_RESULT([$host is unknown! Please use --with-nictest to select an interface for 'make test']) ;; esac]) AC_ARG_WITH(testnic2, AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]), [nic2=$withval]) AC_MSG_NOTICE(Using $nic1 for 1st test network interface card) AC_MSG_NOTICE(Using $nic2 for 2nd test network interface card) AC_SUBST(nic1) AC_SUBST(nic2) AC_OUTPUT(Makefile) AC_OUTPUT(test/Makefile) AC_OUTPUT(test/config) AC_OUTPUT(tcpreplay.spec)