diff mbox

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

Message ID 1500014199-15784-1-git-send-email-christian.ehrhardt@canonical.com
State Accepted
Headers show

Commit Message

Christian Ehrhardt July 14, 2017, 6:36 a.m. UTC
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@canonical.com>
Suggested-by: Luca Boccassi <luca.boccassi@gmail.com>
Acked-by: Luca Boccassi <luca.boccassi@gmail.com>
---
 Documentation/intro/install/dpdk.rst |  6 +++++-
 acinclude.m4                         | 17 ++++++++++-------
 configure.ac                         |  1 +
 3 files changed, 16 insertions(+), 8 deletions(-)

Comments

Christian Ehrhardt Aug. 7, 2017, 10:24 a.m. UTC | #1
Ping, any update on including this?

On Fri, Jul 14, 2017 at 8:36 AM, Christian Ehrhardt <
christian.ehrhardt@canonical.com> wrote:

> 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@canonical.com>
> Suggested-by: Luca Boccassi <luca.boccassi@gmail.com>
> Acked-by: Luca Boccassi <luca.boccassi@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
>
>
Gao Zhenyu Aug. 7, 2017, 11:18 a.m. UTC | #2
LGTM

Thanks
Zhenyu Gao

2017-08-07 18:24 GMT+08:00 Christian Ehrhardt <
christian.ehrhardt@canonical.com>:

> Ping, any update on including this?
>
> On Fri, Jul 14, 2017 at 8:36 AM, Christian Ehrhardt <
> christian.ehrhardt@canonical.com> wrote:
>
> > 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@canonical.com>
> > Suggested-by: Luca Boccassi <luca.boccassi@gmail.com>
> > Acked-by: Luca Boccassi <luca.boccassi@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
> >
> >
>
>
> --
> Christian Ehrhardt
> Software Engineer, Ubuntu Server
> Canonical Ltd
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Ben Pfaff Aug. 7, 2017, 6:42 p.m. UTC | #3
On Fri, Jul 14, 2017 at 08:36:39AM +0200, Christian Ehrhardt wrote:
> 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@canonical.com>
> Suggested-by: Luca Boccassi <luca.boccassi@gmail.com>
> Acked-by: Luca Boccassi <luca.boccassi@gmail.com>

Applied to master, thanks!
Christian Ehrhardt Aug. 8, 2017, 5:52 a.m. UTC | #4
On Mon, Aug 7, 2017 at 8:42 PM, Ben Pfaff <blp@ovn.org> wrote:

> On Fri, Jul 14, 2017 at 08:36:39AM +0200, Christian Ehrhardt wrote:
> > 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@canonical.com>
> > Suggested-by: Luca Boccassi <luca.boccassi@gmail.com>
> > Acked-by: Luca Boccassi <luca.boccassi@gmail.com>
>
> Applied to master, thanks!
>

Thanks Ben and everybody else involved, any chance/opinion to get that into
branch-2.8 as well before it is tagged final?
Ben Pfaff Aug. 8, 2017, 6:31 p.m. UTC | #5
On Tue, Aug 08, 2017 at 07:52:13AM +0200, Christian Ehrhardt wrote:
> On Mon, Aug 7, 2017 at 8:42 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> > On Fri, Jul 14, 2017 at 08:36:39AM +0200, Christian Ehrhardt wrote:
> > > 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@canonical.com>
> > > Suggested-by: Luca Boccassi <luca.boccassi@gmail.com>
> > > Acked-by: Luca Boccassi <luca.boccassi@gmail.com>
> >
> > Applied to master, thanks!
> >
> 
> Thanks Ben and everybody else involved, any chance/opinion to get that into
> branch-2.8 as well before it is tagged final?

OK, I applied it to branch-2.8 also.
diff mbox

Patch

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)