net/hns3: fix setting default MAC address in bonding of VF
[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/cnxk', # depends on bus.
9         'common/mlx5', # depends on bus.
10         'common/qat', # depends on bus.
11         'common/sfc_efx', # depends on bus.
12         'mempool', # depends on common and bus.
13         'net',     # depends on common, bus, mempool
14         'raw',     # depends on common, bus and net.
15         'crypto',  # depends on common, bus and mempool (net in future).
16         'compress', # depends on common, bus, mempool.
17         'regex', # depends on common, bus, regexdev.
18         'vdpa',    # depends on common, bus and mempool.
19         'event',   # depends on common, bus, mempool and net.
20         'baseband', # depends on common and bus.
21 ]
22
23 disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
24                 ).stdout().split()
25
26 default_cflags = machine_args
27 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
28 default_cflags += ['-DALLOW_INTERNAL_API']
29
30 if cc.has_argument('-Wno-format-truncation')
31         default_cflags += '-Wno-format-truncation'
32 endif
33
34 foreach subpath:subdirs
35         drivers = []
36         std_deps = []
37
38         # subpath can be either "class" or "class/driver"
39         if subpath.contains('/')
40                 driver_path = subpath.split('/')
41                 class = driver_path[0]
42                 drivers += driver_path[1]
43         else
44                 class = subpath
45                 subdir(class)
46         endif
47
48         # save class name on first occurrence
49         if not dpdk_driver_classes.contains(class)
50                 dpdk_driver_classes += class
51         endif
52         # get already enabled drivers of the same class
53         enabled_drivers = get_variable(class + '_drivers', [])
54
55         foreach drv:drivers
56                 drv_path = join_paths(class, drv)
57
58                 # set up empty variables used for build
59                 build = true # set to false to disable, e.g. missing deps
60                 reason = '<unknown reason>' # set if build == false to explain
61                 name = drv
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                         dpdk_extra_ldflags += pkgconfig_extra_libs
118
119                         install_headers(headers)
120
121                         # generate pmdinfo sources by building a temporary
122                         # lib and then running pmdinfogen on the contents of
123                         # that lib. The final lib reuses the object files and
124                         # adds in the new source file.
125                         out_filename = lib_name + '.pmd.c'
126                         tmp_lib = static_library('tmp_' + lib_name,
127                                         sources,
128                                         include_directories: includes,
129                                         dependencies: static_deps,
130                                         c_args: cflags)
131                         objs += tmp_lib.extract_all_objects()
132                         sources = custom_target(out_filename,
133                                         command: [pmdinfo, tmp_lib.full_path(),
134                                                 '@OUTPUT@', pmdinfogen],
135                                         output: out_filename,
136                                         depends: [tmp_lib])
137
138                         # now build the static driver
139                         static_lib = static_library(lib_name,
140                                 sources,
141                                 objects: objs,
142                                 include_directories: includes,
143                                 dependencies: static_deps,
144                                 c_args: cflags,
145                                 install: true)
146
147                         # now build the shared driver
148                         version_map = '@0@/@1@/version.map'.format(
149                                         meson.current_source_dir(),
150                                         drv_path)
151                         implib = 'lib' + lib_name + '.dll.a'
152
153                         def_file = custom_target(lib_name + '_def',
154                                 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
155                                 input: version_map,
156                                 output: '@0@_exports.def'.format(lib_name))
157
158                         mingw_map = custom_target(lib_name + '_mingw',
159                                 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
160                                 input: version_map,
161                                 output: '@0@_mingw.map'.format(lib_name))
162
163                         lk_deps = [version_map, def_file, mingw_map]
164                         if is_windows
165                                 if is_ms_linker
166                                         lk_args = ['-Wl,/def:' + def_file.full_path()]
167                                         if meson.version().version_compare('<0.54.0')
168                                                 lk_args += ['-Wl,/implib:drivers\\' + implib]
169                                         endif
170                                 else
171                                         lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
172                                 endif
173                         else
174                                 lk_args = ['-Wl,--version-script=' + version_map]
175                                 if developer_mode
176                                         # on unix systems check the output of the
177                                         # check-symbols.sh script, using it as a
178                                         # dependency of the .so build
179                                         lk_deps += custom_target(lib_name + '.sym_chk',
180                                                 command: [check_symbols,
181                                                         version_map, '@INPUT@'],
182                                                 capture: true,
183                                                 input: static_lib,
184                                                 output: lib_name + '.sym_chk')
185                                 endif
186                         endif
187
188                         shared_lib = shared_library(lib_name,
189                                 sources,
190                                 objects: objs,
191                                 include_directories: includes,
192                                 dependencies: shared_deps,
193                                 c_args: cflags,
194                                 link_args: lk_args,
195                                 link_depends: lk_deps,
196                                 version: abi_version,
197                                 soversion: so_version,
198                                 install: true,
199                                 install_dir: driver_install_path)
200
201                         # create a dependency object and add it to the global dictionary so
202                         # testpmd or other built-in apps can find it if necessary
203                         shared_dep = declare_dependency(link_with: shared_lib,
204                                         include_directories: includes,
205                                         dependencies: shared_deps)
206                         static_dep = declare_dependency(
207                                         include_directories: includes,
208                                         dependencies: static_deps)
209
210                         dpdk_drivers += static_lib
211
212                         set_variable('shared_@0@'.format(lib_name), shared_dep)
213                         set_variable('static_@0@'.format(lib_name), static_dep)
214                         dependency_name = ''.join(lib_name.split('rte_'))
215                         if developer_mode
216                                 message('drivers/@0@: Defining dependency "@1@"'.format(
217                                                 drv_path, dependency_name))
218                         endif
219                 endif # build
220         endforeach
221
222         set_variable(class + '_drivers', enabled_drivers)
223 endforeach