+dnl OVS_CHECK_DPDK
+dnl
+dnl Configure DPDK source tree
+AC_DEFUN([OVS_CHECK_DPDK], [
+ AC_ARG_WITH([dpdk],
+ [AC_HELP_STRING([--with-dpdk=/path/to/dpdk],
+ [Specify the DPDK build directory])])
+
+ if test X"$with_dpdk" != X; then
+ RTE_SDK=$with_dpdk
+
+ DPDK_INCLUDE=$RTE_SDK/include
+ DPDK_LIB_DIR=$RTE_SDK/lib
+ DPDK_LIB="-ldpdk"
+ DPDK_EXTRA_LIB=""
+ RTE_SDK_FULL=`readlink -f $RTE_SDK`
+
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([#include <$RTE_SDK_FULL/include/rte_config.h>
+#if !RTE_LIBRTE_VHOST_USER
+#error
+#endif], [])],
+ [], [AC_DEFINE([VHOST_CUSE], [1], [DPDK vhost-cuse support enabled, vhost-user disabled.])
+ DPDK_EXTRA_LIB="-lfuse"])
+
+ ovs_save_CFLAGS="$CFLAGS"
+ ovs_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -L$DPDK_LIB_DIR"
+ CFLAGS="$CFLAGS -I$DPDK_INCLUDE"
+
+ # On some systems we have to add -ldl to link with dpdk
+ #
+ # This code, at first, tries to link without -ldl (""),
+ # then adds it and tries again.
+ # Before each attempt the search cache must be unset,
+ # otherwise autoconf will stick with the old result
+
+ found=false
+ save_LIBS=$LIBS
+ for extras in "" "-ldl"; do
+ LIBS="$DPDK_LIB $extras $save_LIBS $DPDK_EXTRA_LIB"
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <rte_config.h>
+ #include <rte_eal.h>],
+ [int rte_argc; char ** rte_argv;
+ rte_eal_init(rte_argc, rte_argv);])],
+ [found=true])
+ if $found; then
+ break
+ fi
+ done
+ if $found; then :; else
+ AC_MSG_ERROR([cannot link with dpdk])
+ fi
+ CFLAGS="$ovs_save_CFLAGS"
+ LDFLAGS="$ovs_save_LDFLAGS"
+ OVS_LDFLAGS="$OVS_LDFLAGS -L$DPDK_LIB_DIR"
+ OVS_CFLAGS="$OVS_CFLAGS -I$DPDK_INCLUDE -mssse3"
+
+ # DPDK pmd drivers are not linked unless --whole-archive is used.
+ #
+ # This happens because the rest of the DPDK code doesn't use any symbol in
+ # the pmd driver objects, and the drivers register themselves using an
+ # __attribute__((constructor)) function.
+ #
+ # These options are specified inside a single -Wl directive to prevent
+ # autotools from reordering them.
+ DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-archive
+ AC_SUBST([DPDK_vswitchd_LDFLAGS])
+ AC_DEFINE([DPDK_NETDEV], [1], [System uses the DPDK module.])
+
+ else
+ RTE_SDK=
+ fi
+
+ AM_CONDITIONAL([DPDK_NETDEV], test -n "$RTE_SDK")
+])
+