a4f5f28b150abea1ec74cff5ce7cc58dca26b9d5
[dpdk.git] / lib / meson.build
1 #   BSD LICENSE
2 #
3 #   Copyright(c) 2017 Intel Corporation.
4 #   All rights reserved.
5 #
6 #   Redistribution and use in source and binary forms, with or without
7 #   modification, are permitted provided that the following conditions
8 #   are met:
9 #
10 #     * Redistributions of source code must retain the above copyright
11 #       notice, this list of conditions and the following disclaimer.
12 #     * Redistributions in binary form must reproduce the above copyright
13 #       notice, this list of conditions and the following disclaimer in
14 #       the documentation and/or other materials provided with the
15 #       distribution.
16 #     * Neither the name of Intel Corporation nor the names of its
17 #       contributors may be used to endorse or promote products derived
18 #       from this software without specific prior written permission.
19 #
20 #   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 #   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 #   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 #   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 #   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 #   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 #   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 #   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 # special case for eal, not a simple lib, and compat, just a header
33 subdir('librte_eal')
34 subdir('librte_compat')
35
36 # process all libraries equally, as far as possible
37 # "core" libs first, then others alphebetically as far as possible
38 # NOTE: for speed of meson runs, the dependencies in the subdirectories
39 # sometimes skip deps that would be implied by others, e.g. if mempool is
40 # given as a dep, no need to mention ring. This is especially true for the
41 # core libs which are widely reused, so their deps are kept to a minimum.
42 libraries = ['ring', 'mempool', 'mbuf', 'net', 'ether', 'pci', # core
43         'metrics', # bitrate/latency stats depends on this
44         'hash',    # efd depends on this
45         'kvargs',  # cryptodev depends on this
46         'acl', 'bbdev', 'bitratestats', 'cfgfile',
47         'cmdline', 'cryptodev',
48         'distributor', 'efd', 'eventdev',
49         'gro', 'gso', 'ip_frag', 'jobstats',
50         'kni', 'latencystats', 'lpm', 'member',
51         'meter', 'power', 'pdump',
52         'reorder', 'sched', 'security', 'timer', 'vhost',
53         # add pkt framework libs which use other libs from above
54         'port', 'table', 'pipeline',
55         # flow_classify lib depends on pkt framework table lib
56         'flow_classify']
57
58 foreach l:libraries
59         build = true
60         name = l
61         version = 1
62         allow_experimental_apis = false
63         sources = []
64         headers = []
65         cflags = []
66         objs = [] # other object files to link against, used e.g. for instruction-
67                   # optimized versions of code
68         # use "deps" for internal DPDK dependencies, and "ext_deps" for
69         # external package/library requirements
70         deps = ['eal']
71         ext_deps = []
72
73         dir_name = 'librte_' + l
74         subdir(dir_name)
75
76         if build
77                 dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1)
78                 install_headers(headers)
79
80                 dep_objs = ext_deps
81                 foreach d:deps
82                         dep_objs += [get_variable('dep_rte_' + d)]
83                 endforeach
84
85                 if allow_experimental_apis
86                         cflags += '-DALLOW_EXPERIMENTAL_API'
87                 endif
88
89                 version_map = '@0@/@1@/rte_@2@_version.map'.format(
90                                 meson.current_source_dir(), dir_name, name)
91                 libname = 'rte_' + name
92                 lib = library(libname,
93                                 sources,
94                                 objects: objs,
95                                 c_args: cflags,
96                                 dependencies: dep_objs,
97                                 include_directories: include_directories(dir_name),
98                                 link_args: '-Wl,--version-script=' + version_map,
99                                 link_depends: version_map,
100                                 version: '@0@.1'.format(version),
101                                 install: true)
102                 dep = declare_dependency(link_with: lib,
103                                 include_directories: include_directories(dir_name),
104                                 dependencies: dep_objs)
105                 set_variable('dep_' + libname, dep)
106
107                 dpdk_libraries = [lib] + dpdk_libraries
108         endif
109 endforeach