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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2019 - 2021 IƱigo Martinez <inigomartinez@gmail.com>
project(
'libqmi', 'c',
version: '1.33.900',
license: 'GPL2',
default_options: [
'buildtype=debugoptimized',
'c_std=gnu89',
'warning_level=2',
],
meson_version: '>= 0.53.0',
)
qmi_name = meson.project_name()
qmi_version = meson.project_version()
version_array = qmi_version.split('.')
qmi_major_version = version_array[0].to_int()
qmi_minor_version = version_array[1].to_int()
qmi_micro_version = version_array[2].to_int()
qmi_prefix = get_option('prefix')
qmi_bindir = get_option('bindir')
qmi_datadir = get_option('datadir')
qmi_includedir = get_option('includedir')
qmi_libexecdir = get_option('libexecdir')
qmi_mandir = get_option('mandir')
qmi_glib_include_subdir = qmi_name + '-glib'
qmi_glib_pkgincludedir = qmi_includedir / qmi_glib_include_subdir
# libtool versioning for libqmi-glib (-version-info c:r:a)
# - If the interface is unchanged, but the implementation has changed or been fixed, then increment r
# - Otherwise, increment c and zero r.
# - If the interface has grown (that is, the new library is compatible with old code), increment a.
# - If the interface has changed in an incompatible way (that is, functions have changed or been removed), then zero a.
current = 14
revision = 0
age = 9
qmi_glib_version = '@0@.@1@.@2@'.format(current - age, age, revision)
qmi_gir_version = '1.0'
gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')
python = import('python').find_installation('python3')
source_root = meson.current_source_dir()
data_dir = source_root / 'data'
templates_dir = source_root / 'build-aux/templates'
qmi_codegen = find_program(source_root / 'build-aux/qmi-codegen/qmi-codegen')
qmi_mkenums = find_program(source_root / 'build-aux/qmi-mkenums')
top_inc = include_directories('.')
cc = meson.get_compiler('c')
config_h = configuration_data()
config_h.set_quoted('PACKAGE_VERSION', qmi_version)
# compiler flags
common_flags = ['-DHAVE_CONFIG_H']
# compiler flags that are always enabled, even in release builds
cc_flags = cc.get_supported_arguments([
# warning on unused parameters is overkill, never do that
'-Wno-unused-parameter',
# function type cast disabled: used throughout the code especially to
# cast GAsyncReadyCallbacks with the real object type instead of GObject
'-Wno-cast-function-type',
# all message protocol structs are packed, never complain about it
'-Wno-packed',
])
# strict flags to use in debug builds
if get_option('buildtype').contains('debug')
cc_flags += cc.get_supported_arguments([
'-fno-strict-aliasing',
'-Waggregate-return',
'-Wcast-align',
'-Wdeclaration-after-statement',
'-Wdouble-promotion',
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wfloat-equal',
'-Wformat=2',
'-Wformat-nonliteral',
'-Wformat-security',
'-Winit-self',
'-Winline',
'-Wjump-misses-init',
'-Wlogical-op',
'-Wnested-externs',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wmissing-prototypes',
'-Wnull-dereference',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wrestrict',
'-Wreturn-type',
'-Wshadow',
'-Wstrict-prototypes',
'-Wsuggest-attribute=format',
'-Wswitch-default',
'-Wswitch-enum',
'-Wundef',
'-Wunused-but-set-variable',
'-Wwrite-strings',
])
endif
add_project_arguments(common_flags + cc_flags, language: 'c')
no_deprecated_declarations_flags = cc.get_supported_arguments('-Wno-deprecated-declarations')
glib_version = '2.56'
glib_dep = dependency('glib-2.0', version: '>= ' + glib_version)
gio_unix_dep = dependency('gio-unix-2.0')
deps = [
glib_dep,
dependency('gio-2.0'),
dependency('gobject-2.0'),
]
c_flags = [
'-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_' + glib_version.underscorify(),
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_' + glib_version.underscorify(),
'-DGLIB_DISABLE_DEPRECATION_WARNINGS',
]
glib_deps = declare_dependency(
dependencies: deps,
compile_args: c_flags,
)
# message collection (existing file in data/qmi-collection-${COLLECTION}.json)
# dnl custom collections may be added as files in data/
qmi_collection_name = get_option('collection')
# qmi-firmware-update is optional, enabled by default
enable_firmware_update = get_option('firmware_update')
assert(not enable_firmware_update or qmi_collection_name != 'minimal', 'Cannot build qmi-firmware-update when \'minimal\' collection enabled, use at least the \'basic\' collection instead.')
# udev support is optional, enabled by default
enable_udev = get_option('udev')
if enable_udev
assert(enable_firmware_update, 'Cannot build udev support without firmware_update support')
gudev_dep = dependency('gudev-1.0', version: '>= 232')
endif
config_h.set('WITH_UDEV', enable_udev)
enable_bash_completion = get_option('bash_completion')
if enable_bash_completion
bash_completion_dep = dependency('bash-completion')
bash_completion_completionsdir = bash_completion_dep.get_pkgconfig_variable(
'completionsdir',
# bash-completion 2.10 changed the substitutions
define_variable: bash_completion_dep.version().version_compare('>= 2.10') ? ['datadir', qmi_datadir] : ['prefix', qmi_prefix],
)
endif
# rmnet link management support
enable_rmnet = get_option('rmnet')
config_h.set('RMNET_SUPPORT_ENABLED', enable_rmnet)
# runtime MM check is optional, enabled by default
config_h.set('MM_RUNTIME_CHECK_ENABLED', get_option('mm_runtime_check'))
# QMI username
qmi_username = get_option('qmi_username')
enable_qmi_username = (qmi_username != '')
if enable_qmi_username
config_h.set_quoted('QMI_USERNAME', qmi_username)
# FIXME: udev base directory, prefix can't be overrided
udev_udevdir = get_option('udevdir')
if udev_udevdir == ''
udev_udevdir = dependency('udev').get_pkgconfig_variable('udevdir')
endif
else
qmi_username = 'no (root)'
endif
config_h.set('QMI_USERNAME_ENABLED', enable_qmi_username)
# MBIM QMUX service support
enable_mbim_qmux = get_option('mbim_qmux')
if enable_mbim_qmux
mbim_glib_dep = dependency('mbim-glib', version: '>= 1.18.0')
endif
config_h.set('MBIM_QMUX_ENABLED', enable_mbim_qmux)
# QRTR support
enable_qrtr = get_option('qrtr')
if enable_qrtr
qrtr_glib_dep = dependency('qrtr-glib', version: '>= 1.0.0')
endif
config_h.set10('QMI_QRTR_SUPPORTED', enable_qrtr)
version_conf = configuration_data()
version_conf.set('VERSION', qmi_version)
version_conf.set('QMI_MAJOR_VERSION', qmi_major_version)
version_conf.set('QMI_MINOR_VERSION', qmi_minor_version)
version_conf.set('QMI_MICRO_VERSION', qmi_micro_version)
version_conf.set10('QMI_MBIM_QMUX_SUPPORTED', enable_mbim_qmux)
version_conf.set10('QMI_QRTR_SUPPORTED', enable_qrtr)
version_conf.set10('QMI_RMNET_SUPPORTED', enable_rmnet)
# introspection support
enable_gir = get_option('introspection')
if enable_gir
dependency('gobject-introspection-1.0', version: '>= 0.9.6')
endif
test_env = {
'G_DEBUG': 'gc-friendly',
'MALLOC_CHECK_': '2',
}
subdir('src')
subdir('utils')
enable_gtk_doc = get_option('gtk_doc')
if enable_gtk_doc
assert(qmi_collection_name == 'full', 'Building documentation requires the \'full\' message collection.')
subdir('docs/reference/libqmi-glib')
endif
enable_man = get_option('man')
if enable_man
subdir('docs/man')
endif
enable_fuzzer = get_option('fuzzer')
configure_file(
output: 'config.h',
configuration: config_h,
)
summary({
'compiler': cc.get_id(),
'cflags': cc_flags,
'Documentation': enable_gtk_doc,
'bash completion': enable_bash_completion,
'gobject introspection': enable_gir,
'man pages': enable_man,
'fuzzer': enable_fuzzer,
}, section: 'Build')
summary({
'prefix': qmi_prefix,
'udev base directory': (enable_qmi_username ? udev_udevdir : 'disabled'),
}, section: 'System paths')
summary({
'QMI over MBIM': enable_mbim_qmux,
'QMI over QRTR': enable_qrtr,
'QMI username': qmi_username,
'rmnet support': enable_rmnet,
}, section: 'Features')
|