[ovs-dev,v2,1/2] acinclude: Transparent checking for DPDK dependencies.
diff mbox series

Message ID 20190411072943.29566-2-i.maximets@samsung.com
State Accepted
Delegated to: Ian Stokes
Headers show
Series
  • acinclude: User/reader-friendly checking for DPDK dependencies.
Related show

Commit Message

Ilya Maximets April 11, 2019, 7:29 a.m. UTC
'AC_CHECK_DECL' makes almost same thing as 'AC_COMPILE_IFELSE', but
looks more pretty. Additionally it prints checking results in a
user-visible way making it easy to understand which configs checked
and why we need one or another dependency.

For exmaple, with this patch, configure log may look like this:

  checking whether dpdk datapath is enabled... yes
  checking for rte_config.h... yes
  checking whether RTE_LIBRTE_VHOST_NUMA is declared... no
  checking whether RTE_EAL_NUMA_AWARE_HUGEPAGES is declared... yes
  checking for library containing get_mempolicy... -lnuma
  checking whether RTE_LIBRTE_VHOST_NUMA is declared... (cached) no
  checking whether RTE_LIBRTE_PMD_PCAP is declared... yes
  checking for library containing pcap_dump... -lpcap
  checking whether RTE_LIBRTE_PDUMP is declared... yes
  checking whether RTE_LIBRTE_MLX5_PMD is declared... no
  checking whether RTE_LIBRTE_MLX4_PMD is declared... yes
  checking whether RTE_LIBRTE_MLX4_DLOPEN_DEPS is declared... yes

Instead of just:

  checking whether dpdk datapath is enabled... yes
  checking for rte_config.h... yes
  checking for library containing get_mempolicy... -lnuma
  checking for library containing pcap_dump... -lpcap

Anyway, code looks more clean and easier to understand. Also, with
this change we're defining VHOST_NUMA only if RTE_LIBRTE_VHOST_NUMA
defined. This costs nothing as all the checks with 'AC_CHECK_DECL'
are cached.

Acked-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 acinclude.m4 | 118 +++++++++++++++++----------------------------------
 1 file changed, 38 insertions(+), 80 deletions(-)

Comments

Aaron Conole April 11, 2019, 1:29 p.m. UTC | #1
Ilya Maximets <i.maximets@samsung.com> writes:

> 'AC_CHECK_DECL' makes almost same thing as 'AC_COMPILE_IFELSE', but
> looks more pretty. Additionally it prints checking results in a
> user-visible way making it easy to understand which configs checked
> and why we need one or another dependency.
>
> For exmaple, with this patch, configure log may look like this:
>
>   checking whether dpdk datapath is enabled... yes
>   checking for rte_config.h... yes
>   checking whether RTE_LIBRTE_VHOST_NUMA is declared... no
>   checking whether RTE_EAL_NUMA_AWARE_HUGEPAGES is declared... yes
>   checking for library containing get_mempolicy... -lnuma
>   checking whether RTE_LIBRTE_VHOST_NUMA is declared... (cached) no
>   checking whether RTE_LIBRTE_PMD_PCAP is declared... yes
>   checking for library containing pcap_dump... -lpcap
>   checking whether RTE_LIBRTE_PDUMP is declared... yes
>   checking whether RTE_LIBRTE_MLX5_PMD is declared... no
>   checking whether RTE_LIBRTE_MLX4_PMD is declared... yes
>   checking whether RTE_LIBRTE_MLX4_DLOPEN_DEPS is declared... yes
>
> Instead of just:
>
>   checking whether dpdk datapath is enabled... yes
>   checking for rte_config.h... yes
>   checking for library containing get_mempolicy... -lnuma
>   checking for library containing pcap_dump... -lpcap
>
> Anyway, code looks more clean and easier to understand. Also, with
> this change we're defining VHOST_NUMA only if RTE_LIBRTE_VHOST_NUMA
> defined. This costs nothing as all the checks with 'AC_CHECK_DECL'
> are cached.
>
> Acked-by: Flavio Leitner <fbl@sysclose.org>
> Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>

Patch
diff mbox series

diff --git a/acinclude.m4 b/acinclude.m4
index cfc8bcd06..22fbf3f40 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -212,6 +212,15 @@  AC_DEFUN([OVS_CHECK_LINUX_TC], [
                [Define to 1 if TCA_SKBEDIT_FLAGS is available.])])
 ])
 
+dnl OVS_FIND_DEPENDENCY(FUNCTION, SEARCH_LIBS, NAME_TO_PRINT)
+dnl
+dnl Check for a function in a library list.
+AC_DEFUN([OVS_FIND_DEPENDENCY], [
+  AC_SEARCH_LIBS([$1], [$2], [], [
+    AC_MSG_ERROR([unable to find $3, install the dependency package])
+  ])
+])
+
 dnl OVS_CHECK_DPDK
 dnl
 dnl Configure DPDK source tree
