build: remove library special cases
[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
33 # process all libraries equally, as far as possible
34 # "core" libs first, then others alphebetically as far as possible
35 # NOTE: for speed of meson runs, the dependencies in the subdirectories
36 # sometimes skip deps that would be implied by others, e.g. if mempool is
37 # given as a dep, no need to mention ring. This is especially true for the
38 # core libs which are widely reused, so their deps are kept to a minimum.
39 libraries = [ 'compat', # just a header, used for versioning
40         'eal', 'ring', 'mempool', 'mbuf', 'net', 'ether', 'pci', # core
41         'metrics', # bitrate/latency stats depends on this
42         'hash',    # efd depends on this
43         'kvargs',  # cryptodev depends on this
44         'acl', 'bbdev', 'bitratestats', 'cfgfile',
45         'cmdline', 'cryptodev',
46         'distributor', 'efd', 'eventdev',
47         'gro', 'gso', 'ip_frag', 'jobstats',
48         'kni', 'latencystats', 'lpm', 'member',
49         'meter', 'power', 'pdump',
50         'reorder', 'sched', 'security', 'timer', 'vhost',
51         # add pkt framework libs which use other libs from above
52         'port', 'table', 'pipeline',
53         # flow_classify lib depends on pkt framework table lib
54         'flow_classify']
55
56 foreach l:libraries
57         build = true
58         name = l
59         version = 1
60         allow_experimental_apis = false
61         sources = []
62         headers = []
63         includes = []
64         cflags = []
65         objs = [] # other object files to link against, used e.g. for
66                   # instruction-set optimized versions of code
67
68         # use "deps" for internal DPDK dependencies, and "ext_deps" for
69         # external package/library requirements
70         ext_deps = []
71         deps = ['eal']   # eal is standard dependency except for itself
72         if l == 'eal'
73                 deps = []
74         endif
75
76         dir_name = 'librte_' + l
77         subdir(dir_name)
78
79         if build
80                 dpdk_conf.set('RTE_LIBRTE_' + name.to_upper(), 1)
81                 install_headers(headers)
82
83                 libname = 'rte_' + name
84                 includes += include_directories(dir_name)
85
86                 if sources.length() == 0
87                         # if no C files, just set a dependency on header path
88                         dep = declare_dependency(include_directories: includes)
89                 else
90                         dep_objs = ext_deps
91                         foreach d:deps
92                                 dep_objs += [get_variable('dep_rte_' + d)]
93                         endforeach
94
95                         if allow_experimental_apis
96                                 cflags += '-DALLOW_EXPERIMENTAL_API'
97                         endif
98
99                         if get_option('per_library_versions')
100                                 lib_version = '@0@.1'.format(version)
101                                 so_version = '@0@'.format(version)
102                         else
103                                 prj_ver = meson.project_version().split('.')
104                                 lib_version = '@0@.@1@'.format(
105                                                 prj_ver.get(0), prj_ver.get(1))
106                                 so_version = lib_version
107                         endif
108
109                         version_map = '@0@/@1@/rte_@2@_version.map'.format(
110                                         meson.current_source_dir(), dir_name, name)
111                         lib = library(libname,
112                                         sources,
113                                         objects: objs,
114                                         c_args: cflags,
115                                         dependencies: dep_objs,
116                                         include_directories: includes,
117                                         link_args: '-Wl,--version-script=' + version_map,
118                                         link_depends: version_map,
119                                         version: lib_version,
120                                         soversion: so_version,
121                                         install: true)
122                         dep = declare_dependency(link_with: lib,
123                                         include_directories: includes,
124                                         dependencies: dep_objs)
125
126                         dpdk_libraries = [lib] + dpdk_libraries
127                 endif # sources.length() > 0
128
129                 set_variable('dep_' + libname, dep)
130         endif # if build
131 endforeach