net/af_xdp: revert use BPF link for XDP programs
[dpdk.git] / lib / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
3
4
5 # process all libraries equally, as far as possible
6 # "core" libs first, then others alphebetically as far as possible
7 # NOTE: for speed of meson runs, the dependencies in the subdirectories
8 # sometimes skip deps that would be implied by others, e.g. if mempool is
9 # given as a dep, no need to mention ring. This is especially true for the
10 # core libs which are widely reused, so their deps are kept to a minimum.
11 libraries = [
12         'kvargs', # eal depends on kvargs
13         'telemetry', # basic info querying
14         'eal', # everything depends on eal
15         'ring',
16         'rcu', # rcu depends on ring
17         'mempool',
18         'mbuf',
19         'net',
20         'meter',
21         'ethdev',
22         'pci', # core
23         'cmdline',
24         'metrics', # bitrate/latency stats depends on this
25         'hash',    # efd depends on this
26         'timer',   # eventdev depends on this
27         'acl',
28         'bbdev',
29         'bitratestats',
30         'bpf',
31         'cfgfile',
32         'compressdev',
33         'cryptodev',
34         'distributor',
35         'efd',
36         'eventdev',
37         'gpudev',
38         'gro',
39         'gso',
40         'ip_frag',
41         'jobstats',
42         'kni',
43         'latencystats',
44         'lpm',
45         'member',
46         'pcapng',
47         'power',
48         'rawdev',
49         'regexdev',
50         'dmadev',
51         'rib',
52         'reorder',
53         'sched',
54         'security',
55         'stack',
56         'vhost',
57         'ipsec', # ipsec lib depends on net, crypto and security
58         'fib', #fib lib depends on rib
59         'port', # pkt framework libs which use other libs from above
60         'pdump', # pdump lib depends on bpf
61         'table',
62         'pipeline',
63         'flow_classify', # flow_classify lib depends on pkt framework table lib
64         'graph',
65         'node',
66 ]
67
68 optional_libs = [
69         'kni',
70         'power',
71         'vhost',
72 ]
73
74 disabled_libs = []
75 opt_disabled_libs = run_command(list_dir_globs, get_option('disable_libs'),
76         check: true).stdout().split()
77 foreach l:opt_disabled_libs
78     if not optional_libs.contains(l)
79         warning('Cannot disable mandatory library "@0@"'.format(l))
80         continue
81     endif
82     disabled_libs += l
83 endforeach
84
85
86 default_cflags = machine_args
87 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
88 default_cflags += ['-DALLOW_INTERNAL_API']
89
90 if cc.has_argument('-Wno-format-truncation')
91     default_cflags += '-Wno-format-truncation'
92 endif
93
94 enabled_libs = [] # used to print summary at the end
95
96 foreach l:libraries
97     build = true
98     reason = '<unknown reason>' # set if build == false to explain why
99     name = l
100     use_function_versioning = false
101     sources = []
102     headers = []
103     indirect_headers = [] # public headers not directly included by apps
104     driver_sdk_headers = [] # public headers included by drivers
105     includes = []
106     cflags = default_cflags
107     objs = [] # other object files to link against, used e.g. for
108               # instruction-set optimized versions of code
109
110     # use "deps" for internal DPDK dependencies, and "ext_deps" for
111     # external package/library requirements
112     ext_deps = []
113     deps = []
114     # eal is standard dependency once built
115     if dpdk_conf.has('RTE_LIB_EAL')
116         deps += ['eal']
117     endif
118
119     if disabled_libs.contains(l)
120         build = false
121         reason = 'explicitly disabled via build config'
122     else
123         subdir(l)
124     endif
125     if name != l
126         warning('Library name, "@0@", and directory name, "@1@", do not match'.format(name, l))
127     endif
128
129     if not build
130         dpdk_libs_disabled += name
131         set_variable(name.underscorify() + '_disable_reason', reason)
132         continue
133     endif
134
135     shared_deps = ext_deps
136     static_deps = ext_deps
137     foreach d:deps
138         if not is_variable('shared_rte_' + d)
139             error('Missing internal dependency "@0@" for @1@ [@2@]'
140                     .format(d, name, 'lib/' + l))
141         endif
142         shared_deps += [get_variable('shared_rte_' + d)]
143         static_deps += [get_variable('static_rte_' + d)]
144     endforeach
145
146     enabled_libs += name
147     dpdk_conf.set('RTE_LIB_' + name.to_upper(), 1)
148     install_headers(headers)
149     install_headers(indirect_headers)
150     if get_option('enable_driver_sdk')
151         install_headers(driver_sdk_headers)
152     endif
153     dpdk_chkinc_headers += headers
154
155     libname = 'rte_' + name
156     includes += include_directories(l)
157
158     if developer_mode and is_windows and use_function_versioning
159         message('@0@: Function versioning is not supported by Windows.'.format(name))
160     endif
161
162     if use_function_versioning
163         cflags += '-DRTE_USE_FUNCTION_VERSIONING'
164     endif
165     cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l
166
167     # first build static lib
168     static_lib = static_library(libname,
169             sources,
170             objects: objs,
171             c_args: cflags,
172             dependencies: static_deps,
173             include_directories: includes,
174             install: true)
175     static_dep = declare_dependency(
176             include_directories: includes,
177             dependencies: static_deps)
178
179     if not use_function_versioning or is_windows
180         # use pre-build objects to build shared lib
181         sources = []
182         objs += static_lib.extract_all_objects(recursive: false)
183     else
184         # for compat we need to rebuild with
185         # RTE_BUILD_SHARED_LIB defined
186         cflags += '-DRTE_BUILD_SHARED_LIB'
187     endif
188     version_map = '@0@/@1@/version.map'.format(
189             meson.current_source_dir(), l)
190     implib = 'librte_' + l + '.dll.a'
191
192     def_file = custom_target(libname + '_def',
193             command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
194             input: version_map,
195             output: '@0@_exports.def'.format(libname))
196
197     mingw_map = custom_target(libname + '_mingw',
198             command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
199             input: version_map,
200             output: '@0@_mingw.map'.format(libname))
201
202     if is_ms_linker
203         lk_args = ['-Wl,/def:' + def_file.full_path()]
204         if meson.version().version_compare('<0.54.0')
205             lk_args += ['-Wl,/implib:lib\\' + implib]
206         endif
207     else
208         if is_windows
209             lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
210         else
211             lk_args = ['-Wl,--version-script=' + version_map]
212         endif
213     endif
214
215     lk_deps = [version_map, def_file, mingw_map]
216     if developer_mode and not is_windows
217         # on unix systems check the output of the
218         # check-symbols.sh script, using it as a
219         # dependency of the .so build
220         lk_deps += custom_target(name + '.sym_chk',
221                 command: [check_symbols,
222                     version_map, '@INPUT@'],
223                 capture: true,
224                 input: static_lib,
225                 output: name + '.sym_chk')
226     endif
227
228     shared_lib = shared_library(libname,
229             sources,
230             objects: objs,
231             c_args: cflags,
232             dependencies: shared_deps,
233             include_directories: includes,
234             link_args: lk_args,
235             link_depends: lk_deps,
236             version: abi_version,
237             soversion: so_version,
238             install: true)
239     shared_dep = declare_dependency(link_with: shared_lib,
240             include_directories: includes,
241             dependencies: shared_deps)
242
243     dpdk_libraries = [shared_lib] + dpdk_libraries
244     dpdk_static_libraries = [static_lib] + dpdk_static_libraries
245
246     set_variable('shared_rte_' + name, shared_dep)
247     set_variable('static_rte_' + name, static_dep)
248     if developer_mode
249         message('lib/@0@: Defining dependency "@1@"'.format(l, name))
250     endif
251 endforeach