This repository has been archived by the owner on Jul 25, 2023. It is now read-only.
forked from libbpf/libbpf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmeson.build
95 lines (75 loc) · 2.69 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# SPDX-License-Identifier: LGPL-2.1 OR BSD-2-Clause
project('libbpf', 'c',
version : '0.0.3',
license : 'LGPL-2.1 OR BSD-2-Clause',
default_options : [
'prefix=/usr',
],
meson_version : '>= 0.46',
)
patchlevel = meson.project_version().split('.')[1]
libbpf_source_dir = './'
libbpf_sources = files(run_command('find',
[
'@0@/src'.format(libbpf_source_dir),
'-type',
'f',
'-name',
'*.[h|c]']).stdout().split())
libbpf_headers = files(
join_paths(libbpf_source_dir, 'src/bpf.h'),
join_paths(libbpf_source_dir, 'src/btf.h'),
join_paths(libbpf_source_dir, 'src/libbpf.h'))
feature_rellocarray = run_command(join_paths(libbpf_source_dir, 'scripts/check-reallocarray.sh'))
libbpf_c_args = ['-g',
'-O2',
'-Werror',
'-Wall',
]
if feature_rellocarray.stdout().strip() != ''
libbpf_c_args += '-DCOMPAT_NEED_REALLOCARRAY'
endif
# bpf_includes are required to include bpf.h, btf.h, libbpf.h
bpf_includes = include_directories(
join_paths(libbpf_source_dir, 'src'))
libbpf_includes = include_directories(
join_paths(libbpf_source_dir, 'include'),
join_paths(libbpf_source_dir, 'include/uapi'))
libelf = dependency('libelf')
libelf = dependency('libelf', required: false)
if not libelf.found()
libelf = cc.find_library('elf', required: true)
endif
deps = [libelf]
libbpf_static = static_library(
'bpf',
libbpf_sources,
c_args : libbpf_c_args,
dependencies : deps,
include_directories : libbpf_includes,
install : true)
libbpf_static_dep = declare_dependency(link_with : libbpf_static)
libbpf_map_source_path = join_paths(libbpf_source_dir, 'src/libbpf.map')
libbpf_map_abs_path = join_paths(meson.current_source_dir(), libbpf_map_source_path)
libbpf_c_args += ['-fPIC', '-fvisibility=hidden']
libbpf_link_args = ['-Wl,--version-script=@0@'.format(libbpf_map_abs_path)]
libbpf_shared = shared_library(
'bpf',
libbpf_sources,
c_args : libbpf_c_args,
dependencies : deps,
include_directories : libbpf_includes,
install : true,
link_args : libbpf_link_args,
link_depends : libbpf_map_source_path,
soversion : patchlevel,
version : meson.project_version())
libbpf_shared_dep = declare_dependency(link_with : libbpf_shared)
install_headers(libbpf_headers, subdir : 'bpf')
pkg = import('pkgconfig')
pkg.generate(
name: meson.project_name(),
version: meson.project_version(),
libraries: libbpf_shared,
requires_private: ['libelf'],
description: '''BPF library''')