Code

Quilt refresh debian/patches/dpdk-pkg-config.patch.
[pkg-collectd.git] / debian / patches / dpdk-pkg-config.patch
1 Description: configure.ac: dpdk: use pkg-config
2  To detect cflags and libs use the sometimes provided pkg-config for
3  libdpdk. That avoids build errors on systems where special flags are
4  needed and provided by dpdk via pkg-config, but not yet considered by
5  the collectd build system.
6 Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 Forwarded: https://github.com/collectd/collectd/pull/2400
8 Reviewed-by: Luca Boccassi <bluca@debian.org>
9 --- a/configure.ac
10 +++ b/configure.ac
11 @@ -2676,34 +2676,69 @@
12  
13  # --with-libdpdk {{{
14  AC_ARG_VAR([LIBDPDK_CPPFLAGS], [Preprocessor flags for libdpdk])
15 +AC_ARG_VAR([LIBDPDK_CFLAGS], [Compiler flags for libdpdk])
16  AC_ARG_VAR([LIBDPDK_LDFLAGS], [Linker flags for libdpdk])
17 +AC_ARG_VAR([LIBDPDK_LIBS], [Libraries to link for libdpdk])
18  
19 -AC_ARG_WITH([libdpdk], [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])])
20 +AC_ARG_WITH([libdpdk],
21 +  [AS_HELP_STRING([--without-libdpdk], [Disable libdpdk.])],
22 +  [with_libdpdk="$withval"],
23 +  [with_libdpdk="yes"]
24 +)
25  
26 -if test "x$with_libdpdk" != "xno"
27 -then
28 -       if test "x$LIBDPDK_CPPFLAGS" = "x"
29 -       then
30 -               LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
31 -       fi
32 -       SAVE_CPPFLAGS="$CPPFLAGS"
33 -       CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
34 -       AC_CHECK_HEADERS([rte_config.h],
35 -               [with_libdpdk="yes"],
36 -               [with_libdpdk="no (rte_config.h not found)"]
37 -       )
38 -       CPPFLAGS="$SAVE_CPPFLAGS"
39 +if test "x$with_libdpdk" != "xno"; then
40 +  PKG_CHECK_MODULES([DPDK], [libdpdk], [],
41 +                   [AC_MSG_NOTICE([no DPDK pkg-config, using defaults])])
42 +  if test "x$LIBDPDK_CPPFLAGS" = "x"; then
43 +    LIBDPDK_CPPFLAGS="-I/usr/include/dpdk"
44 +  fi
45 +  if test "x$LIBDPDK_CFLAGS" = "x"; then
46 +      LIBDPDK_CFLAGS="$DPDK_CFLAGS"
47 +      LIBDPDK_CPPFLAGS="$LIBDPDK_CPPFLAGS $DPDK_CFLAGS"
48 +  fi
49 +  if test "x$LIBDPDK_LIBS" = "x"; then
50 +      if test "x$DPDK_LIBS" != "x"; then
51 +          LIBDPDK_LIBS="$DPDK_LIBS"
52 +      else
53 +          LIBDPDK_LIBS="-ldpdk"
54 +      fi
55 +  fi
56 +  SAVE_CPPFLAGS="$CPPFLAGS"
57 +  CPPFLAGS="$LIBDPDK_CPPFLAGS $CPPFLAGS"
58 +  SAVE_CFLAGS="$CFLAGS"
59 +  CFLAGS="$LIBDPDK_CFLAGS $CFLAGS"
60 +  AC_CHECK_HEADERS([rte_config.h],
61 +    [
62 +      with_libdpdk="yes"
63 +      AC_PREPROC_IFELSE(
64 +        [
65 +          AC_LANG_SOURCE(
66 +            [[
67 +              #include <rte_version.h>
68 +              #if RTE_VERSION < RTE_VERSION_NUM(16,7,0,0)
69 +              #error "required DPDK >= 16.07"
70 +              #endif
71 +            ]]
72 +          )
73 +        ],
74 +        [dpdk_keepalive="yes"],
75 +        [dpdk_keepalive="no (DPDK version < 16.07)"]
76 +      )
77 +    ],
78 +    [with_libdpdk="no (rte_config.h not found)"]
79 +  )
80 +  CPPFLAGS="$SAVE_CPPFLAGS"
81 +  CFLAGS="$SAVE_CFLAGS"
82  fi
83  
84 -if test "x$with_libdpdk" = "xyes"
85 -then
86 -       SAVE_LDFLAGS="$LDFLAGS"
87 -       LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
88 -       AC_CHECK_LIB([dpdk], [rte_eal_init],
89 -               [with_libdpdk="yes"],
90 -               [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
91 -       )
92 -       LDFLAGS="$SAVE_LDFLAGS"
93 +if test "x$with_libdpdk" = "xyes"; then
94 +  SAVE_LDFLAGS="$LDFLAGS"
95 +  LDFLAGS="$LIBDPDK_LDFLAGS $LDFLAGS"
96 +  AC_CHECK_LIB([dpdk], [rte_eal_init],
97 +    [with_libdpdk="yes"],
98 +    [with_libdpdk="no (symbol 'rte_eal_init' not found)"]
99 +  )
100 +  LDFLAGS="$SAVE_LDFLAGS"
101  fi
102  
103  # }}}
104 --- a/src/Makefile.am
105 +++ b/src/Makefile.am
106 @@ -420,8 +420,9 @@
107  pkglib_LTLIBRARIES += dpdkstat.la
108  dpdkstat_la_SOURCES = dpdkstat.c
109  dpdkstat_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBDPDK_CPPFLAGS)
110 +dpdkstat_la_CFLAGS = $(AM_CFLAGS) $(LIBDPDK_CFLAGS)
111  dpdkstat_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(LIBDPDK_LDFLAGS)
112 -dpdkstat_la_LIBADD = -ldpdk
113 +dpdkstat_la_LIBADD = $(LIBDPDK_LIBS)
114  endif
115  
116  if BUILD_PLUGIN_DRBD