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