]>
Commit | Line | Data |
---|---|---|
d40ce018 JH |
1 | # SPDX-License-Identifier: LGPL-2.1+ |
2 | ||
77a34a37 YW |
3 | if conf.get('BPF_FRAMEWORK') != 1 |
4 | subdir_done() | |
5 | endif | |
d40ce018 | 6 | |
77a34a37 YW |
7 | clang_flags = [ |
8 | '-Wno-compare-distinct-pointer-types', | |
9 | '-O2', | |
10 | '-target', | |
11 | 'bpf', | |
12 | '-g', | |
13 | '-c', | |
14 | ] | |
15 | ||
e897b07f ZJS |
16 | # Generate defines that are appropriate to tell the compiler what architecture |
17 | # we're compiling for. By default we just map meson's cpu_family to __<cpu_family>__. | |
18 | # This dictionary contains the exceptions where this doesn't work. | |
19 | # | |
20 | # C.f. https://mesonbuild.com/Reference-tables.html#cpu-families | |
21 | # and src/basic/missing_syscall_def.h. | |
22 | cpu_arch_defines = { | |
23 | 'ppc' : ['-D__powerpc__'], | |
24 | 'ppc64' : ['-D__powerpc64__', '-D_CALL_ELF=2'], | |
25 | 'riscv32' : ['-D__riscv', '-D__riscv_xlen=32'], | |
26 | 'riscv64' : ['-D__riscv', '-D__riscv_xlen=64'], | |
27 | 'x86' : ['-D__i386__'], | |
28 | ||
29 | # For arm, assume hardware fp is available. | |
30 | 'arm' : ['-D__arm__', '-D__ARM_PCS_VFP'], | |
31 | } | |
32 | ||
33 | clang_arch_flags = cpu_arch_defines.get(host_machine.cpu_family(), | |
34 | ['-D__@0@__'.format(host_machine.cpu_family())]) | |
77a34a37 YW |
35 | |
36 | if meson.version().version_compare('>= 0.58') | |
37 | libbpf_include_dir = libbpf.get_variable('includedir') | |
38 | else | |
39 | libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir') | |
40 | endif | |
d40ce018 | 41 | |
77a34a37 YW |
42 | bpf_o_unstripped_cmd = [ |
43 | clang, | |
44 | clang_flags, | |
e897b07f | 45 | clang_arch_flags, |
77a34a37 YW |
46 | '-I.' |
47 | ] | |
48 | ||
49 | if not meson.is_cross_build() | |
50 | target_triplet_cmd = run_command('gcc', '-dumpmachine', check: false) | |
51 | if target_triplet_cmd.returncode() == 0 | |
52 | target_triplet = target_triplet_cmd.stdout().strip() | |
53 | bpf_o_unstripped_cmd += [ | |
54 | '-isystem', | |
55 | '/usr/include/@0@'.format(target_triplet) | |
56 | ] | |
57 | endif | |
d40ce018 | 58 | endif |
77a34a37 YW |
59 | |
60 | bpf_o_unstripped_cmd += [ | |
61 | '-idirafter', | |
62 | libbpf_include_dir, | |
63 | '@INPUT@', | |
64 | '-o', | |
65 | '@OUTPUT@' | |
66 | ] | |
67 | ||
e3759ac4 JH |
68 | if bpftool_strip |
69 | bpf_o_cmd = [ | |
70 | bpftool, | |
71 | 'g', | |
72 | 'o', | |
73 | '@OUTPUT@', | |
74 | '@INPUT@' | |
75 | ] | |
76 | else | |
77 | bpf_o_cmd = [ | |
78 | llvm_strip, | |
79 | '-g', | |
80 | '@INPUT@', | |
81 | '-o', | |
82 | '@OUTPUT@' | |
83 | ] | |
84 | endif | |
77a34a37 YW |
85 | |
86 | skel_h_cmd = [ | |
87 | bpftool, | |
88 | 'g', | |
89 | 's', | |
90 | '@INPUT@' | |
91 | ] |