buildtools: make experimental symbol check lighter
[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         'eal', # everything depends on eal
14         'ring', 'mempool', 'mbuf', 'net', 'meter', 'ethdev', 'pci', # core
15         'cmdline',
16         'metrics', # bitrate/latency stats depends on this
17         'hash',    # efd depends on this
18         'timer',   # eventdev depends on this
19         'acl', 'bbdev', 'bitratestats', 'cfgfile',
20         'compressdev', 'cryptodev',
21         'distributor', 'efd', 'eventdev',
22         'gro', 'gso', 'ip_frag', 'jobstats',
23         'kni', 'latencystats', 'lpm', 'member',
24         'power', 'pdump', 'rawdev',
25         'rcu', 'reorder', 'sched', 'security', 'stack', 'vhost',
26         # ipsec lib depends on net, crypto and security
27         'ipsec',
28         # add pkt framework libs which use other libs from above
29         'port', 'table', 'pipeline',
30         # flow_classify lib depends on pkt framework table lib
31         'flow_classify', 'bpf', 'telemetry']
32
33 if is_windows
34         libraries = ['kvargs','eal'] # only supported libraries for windows
35 endif
36
37 default_cflags = machine_args
38 if cc.has_argument('-Wno-format-truncation')
39         default_cflags += '-Wno-format-truncation'
40 endif
41
42 enabled_libs = [] # used to print summary at the end
43
44 foreach l:libraries
45         build = true
46         reason = '<unknown reason>' # set if build == false to explain why
47         name = l
48         version = 1
49         allow_experimental_apis = false
50         sources = []
51         headers = []
52         includes = []
53         cflags = default_cflags
54         objs = [] # other object files to link against, used e.g. for
55                   # instruction-set optimized versions of code
56
57         # use "deps" for internal DPDK dependencies, and "ext_deps" for
58         # external package/library requirements
59         ext_deps = []
60         deps = []
61         # eal is standard dependency once built
62         if dpdk_conf.has('RTE_LIBRTE_EAL')
63                 deps += ['eal']
64         endif
65
66         dir_name = 'librte_' + l
67         subdir(dir_name)
68
69         if not build
70                 dpdk_libs_disabled += name
71                 set_variable(name.underscorify() + '_disable_reason', reason)
72         else
73                 enabled_libs += name
74                 dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1)
75                 install_headers(headers)
76
77                 libname = 'rte_' + name
78                 includes += include_directories(dir_name)
79
80                 if sources.length() == 0
81                         # if no C files, just set a dependency on header path
82                         shared_dep = declare_dependency(include_directories: includes)
83                         static_dep = shared_dep
84                 else
85                         shared_deps = ext_deps
86                         static_deps = ext_deps
87                         foreach d:deps
88                                 if not is_variable('shared_rte_' + d)
89                                         error('Missing dependency ' + d +
90                                                 ' for library ' + libname)
91                                 endif
92                                 shared_deps += [get_variable('shared_rte_' + d)]
93                                 static_deps += [get_variable('static_rte_' + d)]
94                         endforeach
95
96                         if allow_experimental_apis
97                                 cflags += '-DALLOW_EXPERIMENTAL_API'
98                         endif
99
100                         if get_option('per_library_versions')
101                                 lib_version = '@0@.1'.format(version)
102                                 so_version = '@0@'.format(version)
103                         else
104                                 lib_version = major_version
105                                 so_version = major_version
106                         endif
107
108                         # first build static lib
109                         static_lib = static_library(libname,
110                                         sources,
111                                         objects: objs,
112                                         c_args: cflags,
113                                         dependencies: static_deps,
114                                         include_directories: includes,
115                                         install: true)
116                         static_dep = declare_dependency(link_with: static_lib,
117                                         include_directories: includes,
118                                         dependencies: static_deps)
119
120                         # then use pre-build objects to build shared lib
121                         sources = []
122                         objs += static_lib.extract_all_objects(recursive: false)
123                         version_map = '@0@/@1@/rte_@2@_version.map'.format(
124                                         meson.current_source_dir(), dir_name, name)
125                         implib = dir_name + '.dll.a'
126
127                         def_file = custom_target(name + '_def',
128                                 command: [map_to_def_cmd, '@INPUT@', '@OUTPUT@'],
129                                 input: version_map,
130                                 output: 'rte_@0@_exports.def'.format(name))
131                         if is_windows
132                                 lk_args = ['-Wl,/def:' + def_file.full_path(),
133                                         '-Wl,/implib:lib\\' + implib]
134                         else
135                                 lk_args = ['-Wl,--version-script=' + version_map]
136                         endif
137
138                         shared_lib = shared_library(libname,
139                                         sources,
140                                         objects: objs,
141                                         c_args: cflags,
142                                         dependencies: shared_deps,
143                                         include_directories: includes,
144                                         link_args: lk_args,
145                                         link_depends: [version_map, def_file],
146                                         version: lib_version,
147                                         soversion: so_version,
148                                         install: true)
149                         shared_dep = declare_dependency(link_with: shared_lib,
150                                         include_directories: includes,
151                                         dependencies: shared_deps)
152
153                         dpdk_libraries = [shared_lib] + dpdk_libraries
154                         dpdk_static_libraries = [static_lib] + dpdk_static_libraries
155                 endif # sources.length() > 0
156
157                 set_variable('shared_' + libname, shared_dep)
158                 set_variable('static_' + libname, static_dep)
159         endif # if build
160 endforeach