forked from linux-nvme/nvme-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
115 lines (100 loc) · 3.24 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
################################################################################
project(
'nvme-cli', ['c', 'cpp'],
meson_version: '>= 0.47.0',
license: 'LGPLv2+',
version: run_command('./nvme-cli-version', check : true).stdout().strip(),
default_options: [
'c_std=gnu99',
'buildtype=release',
'prefix=/usr',
]
)
################################################################################
cc = meson.get_compiler('c')
prefixdir = get_option('prefix')
libdir = join_paths(prefixdir, get_option('libdir'))
includedir = join_paths(prefixdir, get_option('includedir'))
datadir = join_paths(prefixdir, get_option('datadir'))
mandir = join_paths(prefixdir, get_option('mandir'))
bindir = join_paths(prefixdir, get_option('bindir'))
###############################################################################
conf = configuration_data()
libnvme_dep = dependency('libnvme', fallback : ['libnvme', 'libnvme_dep'])
# Check for libuuid availability
libuuid = dependency('uuid', required: true)
conf.set('LIBUUID', libuuid.found(), description: 'Is libuuid required?')
# Check for libjson-c availability
json_c = dependency('json-c', version: '>=0.13', fallback : ['json-c', 'json_c'])
conf.set('CONFIG_JSONC', json_c.found(), description: 'Is json-c required?')
# Check for libhugetlbfs availability
libhugetlbfs = dependency('hugetlbfs', required: false)
conf.set('LIBHUGETLBFS', libhugetlbfs.found(), description: 'Is libhugetlbfs required?')
# Set the nvme-cli version
conf.set('NVME_VERSION', '"' + meson.project_version() + '"')
conf.set10(
'HAVE_BYTESWAP_H',
cc.compiles(
'''#include <byteswap.h>''',
name: 'byteswap.h'
),
description: 'Is byteswap.h include-able?'
)
conf.set10(
'HAVE_BSWAP_64',
cc.links(
'''#include <byteswap.h>
int main(void) {
return bswap_64(0);
}
''',
name: 'bswap64'
),
description: 'Is bswap_64 available?'
)
conf.set10(
'HAVE_LITTLE_ENDIAN',
build_machine.endian() == 'little',
description: 'Building for little-endian'
)
conf.set10(
'HAVE_BIG_ENDIAN',
build_machine.endian() == 'big',
description: 'Building for big-endian'
)
configure_file(
output: 'config-host.h',
configuration: conf
)
################################################################################
substs = configuration_data()
substs.set('NAME', meson.project_name())
substs.set('VERSION', meson.project_version())
substs.set('LICENSE', meson.project_license()[0])
configure_file(
input: 'nvme.spec.in',
output: 'nvme.spec',
configuration: substs,
)
################################################################################
add_project_arguments(['-fomit-frame-pointer', '-D_GNU_SOURCE',
'-include', 'config-host.h'], language : 'c')
incdir = include_directories(['ccan'])
################################################################################
sources = [
'fabrics.c',
'nvme.c',
'nvme-models.c',
'nvme-print.c',
'nvme-rpmb.c',
'plugin.c',
]
subdir('plugins')
subdir('tests')
subdir('util')
executable(
'nvme',
sources,
dependencies: [ libnvme_dep, libuuid, json_c ],
include_directories: incdir,
)