summaryrefslogtreecommitdiff
path: root/meson.build
blob: b1237e61e26b776cadc179e6cc02e37a2842b849 (plain)
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
#
# project definition
#
project('spice', 'c', 'cpp',
        version : run_command('build-aux/git-version-gen', meson.source_root() + '/.tarball-version', check : true).stdout().strip(),
        license : 'LGPLv2.1',
        meson_version : '>= 0.49',
        default_options : ['buildtype=debugoptimized',
                           'warning_level=2'])

meson.add_dist_script('build-aux/meson-dist', meson.project_version(), meson.source_root())

message('Updating submodules')
run_command('build-aux/meson/check-spice-common', check : true)

#
# soversion
# The versioning is defined by the forumla (CURRENT-AGE.AGE.REVISION)
#
# XXX: KEEP IN SYNC WITH configure.ac file
#
# Follow the libtool manual for the so version:
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
# - If the library source code has changed at all since the last update,
#   then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).
# - If any interfaces have been added, removed, or changed since the last update,
#   increment current, and set revision to 0.
# - If any interfaces have been added since the last public release,
#   then increment age.
# - If any interfaces have been removed or changed since the last public release,
#   then set age to 0.
#
#
spice_server_current = 15
spice_server_revision = 3
spice_server_age = 14
spice_server_so_version = '@0@.@1@.@2@'.format(spice_server_current - spice_server_age,
                                               spice_server_age,
                                               spice_server_revision)
message('libspice.so version: ' + spice_server_so_version)

# some global vars
spice_server_global_cflags = ['-DSPICE_SERVER_INTERNAL',
                              '-DG_LOG_DOMAIN="Spice"',
                              '-Wno-sign-compare',
                              '-Wno-unused-parameter']

compiler = meson.get_compiler('c')
cxx_compiler = meson.get_compiler('cpp')
spice_server_config_data = configuration_data()
spice_server_include = [include_directories('.')]
spice_server_deps = [dependency('threads')]
spice_server_link_args = []
spice_server_requires = ''
spice_protocol_version='0.14.3'

#
# Spice common subproject
#
spice_common = subproject('spice-common',
                          default_options : [
                            'generate-code=server',
                            'spice-protocol-version=@0@'.format(spice_protocol_version),
                          ])
spice_server_config_data.merge_from(spice_common.get_variable('spice_common_config_data'))
spice_server_deps += spice_common.get_variable('spice_common_server_dep')
spice_protocol_version = spice_common.get_variable('spice_protocol_version')

#
# check for system headers
#
headers = ['sys/time.h',
           'execinfo.h',
           'linux/sockios.h',
           'pthread_np.h']

foreach header : headers
  if compiler.has_header(header)
    spice_server_config_data.set('HAVE_@0@'.format(header.underscorify().to_upper()), '1')
  endif
endforeach

# TCP_KEEPIDLE definition in netinet/tcp.h
if compiler.has_header_symbol('netinet/tcp.h', 'TCP_KEEPIDLE')
  spice_server_config_data.set('HAVE_TCP_KEEPIDLE', '1')
endif

#
# check for mandatory dependencies
#
glib_version = '2.38'
glib_version_info = '>= @0@'.format(glib_version)
pixman_version = '>= 0.17.7'

deps = {'glib-2.0'       : glib_version_info,
        'pixman-1'       : pixman_version,
        'openssl'        : '>= 1.0.0'}

foreach dep, version : deps
  spice_server_deps += dependency(dep, version : version)
endforeach

# TODO: specify minimum version for jpeg and zlib?
foreach dep : ['libjpeg', 'zlib']
  spice_server_deps += dependency(dep)
endforeach

if host_machine.system() != 'windows'
  foreach dep : ['rt', 'm']
    spice_server_deps += compiler.find_library(dep)
  endforeach
else
  foreach dep : ['ws2_32', 'shlwapi']
    spice_server_deps += compiler.find_library(dep)
  endforeach
endif

#
# 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_server_deps += d
    spice_server_config_data.set('HAVE_@0@'.format(dep.underscorify().to_upper()), '1')
  endif
endforeach

# gstreamer
spice_server_has_gstreamer = false
spice_server_gst_version = get_option('gstreamer')
if spice_server_gst_version != 'no'
  gst_deps = ['gstreamer', 'gstreamer-base', 'gstreamer-app', 'gstreamer-video']
  foreach dep : gst_deps
    dep = '@0@-@1@'.format(dep, spice_server_gst_version)
    spice_server_deps += dependency(dep)
  endforeach
  spice_server_deps += dependency('orc-0.4')

  gst_def = 'HAVE_GSTREAMER_1_0'
  spice_server_config_data.set(gst_def, '1')
  spice_server_has_gstreamer = true
endif

# lz4
spice_server_has_lz4 = false
if get_option('lz4')
  lz4_dep = dependency('liblz4', required : false, version : '>= 129')
  if not lz4_dep.found()
    lz4_dep = dependency('liblz4', version : '>= 1.7.3')
  endif

  if compiler.has_function('LZ4_compress_fast_continue', dependencies : lz4_dep)
    spice_server_config_data.set('HAVE_LZ4_COMPRESS_FAST_CONTINUE', '1')
  endif

  spice_server_deps += lz4_dep
  spice_server_config_data.set('USE_LZ4', '1')
  spice_server_has_lz4 = true
endif

# sasl
spice_server_has_sasl = false
if get_option('sasl')
  spice_server_deps += dependency('libsasl2')
  spice_server_config_data.set('HAVE_SASL', '1')
  spice_server_has_sasl = true
endif

# smartcard check
spice_server_has_smartcard = false
smartcard_dep = dependency('libcacard', required : get_option('smartcard'), version : '>= 2.5.1')
if smartcard_dep.found()
  spice_server_deps += smartcard_dep
  spice_server_config_data.set('USE_SMARTCARD', '1')
  spice_server_has_smartcard = true
  spice_server_requires += 'libcacard >= 2.5.1 '
endif

#
# global C defines
#
glib_encoded_version = 'GLIB_VERSION_@0@'.format(glib_version.underscorify())
spice_server_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_server_global_cflags),
                      language : 'c')

spice_server_global_cxxflags = spice_server_global_cflags
spice_server_global_cxxflags += [
  '-fno-exceptions',
  '-Wno-suggest-final-methods',
  '-Wno-suggest-final-types',
  '-Wno-array-bounds',
  '-Wno-stringop-overflow',
  '-Wno-narrowing',
  '-Wno-missing-field-initializers',
  '-Wno-deprecated-declarations',
  '-Wshadow',
]
add_project_arguments(cxx_compiler.get_supported_arguments(spice_server_global_cxxflags),
                      language : 'cpp')

#
# Subdirectories
#
subdir('server')
subdir('tools')
subdir('docs')

#
# write config.h
#
spice_server_config_data.set_quoted('VERSION', meson.project_version())
spice_server_config_data.set('SPICE_USE_SAFER_CONTAINEROF', '1')

if get_option('statistics')
  spice_server_config_data.set('RED_STATISTICS', '1')
endif

# Minimal Win32 version
if host_machine.system() == 'windows'
  spice_server_config_data.set('_WIN32_WINNT', '0x600')
endif

configure_file(output : 'config.h',
               configuration : spice_server_config_data)

run_target('doxy', command : './doxygen.sh')