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