@@ -262,86 +271,35 @@  AC_DEFUN([OVS_CHECK_DPDK], [
       AC_MSG_ERROR([unable to find rte_config.h in $with_dpdk])
     ], [AC_INCLUDES_DEFAULT])
 
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM(
-        [
-          #include <rte_config.h>
-#if defined(RTE_LIBRTE_VHOST_NUMA) || defined(RTE_EAL_NUMA_AWARE_HUGEPAGES)
-#error
-#endif
-        ], [])
-      ], [],
-      [AC_SEARCH_LIBS([get_mempolicy],[numa],[],[AC_MSG_ERROR([unable to find libnuma, install the dependency package])])
-       AC_DEFINE([VHOST_NUMA], [1], [NUMA Aware vHost support detected in DPDK.])])
-
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM(
-        [
-          #include <rte_config.h>
-#if RTE_LIBRTE_PMD_PCAP
-#error
-#endif
-        ], [])
-      ], [],
-      [AC_SEARCH_LIBS([pcap_dump],[pcap],[],[AC_MSG_ERROR([unable to find libpcap, install the dependency package])])
-       AC_COMPILE_IFELSE([
-         AC_LANG_PROGRAM(
-           [
-             #include <rte_config.h>
-#if RTE_LIBRTE_PDUMP
-#error
-#endif
-         ], [])
-       ], [],
-       [AC_DEFINE([DPDK_PDUMP], [1], [DPDK pdump enabled in OVS.])])
-     ])
-
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM(
-        [
-          #include <rte_config.h>
-#if RTE_LIBRTE_MLX5_PMD
-#error
-#endif
-        ], [])
-      ], [],
-      [AC_SEARCH_LIBS([mnl_attr_put],[mnl],[],[AC_MSG_ERROR([unable to find libmnl, install the dependency package])])])
-
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM(
-        [
-          #include <rte_config.h>
-#if defined(RTE_LIBRTE_MLX5_PMD) && !defined(RTE_LIBRTE_MLX5_DLOPEN_DEPS)
-#error
-#endif
-        ], [])
-      ], [],
-      [AC_SEARCH_LIBS([mlx5dv_create_wq],[mlx5],[],[AC_MSG_ERROR([unable to find libmlx5, install the dependency package])])])
-
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM(
-        [
-          #include <rte_config.h>
-#if defined(RTE_LIBRTE_MLX4_PMD) && !defined(RTE_LIBRTE_MLX4_DLOPEN_DEPS)
-#error
-#endif
-        ], [])
-      ], [],
-      [AC_SEARCH_LIBS([mlx4dv_init_obj],[mlx4],[],[AC_MSG_ERROR([unable to find libmlx4, install the dependency package])])])
-
-    AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM(
-        [
-          #include <rte_config.h>
-#if defined(RTE_LIBRTE_MLX5_PMD) && !defined(RTE_LIBRTE_MLX5_DLOPEN_DEPS)
-#error
-#endif
-#if defined(RTE_LIBRTE_MLX4_PMD) && !defined(RTE_LIBRTE_MLX4_DLOPEN_DEPS)
-#error
-#endif
-        ], [])
-      ], [],
-      [AC_SEARCH_LIBS([verbs_init_cq],[ibverbs],[],[AC_MSG_ERROR([unable to find libibverbs, install the dependency package])])])
+    AC_CHECK_DECLS([RTE_LIBRTE_VHOST_NUMA, RTE_EAL_NUMA_AWARE_HUGEPAGES], [
+      OVS_FIND_DEPENDENCY([get_mempolicy], [numa], [libnuma])
+    ], [], [[#include <rte_config.h>]])
+
+    AC_CHECK_DECL([RTE_LIBRTE_VHOST_NUMA], [
+      AC_DEFINE([VHOST_NUMA], [1], [NUMA Aware vHost support detected in DPDK.])
+    ], [], [[#include <rte_config.h>]])
+
+    AC_CHECK_DECL([RTE_LIBRTE_PMD_PCAP], [
+      OVS_FIND_DEPENDENCY([pcap_dump], [pcap], [libpcap])
+      AC_CHECK_DECL([RTE_LIBRTE_PDUMP], [
+        AC_DEFINE([DPDK_PDUMP], [1], [DPDK pdump enabled in OVS.])
+      ], [], [[#include <rte_config.h>]])
+    ], [], [[#include <rte_config.h>]])
+
+    AC_CHECK_DECL([RTE_LIBRTE_MLX5_PMD], [dnl found
+      OVS_FIND_DEPENDENCY([mnl_attr_put], [mnl], [libmnl])
+      AC_CHECK_DECL([RTE_LIBRTE_MLX5_DLOPEN_DEPS], [], [dnl not found
+        OVS_FIND_DEPENDENCY([mlx5dv_create_wq], [mlx5], [libmlx5])
+        OVS_FIND_DEPENDENCY([verbs_init_cq], [ibverbs], [libibverbs])
+      ], [[#include <rte_config.h>]])
+    ], [], [[#include <rte_config.h>]])
+
+    AC_CHECK_DECL([RTE_LIBRTE_MLX4_PMD], [dnl found
+      AC_CHECK_DECL([RTE_LIBRTE_MLX4_DLOPEN_DEPS], [], [dnl not found
+        OVS_FIND_DEPENDENCY([mlx4dv_init_obj], [mlx4], [libmlx4])
+        OVS_FIND_DEPENDENCY([verbs_init_cq], [ibverbs], [libibverbs])
+      ], [[#include <rte_config.h>]])
+    ], [], [[#include <rte_config.h>]])
 
     # On some systems we have to add -ldl to link with dpdk
     #