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