diff mbox series

[API-NEXT,v1,5/14] configure: separate common DPDK check to odp_dpdk.m4

Message ID 1513008012-9231-6-git-send-email-odpbot@yandex.ru
State New
Headers show
Series None | expand

Commit Message

Github ODP bot Dec. 11, 2017, 4 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Separate DPDK macros to top-level file so that they can be reused by
other implementations (like ODP-DPDK).

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

Reviewed-and-tested-by: Matias Elo <matias.elo@nokia.com>
---
/** Email created from pull request 335 (muvarov:devel/api-next_master_merge)
 ** https://github.com/Linaro/odp/pull/335
 ** Patch: https://github.com/Linaro/odp/pull/335.patch
 ** Base sha: 630d8422564ebf4991b468cb38a29e9483fc2ec2
 ** Merge commit sha: 2de2af9eca01b713e51c66fee7a5c7e535502f85
 **/
 m4/odp_dpdk.m4                        | 49 +++++++++++++++++++++++++++++++++++
 platform/linux-generic/m4/odp_dpdk.m4 | 35 +++++--------------------
 2 files changed, 56 insertions(+), 28 deletions(-)
 create mode 100644 m4/odp_dpdk.m4
diff mbox series

Patch

diff --git a/m4/odp_dpdk.m4 b/m4/odp_dpdk.m4
new file mode 100644
index 000000000..636170a7f
--- /dev/null
+++ b/m4/odp_dpdk.m4
@@ -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
+])
diff --git a/platform/linux-generic/m4/odp_dpdk.m4 b/platform/linux-generic/m4/odp_dpdk.m4
index 1e8fa2de9..ba0fdc935 100644
--- a/platform/linux-generic/m4/odp_dpdk.m4
+++ b/platform/linux-generic/m4/odp_dpdk.m4
@@ -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 ])