[ovs-dev] [PATCH v2] acinclude: netdev-dpdk: use pkg-config of libdpdk

Christian Ehrhardt christian.ehrhardt at canonical.com
Fri Jul 14 06:36:39 UTC 2017


If available use dpdk pkg-config info of libdpdk to set the right
include paths.
That for example, allows packagers to provide non default include
paths in a common way (pkg-config).

*update in v2*
 - following the change in 214ac6d4 "configure: Fix check for
   rte_config.h to handle cross-compilation."

Signed-off-by: Christian Ehrhardt <christian.ehrhardt at canonical.com>
Suggested-by: Luca Boccassi <luca.boccassi at gmail.com>
Acked-by: Luca Boccassi <luca.boccassi at gmail.com>
---
 Documentation/intro/install/dpdk.rst |  6 +++++-
 acinclude.m4                         | 17 ++++++++++-------
 configure.ac                         |  1 +
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Documentation/intro/install/dpdk.rst b/Documentation/intro/install/dpdk.rst
index a05aa1a..e3dcd6c 100644
--- a/Documentation/intro/install/dpdk.rst
+++ b/Documentation/intro/install/dpdk.rst
@@ -124,7 +124,11 @@ has to be configured with DPDK support (``--with-dpdk``).
        $ ./configure --with-dpdk=$DPDK_BUILD
 
    where ``DPDK_BUILD`` is the path to the built DPDK library. This can be
-   skipped if DPDK library is installed in its default location
+   skipped if DPDK library is installed in its default location.
+
+   If no path is provided to ``--with-dpdk``, but a pkg-config configuration
+   for libdpdk is available the include paths will be generated via an
+   equivalent ``pkg-config --cflags libdpdk``.
 
    .. note::
      While ``--with-dpdk`` is required, you can pass any other configuration
diff --git a/acinclude.m4 b/acinclude.m4
index 48fc856..aea5502 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -208,16 +208,19 @@ AC_DEFUN([OVS_CHECK_DPDK], [
     case "$with_dpdk" in
       yes)
         DPDK_AUTO_DISCOVER="true"
-        DPDK_INCLUDE="/usr/local/include/dpdk -I/usr/include/dpdk"
+        PKG_CHECK_MODULES([DPDK], [libdpdk],
+                          [DPDK_INCLUDE="$DPDK_CFLAGS"],
+                          [DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"])
         ;;
       *)
         DPDK_AUTO_DISCOVER="false"
-        DPDK_INCLUDE="$with_dpdk/include"
+        DPDK_INCLUDE_PATH="$with_dpdk/include"
         # If 'with_dpdk' is passed install directory, point to headers
         # installed in $DESTDIR/$prefix/include/dpdk
-        if test ! -e "$DPDK_INCLUDE/rte_config.h" && \
-           test -e "$DPDK_INCLUDE/dpdk/rte_config.h"; then
-           DPDK_INCLUDE=$DPDK_INCLUDE/dpdk
+        if test -e "$DPDK_INCLUDE_PATH/rte_config.h"; then
+           DPDK_INCLUDE="-I$DPDK_INCLUDE_PATH"
+        elif test -e "$DPDK_INCLUDE_PATH/dpdk/rte_config.h"; then
+           DPDK_INCLUDE="-I$DPDK_INCLUDE_PATH/dpdk"
         fi
         DPDK_LIB_DIR="$with_dpdk/lib"
         ;;
@@ -228,7 +231,7 @@ AC_DEFUN([OVS_CHECK_DPDK], [
 
     ovs_save_CFLAGS="$CFLAGS"
     ovs_save_LDFLAGS="$LDFLAGS"
-    CFLAGS="$CFLAGS -I$DPDK_INCLUDE"
+    CFLAGS="$CFLAGS $DPDK_INCLUDE"
     if test "$DPDK_AUTO_DISCOVER" = "false"; then
       LDFLAGS="$LDFLAGS -L${DPDK_LIB_DIR}"
     fi
@@ -304,7 +307,7 @@ AC_DEFUN([OVS_CHECK_DPDK], [
     if test "$DPDK_AUTO_DISCOVER" = "false"; then
       OVS_LDFLAGS="$OVS_LDFLAGS -L$DPDK_LIB_DIR"
     fi
-    OVS_CFLAGS="$OVS_CFLAGS -I$DPDK_INCLUDE"
+    OVS_CFLAGS="$OVS_CFLAGS $DPDK_INCLUDE"
     OVS_ENABLE_OPTION([-mssse3])
 
     # DPDK pmd drivers are not linked unless --whole-archive is used.
diff --git a/configure.ac b/configure.ac
index 23afe4c..a13bca7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,7 @@ AC_PROG_CPP
 AC_PROG_MKDIR_P
 AC_PROG_FGREP
 AC_PROG_EGREP
+PKG_PROG_PKG_CONFIG
 
 AC_ARG_VAR([PERL], [path to Perl interpreter])
 AC_PATH_PROG([PERL], perl, no)
-- 
2.7.4



More information about the dev mailing list