new file mode 100644
@@ -0,0 +1,49 @@
+# ODP_DPDK_PMDS(DPDK_DRIVER_PATH)
+# -------------------------------
+# Build a list of DPDK PMD drivers in DPDK_PMDS variable
+AC_DEFUN([ODP_DPDK_PMDS], [dnl
+AS_VAR_SET([DPDK_PMDS], [-Wl,--whole-archive,])
+for filename in "$1"/librte_pmd_*.a; do
+cur_driver=`basename "$filename" .a | sed -e 's/^lib//'`
+# rte_pmd_nfp has external dependencies which break linking
+if test "$cur_driver" = "rte_pmd_nfp"; then
+ echo "skip linking rte_pmd_nfp"
+else
+ AS_VAR_APPEND([DPDK_PMDS], [-l$cur_driver,])
+fi
+done
+AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive])
+AC_SUBST([DPDK_PMDS])
+])
+
+# ODP_DPDK_CHECK(CPPFLAGS, LDFLAGS, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
+# -----------------------------------------------------------------------
+# Check for DPDK availability
+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
+
+AC_CHECK_HEADERS([rte_config.h], [],
+ [dpdk_check_ok=no])
+
+AC_CHECK_LIB([dpdk], [rte_eal_init], [],
+ [dpdk_check_ok=no], [-ldl -lpthread -lnuma])
+AS_IF([test "x$dpdk_check_ok" != "xno"],
+ [m4_default([$3], [:])],
+ [m4_default([$4], [:])])
+
+##########################################################################
+# Restore old saved variables
+##########################################################################
+LDFLAGS=$OLD_LDFLAGS
+LIBS=$OLD_LIBS
+CPPFLAGS=$OLD_CPPFLAGS
+])
@@ -3,9 +3,10 @@
##########################################################################
pktio_dpdk_support=no
AC_ARG_WITH([dpdk-path],
-AS_HELP_STRING([--with-dpdk-path=DIR path to dpdk build directory]),
+[AS_HELP_STRING([--with-dpdk-path=DIR], [path to dpdk build directory])],
[DPDK_PATH="$withval"
DPDK_CPPFLAGS="-msse4.2 -isystem $DPDK_PATH/include"
+ DPDK_LDFLAGS="-L$DPDK_PATH/lib"
pktio_dpdk_support=yes],[])
##########################################################################
@@ -13,17 +14,11 @@ AS_HELP_STRING([--with-dpdk-path=DIR path to dpdk build directory]),
##########################################################################
zero_copy=0
AC_ARG_ENABLE([dpdk-zero-copy],
- [ --enable-dpdk-zero-copy enable experimental zero-copy DPDK pktio mode],
+ [AS_HELP_STRING([--enable-dpdk-zero-copy], [enable experimental zero-copy DPDK pktio mode])],
[if test x$enableval = xyes; then
zero_copy=1
fi])
-##########################################################################
-# Save and set temporary compilation flags
-##########################################################################
-OLD_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$DPDK_CPPFLAGS $CPPFLAGS"
-
##########################################################################
# Check for DPDK availability
#
@@ -32,37 +27,21 @@ CPPFLAGS="$DPDK_CPPFLAGS $CPPFLAGS"
##########################################################################
if test x$pktio_dpdk_support = xyes
then
- AC_CHECK_HEADERS([rte_config.h], [],
- [AC_MSG_FAILURE(["can't find DPDK header"])])
+ ODP_DPDK_CHECK([$DPDK_CPPFLAGS], [$DPDK_LDFLAGS], [],
+ [AC_MSG_FAILURE([can't find DPDK])])
- AS_VAR_SET([DPDK_PMDS], [-Wl,--whole-archive,])
- for filename in "$DPDK_PATH"/lib/librte_pmd_*.a; do
- cur_driver=`basename "$filename" .a | sed -e 's/^lib//'`
- # rte_pmd_nfp has external dependencies which break linking
- if test "$cur_driver" = "rte_pmd_nfp"; then
- echo "skip linking rte_pmd_nfp"
- else
- AS_VAR_APPEND([DPDK_PMDS], [-l$cur_driver,])
- fi
- done
- AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive])
+ ODP_DPDK_PMDS([$DPDK_PATH/lib])
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="-L$DPDK_PATH/lib -ldpdk -lpthread -ldl -lpcap -lm -lnuma"
+ DPDK_LIBS="$DPDK_LDFLAGS -ldpdk -lpthread -ldl -lpcap -lm -lnuma"
AC_SUBST([DPDK_CPPFLAGS])
AC_SUBST([DPDK_LIBS])
- AC_SUBST([DPDK_PMDS])
else
pktio_dpdk_support=no
fi
-##########################################################################
-# Restore old saved variables
-##########################################################################
-CPPFLAGS=$OLD_CPPFLAGS
-
AM_CONDITIONAL([PKTIO_DPDK], [test x$pktio_dpdk_support = xyes ])