net/mlx5: set representor to first PF in bonding mode
[dpdk.git] / drivers / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
3
4 # Defines the order of dependencies evaluation
5 subdirs = [
6         'common',
7         'bus',
8         'common/mlx5', # depends on bus.
9         'common/qat', # depends on bus.
10         'mempool', # depends on common and bus.
11         'net',     # depends on common, bus, mempool
12         'raw',     # depends on common, bus and net.
13         'crypto',  # depends on common, bus and mempool (net in future).
14         'compress', # depends on common, bus, mempool.
15         'regex', # depends on common, bus, regexdev.
16         'vdpa',    # depends on common, bus and mempool.
17         'event',   # depends on common, bus, mempool and net.
18         'baseband', # depends on common and bus.
19 ]
20
21 disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
22                 ).stdout().split()
23
24 default_cflags = machine_args
25 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
26 default_cflags += ['-DALLOW_INTERNAL_API']
27
28 if cc.has_argument('-Wno-format-truncation')
29         default_cflags += '-Wno-format-truncation'
30 endif
31
32 foreach subpath:subdirs
33         drivers = []
34         std_deps = []
35         config_flag_fmt = '' # format string used to set the value in dpdk_conf
36
37         # subpath can be either "class" or "class/driver"
38         if subpath.contains('/')
39                 driver_path = subpath.split('/')
40                 class = driver_path[0]
41                 drivers += driver_path[1]
42         else
43                 class = subpath
44                 subdir(class)
45         endif
46
47         # save class name on first occurrence
48         if not dpdk_driver_classes.contains(class)
49                 dpdk_driver_classes += class
50         endif
51         # get already enabled drivers of the same class
52         enabled_drivers = get_variable(class + '_drivers', [])
53
54         foreach drv:drivers
55                 drv_path = join_paths(class, drv)
56
57                 # set up empty variables used for build
58                 build = true # set to false to disable, e.g. missing deps
59                 reason = '<unknown reason>' # set if build == false to explain
60                 name = drv
61                 fmt_name = ''
62                 sources = []
63                 headers = []
64                 objs = []
65                 cflags = default_cflags
66                 includes = [include_directories(drv_path)]
67                 # set up internal deps. Drivers can append/override as necessary
68                 deps = std_deps
69                 # ext_deps: Stores external library dependency got
70                 # using dependency() (preferred) or find_library().
71                 # For the find_library() case (but not with dependency()) we also
72                 # need to specify the "-l" flags in pkgconfig_extra_libs variable
73                 # too, so that it can be reflected in the pkgconfig output for
74                 # static builds.
75                 ext_deps = []
76                 pkgconfig_extra_libs = []
77
78                 if disabled_drivers.contains(drv_path)
79                         build = false
80                         reason = 'explicitly disabled via build config'
81                 else
82                         # pull in driver directory which should update all the local variables
83                         subdir(drv_path)
84                 endif
85
86                 if build
87                         # get dependency objs from strings
88                         shared_deps = ext_deps
89                         static_deps = ext_deps
90                         foreach d:deps
91                                 if not is_variable('shared_rte_' + d)
92                                         build = false
93                                         reason = 'missing internal dependency, "@0@"'.format(d)
94                                         message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
95                                                         .format(d, name, 'drivers/' + drv_path))
96                                 else
97                                         shared_deps += [get_variable('shared_rte_' + d)]
98                                         static_deps += [get_variable('static_rte_' + d)]
99                                 endif
100                         endforeach
101                 endif
102
103                 if not build
104                         # some driver directories are placeholders which
105                         # are never built, so we allow suppression of the
106                         # component disable printout in those cases
107                         if reason != ''
108                                 dpdk_drvs_disabled += drv_path
109                                 set_variable(drv_path.underscorify() +
110                                                 '_disable_reason', reason)
111                         endif
112                 else
113                         enabled_drivers += name
114                         lib_name = '_'.join(['rte', class, name])
115                         dpdk_conf.set(lib_name.to_upper(), 1)
116
117                         if fmt_name == ''
118                                 fmt_name = name
119                         endif
120
121                         dpdk_conf.set(config_flag_fmt.format(fmt_name.to_upper()),1) #old-style macro
122                         # for driver compatibility, since we changed the
123                         # default to match that of make. Remove in future release
124                         # after following deprecation process
125                         if config_flag_fmt.contains('_PMD_@0@') and (class == 'crypto'
126                                         or class == 'compress'
127                                         or class == 'event')
128                                 alt_flag_fmt = '_@0@_PMD'.join(
129                                                 config_flag_fmt.split('_PMD_@0@'))
130                                 if config_flag_fmt.contains('EVENTDEV')
131                                         alt_flag_fmt = '_@0@_EVENTDEV_PMD'.join(
132                                                 config_flag_fmt.split('_PMD_@0@_EVENTDEV'))
133                                 endif
134                                 dpdk_conf.set(alt_flag_fmt.format(
135                                                 fmt_name.to_upper()), 1)
136                         endif
137
138                         dpdk_extra_ldflags += pkgconfig_extra_libs
139
140                         install_headers(headers)
141
142                         # generate pmdinfo sources by building a temporary
143                         # lib and then running pmdinfogen on the contents of
144                         # that lib. The final lib reuses the object files and
145                         # adds in the new source file.
146                         if not is_windows
147                                 out_filename = lib_name + '.pmd.c'
148                                 tmp_lib = static_library('tmp_' + lib_name,
149                                                 sources,
150                                                 include_directories: includes,
151                                                 dependencies: static_deps,
152                                                 c_args: cflags)
153                                 objs += tmp_lib.extract_all_objects()
154                                 sources = custom_target(out_filename,
155                                                 command: [pmdinfo, tmp_lib.full_path(),
156                                                         '@OUTPUT@', pmdinfogen],
157                                                 output: out_filename,
158                                                 depends: [pmdinfogen, tmp_lib])
159                         endif
160
161                         # now build the static driver
162                         static_lib = static_library(lib_name,
163                                 sources,
164                                 objects: objs,
165                                 include_directories: includes,
166                                 dependencies: static_deps,
167                                 c_args: cflags,
168                                 install: true)
169
170                         # now build the shared driver
171                         version_map = '@0@/@1@/version.map'.format(
172                                         meson.current_source_dir(),
173                                         drv_path)
174                         implib = 'lib' + lib_name + '.dll.a'
175
176                         def_file = custom_target(lib_name + '_def',
177                                 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
178                                 input: version_map,
179                                 output: '@0@_exports.def'.format(lib_name))
180
181                         mingw_map = custom_target(lib_name + '_mingw',
182                                 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
183                                 input: version_map,
184                                 output: '@0@_mingw.map'.format(lib_name))
185
186                         lk_deps = [version_map, def_file, mingw_map]
187                         if is_windows
188                                 if is_ms_linker
189                                         lk_args = ['-Wl,/def:' + def_file.full_path()]
190                                         if meson.version().version_compare('<0.54.0')
191                                                 lk_args += ['-Wl,/implib:drivers\\' + implib]
192                                         endif
193                                 else
194                                         lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
195                                 endif
196                         else
197                                 lk_args = ['-Wl,--version-script=' + version_map]
198                                 # on unix systems check the output of the
199                                 # check-symbols.sh script, using it as a
200                                 # dependency of the .so build
201                                 lk_deps += custom_target(lib_name + '.sym_chk',
202                                         command: [check_symbols,
203                                                 version_map, '@INPUT@'],
204                                         capture: true,
205                                         input: static_lib,
206                                         output: lib_name + '.sym_chk')
207                         endif
208
209                         shared_lib = shared_library(lib_name,
210                                 sources,
211                                 objects: objs,
212                                 include_directories: includes,
213                                 dependencies: shared_deps,
214                                 c_args: cflags,
215                                 link_args: lk_args,
216                                 link_depends: lk_deps,
217                                 version: abi_version,
218                                 soversion: so_version,
219                                 install: true,
220                                 install_dir: driver_install_path)
221
222                         # create a dependency object and add it to the global dictionary so
223                         # testpmd or other built-in apps can find it if necessary
224                         shared_dep = declare_dependency(link_with: shared_lib,
225                                         include_directories: includes,
226                                         dependencies: shared_deps)
227                         static_dep = declare_dependency(
228                                         include_directories: includes,
229                                         dependencies: static_deps)
230
231                         dpdk_drivers += static_lib
232
233                         set_variable('shared_@0@'.format(lib_name), shared_dep)
234                         set_variable('static_@0@'.format(lib_name), static_dep)
235                         dependency_name = ''.join(lib_name.split('rte_'))
236                         message('drivers/@0@: Defining dependency "@1@"'.format(
237                                         drv_path, dependency_name))
238                 endif # build
239         endforeach
240
241         set_variable(class + '_drivers', enabled_drivers)
242 endforeach