On Thu, Jul 30, 2009 at 9:57 AM, Chris Packham<judge.pack...@gmail.com> wrote:
> A bit of googling turned up some guideance on how to handle this [1].
> Looks like there is an optional argument to AC_RUN_IFELSE that can be
> used for an action-if-cross-compiling. The cache manipulation trick is
> also mentioned. I'll post a patch shortly.

Turned out to be easy enough after I figured out the autoconf syntax.

The changes are basically to 1) allow the tests that execute code to
be skipped if cross compiling and 2) turn the libpcap_version into a
cached variable so that we can tell tcpreplay which version of libpcap
is used in our target environment.

With my patch applied the typical usage is

autoreconf    # this won't be necessary once my patch is accepted upstream

tr_cv_libpcap_version=">= 0.7.0" \
./configure --target=powerpc-linux \
                --host=powerpc-linux \
                --build=i386-pc-linux-gnu \
                --program-prefix="" \
                --with-libpcap=<path-to-libpcap>
--- tcpreplay-3.4.3/configure.ac	2009-06-26 06:45:55.000000000 +1200
+++ tcpreplay-3.4.3-new/configure.ac	2009-07-30 11:59:35.000000000 +1200
@@ -420,6 +420,11 @@
     exit(1);
 ]]), [
     libpcap_version_096=yes
+], [
+    libpcap_version_096=no
+], [
+    AC_MSG_WARN([Tests not run when cross compiling])
+    libpcap_version_096=no
 ])
 
 libpcap_ver8=no
@@ -447,6 +452,9 @@
     libpcap_ver8=yes
 ], [
     libpcap_ver8=no
+], [
+    AC_MSG_WARN([Tests not run when cross compiling])
+    libpcap_ver8=no
 ])
 
 libpcap_ver7=no
@@ -472,25 +480,31 @@
     libpcap_ver7=yes
 ], [
     libpcap_ver7=no
+], [
+    AC_MSG_WARN([Tests not run when cross compiling])
+    libpcap_ver7=no
 ])
 
-if test x$libpcap_ver8 = xyes ; then
-    AC_MSG_RESULT(>= 0.8.0)
-elif test x$libpcap_ver7 = xyes ; then
-    AC_MSG_RESULT(>= 0.7.2)
-else 
-    AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
-    Please upgrade to version 0.7.2 or better])
-fi
-
-libpcap_version=unknown
-if test x$libpcap_version_096 = xyes ; then
-    libpcap_version=">= 0.9.6"
-elif test x$libpcap_ver8 = xyes ; then
-    libpcap_version=">= 0.8.0"
-elif test x$libcap_ver7 = xyes ; then
-    libpcap_version=">= 0.7.0"
-fi
+AC_CACHE_CHECK([for supported libpcap verision], [tr_cv_libpcap_version],
+[
+    if test x$libpcap_ver8 = xyes ; then
+        AC_MSG_RESULT(>= 0.8.0)
+    elif test x$libpcap_ver7 = xyes ; then
+        AC_MSG_RESULT(>= 0.7.2)
+    else 
+        AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
+        Please upgrade to version 0.7.2 or better])
+    fi
+
+    tr_cv_libpcap_version=unknown
+    if test x$tr_cv_libpcap_version_096 = xyes ; then
+        tr_cv_libpcap_version=">= 0.9.6"
+    elif test x$libpcap_ver8 = xyes ; then
+        tr_cv_libpcap_version=">= 0.8.0"
+    elif test x$libcap_ver7 = xyes ; then
+        tr_cv_libpcap_version=">= 0.7.0"
+    fi
+] )
 
 dnl Check for pcap_setnonblock()
 AC_MSG_CHECKING(for pcap_setnonblock)
@@ -770,6 +784,9 @@
     have_bpf=yes
 ],[
     AC_MSG_RESULT(no)
+],[
+    AC_MSG_WARN([Tests not run when cross compiling])
+    AC_MSG_RESULT(no)
 ])
 
 
@@ -1189,7 +1206,7 @@
 ##########################################################################
              TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
 ##########################################################################
-libpcap:                    ${foundpcap} (${libpcap_version})
+libpcap:                    ${foundpcap} (${tr_cv_libpcap_version})
 libdnet:                    ${founddnet} (${libdnet_version})
 autogen:                    ${AUTOGEN} (${AUTOGEN_VERSION})
 Use libopts tearoff:        ${enable_local_libopts}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tcpreplay-users mailing list
Tcpreplay-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcpreplay-users
Support Information: http://tcpreplay.synfin.net/trac/wiki/Support

Reply via email to