@@ -16,6 +16,31 @@ AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive])
AC_SUBST([DPDK_PMDS])
])
+# _ODP_DPDK_CHECK_LIB(LDFLAGS, [LIBS], [EXTRA_LIBS])
+# ----------------------------------
+# Check if one can use -ldpdk with provided set of libs
+AC_DEFUN([_ODP_DPDK_CHECK_LIB], [dnl
+##########################################################################
+# Save and set temporary compilation flags
+##########################################################################
+OLD_LDFLAGS=$LDFLAGS
+OLD_LIBS=$LIBS
+LDFLAGS="$1 $LDFLAGS"
+LIBS="$LIBS -ldpdk $2"
+
+AC_MSG_CHECKING([for rte_eal_init in -ldpdk $2])
+AC_LINK_IFELSE([AC_LANG_CALL([], [rte_eal_init])],
+ [AC_MSG_RESULT([yes])
+ DPDK_LIBS="$1 -ldpdk $3 $2"],
+ [AC_MSG_RESULT([no])])
+
+##########################################################################
+# Restore old saved variables
+##########################################################################
+LDFLAGS=$OLD_LDFLAGS
+LIBS=$OLD_LIBS
+])
+
# ODP_DPDK_CHECK(CPPFLAGS, LDFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
# -----------------------------------------------------------------------
# Check for DPDK availability
@@ -23,10 +48,7 @@ AC_DEFUN([ODP_DPDK_CHECK], [dnl
##########################################################################
# Save and set temporary compilation flags
##########################################################################
-OLD_LDFLAGS=$LDFLAGS
-OLD_LIBS=$LIBS
OLD_CPPFLAGS=$CPPFLAGS
-LDFLAGS="$2 $LDFLAGS"
CPPFLAGS="$1 $CPPFLAGS"
dpdk_check_ok=yes
@@ -34,16 +56,21 @@ dpdk_check_ok=yes
AC_CHECK_HEADERS([rte_config.h], [],
[dpdk_check_ok=no])
-AC_CHECK_LIB([dpdk], [rte_eal_init], [],
- [dpdk_check_ok=no], [-ldl -lpthread -lnuma])
+DPDK_LIBS=""
+_ODP_DPDK_CHECK_LIB([$2])
+AS_IF([test "x$DPDK_LIBS" = "x"],
+ [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread], [-lm])])
+AS_IF([test "x$DPDK_LIBS" = "x"],
+ [_ODP_DPDK_CHECK_LIB([$2], [-ldl -lpthread -lnuma], [-lm])])
+AS_IF([test "x$DPDK_LIBS" = "x"],
+ [dpdk_check_ok=no])
AS_IF([test "x$dpdk_check_ok" != "xno"],
- [m4_default([$3], [:])],
+ [AC_SUBST([DPDK_LIBS])
+ m4_default([$3], [:])],
[m4_default([$4], [:])])
##########################################################################
# Restore old saved variables
##########################################################################
-LDFLAGS=$OLD_LDFLAGS
-LIBS=$OLD_LIBS
CPPFLAGS=$OLD_CPPFLAGS
])
@@ -2,12 +2,27 @@
# Enable DPDK support
##########################################################################
pktio_dpdk_support=no
+
+AC_ARG_ENABLE([dpdk],
+ [AS_HELP_STRING([--enable-dpdk], [enable DPDK support for Packet I/O])],
+ [pktio_dpdk_support=$enableval
+ DPDK_PATH=system])
+
AC_ARG_WITH([dpdk-path],
[AS_HELP_STRING([--with-dpdk-path=DIR], [path to dpdk build directory])],
[DPDK_PATH="$withval"
- DPDK_CPPFLAGS="-isystem $DPDK_PATH/include"
- DPDK_LDFLAGS="-L$DPDK_PATH/lib"
- pktio_dpdk_support=yes],[])
+ pktio_dpdk_support=yes],[])
+
+AS_IF([test "x$DPDK_PATH" = "xsystem"],
+ [DPDK_CPPFLAGS="-isystem/usr/include/dpdk"
+ DPDK_LDFLAGS=""
+ DPDK_PMD_PATH="`$CC --print-file-name=librte_pmd_null.a`"
+ DPDK_PMD_PATH="`dirname "$DPDK_PMD_PATH"`"
+ AS_IF([test "x$DPDK_PMD_PATH" = "x"],
+ [AC_MSG_FAILURE([Could not locate system DPDK PMD directory])])],
+ [DPDK_CPPFLAGS="-isystem $DPDK_PATH/include"
+ DPDK_LDFLAGS="-L$DPDK_PATH/lib"
+ DPDK_PMD_PATH="$DPDK_PATH/lib"])
##########################################################################
# Enable zero-copy DPDK pktio
@@ -30,14 +45,17 @@ then
ODP_DPDK_CHECK([$DPDK_CPPFLAGS], [$DPDK_LDFLAGS], [],
[AC_MSG_FAILURE([can't find DPDK])])
- ODP_DPDK_PMDS([$DPDK_PATH/lib])
+ ODP_DPDK_PMDS([$DPDK_PMD_PATH])
AC_DEFINE([ODP_PKTIO_DPDK], [1],
[Define to 1 to enable DPDK packet I/O support])
AC_DEFINE_UNQUOTED([ODP_DPDK_ZERO_COPY], [$zero_copy],
[Define to 1 to enable DPDK zero copy support])
- DPDK_LIBS="$DPDK_LDFLAGS -ldpdk -lpthread -ldl -lpcap -lm -lnuma"
+ if test -r "$DPDK_PMD_PATH/librte_pmd_pcap.a" &&
+ ! test -r "$DPDK_PMD_PATH/librte_pmd_pcap.so" ; then
+ DPDK_LIBS="$DPDK_LIBS -lpcap"
+ fi
AC_SUBST([DPDK_CPPFLAGS])
AC_SUBST([DPDK_LIBS])
else