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