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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
#
# project definition
#
project('spice-gtk', 'c',
version : run_command('build-aux/git-version-gen', '@0@/.tarball-version'.format(meson.source_root()), check : true).stdout().strip(),
license : 'LGPLv2.1',
meson_version : '>= 0.49')
message('Updating submodules')
run_command('build-aux/meson/check-spice-common', check : true)
meson.add_dist_script('sh', '-c', 'echo @0@>"$MESON_DIST_ROOT/.tarball-version"'.format(meson.project_version()))
#
# global C defines
#
spice_gtk_prefix = get_option('prefix')
spice_gtk_bindir = join_paths(spice_gtk_prefix, get_option('bindir'))
spice_gtk_datadir = join_paths(spice_gtk_prefix, get_option('datadir'))
spice_gtk_localedir = join_paths(spice_gtk_datadir, 'locale')
spice_gtk_includedir = join_paths(spice_gtk_prefix, get_option('includedir'))
spice_gtk_global_cflags = ['-DHAVE_CONFIG_H',
'-DSPICE_COMPILATION',
'-DG_LOG_DOMAIN="GSpice"',
#'-Werror',
'-Wall',
'-Wextra',
'-Wno-sign-compare',
'-Wno-unused-parameter',
'-Wno-cast-function-type']
# other global vars
compiler = meson.get_compiler('c')
spice_gtk_config_data = configuration_data()
spice_gtk_include = [include_directories('.')]
spice_glib_deps = []
spice_gtk_deps = []
spice_acl_deps = []
#
# Set up subprojects
#
spice_common = subproject('spice-common', default_options : ['generate-code=client'])
spice_gtk_config_data.merge_from(spice_common.get_variable('spice_common_config_data'))
spice_glib_deps += spice_common.get_variable('spice_common_client_dep')
subproject('keycodemapdb')
keymapgen = files('subprojects/keycodemapdb/tools/keymap-gen')
keymapcsv = files('subprojects/keycodemapdb/data/keymaps.csv')
#
# check for system headers
#
headers = ['termios.h',
'X11/XKBlib.h']
foreach header : headers
if compiler.has_header(header)
spice_gtk_config_data.set('HAVE_@0@'.format(header.underscorify().to_upper()), '1')
endif
endforeach
spice_gtk_has_egl = compiler.has_header('epoxy/egl.h')
if spice_gtk_has_egl
spice_gtk_config_data.set('HAVE_EPOXY_EGL_H', '1')
spice_gtk_config_data.set('HAVE_EGL', '1') # FIXME: Use single define?
endif
#
# check for system functions
#
foreach func : ['clearenv', 'strtok_r']
if compiler.has_function(func)
spice_gtk_config_data.set('HAVE_@0@'.format(func.underscorify().to_upper()), '1')
endif
endforeach
#
# check for mandatory dependencies
#
spice_protocol_version='>= 0.12.15'
glib_version = '2.46'
glib_version_info = '>= @0@'.format(glib_version)
pixman_version = '>= 0.17.7'
deps = {'spice-protocol' : spice_protocol_version,
'glib-2.0' : glib_version_info,
'gio-2.0' : glib_version_info,
'gobject-2.0' : glib_version_info,
'pixman-1' : pixman_version,
'openssl' : '>= 1.0.0'}
foreach dep, version : deps
spice_glib_deps += dependency(dep, version : version)
endforeach
# mandatory dependencies, without specific version requirement
# TODO: specify minimum version for cairo, jpeg and zlib?
deps = ['cairo', 'libjpeg', 'zlib', 'json-glib-1.0']
if host_machine.system() == 'windows'
deps += 'gio-windows-2.0'
else
deps += 'gio-unix-2.0'
endif
foreach dep : deps
spice_glib_deps += dependency(dep)
endforeach
deps = []
if host_machine.system() == 'windows'
deps += ['libws2_32', 'libgdi32']
endif
foreach dep : deps
spice_glib_deps += compiler.find_library(dep)
endforeach
#
# Non-mandatory/optional dependencies
#
optional_deps = {'celt051' : '>= 0.5.1.1',
'opus' : '>= 0.9.14'}
foreach dep, version : optional_deps
d = dependency(dep, required : get_option(dep), version : version)
if d.found()
spice_glib_deps += d
spice_gtk_config_data.set('HAVE_@0@'.format(dep.underscorify().to_upper()), '1')
endif
endforeach
# gtk
spice_gtk_has_gtk = false
gtk_version_required = '3.22'
d = dependency('gtk+-3.0', version : '>= @0@'.format(gtk_version_required),
required: get_option('gtk'))
if d.found()
spice_gtk_deps += d
if host_machine.system() != 'windows'
spice_gtk_deps += dependency('epoxy')
spice_gtk_deps += dependency('x11')
d = dependency('libva-x11', required: false)
if d.found()
spice_gtk_deps += d
spice_gtk_config_data.set('HAVE_LIBVA', '1')
endif
endif
spice_gtk_has_gtk = true
endif
# webdav
spice_gtk_has_phodav = false
d = dependency('libphodav-2.0', required: get_option('webdav'))
if d.found()
spice_glib_deps += d
d = dependency('libsoup-2.4', version : '>= 2.49.91', required: get_option('webdav'))
if d.found()
spice_glib_deps += d
spice_gtk_config_data.set('USE_PHODAV', '1')
spice_gtk_has_phodav = true
endif
endif
# pulse
spice_gtk_has_pulse = false
d = dependency('libpulse-mainloop-glib', required: get_option('pulse'))
if d.found()
warning('PulseAudio backend is deprecated and will be removed in a future release')
spice_glib_deps += d
spice_gtk_config_data.set('HAVE_PULSE', '1')
spice_gtk_has_pulse = true
endif
gstreamer_version = '1.10'
gstreamer_version_info = '>= @0@'.format(gstreamer_version)
deps = ['gstreamer-1.0', 'gstreamer-base-1.0', 'gstreamer-app-1.0', 'gstreamer-audio-1.0', 'gstreamer-video-1.0']
foreach dep : deps
spice_glib_deps += dependency(dep, version: gstreamer_version_info)
endforeach
# builtin-mjpeg
spice_gtk_has_builtin_mjpeg = false
if get_option('builtin-mjpeg')
spice_gtk_config_data.set('HAVE_BUILTIN_MJPEG', '1')
spice_gtk_has_builtin_mjpeg = true
endif
# usbredir
spice_gtk_has_usbredir = false
d1 = dependency('libusbredirparser-0.5', required : get_option('usbredir'))
d2 = dependency('libusbredirhost', version : '>= 0.4.2', required : get_option('usbredir'))
d3 = dependency('libusb-1.0', version : '>= 1.0.16', required : get_option('usbredir'))
if d1.found() and d2.found() and d3.found()
spice_glib_deps += [d1, d2, d3]
spice_gtk_config_data.set('USE_USBREDIR', '1')
spice_gtk_has_usbredir = true
endif
# polkit
spice_gtk_has_polkit = false
d = dependency('polkit-gobject-1', version : '>= 0.96', required : get_option('polkit'))
if d.found()
spice_gtk_policy_dir = d.get_pkgconfig_variable('policydir')
foreach func : ['polkit_authority_get_sync', 'polkit_authorization_result_get_dismissed']
if compiler.has_function(func, dependencies : d)
spice_gtk_config_data.set('HAVE_@0@'.format(func.to_upper()), '1')
endif
endforeach
# TODO: With 'auto', we should just disable polkit support if this is missing.
if not compiler.has_function('acl_get_file')
acl_dep = compiler.find_library('acl')
if not compiler.has_function('acl_get_file', dependencies : acl_dep)
error('PolicyKit support requested, but some required packages are not available')
endif
spice_acl_deps += acl_dep
endif
spice_acl_deps += d
spice_acl_deps += dependency('gio-unix-2.0')
spice_gtk_config_data.set('USE_POLKIT', '1')
spice_gtk_has_polkit = true
endif
if spice_gtk_has_usbredir and not spice_gtk_has_polkit
warning('Building with usbredir support, but *not* building the usb acl helper')
endif
# pie
spice_gtk_has_pie = false
if get_option('pie')
spice_gtk_has_pie = true
endif
# usb-acl-helper-dir
spice_gtk_usb_acl_helper_dir = get_option('usb-acl-helper-dir')
if spice_gtk_usb_acl_helper_dir.strip() == ''
spice_gtk_usb_acl_helper_dir = spice_gtk_bindir
endif
spice_gtk_config_data.set_quoted('ACL_HELPER_PATH', spice_gtk_usb_acl_helper_dir)
# usb-ids-path
spice_gtk_usb_ids_path = get_option('usb-ids-path')
if spice_gtk_usb_ids_path.strip() == ''
usbutils = dependency('usbutils', required : false)
if usbutils.found()
spice_gtk_usb_ids_path = usbutils.get_pkgconfig_variable('usbids')
endif
endif
if spice_gtk_usb_ids_path.strip() != ''
spice_gtk_config_data.set('WITH_USBIDS', '1')
spice_gtk_config_data.set_quoted('USB_IDS', spice_gtk_usb_ids_path)
endif
# coroutine
spice_gtk_coroutine = get_option('coroutine')
if spice_gtk_coroutine == 'auto'
if host_machine.system() == 'windows'
spice_gtk_coroutine = 'winfiber'
else
spice_gtk_coroutine = 'ucontext'
endif
endif
if spice_gtk_coroutine == 'ucontext'
foreach f : ['makecontext', 'swapcontext', 'getcontext']
if not compiler.has_function(f)
error('Function missing:' + f)
endif
endforeach
spice_gtk_config_data.set('WITH_UCONTEXT', '1')
if host_machine.system() == 'darwin'
spice_gtk_config_data.set('_XOPEN_SOURCE', '1')
endif
endif
if spice_gtk_coroutine == 'gthread'
spice_gtk_config_data.set('WITH_GTHREAD', '1')
endif
if spice_gtk_coroutine == 'winfiber'
spice_gtk_config_data.set('WITH_WINFIBER', '1')
endif
# introspection
spice_gtk_has_introspection = false
d = dependency('gobject-introspection-1.0', version : '>= 0.94', required : get_option('introspection'))
if d.found()
spice_glib_deps += d
spice_gtk_has_introspection = true
endif
# vala (depends on introspection)
spice_gtk_has_vala = false
d = dependency('vapigen', required : get_option('vapi'))
if d.found()
if not spice_gtk_has_introspection
error('VAPI support requested without introspection')
endif
spice_gtk_has_vala = true
endif
# lz4
d = dependency('liblz4', required : get_option('lz4'))
if d.found()
spice_glib_deps += d
spice_gtk_config_data.set('USE_LZ4', '1')
endif
# sasl
d = dependency('libsasl2', required : get_option('sasl'))
if d.found()
spice_glib_deps += d
spice_gtk_config_data.set('HAVE_SASL', '1')
endif
# smartcard check
d = dependency('libcacard', version : '>= 2.5.1', required : get_option('smartcard'))
if d.found()
spice_glib_deps += d
spice_gtk_config_data.set('USE_SMARTCARD', '1')
endif
#
# global C defines
#
glib_encoded_version = 'GLIB_VERSION_@0@'.format(glib_version.underscorify())
spice_gtk_global_cflags += ['-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_encoded_version),
'-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_encoded_version)]
if spice_gtk_has_gtk
gtk_encoded_version='GDK_VERSION_@0@'.format(gtk_version_required.underscorify())
spice_gtk_global_cflags += ['-DGDK_VERSION_MIN_REQUIRED=@0@'.format(gtk_encoded_version),
'-DGDK_VERSION_MAX_ALLOWED=@0@'.format(gtk_encoded_version)]
endif
add_project_arguments(compiler.get_supported_arguments(spice_gtk_global_cflags),
language : 'c')
#
# Subdirectories
#
subdir('src')
subdir('tools')
subdir('tests')
if build_machine.system() == 'windows'
message('Disabling gtk-doc while building on Windows')
else
if find_program('gtkdoc-scan', required : get_option('gtk_doc')).found()
subdir('doc')
else
message('Not building documentation as gtk-doc was not found')
endif
endif
subdir('data')
subdir('man')
subdir('po')
subdir('vapi')
#
# write config.h
#
proj_version = meson.project_version()
proj_name = meson.project_name()
config_data = {'VERSION' : proj_version,
'PACKAGE_VERSION' : proj_version,
'GETTEXT_PACKAGE' : proj_name,
'LOCALE_DIR' : spice_gtk_localedir,
'PACKAGE_STRING' : '@0@ @1@'.format(proj_name, proj_version),
'PACKAGE_BUGREPORT' : 'spice-devel@lists.freedesktop.org'}
foreach key, value : config_data
spice_gtk_config_data.set_quoted(key, value)
endforeach
configure_file(output : 'config.h',
install : false,
configuration : spice_gtk_config_data)
#
# write spice-client-glib.pc
#
pkgconfig = import('pkgconfig')
pkgconfig.generate(spice_client_glib_lib,
description : 'SPICE Client GLib 2.0 library',
subdirs : 'spice-client-glib-2.0',
requires : 'spice-protocol',
variables : 'exec_prefix=${prefix}')
#
# write spice-client-gtk.pc
#
if spice_gtk_has_gtk
pkgconfig.generate(spice_client_gtk_lib,
description : 'SPICE Client Gtk 3.0 library',
subdirs : 'spice-client-gtk-3.0',
requires : 'spice-client-glib-2.0 gtk+-3.0 >= @0@'.format(gtk_version_required),
variables : 'exec_prefix=${prefix}')
endif
|