-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
94 lines (79 loc) · 1.94 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
# SPDX-FileCopyrightText: Red Hat Inc
# SPDX-License-Identifier: LGPL-2.1-or-later
project(
'blkhash', 'c',
version: '0.11.0',
license: 'LGPL-2.1-or-later',
meson_version: '>= 0.58.0',
default_options: [
'b_pie=true',
'buildtype=debugoptimized',
'c_std=gnu99',
'warning_level=2',
],
)
conf_data = configuration_data()
libnbd = dependency(
'libnbd',
version : '>=1.2.2', # RHEL 8.5
required: get_option('nbd'),
)
conf_data.set('HAVE_NBD', libnbd.found())
openssl = dependency('openssl')
blake3 = dependency(
'libblake3',
required: get_option('blake3'),
)
conf_data.set('HAVE_BLAKE3', blake3.found())
compiler = meson.get_compiler('c')
detect_cache_line_size = '''
#include <stdio.h>
#include <sys/param.h>
#if defined(linux)
#include <unistd.h>
#endif
#if defined(__APPLE__)
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
int main()
{
size_t cache_line_size = 64;
#ifdef CACHE_LINE_SIZE
cache_line_size = CACHE_LINE_SIZE;
#endif
#ifdef _SC_LEVEL1_DCACHE_LINESIZE
cache_line_size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
#endif
#if defined(__APPLE__)
size_t size = sizeof(cache_line_size);
sysctlbyname("hw.cachelinesize", &cache_line_size, &size, 0, 0);
#endif
printf("%ld\n", cache_line_size);
}
'''
result = compiler.run(
detect_cache_line_size,
name: 'detect cache line size',
)
if result.returncode() == 0
conf_data.set('CACHE_LINE_SIZE', result.stdout().strip())
endif
summary_info = {}
summary_info += {'nbd': conf_data.get('HAVE_NBD')}
summary_info += {'blake3': conf_data.get('HAVE_BLAKE3')}
summary_info += {'cache line size': conf_data.get('CACHE_LINE_SIZE')}
summary(summary_info, bool_yn: true, section: 'config')
configure_file(
output : 'blkhash-config.h',
configuration : conf_data,
)
config_inc = include_directories('.')
subdir('include')
subdir('common')
subdir('lib')
subdir('bin')
subdir('test')
subdir('man')
pkg_config = import('pkgconfig')
pkg_config.generate(blkhash_lib)