6d2397b3ccd4b1afbec9f06c06d6a929282de5b1
[dpdk.git] / drivers / net / mlx4 / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2018 6WIND S.A.
3 # Copyright 2018 Mellanox Technologies, Ltd
4
5 if not is_linux
6         build = false
7         reason = 'only supported on Linux'
8         subdir_done()
9 endif
10
11 pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
12 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
13 LIB_GLUE_VERSION = '18.02.0'
14 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
15 if pmd_dlopen
16         dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
17         cflags += [
18                 '-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
19                 '-DMLX4_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
20         ]
21 endif
22
23 libnames = [ 'mlx4', 'ibverbs' ]
24 libs = []
25 foreach libname:libnames
26         lib = dependency('lib' + libname, required:false)
27         if not lib.found()
28                 lib = cc.find_library(libname, required:false)
29         endif
30         if lib.found()
31                 libs += [ lib ]
32         else
33                 build = false
34                 reason = 'missing dependency, "' + libname + '"'
35                 subdir_done()
36         endif
37 endforeach
38
39 allow_experimental_apis = true
40 ext_deps += libs
41 sources = files(
42         'mlx4.c',
43         'mlx4_ethdev.c',
44         'mlx4_flow.c',
45         'mlx4_intr.c',
46         'mlx4_mp.c',
47         'mlx4_mr.c',
48         'mlx4_rxq.c',
49         'mlx4_rxtx.c',
50         'mlx4_txq.c',
51         'mlx4_utils.c',
52 )
53 if not pmd_dlopen
54         sources += files('mlx4_glue.c')
55 endif
56 cflags_options = [
57         '-std=c11',
58         '-Wno-strict-prototypes',
59         '-D_BSD_SOURCE',
60         '-D_DEFAULT_SOURCE',
61         '-D_XOPEN_SOURCE=600'
62 ]
63 foreach option:cflags_options
64         if cc.has_argument(option)
65                 cflags += option
66         endif
67 endforeach
68 if get_option('buildtype').contains('debug')
69         cflags += [ '-pedantic', '-DPEDANTIC' ]
70 else
71         cflags += [ '-UPEDANTIC' ]
72 endif
73 # To maintain the compatibility with the make build system
74 # mlx4_autoconf.h file is still generated.
75 # input array for meson member search:
76 # [ "MACRO to define if found", "header for the search",
77 #   "symbol to search", "struct member to search" ]
78 #
79 has_member_args = [
80         [ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
81         'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
82 ]
83 # input array for meson symbol search:
84 # [ "MACRO to define if found", "header for the search",
85 #   "symbol to search" ]
86 has_sym_args = [
87         [ 'HAVE_IBV_MLX4_BUF_ALLOCATORS', 'infiniband/mlx4dv.h',
88         'MLX4DV_SET_CTX_ATTR_BUF_ALLOCATORS' ],
89         [ 'HAVE_IBV_MLX4_UAR_MMAP_OFFSET', 'infiniband/mlx4dv.h',
90         'MLX4DV_QP_MASK_UAR_MMAP_OFFSET' ],
91 ]
92 config = configuration_data()
93 foreach arg:has_sym_args
94         config.set(arg[0], cc.has_header_symbol(arg[1], arg[2],
95                 dependencies: libs))
96 endforeach
97 foreach arg:has_member_args
98         file_prefix = '#include <' + arg[1] + '>'
99         config.set(arg[0], cc.has_member(arg[2], arg[3],
100                 prefix: file_prefix, dependencies: libs))
101 endforeach
102 configure_file(output : 'mlx4_autoconf.h', configuration : config)
103
104 # Build Glue Library
105 if pmd_dlopen
106         dlopen_name = 'mlx4_glue'
107         dlopen_lib_name = driver_name_fmt.format(dlopen_name)
108         dlopen_so_version = LIB_GLUE_VERSION
109         dlopen_sources = files('mlx4_glue.c')
110         dlopen_install_dir = [ eal_pmd_path + '-glue' ]
111         shared_lib = shared_library(
112                 dlopen_lib_name,
113                 dlopen_sources,
114                 include_directories: global_inc,
115                 c_args: cflags,
116                 dependencies: libs,
117                 link_args: [
118                 '-Wl,-export-dynamic',
119                 '-Wl,-h,@0@'.format(LIB_GLUE),
120                 ],
121                 soversion: dlopen_so_version,
122                 install: true,
123                 install_dir: dlopen_install_dir,
124         )
125 endif