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