forked from magicdmer/spice-common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeson.build
174 lines (147 loc) · 4.8 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
#
# project definition
#
project('spice-common', 'c',
meson_version : '>= 0.49.0',
license : 'LGPLv2.1',
default_options : ['warning_level=2'])
if not meson.is_subproject()
warning('This project is only intended to be used as a subproject!')
endif
# some global vars
spice_common_global_cflags = ['-DG_LOG_DOMAIN="Spice"',
'-Wno-unused-parameter']
if get_option('alignment-checks')
spice_common_global_cflags += ['-DSPICE_DEBUG_ALIGNMENT']
endif
spice_common_deps = []
spice_common_include = include_directories('.')
spice_proto = files('spice.proto')
spice_codegen = files('spice_codegen.py')
spice_codegen_files = [spice_codegen]
compiler = meson.get_compiler('c')
spice_common_config_data = configuration_data()
if get_option('extra-checks')
spice_common_config_data.set('ENABLE_EXTRA_CHECKS', '1')
endif
if host_machine.endian() == 'big'
spice_common_config_data.set('WORDS_BIGENDIAN', '1')
endif
if get_option('instrumentation') == 'recorder'
spice_common_config_data.set('ENABLE_RECORDER', '1')
endif
if get_option('instrumentation') == 'agent'
spice_common_config_data.set('ENABLE_AGENT_INTERFACE', '1')
endif
spice_common_generate_code = get_option('generate-code')
spice_common_generate_client_code = spice_common_generate_code == 'all' or spice_common_generate_code == 'client'
spice_common_generate_server_code = spice_common_generate_code == 'all' or spice_common_generate_code == 'server'
#
# check for system headers
#
headers = ['alloca.h',
'arpa/inet.h',
'dlfcn.h',
'inttypes.h',
'netinet/in.h',
'stdlib.h',
'sys/socket.h',
'sys/stat.h',
'sys/types.h',
'unistd.h',
'regex.h',
'sys/mman.h']
foreach header : headers
if compiler.has_header(header)
spice_common_config_data.set('HAVE_@0@'.format(header.underscorify().to_upper()), '1')
endif
endforeach
#
# check for system functions
#
functions = ['alloca',
'sigaction',
'drand48',
'setlinebuf']
foreach func : functions
if compiler.has_function(func)
spice_common_config_data.set('HAVE_@0@'.format(func.underscorify().to_upper()), '1')
endif
endforeach
# FIXME
# check for libm, as workaround for https://github.com/mesonbuild/meson/issues/3740
libm = compiler.find_library('m', required : false)
if libm.found()
spice_common_deps += libm
endif
#
# check for mandatory dependencies
#
glib_version = '2.38'
glib_version_info = '>= @0@'.format(glib_version)
spice_protocol_version = '0.14.2'
spice_protocol_version_req = get_option('spice-protocol-version')
if spice_protocol_version_req.version_compare('> @0@'.format(spice_protocol_version))
spice_protocol_version = spice_protocol_version_req
endif
deps = {'spice-protocol' : '>= @0@'.format(spice_protocol_version),
'glib-2.0' : glib_version_info,
'pixman-1' : '>= 0.17.7',
'openssl' : '>= 1.0.0'}
foreach dep, version : deps
spice_common_deps += dependency(dep, version : version)
endforeach
gio2_deps = dependency('gio-2.0', version : glib_version_info)
#
# Non-mandatory/optional dependencies
#
optional_deps = {'opus' : '>= 0.9.14'}
foreach dep, version : optional_deps
d = dependency(dep, required : get_option(dep), version : version)
if d.found()
spice_common_deps += d
spice_common_config_data.set('HAVE_@0@'.format(dep.underscorify().to_upper()), '1')
endif
endforeach
# Python
if spice_common_generate_client_code or spice_common_generate_server_code
py_module = import('python')
python = py_module.find_installation('python3')
if get_option('python-checks')
foreach module : ['six', 'pyparsing']
message('Checking for python module @0@'.format(module))
cmd = run_command(python, '-c', 'import @0@'.format(module))
if cmd.returncode() != 0
error('Python module @0@ not found'.format(module))
endif
endforeach
endif
endif
# smartcard check
smartcard_dep = dependency('libcacard', required : get_option('smartcard'), version : '>= 2.5.1')
if smartcard_dep.found()
spice_common_deps += smartcard_dep
spice_common_config_data.set('USE_SMARTCARD', '1')
endif
#
# global C defines
#
glib_encoded_version = 'GLIB_VERSION_@0@'.format(glib_version.underscorify())
spice_common_global_cflags += ['-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_encoded_version),
'-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_encoded_version)]
add_project_arguments(compiler.get_supported_arguments(spice_common_global_cflags),
language : 'c')
#
# Subdirectories
#
subdir('python_modules')
subdir('common')
if get_option('tests')
subdir('tests')
endif
subdir('docs')
#
# write config.h
#
configure_file(output : 'config.h',
configuration : spice_common_config_data)