config: gather options for dlopen mlx dependency
[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 pmd_dlopen = (get_option('ibverbs_link') == 'dlopen')
6 LIB_GLUE_BASE = 'librte_pmd_mlx4_glue.so'
7 LIB_GLUE_VERSION = '18.02.0'
8 LIB_GLUE = LIB_GLUE_BASE + '.' + LIB_GLUE_VERSION
9 if pmd_dlopen
10         dpdk_conf.set('RTE_IBVERBS_LINK_DLOPEN', 1)
11         cflags += [
12                 '-DMLX4_GLUE="@0@"'.format(LIB_GLUE),
13                 '-DMLX4_GLUE_VERSION="@0@"'.format(LIB_GLUE_VERSION),
14         ]
15 endif
16 libs = [
17         cc.find_library('mnl', required:false),
18         cc.find_library('mlx4', required:false),
19         cc.find_library('ibverbs', required:false),
20 ]
21 build = true
22 foreach lib:libs
23         if not lib.found()
24                 build = false
25         endif
26 endforeach
27 # Compile PMD
28 if build
29         allow_experimental_apis = true
30         ext_deps += libs
31         sources = files(
32                 'mlx4.c',
33                 'mlx4_ethdev.c',
34                 'mlx4_flow.c',
35                 'mlx4_intr.c',
36                 'mlx4_mr.c',
37                 'mlx4_rxq.c',
38                 'mlx4_rxtx.c',
39                 'mlx4_txq.c',
40                 'mlx4_utils.c',
41         )
42         if not pmd_dlopen
43                 sources += files('mlx4_glue.c')
44         endif
45         cflags_options = [
46                 '-Wextra',
47                 '-std=c11',
48                 '-Wno-strict-prototypes',
49                 '-D_BSD_SOURCE',
50                 '-D_DEFAULT_SOURCE',
51                 '-D_XOPEN_SOURCE=600'
52         ]
53         foreach option:cflags_options
54                 if cc.has_argument(option)
55                         cflags += option
56                 endif
57         endforeach
58         if get_option('buildtype').contains('debug')
59                 cflags += [ '-pedantic', '-UNDEBUG', '-DPEDANTIC' ]
60         else
61                 cflags += [ '-DNDEBUG', '-UPEDANTIC' ]
62         endif
63         # To maintain the compatibility with the make build system
64         # mlx4_autoconf.h file is still generated.
65         # input array for meson member search:
66         # [ "MACRO to define if found", "header for the search",
67         #   "symbol to search","struct member to search" ]
68         #
69         has_member_args = [
70                 [ 'HAVE_IBV_MLX4_WQE_LSO_SEG', 'infiniband/mlx4dv.h',
71                 'struct mlx4_wqe_lso_seg', 'mss_hdr_size' ],
72         ]
73         config = configuration_data()
74         foreach arg:has_member_args
75                 file_prefix = '#include<' + arg[1] + '>'
76                 config.set(arg[0], cc.has_member(arg[2], arg[3],
77                         prefix : file_prefix))
78         endforeach
79         configure_file(output : 'mlx4_autoconf.h', configuration : config)
80 endif
81 # Build Glue Library
82 if pmd_dlopen and build
83         dlopen_name = 'mlx4_glue'
84         dlopen_lib_name = driver_name_fmt.format(dlopen_name)
85         dlopen_so_version = LIB_GLUE_VERSION
86         dlopen_sources = files('mlx4_glue.c')
87         dlopen_install_dir = [ eal_pmd_path + '-glue' ]
88         shared_lib = shared_library(
89                 dlopen_lib_name,
90                 dlopen_sources,
91                 include_directories: global_inc,
92                 c_args: cflags,
93                 dependencies: libs,
94                 link_args: [
95                 '-Wl,-export-dynamic',
96                 '-Wl,-h,@0@'.format(LIB_GLUE),
97                 ],
98                 soversion: dlopen_so_version,
99                 install: true,
100                 install_dir: dlopen_install_dir,
101         )
102 endif