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