-
Notifications
You must be signed in to change notification settings - Fork 8
/
meson.build
174 lines (138 loc) · 3.85 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
##
## General
## -------
##
project('libvfn', ['c', 'cpp'],
version : '5.1.0',
license : 'LGPL-2.1-or-later',
default_options: [
'warning_level=2',
'c_std=gnu11',
'werror=true',
],
meson_version: '>=0.59.0',
)
add_project_arguments([
'-D_GNU_SOURCE',
], language: ['c', 'cpp'],
)
if get_option('profiling')
add_global_arguments('-pg', language: 'c')
add_global_link_arguments('-pg', language: 'c')
endif
if get_option('debug')
add_project_arguments(['-DDEBUG'], language: ['c', 'cpp'])
endif
##
## Programs
## --------
##
perl = find_program('perl')
trace_pl = find_program('scripts/trace.pl')
##
## Compiler Configuration
## ----------------------
##
cc = meson.get_compiler('c')
# strip relative path prefixes from the code if possible
if cc.has_argument('-fmacro-prefix-map=prefix=')
add_project_arguments([
'-fmacro-prefix-map=../=',
], language: 'c',
)
endif
##
## Host Configuration
## ------------------
##
config_host = configuration_data()
# library configuration
config_host.set('NVME_AQ_QSIZE', get_option('aq_qsize'),
description: 'admin command queue size')
config_host.set('HAVE_VFIO_DEVICE_BIND_IOMMUFD',
cc.has_header_symbol('linux/vfio.h', 'VFIO_DEVICE_BIND_IOMMUFD'),
description: 'weather VFIO_DEVICE_BIND_IOMMUFD is defined in linux/vfio.h')
subdir('internal')
add_project_arguments([
'-include', meson.current_build_dir() / 'internal/config-host.h',
], language: 'c',
)
##
## Optional dependencies
## ---------------------
##
# libnvme
libnvme = dependency('libnvme', version: '>=1.0',
required: get_option('libnvme'), disabler: true,
)
##
## Subdirectories
## --------------
##
# collect a list of files to use as dependencies for generating api
# documentation
docs_deps = files()
# core
subdir('ccan')
subdir('include')
subdir('lib')
subdir('src')
# tests
subdir('tests')
# examples
subdir('examples')
# tools
subdir('tools/vfntool')
# documentation
subdir('docs')
##
## Run targets
## -----------
##
# generate tags
ctags = find_program('ctags', required: false)
if ctags.found()
run_target('ctags', command: [
find_program('scripts/ctags.sh')
])
endif
# sparse
sparse = find_program('cgcc', required: false)
if sparse.found()
run_target('sparse', command: [
find_program('scripts/sparse.py'), 'compile_commands.json', sparse.full_path(),
'-Wbitwise-pointer', '-Wconstant-suffix', '-Wshadow', '-Wundef', '-Wunion-cast',
'-Wdeclaration-after-statement',
], depends: [trace_events_h, trace_events_c, crc64table_h])
endif
##
## Summaries
## ---------
##
summary_info = {}
summary_info += {'Install prefix': get_option('prefix')}
summary_info += {'Binary directory': get_option('bindir')}
summary_info += {'Library directory': get_option('libdir')}
summary_info += {'Include directory': get_option('includedir')}
summary_info += {'Build directory': meson.current_build_dir()}
summary(summary_info, section: 'Directories')
summary_info = {}
summary_info += {'Host CPU': host_machine.cpu_family()}
summary_info += {'Host endianness': host_machine.endian()}
summary_info += {'C compiler': ' '.join(cc.cmd_array())}
summary_info += {'CFLAGS': ' '.join(get_option('c_args')
+ ['-O' + get_option('optimization')]
+ (get_option('debug') ? ['-g'] : [])
+ (get_option('profiling') ? ['-pg'] : []))}
summary_info += {'LDFLAGS': ' '.join(get_option('c_link_args')
+ (get_option('profiling') ? ['-pg'] : []))}
summary(summary_info, section: 'Compilation')
summary_info = {}
summary_info += {'libnvme': libnvme.found()}
summary(summary_info, bool_yn: true, section: 'Dependencies')
summary_info = {}
summary_info += {'Debugging': get_option('debug')}
summary_info += {'Documentation': build_docs}
summary_info += {'Profiling': get_option('profiling')}
summary_info += {'iommufd': config_host.get('HAVE_VFIO_DEVICE_BIND_IOMMUFD')}
summary(summary_info, bool_yn: true, section: 'Features')