raw/skeleton: fix test of attribute set/get
[dpdk.git] / drivers / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
3
4 if is_windows
5         subdir_done()
6 endif
7
8 # Defines the order in which the drivers are buit.
9 dpdk_driver_classes = ['common',
10                'bus',
11                'mempool', # depends on common and bus.
12                'net',     # depends on common, bus and mempool.
13                'crypto',  # depends on common, bus and mempool (net in future).
14                'compress', # depends on common, bus, mempool.
15                'event',   # depends on common, bus, mempool and net.
16                'baseband', # depends on common and bus.
17                'raw']     # depends on common, bus, mempool, net and event.
18
19 default_cflags = machine_args
20 if cc.has_argument('-Wno-format-truncation')
21         default_cflags += '-Wno-format-truncation'
22 endif
23
24 foreach class:dpdk_driver_classes
25         drivers = []
26         std_deps = []
27         config_flag_fmt = '' # format string used to set the value in dpdk_conf
28         driver_name_fmt = '' # format string for driver name, used to name
29                              # the library, the dependency and to find the
30                              # version file for linking
31
32         subdir(class)
33         class_drivers = []
34
35         foreach drv:drivers
36                 drv_path = join_paths(class, drv)
37
38                 # set up empty variables used for build
39                 build = true # set to false to disable, e.g. missing deps
40                 name = drv
41                 version = 1
42                 allow_experimental_apis = false
43                 sources = []
44                 objs = []
45                 cflags = default_cflags
46                 includes = [include_directories(drv_path)]
47                 # set up internal deps. Drivers can append/override as necessary
48                 deps = std_deps
49                 # ext_deps: Stores external library dependency got
50                 # using dependency() (preferred) or find_library().
51                 # For the find_library() case (but not with dependency()) we also
52                 # need to specify the "-l" flags in pkgconfig_extra_libs variable
53                 # too, so that it can be reflected in the pkgconfig output for
54                 # static builds.
55                 ext_deps = []
56                 pkgconfig_extra_libs = []
57
58                 # pull in driver directory which should assign to each of the above
59                 subdir(drv_path)
60
61                 if build
62                         class_drivers += name
63
64                         dpdk_conf.set(config_flag_fmt.format(name.to_upper()),1)
65                         lib_name = driver_name_fmt.format(name)
66
67                         if allow_experimental_apis
68                                 cflags += '-DALLOW_EXPERIMENTAL_API'
69                         endif
70
71                         # get dependency objs from strings
72                         shared_objs = []
73                         static_objs = []
74                         foreach d:deps
75                                 if not is_variable('shared_rte_' + d)
76                                         error('Missing dependency ' + d +
77                                                 ' for driver ' + lib_name)
78                                 endif
79                                 shared_objs += [get_variable('shared_rte_' + d)]
80                                 static_objs += [get_variable('static_rte_' + d)]
81                         endforeach
82                         shared_objs += ext_deps
83                         static_objs += ext_deps
84                         dpdk_extra_ldflags += pkgconfig_extra_libs
85
86                         # generate pmdinfo sources by building a temporary
87                         # lib and then running pmdinfogen on the contents of
88                         # that lib. The final lib reuses the object files and
89                         # adds in the new source file.
90                         out_filename = lib_name + '.pmd.c'
91                         tmp_lib = static_library('tmp_' + lib_name,
92                                         sources,
93                                         include_directories: includes,
94                                         dependencies: static_objs,
95                                         c_args: cflags)
96                         objs += tmp_lib.extract_all_objects()
97                         sources = custom_target(out_filename,
98                                         command: [pmdinfo, tmp_lib.full_path(),
99                                                 '@OUTPUT@', pmdinfogen],
100                                         output: out_filename,
101                                         depends: [pmdinfogen, tmp_lib])
102
103                         if get_option('per_library_versions')
104                                 lib_version = '@0@.1'.format(version)
105                                 so_version = '@0@'.format(version)
106                         else
107                                 lib_version = major_version
108                                 so_version = major_version
109                         endif
110
111                         # now build the static driver
112                         static_lib = static_library(lib_name,
113                                 sources,
114                                 objects: objs,
115                                 include_directories: includes,
116                                 dependencies: static_objs,
117                                 c_args: cflags,
118                                 install: true)
119
120                         # now build the shared driver
121                         version_map = '@0@/@1@/@2@_version.map'.format(
122                                         meson.current_source_dir(),
123                                         drv_path, lib_name)
124                         shared_lib = shared_library(lib_name,
125                                 sources,
126                                 objects: objs,
127                                 include_directories: includes,
128                                 dependencies: shared_objs,
129                                 c_args: cflags,
130                                 link_args: '-Wl,--version-script=' + version_map,
131                                 link_depends: version_map,
132                                 version: lib_version,
133                                 soversion: so_version,
134                                 install: true,
135                                 install_dir: driver_install_path)
136
137                         # create a dependency object and add it to the global dictionary so
138                         # testpmd or other built-in apps can find it if necessary
139                         shared_dep = declare_dependency(link_with: shared_lib,
140                                         include_directories: includes,
141                                         dependencies: shared_objs)
142                         static_dep = declare_dependency(link_with: static_lib,
143                                         include_directories: includes,
144                                         dependencies: static_objs)
145
146                         dpdk_drivers += static_lib
147
148                         set_variable('shared_@0@'.format(lib_name), shared_dep)
149                         set_variable('static_@0@'.format(lib_name), static_dep)
150                 endif # build
151         endforeach
152
153         set_variable(class + '_drivers', class_drivers)
154 endforeach