]> git.proxmox.com Git - mirror_qemu.git/blame - meson.build
kconfig: split CONFIG_SPARSE_MEM from fuzzing
[mirror_qemu.git] / meson.build
CommitLineData
654d6b04
PB
1project('qemu', ['c'], meson_version: '>=0.58.2',
2 default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
3 'b_staticpic=false'],
4 version: files('VERSION'))
a5665051
PB
5
6not_found = dependency('', required: false)
654d6b04 7keyval = import('keyval')
a81df1b6 8ss = import('sourceset')
8b18cdbf 9fs = import('fs')
a81df1b6 10
ce1c1e7a 11sh = find_program('sh')
a81df1b6 12cc = meson.get_compiler('c')
a5665051 13config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
3154fee4 14enable_modules = 'CONFIG_MODULES' in config_host
35be72ba 15enable_static = 'CONFIG_STATIC' in config_host
e3667660 16
d7dedf42
PB
17# Allow both shared and static libraries unless --enable-static
18static_kwargs = enable_static ? {'static': true} : {}
19
e3667660
YL
20# Temporary directory used for files created while
21# configure runs. Since it is in the build directory
22# we can safely blow away any previous version of it
23# (and we need not jump through hoops to try to delete
24# it when configure exits.)
25tmpdir = meson.current_build_dir() / 'meson-private/temp'
8fe11232
MAL
26
27if get_option('qemu_suffix').startswith('/')
28 error('qemu_suffix cannot start with a /')
29endif
30
16bf7a33 31qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
ab4c0996 32qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
491e74c1 33qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
16bf7a33
PB
34qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
35
36qemu_desktopdir = get_option('datadir') / 'applications'
37qemu_icondir = get_option('datadir') / 'icons'
38
859aef02
PB
39config_host_data = configuration_data()
40genh = []
a5665051 41
760e4327
PB
42target_dirs = config_host['TARGET_DIRS'].split()
43have_user = false
44have_system = false
45foreach target : target_dirs
46 have_user = have_user or target.endswith('-user')
47 have_system = have_system or target.endswith('-softmmu')
48endforeach
49have_tools = 'CONFIG_TOOLS' in config_host
50have_block = have_system or have_tools
51
201e8ed7
PB
52python = import('python').find_installation()
53
54supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
6125673e 55supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
201e8ed7
PB
56 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
57
58cpu = host_machine.cpu_family()
59targetos = host_machine.system()
60
8a19980e
PB
61if cpu in ['x86', 'x86_64']
62 kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
63elif cpu == 'aarch64'
64 kvm_targets = ['aarch64-softmmu']
65elif cpu == 's390x'
66 kvm_targets = ['s390x-softmmu']
67elif cpu in ['ppc', 'ppc64']
68 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
fbc5884c
HC
69elif cpu in ['mips', 'mips64']
70 kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
8a19980e
PB
71else
72 kvm_targets = []
73endif
74
75accelerator_targets = { 'CONFIG_KVM': kvm_targets }
844a06bb
AG
76
77if cpu in ['aarch64']
78 accelerator_targets += {
79 'CONFIG_HVF': ['aarch64-softmmu']
80 }
81endif
82
0c3e41d4 83if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
2a2d51bc 84 # i386 emulator provides xenpv machine type for multiple architectures
0c3e41d4
AB
85 accelerator_targets += {
86 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
87 }
88endif
8a19980e
PB
89if cpu in ['x86', 'x86_64']
90 accelerator_targets += {
91 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
8a19980e 92 'CONFIG_HVF': ['x86_64-softmmu'],
74a414a1 93 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
8a19980e
PB
94 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
95 }
96endif
97
a1b176f9
PB
98modular_tcg = []
99# Darwin does not support references to thread-local variables in modules
100if targetos != 'darwin'
101 modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
102endif
dae0ec15 103
eae9a1d1 104edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
e49c0ef6
PB
105unpack_edk2_blobs = false
106foreach target : edk2_targets
107 if target in target_dirs
108 bzip2 = find_program('bzip2', required: get_option('install_blobs'))
109 unpack_edk2_blobs = bzip2.found()
110 break
111 endif
112endforeach
45b545dd 113
201e8ed7
PB
114##################
115# Compiler flags #
116##################
117
ff9ed62b
AB
118# Specify linker-script with add_project_link_arguments so that it is not placed
119# within a linker --start-group/--end-group pair
120if 'CONFIG_FUZZ' in config_host
121 add_project_link_arguments(['-Wl,-T,',
122 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
123 native: false, language: ['c', 'cpp', 'objc'])
124endif
125
5fc0617f
MAL
126add_global_arguments(config_host['QEMU_CFLAGS'].split(),
127 native: false, language: ['c', 'objc'])
128add_global_arguments(config_host['QEMU_CXXFLAGS'].split(),
129 native: false, language: 'cpp')
130add_global_link_arguments(config_host['QEMU_LDFLAGS'].split(),
131 native: false, language: ['c', 'cpp', 'objc'])
a5665051 132
1e6e616d
PB
133if targetos == 'linux'
134 add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
135 '-isystem', 'linux-headers',
136 language: ['c', 'cpp'])
137endif
138
23a77b2d 139add_project_arguments('-iquote', '.',
1e6e616d 140 '-iquote', meson.current_source_dir(),
1e6e616d
PB
141 '-iquote', meson.current_source_dir() / 'include',
142 '-iquote', meson.current_source_dir() / 'disas/libvixl',
143 language: ['c', 'cpp', 'objc'])
c46f76d1 144
fc929892
MAL
145link_language = meson.get_external_property('link_language', 'cpp')
146if link_language == 'cpp'
147 add_languages('cpp', required: true, native: false)
148endif
a5665051
PB
149if host_machine.system() == 'darwin'
150 add_languages('objc', required: false, native: false)
151endif
152
deb62371
PB
153sparse = find_program('cgcc', required: get_option('sparse'))
154if sparse.found()
968b4db3
PB
155 run_target('sparse',
156 command: [find_program('scripts/check_sparse.py'),
deb62371
PB
157 'compile_commands.json', sparse.full_path(), '-Wbitwise',
158 '-Wno-transparent-union', '-Wno-old-initializer',
159 '-Wno-non-pointer-null'])
968b4db3
PB
160endif
161
6ec0e15d
PB
162###########################################
163# Target-specific checks and dependencies #
164###########################################
165
166if targetos != 'linux' and get_option('mpath').enabled()
167 error('Multipath is supported only on Linux')
168endif
169
106ad1f9
PB
170if targetos != 'linux' and get_option('multiprocess').enabled()
171 error('Multiprocess QEMU is supported only on Linux')
172endif
173multiprocess_allowed = targetos == 'linux' and not get_option('multiprocess').disabled()
174
7fa1c635 175libm = cc.find_library('m', required: false)
6d7c7c2d 176threads = dependency('threads')
a81df1b6 177util = cc.find_library('util', required: false)
4a96337d 178winmm = []
a81df1b6 179socket = []
04c6f1e7 180version_res = []
d92989aa
MAL
181coref = []
182iokit = []
b6c7cfd4 183emulator_link_args = []
74a414a1 184nvmm =not_found
8a19980e 185hvf = not_found
a81df1b6
PB
186if targetos == 'windows'
187 socket = cc.find_library('ws2_32')
4a96337d 188 winmm = cc.find_library('winmm')
04c6f1e7
MAL
189
190 win = import('windows')
191 version_res = win.compile_resources('version.rc',
192 depend_files: files('pc-bios/qemu-nsis.ico'),
193 include_directories: include_directories('.'))
d92989aa
MAL
194elif targetos == 'darwin'
195 coref = dependency('appleframeworks', modules: 'CoreFoundation')
14176c8d 196 iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
cfad62f1
PB
197elif targetos == 'sunos'
198 socket = [cc.find_library('socket'),
199 cc.find_library('nsl'),
200 cc.find_library('resolv')]
201elif targetos == 'haiku'
202 socket = [cc.find_library('posix_error_mapper'),
203 cc.find_library('network'),
204 cc.find_library('bsd')]
b6c7cfd4
PB
205elif targetos == 'openbsd'
206 if not get_option('tcg').disabled() and target_dirs.length() > 0
207 # Disable OpenBSD W^X if available
208 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
209 endif
a81df1b6 210endif
6ec0e15d 211
8a19980e
PB
212accelerators = []
213if not get_option('kvm').disabled() and targetos == 'linux'
214 accelerators += 'CONFIG_KVM'
215endif
216if not get_option('xen').disabled() and 'CONFIG_XEN_BACKEND' in config_host
217 accelerators += 'CONFIG_XEN'
218 have_xen_pci_passthrough = not get_option('xen_pci_passthrough').disabled() and targetos == 'linux'
219else
220 have_xen_pci_passthrough = false
221endif
222if not get_option('whpx').disabled() and targetos == 'windows'
57e2a1f8 223 if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
8a19980e
PB
224 error('WHPX requires 64-bit host')
225 elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
226 cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
227 accelerators += 'CONFIG_WHPX'
228 endif
229endif
230if not get_option('hvf').disabled()
231 hvf = dependency('appleframeworks', modules: 'Hypervisor',
232 required: get_option('hvf'))
233 if hvf.found()
234 accelerators += 'CONFIG_HVF'
235 endif
236endif
237if not get_option('hax').disabled()
238 if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
239 accelerators += 'CONFIG_HAX'
240 endif
241endif
74a414a1
RZ
242if targetos == 'netbsd'
243 if cc.has_header_symbol('nvmm.h', 'nvmm_cpu_stop', required: get_option('nvmm'))
244 nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
245 endif
246 if nvmm.found()
247 accelerators += 'CONFIG_NVMM'
248 endif
249endif
23a77b2d
PB
250
251tcg_arch = config_host['ARCH']
8a19980e
PB
252if not get_option('tcg').disabled()
253 if cpu not in supported_cpus
23a77b2d 254 if get_option('tcg_interpreter')
39687aca 255 warning('Unsupported CPU @0@, will use TCG with TCI (experimental and slow)'.format(cpu))
8a19980e
PB
256 else
257 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
258 endif
fa2f7b0b
PMD
259 elif get_option('tcg_interpreter')
260 warning('Use of the TCG interpretor is not recommended on this host')
261 warning('architecture. There is a native TCG execution backend available')
262 warning('which provides substantially better performance and reliability.')
263 warning('It is strongly recommended to remove the --enable-tcg-interpreter')
264 warning('configuration option on this architecture to use the native')
265 warning('backend.')
8a19980e 266 endif
23a77b2d
PB
267 if get_option('tcg_interpreter')
268 tcg_arch = 'tci'
269 elif config_host['ARCH'] == 'sparc64'
270 tcg_arch = 'sparc'
23a77b2d
PB
271 elif config_host['ARCH'] in ['x86_64', 'x32']
272 tcg_arch = 'i386'
273 elif config_host['ARCH'] == 'ppc64'
274 tcg_arch = 'ppc'
275 elif config_host['ARCH'] in ['riscv32', 'riscv64']
276 tcg_arch = 'riscv'
277 endif
278 add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
23a77b2d
PB
279 language: ['c', 'cpp', 'objc'])
280
8a19980e
PB
281 accelerators += 'CONFIG_TCG'
282 config_host += { 'CONFIG_TCG': 'y' }
283endif
284
285if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
286 error('KVM not available on this platform')
287endif
288if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
289 error('HVF not available on this platform')
290endif
74a414a1
RZ
291if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
292 error('NVMM not available on this platform')
293endif
8a19980e
PB
294if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
295 error('WHPX not available on this platform')
296endif
297if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
298 if 'CONFIG_XEN' in accelerators
299 error('Xen PCI passthrough not available on this platform')
300 else
301 error('Xen PCI passthrough requested but Xen not enabled')
302 endif
303endif
b4e312e9 304
6ec0e15d
PB
305################
306# Dependencies #
307################
308
215b0c2f
PB
309# The path to glib.h is added to all compilation commands. This was
310# grandfathered in from the QEMU Makefiles.
311add_project_arguments(config_host['GLIB_CFLAGS'].split(),
312 native: false, language: ['c', 'cpp', 'objc'])
953d5a9e
MAL
313glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
314 link_args: config_host['GLIB_LIBS'].split())
315# override glib dep with the configure results (for subprojects)
316meson.override_dependency('glib-2.0', glib)
317
a81df1b6
PB
318gio = not_found
319if 'CONFIG_GIO' in config_host
320 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
321 link_args: config_host['GIO_LIBS'].split())
322endif
323lttng = not_found
324if 'CONFIG_TRACE_UST' in config_host
325 lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
326endif
b7612f45
PB
327pixman = not_found
328if have_system or have_tools
329 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
d7dedf42 330 method: 'pkg-config', kwargs: static_kwargs)
b7612f45 331endif
5e5733e5 332libaio = cc.find_library('aio', required: false)
d7dedf42 333zlib = dependency('zlib', required: true, kwargs: static_kwargs)
53c22b68 334
5e5733e5 335linux_io_uring = not_found
53c22b68
PB
336if not get_option('linux_io_uring').auto() or have_block
337 linux_io_uring = dependency('liburing', required: get_option('linux_io_uring'),
338 method: 'pkg-config', kwargs: static_kwargs)
5e5733e5
MAL
339endif
340libxml2 = not_found
c5b36c25
PB
341if not get_option('libxml2').auto() or have_block
342 libxml2 = dependency('libxml-2.0', required: get_option('libxml2'),
343 method: 'pkg-config', kwargs: static_kwargs)
5e5733e5
MAL
344endif
345libnfs = not_found
30045c05
PB
346if not get_option('libnfs').auto() or have_block
347 libnfs = dependency('libnfs', version: '>=1.9.3',
348 required: get_option('libnfs'),
d7dedf42 349 method: 'pkg-config', kwargs: static_kwargs)
5e5733e5 350endif
f7f2d651
PB
351
352libattr_test = '''
353 #include <stddef.h>
354 #include <sys/types.h>
355 #ifdef CONFIG_LIBATTR
356 #include <attr/xattr.h>
357 #else
358 #include <sys/xattr.h>
359 #endif
360 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
361
ec0d5893 362libattr = not_found
f7f2d651
PB
363have_old_libattr = false
364if not get_option('attr').disabled()
365 if cc.links(libattr_test)
366 libattr = declare_dependency()
367 else
368 libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
369 required: get_option('attr'),
d7dedf42 370 kwargs: static_kwargs)
f7f2d651
PB
371 if libattr.found() and not \
372 cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
373 libattr = not_found
374 if get_option('attr').enabled()
375 error('could not link libattr')
376 else
377 warning('could not link libattr, disabling')
378 endif
379 else
380 have_old_libattr = libattr.found()
381 endif
382 endif
ec0d5893 383endif
f7f2d651 384
c1ec4941
PB
385cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
386if cocoa.found() and get_option('sdl').enabled()
387 error('Cocoa and SDL cannot be enabled at the same time')
388endif
389if cocoa.found() and get_option('gtk').enabled()
390 error('Cocoa and GTK+ cannot be enabled at the same time')
391endif
392
3f99cf57 393seccomp = not_found
90835c2b
PB
394if not get_option('seccomp').auto() or have_system or have_tools
395 seccomp = dependency('libseccomp', version: '>=2.3.0',
396 required: get_option('seccomp'),
d7dedf42 397 method: 'pkg-config', kwargs: static_kwargs)
3f99cf57 398endif
727c8bb8 399
3f99cf57 400libcap_ng = not_found
727c8bb8
PB
401if not get_option('cap_ng').auto() or have_system or have_tools
402 libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
403 required: get_option('cap_ng'),
d7dedf42 404 kwargs: static_kwargs)
727c8bb8
PB
405endif
406if libcap_ng.found() and not cc.links('''
407 #include <cap-ng.h>
408 int main(void)
409 {
410 capng_capability_to_name(CAPNG_EFFECTIVE);
411 return 0;
412 }''', dependencies: libcap_ng)
413 libcap_ng = not_found
414 if get_option('cap_ng').enabled()
415 error('could not link libcap-ng')
416 else
417 warning('could not link libcap-ng, disabling')
418 endif
3f99cf57 419endif
727c8bb8 420
1917ec6d
PB
421if get_option('xkbcommon').auto() and not have_system and not have_tools
422 xkbcommon = not_found
423else
424 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
d7dedf42 425 method: 'pkg-config', kwargs: static_kwargs)
ade60d4f 426endif
cdaf0722
MAL
427vde = not_found
428if config_host.has_key('CONFIG_VDE')
429 vde = declare_dependency(link_args: config_host['VDE_LIBS'].split())
430endif
87430d5b 431
478e943f 432pulse = not_found
87430d5b
PB
433if not get_option('pa').auto() or (targetos == 'linux' and have_system)
434 pulse = dependency('libpulse', required: get_option('pa'),
435 method: 'pkg-config', kwargs: static_kwargs)
478e943f
PB
436endif
437alsa = not_found
87430d5b
PB
438if not get_option('alsa').auto() or (targetos == 'linux' and have_system)
439 alsa = dependency('alsa', required: get_option('alsa'),
440 method: 'pkg-config', kwargs: static_kwargs)
478e943f
PB
441endif
442jack = not_found
87430d5b
PB
443if not get_option('jack').auto() or have_system
444 jack = dependency('jack', required: get_option('jack'),
445 method: 'pkg-config', kwargs: static_kwargs)
478e943f 446endif
87430d5b 447
2634733c 448spice = not_found
d72c34cc 449spice_headers = not_found
58d3f3ff 450spice_protocol = not_found
2634733c
PB
451if 'CONFIG_SPICE' in config_host
452 spice = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split(),
453 link_args: config_host['SPICE_LIBS'].split())
d72c34cc 454 spice_headers = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split())
2634733c 455endif
58d3f3ff
GH
456if 'CONFIG_SPICE_PROTOCOL' in config_host
457 spice_protocol = declare_dependency(compile_args: config_host['SPICE_PROTOCOL_CFLAGS'].split())
458endif
5ee24e78 459rt = cc.find_library('rt', required: false)
ccf7afa5
PB
460libdl = not_found
461if 'CONFIG_PLUGIN' in config_host
e8575f25
AB
462 libdl = cc.find_library('dl', required: false)
463 if not cc.has_function('dlopen', dependencies: libdl)
464 error('dlopen not found')
465 endif
ccf7afa5 466endif
99650b62 467libiscsi = not_found
9db405a3
PB
468if not get_option('libiscsi').auto() or have_block
469 libiscsi = dependency('libiscsi', version: '>=1.9.0',
470 required: get_option('libiscsi'),
d7dedf42 471 method: 'pkg-config', kwargs: static_kwargs)
99650b62 472endif
5e5733e5 473zstd = not_found
b1def33d
PB
474if not get_option('zstd').auto() or have_block
475 zstd = dependency('libzstd', version: '>=1.4.0',
476 required: get_option('zstd'),
d7dedf42 477 method: 'pkg-config', kwargs: static_kwargs)
5e5733e5 478endif
ea458960 479virgl = not_found
587d59d6
PB
480if not get_option('virglrenderer').auto() or have_system
481 virgl = dependency('virglrenderer',
482 method: 'pkg-config',
483 required: get_option('virglrenderer'),
484 kwargs: static_kwargs)
ea458960 485endif
1d7bb6ab 486curl = not_found
f9cd86fe
PB
487if not get_option('curl').auto() or have_block
488 curl = dependency('libcurl', version: '>=7.29.0',
489 method: 'pkg-config',
490 required: get_option('curl'),
d7dedf42 491 kwargs: static_kwargs)
1d7bb6ab 492endif
f15bff25 493libudev = not_found
f01496a3 494if targetos == 'linux' and (have_system or have_tools)
6ec0e15d 495 libudev = dependency('libudev',
a0fbbb6e 496 method: 'pkg-config',
5c53015a 497 required: get_option('libudev'),
d7dedf42 498 kwargs: static_kwargs)
6ec0e15d
PB
499endif
500
5c53015a 501mpathlibs = [libudev]
6ec0e15d
PB
502mpathpersist = not_found
503mpathpersist_new_api = false
504if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
505 mpath_test_source_new = '''
506 #include <libudev.h>
507 #include <mpath_persist.h>
508 unsigned mpath_mx_alloc_len = 1024;
509 int logsink;
510 static struct config *multipath_conf;
511 extern struct udev *udev;
512 extern struct config *get_multipath_config(void);
513 extern void put_multipath_config(struct config *conf);
514 struct udev *udev;
515 struct config *get_multipath_config(void) { return multipath_conf; }
516 void put_multipath_config(struct config *conf) { }
517 int main(void) {
518 udev = udev_new();
519 multipath_conf = mpath_lib_init();
520 return 0;
521 }'''
522 mpath_test_source_old = '''
523 #include <libudev.h>
524 #include <mpath_persist.h>
525 unsigned mpath_mx_alloc_len = 1024;
526 int logsink;
527 int main(void) {
528 struct udev *udev = udev_new();
529 mpath_lib_init(udev);
530 return 0;
531 }'''
5c53015a
PB
532 libmpathpersist = cc.find_library('mpathpersist',
533 required: get_option('mpath'),
d7dedf42 534 kwargs: static_kwargs)
5c53015a
PB
535 if libmpathpersist.found()
536 mpathlibs += libmpathpersist
537 if enable_static
538 mpathlibs += cc.find_library('devmapper',
539 required: get_option('mpath'),
d7dedf42 540 kwargs: static_kwargs)
43b43a40 541 endif
5c53015a
PB
542 mpathlibs += cc.find_library('multipath',
543 required: get_option('mpath'),
d7dedf42 544 kwargs: static_kwargs)
5c53015a
PB
545 foreach lib: mpathlibs
546 if not lib.found()
547 mpathlibs = []
548 break
549 endif
550 endforeach
551 if mpathlibs.length() == 0
552 msg = 'Dependencies missing for libmpathpersist'
553 elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
6ec0e15d
PB
554 mpathpersist = declare_dependency(dependencies: mpathlibs)
555 mpathpersist_new_api = true
556 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
557 mpathpersist = declare_dependency(dependencies: mpathlibs)
558 else
5c53015a
PB
559 msg = 'Cannot detect libmpathpersist API'
560 endif
561 if not mpathpersist.found()
6ec0e15d 562 if get_option('mpath').enabled()
5c53015a 563 error(msg)
6ec0e15d 564 else
5c53015a 565 warning(msg + ', disabling')
6ec0e15d
PB
566 endif
567 endif
568 endif
f15bff25 569endif
6ec0e15d 570
5285e593 571iconv = not_found
5285e593 572curses = not_found
30fe76b1 573if have_system and not get_option('curses').disabled()
925a40df
PB
574 curses_test = '''
575 #include <locale.h>
576 #include <curses.h>
577 #include <wchar.h>
578 int main(void) {
579 wchar_t wch = L'w';
580 setlocale(LC_ALL, "");
581 resize_term(0, 0);
582 addwstr(L"wide chars\n");
583 addnwstr(&wch, 1);
584 add_wch(WACS_DEGREE);
585 return 0;
586 }'''
587
ca31e307
YL
588 curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
589 foreach curses_dep : curses_dep_list
590 if not curses.found()
591 curses = dependency(curses_dep,
592 required: false,
593 method: 'pkg-config',
d7dedf42 594 kwargs: static_kwargs)
ca31e307
YL
595 endif
596 endforeach
925a40df 597 msg = get_option('curses').enabled() ? 'curses library not found' : ''
0dbce6ef 598 curses_compile_args = ['-DNCURSES_WIDECHAR']
925a40df 599 if curses.found()
0dbce6ef
PB
600 if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
601 curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses])
925a40df
PB
602 else
603 msg = 'curses package not usable'
604 curses = not_found
5285e593
YL
605 endif
606 endif
925a40df 607 if not curses.found()
925a40df
PB
608 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
609 if targetos != 'windows' and not has_curses_h
610 message('Trying with /usr/include/ncursesw')
611 curses_compile_args += ['-I/usr/include/ncursesw']
612 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
613 endif
614 if has_curses_h
615 curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
616 foreach curses_libname : curses_libname_list
5285e593
YL
617 libcurses = cc.find_library(curses_libname,
618 required: false,
d7dedf42 619 kwargs: static_kwargs)
925a40df
PB
620 if libcurses.found()
621 if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
622 curses = declare_dependency(compile_args: curses_compile_args,
623 dependencies: [libcurses])
624 break
625 else
626 msg = 'curses library not usable'
627 endif
5285e593 628 endif
925a40df
PB
629 endforeach
630 endif
631 endif
632 if not get_option('iconv').disabled()
633 foreach link_args : [ ['-liconv'], [] ]
634 # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
635 # We need to use libiconv if available because mixing libiconv's headers with
636 # the system libc does not work.
637 # However, without adding glib to the dependencies -L/usr/local/lib will not be
638 # included in the command line and libiconv will not be found.
639 if cc.links('''
640 #include <iconv.h>
641 int main(void) {
642 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
643 return conv != (iconv_t) -1;
644 }''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
645 iconv = declare_dependency(link_args: link_args, dependencies: glib)
646 break
5285e593 647 endif
30fe76b1
PB
648 endforeach
649 endif
925a40df
PB
650 if curses.found() and not iconv.found()
651 if get_option('iconv').enabled()
652 error('iconv not available')
653 endif
654 msg = 'iconv required for curses UI but not available'
655 curses = not_found
656 endif
657 if not curses.found() and msg != ''
658 if get_option('curses').enabled()
659 error(msg)
30fe76b1 660 else
925a40df 661 warning(msg + ', disabling')
30fe76b1 662 endif
5285e593
YL
663 endif
664endif
665
2634733c 666brlapi = not_found
8c6d4ff4
PB
667if not get_option('brlapi').auto() or have_system
668 brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
669 required: get_option('brlapi'),
d7dedf42 670 kwargs: static_kwargs)
8c6d4ff4
PB
671 if brlapi.found() and not cc.links('''
672 #include <brlapi.h>
673 #include <stddef.h>
674 int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
675 brlapi = not_found
676 if get_option('brlapi').enabled()
677 error('could not link brlapi')
678 else
679 warning('could not link brlapi, disabling')
680 endif
681 endif
2634733c 682endif
35be72ba 683
760e4327 684sdl = not_found
c1ec4941 685if not get_option('sdl').auto() or (have_system and not cocoa.found())
d7dedf42 686 sdl = dependency('sdl2', required: get_option('sdl'), kwargs: static_kwargs)
760e4327
PB
687 sdl_image = not_found
688endif
35be72ba
PB
689if sdl.found()
690 # work around 2.0.8 bug
691 sdl = declare_dependency(compile_args: '-Wno-undef',
692 dependencies: sdl)
7161a433 693 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
d7dedf42 694 method: 'pkg-config', kwargs: static_kwargs)
35be72ba
PB
695else
696 if get_option('sdl_image').enabled()
a8dc2ace
ST
697 error('sdl-image required, but SDL was @0@'.format(
698 get_option('sdl').disabled() ? 'disabled' : 'not found'))
35be72ba
PB
699 endif
700 sdl_image = not_found
2634733c 701endif
35be72ba 702
5e5733e5 703rbd = not_found
fabd1e93
PB
704if not get_option('rbd').auto() or have_block
705 librados = cc.find_library('rados', required: get_option('rbd'),
d7dedf42 706 kwargs: static_kwargs)
fabd1e93
PB
707 librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
708 required: get_option('rbd'),
d7dedf42 709 kwargs: static_kwargs)
c518d6c2
PB
710 if librados.found() and librbd.found()
711 if cc.links('''
712 #include <stdio.h>
713 #include <rbd/librbd.h>
714 int main(void) {
715 rados_t cluster;
716 rados_create(&cluster, NULL);
48672ac0
PL
717 #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0)
718 #error
719 #endif
c518d6c2
PB
720 return 0;
721 }''', dependencies: [librbd, librados])
722 rbd = declare_dependency(dependencies: [librbd, librados])
723 elif get_option('rbd').enabled()
48672ac0 724 error('librbd >= 1.12.0 required')
c518d6c2 725 else
48672ac0 726 warning('librbd >= 1.12.0 not found, disabling')
c518d6c2 727 endif
fabd1e93 728 endif
5e5733e5 729endif
fabd1e93 730
5e5733e5 731glusterfs = not_found
08821ca2
PB
732glusterfs_ftruncate_has_stat = false
733glusterfs_iocb_has_stat = false
734if not get_option('glusterfs').auto() or have_block
735 glusterfs = dependency('glusterfs-api', version: '>=3',
736 required: get_option('glusterfs'),
d7dedf42 737 method: 'pkg-config', kwargs: static_kwargs)
08821ca2
PB
738 if glusterfs.found()
739 glusterfs_ftruncate_has_stat = cc.links('''
740 #include <glusterfs/api/glfs.h>
741
742 int
743 main(void)
744 {
745 /* new glfs_ftruncate() passes two additional args */
746 return glfs_ftruncate(NULL, 0, NULL, NULL);
747 }
748 ''', dependencies: glusterfs)
749 glusterfs_iocb_has_stat = cc.links('''
750 #include <glusterfs/api/glfs.h>
751
752 /* new glfs_io_cbk() passes two additional glfs_stat structs */
753 static void
754 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
755 {}
756
757 int
758 main(void)
759 {
760 glfs_io_cbk iocb = &glusterfs_iocb;
761 iocb(NULL, 0 , NULL, NULL, NULL);
762 return 0;
763 }
764 ''', dependencies: glusterfs)
765 endif
5e5733e5
MAL
766endif
767libssh = not_found
768if 'CONFIG_LIBSSH' in config_host
769 libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
770 link_args: config_host['LIBSSH_LIBS'].split())
771endif
772libbzip2 = not_found
29ba6116
PB
773if not get_option('bzip2').auto() or have_block
774 libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
775 required: get_option('bzip2'),
d7dedf42 776 kwargs: static_kwargs)
29ba6116
PB
777 if libbzip2.found() and not cc.links('''
778 #include <bzlib.h>
779 int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
780 libbzip2 = not_found
781 if get_option('bzip2').enabled()
782 error('could not link libbzip2')
783 else
784 warning('could not link libbzip2, disabling')
785 endif
786 endif
5e5733e5 787endif
ecea3696 788
5e5733e5 789liblzfse = not_found
ecea3696
PB
790if not get_option('lzfse').auto() or have_block
791 liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
792 required: get_option('lzfse'),
d7dedf42 793 kwargs: static_kwargs)
ecea3696
PB
794endif
795if liblzfse.found() and not cc.links('''
796 #include <lzfse.h>
797 int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
798 liblzfse = not_found
799 if get_option('lzfse').enabled()
800 error('could not link liblzfse')
801 else
802 warning('could not link liblzfse, disabling')
803 endif
5e5733e5 804endif
ecea3696 805
478e943f 806oss = not_found
87430d5b
PB
807if not get_option('oss').auto() or have_system
808 if not cc.has_header('sys/soundcard.h')
809 # not found
810 elif targetos == 'netbsd'
811 oss = cc.find_library('ossaudio', required: get_option('oss'),
812 kwargs: static_kwargs)
813 else
814 oss = declare_dependency()
815 endif
816
817 if not oss.found()
818 if get_option('oss').enabled()
819 error('OSS not found')
820 else
821 warning('OSS not found, disabling')
822 endif
823 endif
478e943f
PB
824endif
825dsound = not_found
87430d5b
PB
826if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
827 if cc.has_header('dsound.h')
828 dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
829 endif
830
831 if not dsound.found()
832 if get_option('dsound').enabled()
833 error('DirectSound not found')
834 else
835 warning('DirectSound not found, disabling')
836 endif
837 endif
478e943f 838endif
87430d5b 839
478e943f 840coreaudio = not_found
87430d5b
PB
841if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
842 coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
843 required: get_option('coreaudio'))
844 if coreaudio.found() and not cc.links('''
845 #include <CoreAudio/CoreAudio.h>
846 int main(void)
847 {
848 return (int)AudioGetCurrentHostTime();
849 }''')
850 coreaudio = not_found
851 endif
852
853 if not coreaudio.found()
854 if get_option('coreaudio').enabled()
855 error('CoreAudio not found')
856 else
857 warning('CoreAudio not found, disabling')
858 endif
859 endif
2b1ccdf4 860endif
8bc5184d 861
2b1ccdf4
MAL
862opengl = not_found
863if 'CONFIG_OPENGL' in config_host
de2d3005
PB
864 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
865 link_args: config_host['OPENGL_LIBS'].split())
2b1ccdf4 866endif
8bc5184d
TH
867gbm = not_found
868if (have_system or have_tools) and (virgl.found() or opengl.found())
869 gbm = dependency('gbm', method: 'pkg-config', required: false,
870 kwargs: static_kwargs)
871endif
1b695471 872
57612511 873gnutls = not_found
cc4c7c73 874gnutls_crypto = not_found
abc14fd0 875if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
cc4c7c73
DB
876 # For general TLS support our min gnutls matches
877 # that implied by our platform support matrix
878 #
879 # For the crypto backends, we look for a newer
880 # gnutls:
881 #
882 # Version 3.6.8 is needed to get XTS
883 # Version 3.6.13 is needed to get PBKDF
884 # Version 3.6.14 is needed to get HW accelerated XTS
885 #
886 # If newer enough gnutls isn't available, we can
887 # still use a different crypto backend to satisfy
888 # the platform support requirements
889 gnutls_crypto = dependency('gnutls', version: '>=3.6.14',
890 method: 'pkg-config',
891 required: false,
892 kwargs: static_kwargs)
893 if gnutls_crypto.found()
894 gnutls = gnutls_crypto
895 else
896 # Our min version if all we need is TLS
897 gnutls = dependency('gnutls', version: '>=3.5.18',
898 method: 'pkg-config',
899 required: get_option('gnutls'),
900 kwargs: static_kwargs)
901 endif
57612511
PB
902endif
903
8bd0931f
DB
904# We prefer use of gnutls for crypto, unless the options
905# explicitly asked for nettle or gcrypt.
906#
907# If gnutls isn't available for crypto, then we'll prefer
908# gcrypt over nettle for performance reasons.
57612511
PB
909gcrypt = not_found
910nettle = not_found
68014044 911xts = 'none'
8bd0931f 912
57612511
PB
913if get_option('nettle').enabled() and get_option('gcrypt').enabled()
914 error('Only one of gcrypt & nettle can be enabled')
57612511 915endif
8bd0931f
DB
916
917# Explicit nettle/gcrypt request, so ignore gnutls for crypto
918if get_option('nettle').enabled() or get_option('gcrypt').enabled()
cc4c7c73
DB
919 gnutls_crypto = not_found
920endif
57612511 921
8bd0931f
DB
922if not gnutls_crypto.found()
923 if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
924 gcrypt = dependency('libgcrypt', version: '>=1.8',
925 method: 'config-tool',
926 required: get_option('gcrypt'),
927 kwargs: static_kwargs)
928 # Debian has removed -lgpg-error from libgcrypt-config
929 # as it "spreads unnecessary dependencies" which in
930 # turn breaks static builds...
931 if gcrypt.found() and enable_static
932 gcrypt = declare_dependency(dependencies: [
933 gcrypt,
934 cc.find_library('gpg-error', required: true, kwargs: static_kwargs)])
935 endif
57612511 936 endif
8bd0931f
DB
937 if (not get_option('nettle').auto() or have_system) and not gcrypt.found()
938 nettle = dependency('nettle', version: '>=3.4',
939 method: 'pkg-config',
940 required: get_option('nettle'),
941 kwargs: static_kwargs)
942 if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle)
943 xts = 'private'
944 endif
57612511
PB
945 endif
946endif
947
2b1ccdf4 948gtk = not_found
1b695471 949gtkx11 = not_found
c23d7b4e 950vte = not_found
c1ec4941 951if not get_option('gtk').auto() or (have_system and not cocoa.found())
1b695471
PB
952 gtk = dependency('gtk+-3.0', version: '>=3.22.0',
953 method: 'pkg-config',
954 required: get_option('gtk'),
d7dedf42 955 kwargs: static_kwargs)
1b695471
PB
956 if gtk.found()
957 gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
958 method: 'pkg-config',
959 required: false,
d7dedf42 960 kwargs: static_kwargs)
1b695471 961 gtk = declare_dependency(dependencies: [gtk, gtkx11])
c23d7b4e
PB
962
963 if not get_option('vte').auto() or have_system
964 vte = dependency('vte-2.91',
965 method: 'pkg-config',
966 required: get_option('vte'),
967 kwargs: static_kwargs)
968 endif
1b695471 969 endif
2b1ccdf4 970endif
1b695471 971
2b1ccdf4 972x11 = not_found
9d49bcf6 973if gtkx11.found()
1b695471 974 x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
d7dedf42 975 kwargs: static_kwargs)
2b1ccdf4 976endif
a0b93237 977vnc = not_found
2b1ccdf4 978png = not_found
2b1ccdf4 979jpeg = not_found
2b1ccdf4 980sasl = not_found
95e2289f 981if have_system and not get_option('vnc').disabled()
a0b93237
PB
982 vnc = declare_dependency() # dummy dependency
983 png = dependency('libpng', required: get_option('vnc_png'),
d7dedf42 984 method: 'pkg-config', kwargs: static_kwargs)
8e242b3c 985 jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
d7dedf42 986 method: 'pkg-config', kwargs: static_kwargs)
a0b93237
PB
987 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
988 required: get_option('vnc_sasl'),
d7dedf42 989 kwargs: static_kwargs)
a0b93237
PB
990 if sasl.found()
991 sasl = declare_dependency(dependencies: sasl,
992 compile_args: '-DSTRUCT_IOVEC_DEFINED')
993 endif
478e943f 994endif
241611ea 995
05e391ae
PB
996pam = not_found
997if not get_option('auth_pam').auto() or have_system
998 pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
999 required: get_option('auth_pam'),
1000 kwargs: static_kwargs)
1001endif
1002if pam.found() and not cc.links('''
1003 #include <stddef.h>
1004 #include <security/pam_appl.h>
1005 int main(void) {
1006 const char *service_name = "qemu";
1007 const char *user = "frank";
1008 const struct pam_conv pam_conv = { 0 };
1009 pam_handle_t *pamh = NULL;
1010 pam_start(service_name, user, &pam_conv, &pamh);
1011 return 0;
1012 }''', dependencies: pam)
1013 pam = not_found
1014 if get_option('auth_pam').enabled()
1015 error('could not link libpam')
1016 else
1017 warning('could not link libpam, disabling')
1018 endif
1019endif
1020
708eab42 1021snappy = not_found
241611ea
PB
1022if not get_option('snappy').auto() or have_system
1023 snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
1024 required: get_option('snappy'),
d7dedf42 1025 kwargs: static_kwargs)
241611ea
PB
1026endif
1027if snappy.found() and not cc.links('''
1028 #include <snappy-c.h>
1029 int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
1030 snappy = not_found
1031 if get_option('snappy').enabled()
1032 error('could not link libsnappy')
1033 else
1034 warning('could not link libsnappy, disabling')
1035 endif
708eab42 1036endif
0c32a0ae 1037
708eab42 1038lzo = not_found
0c32a0ae
PB
1039if not get_option('lzo').auto() or have_system
1040 lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
1041 required: get_option('lzo'),
d7dedf42 1042 kwargs: static_kwargs)
0c32a0ae
PB
1043endif
1044if lzo.found() and not cc.links('''
1045 #include <lzo/lzo1x.h>
1046 int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
1047 lzo = not_found
1048 if get_option('lzo').enabled()
1049 error('could not link liblzo2')
1050 else
1051 warning('could not link liblzo2, disabling')
1052 endif
708eab42 1053endif
0c32a0ae 1054
55166230
MAL
1055rdma = not_found
1056if 'CONFIG_RDMA' in config_host
1057 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
1058endif
ab318051
MAL
1059numa = not_found
1060if 'CONFIG_NUMA' in config_host
1061 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
1062endif
582ea95f
MAL
1063xen = not_found
1064if 'CONFIG_XEN_BACKEND' in config_host
1065 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
1066 link_args: config_host['XEN_LIBS'].split())
1067endif
06677ce1 1068cacard = not_found
5f364c57
PB
1069if not get_option('smartcard').auto() or have_system
1070 cacard = dependency('libcacard', required: get_option('smartcard'),
1071 version: '>=2.5.1', method: 'pkg-config',
1072 kwargs: static_kwargs)
06677ce1 1073endif
0a40bcb7
CB
1074u2f = not_found
1075if have_system
1076 u2f = dependency('u2f-emu', required: get_option('u2f'),
1077 method: 'pkg-config',
d7dedf42 1078 kwargs: static_kwargs)
0a40bcb7 1079endif
06677ce1 1080usbredir = not_found
18f31e60
PB
1081if not get_option('usb_redir').auto() or have_system
1082 usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
1083 version: '>=0.6', method: 'pkg-config',
1084 kwargs: static_kwargs)
06677ce1
PB
1085endif
1086libusb = not_found
90540f32
PB
1087if not get_option('libusb').auto() or have_system
1088 libusb = dependency('libusb-1.0', required: get_option('libusb'),
1089 version: '>=1.0.13', method: 'pkg-config',
1090 kwargs: static_kwargs)
06677ce1 1091endif
90540f32 1092
c9322ab5 1093libpmem = not_found
e36e8c70
PB
1094if not get_option('libpmem').auto() or have_system
1095 libpmem = dependency('libpmem', required: get_option('libpmem'),
1096 method: 'pkg-config', kwargs: static_kwargs)
c9322ab5 1097endif
c7c91a74 1098libdaxctl = not_found
83ef1682
PB
1099if not get_option('libdaxctl').auto() or have_system
1100 libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'),
1101 version: '>=57', method: 'pkg-config',
1102 kwargs: static_kwargs)
c7c91a74 1103endif
8ce0a45f 1104tasn1 = not_found
ba7ed407
PB
1105if gnutls.found()
1106 tasn1 = dependency('libtasn1',
1107 method: 'pkg-config',
1108 kwargs: static_kwargs)
8ce0a45f 1109endif
af04e89d 1110keyutils = dependency('libkeyutils', required: false,
d7dedf42 1111 method: 'pkg-config', kwargs: static_kwargs)
a81df1b6 1112
3909def8
MAL
1113has_gettid = cc.has_function('gettid')
1114
aa087962
PB
1115# Malloc tests
1116
1117malloc = []
1118if get_option('malloc') == 'system'
1119 has_malloc_trim = \
1120 not get_option('malloc_trim').disabled() and \
1121 cc.links('''#include <malloc.h>
1122 int main(void) { malloc_trim(0); return 0; }''')
1123else
1124 has_malloc_trim = false
1125 malloc = cc.find_library(get_option('malloc'), required: true)
1126endif
1127if not has_malloc_trim and get_option('malloc_trim').enabled()
1128 if get_option('malloc') == 'system'
1129 error('malloc_trim not available on this platform.')
1130 else
1131 error('malloc_trim not available with non-libc memory allocator')
1132 endif
1133endif
1134
84e319a5
HR
1135# Check whether the glibc provides statx()
1136
e66420ac 1137gnu_source_prefix = '''
84e319a5
HR
1138 #ifndef _GNU_SOURCE
1139 #define _GNU_SOURCE
1140 #endif
e66420ac
PB
1141'''
1142statx_test = gnu_source_prefix + '''
84e319a5
HR
1143 #include <sys/stat.h>
1144 int main(void) {
1145 struct statx statxbuf;
1146 statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
1147 return 0;
1148 }'''
1149
1150has_statx = cc.links(statx_test)
1151
eb6a3886
SH
1152have_vhost_user_blk_server = (targetos == 'linux' and
1153 'CONFIG_VHOST_USER' in config_host)
e5e856c1
SH
1154
1155if get_option('vhost_user_blk_server').enabled()
1156 if targetos != 'linux'
1157 error('vhost_user_blk_server requires linux')
eb6a3886
SH
1158 elif 'CONFIG_VHOST_USER' not in config_host
1159 error('vhost_user_blk_server requires vhost-user support')
e5e856c1
SH
1160 endif
1161elif get_option('vhost_user_blk_server').disabled() or not have_system
1162 have_vhost_user_blk_server = false
1163endif
1164
9e62ba48 1165
df4ea709
HR
1166if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
1167 error('Cannot enable fuse-lseek while fuse is disabled')
1168endif
1169
a484a719
HR
1170fuse = dependency('fuse3', required: get_option('fuse'),
1171 version: '>=3.1', method: 'pkg-config',
d7dedf42 1172 kwargs: static_kwargs)
a484a719 1173
df4ea709
HR
1174fuse_lseek = not_found
1175if not get_option('fuse_lseek').disabled()
1176 if fuse.version().version_compare('>=3.8')
1177 # Dummy dependency
1178 fuse_lseek = declare_dependency()
1179 elif get_option('fuse_lseek').enabled()
1180 if fuse.found()
1181 error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
1182 else
1183 error('fuse-lseek requires libfuse, which was not found')
1184 endif
1185 endif
1186endif
1187
46627f41
AM
1188# libbpf
1189libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config')
1190if libbpf.found() and not cc.links('''
1191 #include <bpf/libbpf.h>
1192 int main(void)
1193 {
1194 bpf_object__destroy_skeleton(NULL);
1195 return 0;
1196 }''', dependencies: libbpf)
1197 libbpf = not_found
1198 if get_option('bpf').enabled()
1199 error('libbpf skeleton test failed')
1200 else
1201 warning('libbpf skeleton test failed, disabling')
1202 endif
1203endif
1204
87430d5b
PB
1205#################
1206# config-host.h #
1207#################
1208
1209audio_drivers_selected = []
1210if have_system
1211 audio_drivers_available = {
1212 'alsa': alsa.found(),
1213 'coreaudio': coreaudio.found(),
1214 'dsound': dsound.found(),
1215 'jack': jack.found(),
1216 'oss': oss.found(),
1217 'pa': pulse.found(),
1218 'sdl': sdl.found(),
1219 }
e5424a29
PB
1220 foreach k, v: audio_drivers_available
1221 config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
1222 endforeach
87430d5b
PB
1223
1224 # Default to native drivers first, OSS second, SDL third
1225 audio_drivers_priority = \
1226 [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \
1227 (targetos == 'linux' ? [] : [ 'sdl' ])
1228 audio_drivers_default = []
1229 foreach k: audio_drivers_priority
1230 if audio_drivers_available[k]
1231 audio_drivers_default += k
1232 endif
1233 endforeach
1234
1235 foreach k: get_option('audio_drv_list')
1236 if k == 'default'
1237 audio_drivers_selected += audio_drivers_default
1238 elif not audio_drivers_available[k]
1239 error('Audio driver "@0@" not available.'.format(k))
1240 else
1241 audio_drivers_selected += k
1242 endif
1243 endforeach
1244endif
87430d5b
PB
1245config_host_data.set('CONFIG_AUDIO_DRIVERS',
1246 '"' + '", "'.join(audio_drivers_selected) + '", ')
1247
9e62ba48
DB
1248if get_option('cfi')
1249 cfi_flags=[]
1250 # Check for dependency on LTO
1251 if not get_option('b_lto')
1252 error('Selected Control-Flow Integrity but LTO is disabled')
1253 endif
1254 if config_host.has_key('CONFIG_MODULES')
1255 error('Selected Control-Flow Integrity is not compatible with modules')
1256 endif
1257 # Check for cfi flags. CFI requires LTO so we can't use
1258 # get_supported_arguments, but need a more complex "compiles" which allows
1259 # custom arguments
1260 if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
1261 args: ['-flto', '-fsanitize=cfi-icall'] )
1262 cfi_flags += '-fsanitize=cfi-icall'
1263 else
1264 error('-fsanitize=cfi-icall is not supported by the compiler')
1265 endif
1266 if cc.compiles('int main () { return 0; }',
1267 name: '-fsanitize-cfi-icall-generalize-pointers',
1268 args: ['-flto', '-fsanitize=cfi-icall',
1269 '-fsanitize-cfi-icall-generalize-pointers'] )
1270 cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
1271 else
1272 error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
1273 endif
1274 if get_option('cfi_debug')
1275 if cc.compiles('int main () { return 0; }',
1276 name: '-fno-sanitize-trap=cfi-icall',
1277 args: ['-flto', '-fsanitize=cfi-icall',
1278 '-fno-sanitize-trap=cfi-icall'] )
1279 cfi_flags += '-fno-sanitize-trap=cfi-icall'
1280 else
1281 error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
1282 endif
1283 endif
5fc0617f
MAL
1284 add_global_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
1285 add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
9e62ba48
DB
1286endif
1287
14176c8d
JD
1288have_host_block_device = (targetos != 'darwin' or
1289 cc.has_header('IOKit/storage/IOMedia.h'))
1290
69202b40
PB
1291have_virtfs = (targetos == 'linux' and
1292 have_system and
1293 libattr.found() and
1294 libcap_ng.found())
1295
3a489d38
PMD
1296have_virtfs_proxy_helper = have_virtfs and have_tools
1297
69202b40
PB
1298if get_option('virtfs').enabled()
1299 if not have_virtfs
1300 if targetos != 'linux'
1301 error('virtio-9p (virtfs) requires Linux')
1302 elif not libcap_ng.found() or not libattr.found()
1303 error('virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel')
1304 elif not have_system
1305 error('virtio-9p (virtfs) needs system emulation support')
1306 endif
1307 endif
1308elif get_option('virtfs').disabled()
1309 have_virtfs = false
1310endif
1311
16bf7a33
PB
1312config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
1313config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
1314config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
1315config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
1316config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
1317config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
1318config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
1319config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
1320config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
1321config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
1322config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
1323config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
1324
f7f2d651 1325config_host_data.set('CONFIG_ATTR', libattr.found())
8c6d4ff4 1326config_host_data.set('CONFIG_BRLAPI', brlapi.found())
b4e312e9 1327config_host_data.set('CONFIG_COCOA', cocoa.found())
f01496a3 1328config_host_data.set('CONFIG_LIBUDEV', libudev.found())
0c32a0ae 1329config_host_data.set('CONFIG_LZO', lzo.found())
6ec0e15d
PB
1330config_host_data.set('CONFIG_MPATH', mpathpersist.found())
1331config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
f9cd86fe 1332config_host_data.set('CONFIG_CURL', curl.found())
5285e593 1333config_host_data.set('CONFIG_CURSES', curses.found())
8bc5184d 1334config_host_data.set('CONFIG_GBM', gbm.found())
08821ca2
PB
1335config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
1336if glusterfs.found()
1337 config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
1338 config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5'))
1339 config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6'))
1340 config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
1341 config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
1342 config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
1343endif
1b695471 1344config_host_data.set('CONFIG_GTK', gtk.found())
c23d7b4e 1345config_host_data.set('CONFIG_VTE', vte.found())
f7f2d651 1346config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
727c8bb8 1347config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
46627f41 1348config_host_data.set('CONFIG_EBPF', libbpf.found())
63a7f853 1349config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
9db405a3 1350config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
30045c05 1351config_host_data.set('CONFIG_LIBNFS', libnfs.found())
63a7f853
PB
1352config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
1353config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
fabd1e93 1354config_host_data.set('CONFIG_RBD', rbd.found())
35be72ba
PB
1355config_host_data.set('CONFIG_SDL', sdl.found())
1356config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
90835c2b 1357config_host_data.set('CONFIG_SECCOMP', seccomp.found())
241611ea 1358config_host_data.set('CONFIG_SNAPPY', snappy.found())
90540f32 1359config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
e5e856c1 1360config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
a0b93237
PB
1361config_host_data.set('CONFIG_VNC', vnc.found())
1362config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
1363config_host_data.set('CONFIG_VNC_PNG', png.found())
1364config_host_data.set('CONFIG_VNC_SASL', sasl.found())
69202b40 1365config_host_data.set('CONFIG_VIRTFS', have_virtfs)
63a7f853 1366config_host_data.set('CONFIG_VTE', vte.found())
4113f4cf 1367config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
af04e89d 1368config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
3909def8 1369config_host_data.set('CONFIG_GETTID', has_gettid)
57612511 1370config_host_data.set('CONFIG_GNUTLS', gnutls.found())
cc4c7c73 1371config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found())
57612511
PB
1372config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
1373config_host_data.set('CONFIG_NETTLE', nettle.found())
1374config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private')
aa087962 1375config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
84e319a5 1376config_host_data.set('CONFIG_STATX', has_statx)
b1def33d 1377config_host_data.set('CONFIG_ZSTD', zstd.found())
a484a719 1378config_host_data.set('CONFIG_FUSE', fuse.found())
df4ea709 1379config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
9d71037f 1380config_host_data.set('CONFIG_X11', x11.found())
9e62ba48 1381config_host_data.set('CONFIG_CFI', get_option('cfi'))
859aef02
PB
1382config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
1383config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
1384config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
1385config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
1386
69d8de7a
PB
1387config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
1388
1389# has_header
e66420ac 1390config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h'))
d47a8b3b
PB
1391config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h'))
1392config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h'))
48f670ec 1393config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
2964be52 1394config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
2802d91d 1395config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
69d8de7a 1396config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
ded5d78c 1397config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
4a9d5f89 1398config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
ded5d78c 1399
69d8de7a 1400# has_function
a620fbe9 1401config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
e66420ac
PB
1402config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
1403config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
1404config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate'))
1405config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
e1fbd2c4 1406config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign'))
e66420ac 1407config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
2b9f74ef 1408config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
ed3b3f17 1409config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
e66420ac
PB
1410config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile'))
1411config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare'))
1412config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
1413config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
1414config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
be7e89f6 1415config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
e66420ac 1416config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
ed3b3f17 1417config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
69d8de7a 1418config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
2b9f74ef 1419
e66420ac
PB
1420# has_header_symbol
1421config_host_data.set('CONFIG_BYTESWAP_H',
1422 cc.has_header_symbol('byteswap.h', 'bswap_32'))
1423config_host_data.set('CONFIG_EPOLL_CREATE1',
1424 cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
d47a8b3b
PB
1425config_host_data.set('CONFIG_HAS_ENVIRON',
1426 cc.has_header_symbol('unistd.h', 'environ', prefix: gnu_source_prefix))
e66420ac
PB
1427config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
1428 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and
1429 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE'))
1430config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE',
1431 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE'))
1432config_host_data.set('CONFIG_FIEMAP',
1433 cc.has_header('linux/fiemap.h') and
1434 cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP'))
be7e89f6
PB
1435config_host_data.set('CONFIG_GETRANDOM',
1436 cc.has_function('getrandom') and
1437 cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK'))
a620fbe9
PB
1438config_host_data.set('CONFIG_INOTIFY',
1439 cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
1440config_host_data.set('CONFIG_INOTIFY1',
1441 cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
e66420ac
PB
1442config_host_data.set('CONFIG_MACHINE_BSWAP_H',
1443 cc.has_header_symbol('machine/bswap.h', 'bswap32',
1444 prefix: '''#include <sys/endian.h>
1445 #include <sys/types.h>'''))
1446config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
1447 cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
be7e89f6
PB
1448config_host_data.set('CONFIG_RTNETLINK',
1449 cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN'))
1450config_host_data.set('CONFIG_SYSMACROS',
1451 cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
e1fbd2c4
PB
1452config_host_data.set('HAVE_OPTRESET',
1453 cc.has_header_symbol('getopt.h', 'optreset'))
be7e89f6
PB
1454config_host_data.set('HAVE_UTMPX',
1455 cc.has_header_symbol('utmpx.h', 'struct utmpx'))
653163fc
MAL
1456config_host_data.set('HAVE_IPPROTO_MPTCP',
1457 cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
e66420ac
PB
1458
1459# has_member
1460config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
1461 cc.has_member('struct sigevent', 'sigev_notify_thread_id',
1462 prefix: '#include <signal.h>'))
ed3b3f17
PB
1463config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM',
1464 cc.has_member('struct stat', 'st_atim',
1465 prefix: '#include <sys/stat.h>'))
e66420ac 1466
904ad5ec 1467config_host_data.set('CONFIG_EVENTFD', cc.links('''
e1fbd2c4
PB
1468 #include <sys/eventfd.h>
1469 int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }'''))
904ad5ec 1470config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + '''
e1fbd2c4
PB
1471 #include <unistd.h>
1472 int main(void) {
1473 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
1474 return fdatasync(0);
1475 #else
1476 #error Not supported
1477 #endif
1478 }'''))
904ad5ec 1479config_host_data.set('CONFIG_MADVISE', cc.links(gnu_source_prefix + '''
e1fbd2c4
PB
1480 #include <sys/types.h>
1481 #include <sys/mman.h>
1482 #include <stddef.h>
1483 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }'''))
904ad5ec 1484config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + '''
e1fbd2c4
PB
1485 #include <sys/mman.h>
1486 int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }'''))
904ad5ec 1487config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
d47a8b3b
PB
1488 #include <fcntl.h>
1489 #if !defined(AT_EMPTY_PATH)
1490 # error missing definition
1491 #else
1492 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
1493 #endif'''))
904ad5ec 1494config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + '''
a620fbe9
PB
1495 #include <unistd.h>
1496 #include <fcntl.h>
1497
1498 int main(void)
1499 {
1500 int pipefd[2];
1501 return pipe2(pipefd, O_CLOEXEC);
1502 }'''))
904ad5ec 1503config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
e1fbd2c4
PB
1504 #include <sys/mman.h>
1505 #include <stddef.h>
1506 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }'''))
904ad5ec 1507config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
6bd17dcc
KS
1508 #include <sys/signalfd.h>
1509 #include <stddef.h>
1510 int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }'''))
904ad5ec 1511config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + '''
a620fbe9
PB
1512 #include <unistd.h>
1513 #include <fcntl.h>
1514 #include <limits.h>
1515
1516 int main(void)
1517 {
1518 int len, fd = 0;
1519 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1520 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1521 return 0;
1522 }'''))
e1fbd2c4 1523
e46bd55d
PB
1524# Some versions of Mac OS X incorrectly define SIZE_MAX
1525config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
1526 #include <stdint.h>
1527 #include <stdio.h>
1528 int main(int argc, char *argv[]) {
1529 return printf("%zu", SIZE_MAX);
1530 }''', args: ['-Werror']))
1531
1532
765686d6 1533ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target
87430d5b 1534arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
16bf7a33 1535strings = ['HOST_DSOSUF', 'CONFIG_IASL']
859aef02 1536foreach k, v: config_host
765686d6
PB
1537 if ignored.contains(k)
1538 # do nothing
1539 elif arrays.contains(k)
859aef02
PB
1540 if v != ''
1541 v = '"' + '", "'.join(v.split()) + '", '
1542 endif
1543 config_host_data.set(k, v)
1544 elif k == 'ARCH'
1545 config_host_data.set('HOST_' + v.to_upper(), 1)
1546 elif strings.contains(k)
1547 if not k.startswith('CONFIG_')
1548 k = 'CONFIG_' + k.to_upper()
1549 endif
1550 config_host_data.set_quoted(k, v)
1551 elif k.startswith('CONFIG_') or k.startswith('HAVE_') or k.startswith('HOST_')
1552 config_host_data.set(k, v == 'y' ? 1 : v)
1553 endif
1554endforeach
859aef02 1555
a0c9162c
PB
1556########################
1557# Target configuration #
1558########################
1559
2becc36a 1560minikconf = find_program('scripts/minikconf.py')
05512f55 1561config_all = {}
a98006bc 1562config_all_devices = {}
ca0fc784 1563config_all_disas = {}
2becc36a
PB
1564config_devices_mak_list = []
1565config_devices_h = {}
859aef02 1566config_target_h = {}
2becc36a 1567config_target_mak = {}
ca0fc784
PB
1568
1569disassemblers = {
1570 'alpha' : ['CONFIG_ALPHA_DIS'],
1571 'arm' : ['CONFIG_ARM_DIS'],
1572 'avr' : ['CONFIG_AVR_DIS'],
1573 'cris' : ['CONFIG_CRIS_DIS'],
3e7a84ee 1574 'hexagon' : ['CONFIG_HEXAGON_DIS'],
ca0fc784
PB
1575 'hppa' : ['CONFIG_HPPA_DIS'],
1576 'i386' : ['CONFIG_I386_DIS'],
1577 'x86_64' : ['CONFIG_I386_DIS'],
1578 'x32' : ['CONFIG_I386_DIS'],
ca0fc784
PB
1579 'm68k' : ['CONFIG_M68K_DIS'],
1580 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
1581 'mips' : ['CONFIG_MIPS_DIS'],
ca0fc784
PB
1582 'nios2' : ['CONFIG_NIOS2_DIS'],
1583 'or1k' : ['CONFIG_OPENRISC_DIS'],
1584 'ppc' : ['CONFIG_PPC_DIS'],
1585 'riscv' : ['CONFIG_RISCV_DIS'],
1586 'rx' : ['CONFIG_RX_DIS'],
1587 's390' : ['CONFIG_S390_DIS'],
1588 'sh4' : ['CONFIG_SH4_DIS'],
1589 'sparc' : ['CONFIG_SPARC_DIS'],
1590 'xtensa' : ['CONFIG_XTENSA_DIS'],
1591}
1592if link_language == 'cpp'
1593 disassemblers += {
1594 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
1595 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
1596 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
1597 }
1598endif
1599
e1fbd2c4 1600have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
0a189110 1601host_kconfig = \
65ce87d4 1602 ('CONFIG_FUZZ' in config_host ? ['CONFIG_FUZZ=y'] : []) + \
0a189110
PB
1603 ('CONFIG_TPM' in config_host ? ['CONFIG_TPM=y'] : []) + \
1604 ('CONFIG_SPICE' in config_host ? ['CONFIG_SPICE=y'] : []) + \
ccd250aa 1605 (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
0a189110 1606 ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
9d71037f 1607 (x11.found() ? ['CONFIG_X11=y'] : []) + \
0a189110
PB
1608 ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
1609 ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
1610 ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
69202b40 1611 (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
0a189110 1612 ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
3090de69 1613 ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
106ad1f9 1614 (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : [])
0a189110 1615
a9a74907 1616ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
05512f55 1617
fdb75aef
PB
1618default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
1619actual_target_dirs = []
fbb4121d 1620fdt_required = []
a81df1b6 1621foreach target : target_dirs
765686d6
PB
1622 config_target = { 'TARGET_NAME': target.split('-')[0] }
1623 if target.endswith('linux-user')
fdb75aef
PB
1624 if targetos != 'linux'
1625 if default_targets
1626 continue
1627 endif
1628 error('Target @0@ is only available on a Linux host'.format(target))
1629 endif
765686d6
PB
1630 config_target += { 'CONFIG_LINUX_USER': 'y' }
1631 elif target.endswith('bsd-user')
fdb75aef
PB
1632 if 'CONFIG_BSD' not in config_host
1633 if default_targets
1634 continue
1635 endif
1636 error('Target @0@ is only available on a BSD host'.format(target))
1637 endif
765686d6
PB
1638 config_target += { 'CONFIG_BSD_USER': 'y' }
1639 elif target.endswith('softmmu')
1640 config_target += { 'CONFIG_SOFTMMU': 'y' }
1641 endif
1642 if target.endswith('-user')
1643 config_target += {
1644 'CONFIG_USER_ONLY': 'y',
1645 'CONFIG_QEMU_INTERP_PREFIX':
1646 config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
1647 }
1648 endif
859aef02 1649
0a189110 1650 accel_kconfig = []
8a19980e
PB
1651 foreach sym: accelerators
1652 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
1653 config_target += { sym: 'y' }
1654 config_all += { sym: 'y' }
23a77b2d
PB
1655 if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
1656 config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
1657 elif sym == 'CONFIG_XEN' and have_xen_pci_passthrough
8a19980e
PB
1658 config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
1659 endif
dae0ec15
GH
1660 if target in modular_tcg
1661 config_target += { 'CONFIG_TCG_MODULAR': 'y' }
1662 else
1663 config_target += { 'CONFIG_TCG_BUILTIN': 'y' }
1664 endif
0a189110 1665 accel_kconfig += [ sym + '=y' ]
8a19980e
PB
1666 endif
1667 endforeach
0a189110 1668 if accel_kconfig.length() == 0
fdb75aef
PB
1669 if default_targets
1670 continue
1671 endif
1672 error('No accelerator available for target @0@'.format(target))
1673 endif
8a19980e 1674
fdb75aef 1675 actual_target_dirs += target
812b31d3 1676 config_target += keyval.load('configs/targets' / target + '.mak')
a9a74907 1677 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
765686d6 1678
fbb4121d
PB
1679 if 'TARGET_NEED_FDT' in config_target
1680 fdt_required += target
1681 endif
1682
fa73168b
PB
1683 # Add default keys
1684 if 'TARGET_BASE_ARCH' not in config_target
1685 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
1686 endif
1687 if 'TARGET_ABI_DIR' not in config_target
1688 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
1689 endif
859aef02 1690
ca0fc784
PB
1691 foreach k, v: disassemblers
1692 if config_host['ARCH'].startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
1693 foreach sym: v
1694 config_target += { sym: 'y' }
1695 config_all_disas += { sym: 'y' }
1696 endforeach
1697 endif
1698 endforeach
1699
859aef02
PB
1700 config_target_data = configuration_data()
1701 foreach k, v: config_target
1702 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
1703 # do nothing
1704 elif ignored.contains(k)
1705 # do nothing
1706 elif k == 'TARGET_BASE_ARCH'
a9a74907
PB
1707 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
1708 # not used to select files from sourcesets.
859aef02 1709 config_target_data.set('TARGET_' + v.to_upper(), 1)
765686d6 1710 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
859aef02
PB
1711 config_target_data.set_quoted(k, v)
1712 elif v == 'y'
1713 config_target_data.set(k, 1)
1714 else
1715 config_target_data.set(k, v)
1716 endif
1717 endforeach
cb2c5531
PM
1718 config_target_data.set('QEMU_ARCH',
1719 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
859aef02
PB
1720 config_target_h += {target: configure_file(output: target + '-config-target.h',
1721 configuration: config_target_data)}
2becc36a
PB
1722
1723 if target.endswith('-softmmu')
d1d5e9ee 1724 config_input = meson.get_external_property(target, 'default')
2becc36a
PB
1725 config_devices_mak = target + '-config-devices.mak'
1726 config_devices_mak = configure_file(
d1d5e9ee 1727 input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'],
2becc36a
PB
1728 output: config_devices_mak,
1729 depfile: config_devices_mak + '.d',
1730 capture: true,
7bc3ca7f
PB
1731 command: [minikconf,
1732 get_option('default_devices') ? '--defconfig' : '--allnoconfig',
2becc36a 1733 config_devices_mak, '@DEPFILE@', '@INPUT@',
f4063f9c
PMD
1734 host_kconfig, accel_kconfig,
1735 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
859aef02
PB
1736
1737 config_devices_data = configuration_data()
1738 config_devices = keyval.load(config_devices_mak)
1739 foreach k, v: config_devices
1740 config_devices_data.set(k, 1)
1741 endforeach
2becc36a 1742 config_devices_mak_list += config_devices_mak
859aef02
PB
1743 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
1744 configuration: config_devices_data)}
1745 config_target += config_devices
a98006bc 1746 config_all_devices += config_devices
2becc36a
PB
1747 endif
1748 config_target_mak += {target: config_target}
a81df1b6 1749endforeach
fdb75aef 1750target_dirs = actual_target_dirs
a81df1b6 1751
2becc36a
PB
1752# This configuration is used to build files that are shared by
1753# multiple binaries, and then extracted out of the "common"
1754# static_library target.
1755#
1756# We do not use all_sources()/all_dependencies(), because it would
1757# build literally all source files, including devices only used by
1758# targets that are not built for this compilation. The CONFIG_ALL
1759# pseudo symbol replaces it.
1760
05512f55 1761config_all += config_all_devices
2becc36a
PB
1762config_all += config_host
1763config_all += config_all_disas
1764config_all += {
1765 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
1766 'CONFIG_SOFTMMU': have_system,
1767 'CONFIG_USER_ONLY': have_user,
1768 'CONFIG_ALL': true,
1769}
1770
a0c9162c
PB
1771##############
1772# Submodules #
1773##############
8b18cdbf
RH
1774
1775capstone = not_found
1776capstone_opt = get_option('capstone')
1777if capstone_opt in ['enabled', 'auto', 'system']
1778 have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
bcf36862 1779 capstone = dependency('capstone', version: '>=4.0',
d7dedf42 1780 kwargs: static_kwargs, method: 'pkg-config',
8b18cdbf
RH
1781 required: capstone_opt == 'system' or
1782 capstone_opt == 'enabled' and not have_internal)
8f4aea71
DB
1783
1784 # Some versions of capstone have broken pkg-config file
1785 # that reports a wrong -I path, causing the #include to
1786 # fail later. If the system has such a broken version
1787 # do not use it.
1788 if capstone.found() and not cc.compiles('#include <capstone.h>',
1789 dependencies: [capstone])
1790 capstone = not_found
1791 if capstone_opt == 'system'
1792 error('system capstone requested, it does not appear to work')
1793 endif
1794 endif
1795
8b18cdbf
RH
1796 if capstone.found()
1797 capstone_opt = 'system'
1798 elif have_internal
1799 capstone_opt = 'internal'
1800 else
1801 capstone_opt = 'disabled'
1802 endif
1803endif
1804if capstone_opt == 'internal'
1805 capstone_data = configuration_data()
1806 capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
1807
1808 capstone_files = files(
1809 'capstone/cs.c',
1810 'capstone/MCInst.c',
1811 'capstone/MCInstrDesc.c',
1812 'capstone/MCRegisterInfo.c',
1813 'capstone/SStream.c',
1814 'capstone/utils.c'
1815 )
1816
1817 if 'CONFIG_ARM_DIS' in config_all_disas
1818 capstone_data.set('CAPSTONE_HAS_ARM', '1')
1819 capstone_files += files(
1820 'capstone/arch/ARM/ARMDisassembler.c',
1821 'capstone/arch/ARM/ARMInstPrinter.c',
1822 'capstone/arch/ARM/ARMMapping.c',
1823 'capstone/arch/ARM/ARMModule.c'
1824 )
1825 endif
1826
1827 # FIXME: This config entry currently depends on a c++ compiler.
1828 # Which is needed for building libvixl, but not for capstone.
1829 if 'CONFIG_ARM_A64_DIS' in config_all_disas
1830 capstone_data.set('CAPSTONE_HAS_ARM64', '1')
1831 capstone_files += files(
1832 'capstone/arch/AArch64/AArch64BaseInfo.c',
1833 'capstone/arch/AArch64/AArch64Disassembler.c',
1834 'capstone/arch/AArch64/AArch64InstPrinter.c',
1835 'capstone/arch/AArch64/AArch64Mapping.c',
1836 'capstone/arch/AArch64/AArch64Module.c'
1837 )
1838 endif
1839
1840 if 'CONFIG_PPC_DIS' in config_all_disas
1841 capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
1842 capstone_files += files(
1843 'capstone/arch/PowerPC/PPCDisassembler.c',
1844 'capstone/arch/PowerPC/PPCInstPrinter.c',
1845 'capstone/arch/PowerPC/PPCMapping.c',
1846 'capstone/arch/PowerPC/PPCModule.c'
1847 )
1848 endif
1849
3d562845
RH
1850 if 'CONFIG_S390_DIS' in config_all_disas
1851 capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
1852 capstone_files += files(
1853 'capstone/arch/SystemZ/SystemZDisassembler.c',
1854 'capstone/arch/SystemZ/SystemZInstPrinter.c',
1855 'capstone/arch/SystemZ/SystemZMapping.c',
1856 'capstone/arch/SystemZ/SystemZModule.c',
1857 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
1858 )
1859 endif
1860
8b18cdbf
RH
1861 if 'CONFIG_I386_DIS' in config_all_disas
1862 capstone_data.set('CAPSTONE_HAS_X86', 1)
1863 capstone_files += files(
1864 'capstone/arch/X86/X86Disassembler.c',
1865 'capstone/arch/X86/X86DisassemblerDecoder.c',
1866 'capstone/arch/X86/X86ATTInstPrinter.c',
1867 'capstone/arch/X86/X86IntelInstPrinter.c',
eef20e40 1868 'capstone/arch/X86/X86InstPrinterCommon.c',
8b18cdbf
RH
1869 'capstone/arch/X86/X86Mapping.c',
1870 'capstone/arch/X86/X86Module.c'
1871 )
1872 endif
1873
1874 configure_file(output: 'capstone-defs.h', configuration: capstone_data)
1875
1876 capstone_cargs = [
1877 # FIXME: There does not seem to be a way to completely replace the c_args
1878 # that come from add_project_arguments() -- we can only add to them.
1879 # So: disable all warnings with a big hammer.
1880 '-Wno-error', '-w',
1881
1882 # Include all configuration defines via a header file, which will wind up
1883 # as a dependency on the object file, and thus changes here will result
1884 # in a rebuild.
1885 '-include', 'capstone-defs.h'
1886 ]
1887
1888 libcapstone = static_library('capstone',
610e7e0e 1889 build_by_default: false,
8b18cdbf
RH
1890 sources: capstone_files,
1891 c_args: capstone_cargs,
1892 include_directories: 'capstone/include')
1893 capstone = declare_dependency(link_with: libcapstone,
eef20e40 1894 include_directories: 'capstone/include/capstone')
8b18cdbf 1895endif
4d34a86b
PB
1896
1897slirp = not_found
1898slirp_opt = 'disabled'
1899if have_system
1900 slirp_opt = get_option('slirp')
1901 if slirp_opt in ['enabled', 'auto', 'system']
1902 have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
d7dedf42 1903 slirp = dependency('slirp', kwargs: static_kwargs,
4d34a86b
PB
1904 method: 'pkg-config',
1905 required: slirp_opt == 'system' or
1906 slirp_opt == 'enabled' and not have_internal)
1907 if slirp.found()
1908 slirp_opt = 'system'
1909 elif have_internal
1910 slirp_opt = 'internal'
1911 else
1912 slirp_opt = 'disabled'
1913 endif
1914 endif
1915 if slirp_opt == 'internal'
1916 slirp_deps = []
1917 if targetos == 'windows'
1918 slirp_deps = cc.find_library('iphlpapi')
43f547b7
MAL
1919 elif targetos == 'darwin'
1920 slirp_deps = cc.find_library('resolv')
4d34a86b
PB
1921 endif
1922 slirp_conf = configuration_data()
1923 slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
1924 slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
1925 slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
1926 slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
1927 slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
1928 slirp_files = [
1929 'slirp/src/arp_table.c',
1930 'slirp/src/bootp.c',
1931 'slirp/src/cksum.c',
1932 'slirp/src/dhcpv6.c',
1933 'slirp/src/dnssearch.c',
1934 'slirp/src/if.c',
1935 'slirp/src/ip6_icmp.c',
1936 'slirp/src/ip6_input.c',
1937 'slirp/src/ip6_output.c',
1938 'slirp/src/ip_icmp.c',
1939 'slirp/src/ip_input.c',
1940 'slirp/src/ip_output.c',
1941 'slirp/src/mbuf.c',
1942 'slirp/src/misc.c',
1943 'slirp/src/ncsi.c',
1944 'slirp/src/ndp_table.c',
1945 'slirp/src/sbuf.c',
1946 'slirp/src/slirp.c',
1947 'slirp/src/socket.c',
1948 'slirp/src/state.c',
1949 'slirp/src/stream.c',
1950 'slirp/src/tcp_input.c',
1951 'slirp/src/tcp_output.c',
1952 'slirp/src/tcp_subr.c',
1953 'slirp/src/tcp_timer.c',
1954 'slirp/src/tftp.c',
1955 'slirp/src/udp.c',
1956 'slirp/src/udp6.c',
1957 'slirp/src/util.c',
1958 'slirp/src/version.c',
1959 'slirp/src/vmstate.c',
1960 ]
1961
1962 configure_file(
1963 input : 'slirp/src/libslirp-version.h.in',
1964 output : 'libslirp-version.h',
1965 configuration: slirp_conf)
1966
1967 slirp_inc = include_directories('slirp', 'slirp/src')
1968 libslirp = static_library('slirp',
610e7e0e 1969 build_by_default: false,
4d34a86b
PB
1970 sources: slirp_files,
1971 c_args: slirp_cargs,
1972 include_directories: slirp_inc)
1973 slirp = declare_dependency(link_with: libslirp,
1974 dependencies: slirp_deps,
1975 include_directories: slirp_inc)
1976 endif
1977endif
1978
c715343f
DB
1979# For CFI, we need to compile slirp as a static library together with qemu.
1980# This is because we register slirp functions as callbacks for QEMU Timers.
1981# When using a system-wide shared libslirp, the type information for the
1982# callback is missing and the timer call produces a false positive with CFI.
1983#
1984# Now that slirp_opt has been defined, check if the selected slirp is compatible
1985# with control-flow integrity.
1986if get_option('cfi') and slirp_opt == 'system'
1987 error('Control-Flow Integrity is not compatible with system-wide slirp.' \
1988 + ' Please configure with --enable-slirp=git')
1989endif
1990
fbb4121d
PB
1991fdt = not_found
1992fdt_opt = get_option('fdt')
1993if have_system
1994 if fdt_opt in ['enabled', 'auto', 'system']
1995 have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
d7dedf42 1996 fdt = cc.find_library('fdt', kwargs: static_kwargs,
fbb4121d
PB
1997 required: fdt_opt == 'system' or
1998 fdt_opt == 'enabled' and not have_internal)
1999 if fdt.found() and cc.links('''
2000 #include <libfdt.h>
2001 #include <libfdt_env.h>
2002 int main(void) { fdt_check_full(NULL, 0); return 0; }''',
2003 dependencies: fdt)
2004 fdt_opt = 'system'
6c22853c
TH
2005 elif fdt_opt == 'system'
2006 error('system libfdt requested, but it is too old (1.5.1 or newer required)')
fbb4121d
PB
2007 elif have_internal
2008 fdt_opt = 'internal'
2009 else
2010 fdt_opt = 'disabled'
87daf898 2011 fdt = not_found
fbb4121d
PB
2012 endif
2013 endif
2014 if fdt_opt == 'internal'
2015 fdt_files = files(
2016 'dtc/libfdt/fdt.c',
2017 'dtc/libfdt/fdt_ro.c',
2018 'dtc/libfdt/fdt_wip.c',
2019 'dtc/libfdt/fdt_sw.c',
2020 'dtc/libfdt/fdt_rw.c',
2021 'dtc/libfdt/fdt_strerror.c',
2022 'dtc/libfdt/fdt_empty_tree.c',
2023 'dtc/libfdt/fdt_addresses.c',
2024 'dtc/libfdt/fdt_overlay.c',
2025 'dtc/libfdt/fdt_check.c',
2026 )
2027
2028 fdt_inc = include_directories('dtc/libfdt')
2029 libfdt = static_library('fdt',
610e7e0e 2030 build_by_default: false,
fbb4121d
PB
2031 sources: fdt_files,
2032 include_directories: fdt_inc)
2033 fdt = declare_dependency(link_with: libfdt,
2034 include_directories: fdt_inc)
2035 endif
2036endif
2037if not fdt.found() and fdt_required.length() > 0
2038 error('fdt not available but required by targets ' + ', '.join(fdt_required))
2039endif
2040
8b18cdbf 2041config_host_data.set('CONFIG_CAPSTONE', capstone.found())
fbb4121d 2042config_host_data.set('CONFIG_FDT', fdt.found())
4d34a86b 2043config_host_data.set('CONFIG_SLIRP', slirp.found())
8b18cdbf 2044
a0c9162c
PB
2045#####################
2046# Generated sources #
2047#####################
8b18cdbf 2048
a0c9162c 2049genh += configure_file(output: 'config-host.h', configuration: config_host_data)
a81df1b6 2050
3f885659 2051hxtool = find_program('scripts/hxtool')
650b5d54 2052shaderinclude = find_program('scripts/shaderinclude.pl')
a81df1b6 2053qapi_gen = find_program('scripts/qapi-gen.py')
654d6b04
PB
2054qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
2055 meson.current_source_dir() / 'scripts/qapi/commands.py',
2056 meson.current_source_dir() / 'scripts/qapi/common.py',
2057 meson.current_source_dir() / 'scripts/qapi/error.py',
2058 meson.current_source_dir() / 'scripts/qapi/events.py',
2059 meson.current_source_dir() / 'scripts/qapi/expr.py',
2060 meson.current_source_dir() / 'scripts/qapi/gen.py',
2061 meson.current_source_dir() / 'scripts/qapi/introspect.py',
2062 meson.current_source_dir() / 'scripts/qapi/parser.py',
2063 meson.current_source_dir() / 'scripts/qapi/schema.py',
2064 meson.current_source_dir() / 'scripts/qapi/source.py',
2065 meson.current_source_dir() / 'scripts/qapi/types.py',
2066 meson.current_source_dir() / 'scripts/qapi/visit.py',
2067 meson.current_source_dir() / 'scripts/qapi/common.py',
2068 meson.current_source_dir() / 'scripts/qapi-gen.py'
a81df1b6
PB
2069]
2070
2071tracetool = [
2072 python, files('scripts/tracetool.py'),
2073 '--backend=' + config_host['TRACE_BACKENDS']
2074]
0572d6cd
SH
2075tracetool_depends = files(
2076 'scripts/tracetool/backend/log.py',
2077 'scripts/tracetool/backend/__init__.py',
2078 'scripts/tracetool/backend/dtrace.py',
2079 'scripts/tracetool/backend/ftrace.py',
2080 'scripts/tracetool/backend/simple.py',
2081 'scripts/tracetool/backend/syslog.py',
2082 'scripts/tracetool/backend/ust.py',
2083 'scripts/tracetool/format/tcg_h.py',
2084 'scripts/tracetool/format/ust_events_c.py',
2085 'scripts/tracetool/format/ust_events_h.py',
2086 'scripts/tracetool/format/__init__.py',
2087 'scripts/tracetool/format/d.py',
2088 'scripts/tracetool/format/tcg_helper_c.py',
2089 'scripts/tracetool/format/simpletrace_stap.py',
2090 'scripts/tracetool/format/c.py',
2091 'scripts/tracetool/format/h.py',
2092 'scripts/tracetool/format/tcg_helper_h.py',
2093 'scripts/tracetool/format/log_stap.py',
2094 'scripts/tracetool/format/stap.py',
2095 'scripts/tracetool/format/tcg_helper_wrapper_h.py',
2096 'scripts/tracetool/__init__.py',
2097 'scripts/tracetool/transform.py',
2098 'scripts/tracetool/vcpu.py'
2099)
a81df1b6 2100
2c273f32
MAL
2101qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
2102 meson.current_source_dir(),
859aef02 2103 config_host['PKGVERSION'], meson.project_version()]
2c273f32
MAL
2104qemu_version = custom_target('qemu-version.h',
2105 output: 'qemu-version.h',
2106 command: qemu_version_cmd,
2107 capture: true,
2108 build_by_default: true,
2109 build_always_stale: true)
2110genh += qemu_version
2111
3f885659
MAL
2112hxdep = []
2113hx_headers = [
2114 ['qemu-options.hx', 'qemu-options.def'],
2115 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
2116]
2117if have_system
2118 hx_headers += [
2119 ['hmp-commands.hx', 'hmp-commands.h'],
2120 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
2121 ]
2122endif
2123foreach d : hx_headers
b7c70bf2 2124 hxdep += custom_target(d[1],
3f885659
MAL
2125 input: files(d[0]),
2126 output: d[1],
2127 capture: true,
2128 build_by_default: true, # to be removed when added to a target
2129 command: [hxtool, '-h', '@INPUT0@'])
2130endforeach
2131genh += hxdep
2132
a0c9162c
PB
2133###################
2134# Collect sources #
2135###################
a81df1b6 2136
55567891 2137authz_ss = ss.source_set()
4a96337d 2138blockdev_ss = ss.source_set()
7e2b888f 2139block_ss = ss.source_set()
2becc36a 2140bsd_user_ss = ss.source_set()
c2306d71 2141chardev_ss = ss.source_set()
7e2b888f 2142common_ss = ss.source_set()
2389304a 2143crypto_ss = ss.source_set()
f78536b1 2144io_ss = ss.source_set()
2becc36a 2145linux_user_ss = ss.source_set()
7e2b888f 2146qmp_ss = ss.source_set()
da33fc09 2147qom_ss = ss.source_set()
7e2b888f 2148softmmu_ss = ss.source_set()
64ed6f92 2149specific_fuzz_ss = ss.source_set()
7e2b888f
PMD
2150specific_ss = ss.source_set()
2151stub_ss = ss.source_set()
2152trace_ss = ss.source_set()
2153user_ss = ss.source_set()
2154util_ss = ss.source_set()
2becc36a 2155
c94a7b88
GH
2156# accel modules
2157qtest_module_ss = ss.source_set()
dae0ec15 2158tcg_module_ss = ss.source_set()
c94a7b88 2159
3154fee4 2160modules = {}
db2e89df 2161target_modules = {}
2becc36a
PB
2162hw_arch = {}
2163target_arch = {}
2164target_softmmu_arch = {}
46369b50 2165target_user_arch = {}
a81df1b6
PB
2166
2167###############
2168# Trace files #
2169###############
2170
c9322ab5
MAL
2171# TODO: add each directory to the subdirs from its own meson.build, once
2172# we have those
a81df1b6 2173trace_events_subdirs = [
a81df1b6 2174 'crypto',
69ff4d0a
PMD
2175 'qapi',
2176 'qom',
a81df1b6 2177 'monitor',
69ff4d0a 2178 'util',
a81df1b6
PB
2179]
2180if have_user
2181 trace_events_subdirs += [ 'linux-user' ]
2182endif
2183if have_block
2184 trace_events_subdirs += [
2185 'authz',
2186 'block',
2187 'io',
2188 'nbd',
2189 'scsi',
2190 ]
2191endif
2192if have_system
2193 trace_events_subdirs += [
8985db26 2194 'accel/kvm',
a81df1b6
PB
2195 'audio',
2196 'backends',
2197 'backends/tpm',
2198 'chardev',
46627f41 2199 'ebpf',
a81df1b6
PB
2200 'hw/9pfs',
2201 'hw/acpi',
77c05b0b 2202 'hw/adc',
a81df1b6
PB
2203 'hw/alpha',
2204 'hw/arm',
2205 'hw/audio',
2206 'hw/block',
2207 'hw/block/dataplane',
2208 'hw/char',
2209 'hw/display',
2210 'hw/dma',
2211 'hw/hppa',
2212 'hw/hyperv',
2213 'hw/i2c',
2214 'hw/i386',
2215 'hw/i386/xen',
2216 'hw/ide',
2217 'hw/input',
2218 'hw/intc',
2219 'hw/isa',
2220 'hw/mem',
2221 'hw/mips',
2222 'hw/misc',
2223 'hw/misc/macio',
2224 'hw/net',
98e5d7a2 2225 'hw/net/can',
ce0e6a2c 2226 'hw/nubus',
88eea45c 2227 'hw/nvme',
a81df1b6
PB
2228 'hw/nvram',
2229 'hw/pci',
2230 'hw/pci-host',
2231 'hw/ppc',
2232 'hw/rdma',
2233 'hw/rdma/vmw',
2234 'hw/rtc',
2235 'hw/s390x',
2236 'hw/scsi',
2237 'hw/sd',
2238 'hw/sparc',
2239 'hw/sparc64',
2240 'hw/ssi',
2241 'hw/timer',
2242 'hw/tpm',
2243 'hw/usb',
2244 'hw/vfio',
2245 'hw/virtio',
2246 'hw/watchdog',
2247 'hw/xen',
2248 'hw/gpio',
a81df1b6
PB
2249 'migration',
2250 'net',
8b7a5507 2251 'softmmu',
a81df1b6 2252 'ui',
ad22c308 2253 'hw/remote',
a81df1b6
PB
2254 ]
2255endif
8985db26
PMD
2256if have_system or have_user
2257 trace_events_subdirs += [
2258 'accel/tcg',
2259 'hw/core',
2260 'target/arm',
a1477da3 2261 'target/arm/hvf',
8985db26
PMD
2262 'target/hppa',
2263 'target/i386',
2264 'target/i386/kvm',
34b8ff25 2265 'target/mips/tcg',
8985db26
PMD
2266 'target/ppc',
2267 'target/riscv',
2268 'target/s390x',
67043607 2269 'target/s390x/kvm',
8985db26
PMD
2270 'target/sparc',
2271 ]
2272endif
a81df1b6 2273
0df750e9
MAL
2274vhost_user = not_found
2275if 'CONFIG_VHOST_USER' in config_host
2276 libvhost_user = subproject('libvhost-user')
2277 vhost_user = libvhost_user.get_variable('vhost_user_dep')
2278endif
2279
a81df1b6
PB
2280subdir('qapi')
2281subdir('qobject')
2282subdir('stubs')
2283subdir('trace')
2284subdir('util')
5582c58f
MAL
2285subdir('qom')
2286subdir('authz')
a81df1b6 2287subdir('crypto')
2d78b56e 2288subdir('ui')
a81df1b6 2289
3154fee4
MAL
2290
2291if enable_modules
2292 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
2293 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
2294endif
2295
2becc36a 2296stub_ss = stub_ss.apply(config_all, strict: false)
a81df1b6
PB
2297
2298util_ss.add_all(trace_ss)
2becc36a 2299util_ss = util_ss.apply(config_all, strict: false)
a81df1b6
PB
2300libqemuutil = static_library('qemuutil',
2301 sources: util_ss.sources() + stub_ss.sources() + genh,
6d7c7c2d 2302 dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman])
a81df1b6 2303qemuutil = declare_dependency(link_with: libqemuutil,
04c6f1e7 2304 sources: genh + version_res)
a81df1b6 2305
957b31f6
PMD
2306if have_system or have_user
2307 decodetree = generator(find_program('scripts/decodetree.py'),
2308 output: 'decode-@BASENAME@.c.inc',
2309 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
2310 subdir('libdecnumber')
2311 subdir('target')
2312endif
abff1abf 2313
478e943f 2314subdir('audio')
7fcfd456 2315subdir('io')
848e8ff6 2316subdir('chardev')
ec0d5893 2317subdir('fsdev')
708eab42 2318subdir('dump')
ec0d5893 2319
f285bd3f
PMD
2320if have_block
2321 block_ss.add(files(
2322 'block.c',
2323 'blockjob.c',
2324 'job.c',
2325 'qemu-io-cmds.c',
2326 ))
2327 block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
2328
2329 subdir('nbd')
2330 subdir('scsi')
2331 subdir('block')
2332
2333 blockdev_ss.add(files(
2334 'blockdev.c',
2335 'blockdev-nbd.c',
2336 'iothread.c',
2337 'job-qmp.c',
2338 ), gnutls)
2339
2340 # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
2341 # os-win32.c does not
2342 blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
2343 softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
2344endif
4a96337d
PB
2345
2346common_ss.add(files('cpus-common.c'))
2347
5d3ea0e1 2348subdir('softmmu')
c9322ab5 2349
f343346b 2350common_ss.add(capstone)
d9f24bf5 2351specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
c9322ab5 2352
44b99a6d
RH
2353# Work around a gcc bug/misfeature wherein constant propagation looks
2354# through an alias:
2355# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696
2356# to guess that a const variable is always zero. Without lto, this is
2357# impossible, as the alias is restricted to page-vary-common.c. Indeed,
2358# without lto, not even the alias is required -- we simply use different
2359# declarations in different compilation units.
2360pagevary = files('page-vary-common.c')
2361if get_option('b_lto')
2362 pagevary_flags = ['-fno-lto']
2363 if get_option('cfi')
2364 pagevary_flags += '-fno-sanitize=cfi-icall'
2365 endif
2366 pagevary = static_library('page-vary-common', sources: pagevary,
2367 c_args: pagevary_flags)
2368 pagevary = declare_dependency(link_with: pagevary)
2369endif
2370common_ss.add(pagevary)
6670d4d0
RH
2371specific_ss.add(files('page-vary.c'))
2372
ab318051 2373subdir('backends')
c574e161 2374subdir('disas')
55166230 2375subdir('migration')
ff219dca 2376subdir('monitor')
cdaf0722 2377subdir('net')
17ef2af6 2378subdir('replay')
8df9f0c3 2379subdir('semihosting')
582ea95f 2380subdir('hw')
104cc2c0 2381subdir('tcg')
c6347541 2382subdir('fpu')
1a82878a 2383subdir('accel')
f556b4a1 2384subdir('plugins')
b309c321 2385subdir('bsd-user')
3a30446a 2386subdir('linux-user')
46627f41
AM
2387subdir('ebpf')
2388
b309c321
MAL
2389bsd_user_ss.add(files('gdbstub.c'))
2390specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
2391
3a30446a
MAL
2392linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
2393specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
5d3ea0e1 2394
a2ce7dbd
PB
2395# needed for fuzzing binaries
2396subdir('tests/qtest/libqos')
64ed6f92 2397subdir('tests/qtest/fuzz')
a2ce7dbd 2398
c94a7b88 2399# accel modules
dae0ec15
GH
2400tcg_real_module_ss = ss.source_set()
2401tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss)
2402specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss)
2403target_modules += { 'accel' : { 'qtest': qtest_module_ss,
2404 'tcg': tcg_real_module_ss }}
c94a7b88 2405
a0c9162c
PB
2406########################
2407# Library dependencies #
2408########################
2409
f5723ab6 2410modinfo_collect = find_program('scripts/modinfo-collect.py')
5ebbfecc 2411modinfo_generate = find_program('scripts/modinfo-generate.py')
f5723ab6
GH
2412modinfo_files = []
2413
3154fee4
MAL
2414block_mods = []
2415softmmu_mods = []
2416foreach d, list : modules
2417 foreach m, module_ss : list
2418 if enable_modules and targetos != 'windows'
3e292c51 2419 module_ss = module_ss.apply(config_all, strict: false)
3154fee4
MAL
2420 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
2421 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
2422 if d == 'block'
2423 block_mods += sl
2424 else
2425 softmmu_mods += sl
2426 endif
f5723ab6
GH
2427 if module_ss.sources() != []
2428 # FIXME: Should use sl.extract_all_objects(recursive: true) as
2429 # input. Sources can be used multiple times but objects are
2430 # unique when it comes to lookup in compile_commands.json.
2431 # Depnds on a mesion version with
2432 # https://github.com/mesonbuild/meson/pull/8900
2433 modinfo_files += custom_target(d + '-' + m + '.modinfo',
2434 output: d + '-' + m + '.modinfo',
ac347111 2435 input: module_ss.sources() + genh,
f5723ab6 2436 capture: true,
ac347111 2437 command: [modinfo_collect, module_ss.sources()])
f5723ab6 2438 endif
3154fee4
MAL
2439 else
2440 if d == 'block'
2441 block_ss.add_all(module_ss)
2442 else
2443 softmmu_ss.add_all(module_ss)
2444 endif
2445 endif
2446 endforeach
2447endforeach
2448
db2e89df
GH
2449foreach d, list : target_modules
2450 foreach m, module_ss : list
2451 if enable_modules and targetos != 'windows'
2452 foreach target : target_dirs
2453 if target.endswith('-softmmu')
2454 config_target = config_target_mak[target]
2455 config_target += config_host
2456 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
2457 c_args = ['-DNEED_CPU_H',
2458 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
2459 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
2460 target_module_ss = module_ss.apply(config_target, strict: false)
2461 if target_module_ss.sources() != []
2462 module_name = d + '-' + m + '-' + config_target['TARGET_NAME']
2463 sl = static_library(module_name,
2464 [genh, target_module_ss.sources()],
2465 dependencies: [modulecommon, target_module_ss.dependencies()],
2466 include_directories: target_inc,
2467 c_args: c_args,
2468 pic: true)
2469 softmmu_mods += sl
2470 # FIXME: Should use sl.extract_all_objects(recursive: true) too.
2471 modinfo_files += custom_target(module_name + '.modinfo',
2472 output: module_name + '.modinfo',
917ddc27 2473 input: target_module_ss.sources() + genh,
db2e89df 2474 capture: true,
917ddc27 2475 command: [modinfo_collect, '--target', target, target_module_ss.sources()])
db2e89df
GH
2476 endif
2477 endif
2478 endforeach
2479 else
2480 specific_ss.add_all(module_ss)
2481 endif
2482 endforeach
2483endforeach
2484
5ebbfecc
GH
2485if enable_modules
2486 modinfo_src = custom_target('modinfo.c',
2487 output: 'modinfo.c',
2488 input: modinfo_files,
2489 command: [modinfo_generate, '@INPUT@'],
2490 capture: true)
2491 modinfo_lib = static_library('modinfo', modinfo_src)
2492 modinfo_dep = declare_dependency(link_whole: modinfo_lib)
2493 softmmu_ss.add(modinfo_dep)
2494endif
2495
3154fee4 2496nm = find_program('nm')
604f3e4e 2497undefsym = find_program('scripts/undefsym.py')
3154fee4
MAL
2498block_syms = custom_target('block.syms', output: 'block.syms',
2499 input: [libqemuutil, block_mods],
2500 capture: true,
2501 command: [undefsym, nm, '@INPUT@'])
2502qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
2503 input: [libqemuutil, softmmu_mods],
2504 capture: true,
2505 command: [undefsym, nm, '@INPUT@'])
2506
da33fc09
PMD
2507qom_ss = qom_ss.apply(config_host, strict: false)
2508libqom = static_library('qom', qom_ss.sources() + genh,
2509 dependencies: [qom_ss.dependencies()],
2510 name_suffix: 'fa')
2511
2512qom = declare_dependency(link_whole: libqom)
2513
55567891
PMD
2514authz_ss = authz_ss.apply(config_host, strict: false)
2515libauthz = static_library('authz', authz_ss.sources() + genh,
2516 dependencies: [authz_ss.dependencies()],
2517 name_suffix: 'fa',
2518 build_by_default: false)
2519
2520authz = declare_dependency(link_whole: libauthz,
2521 dependencies: qom)
2522
2389304a
PMD
2523crypto_ss = crypto_ss.apply(config_host, strict: false)
2524libcrypto = static_library('crypto', crypto_ss.sources() + genh,
2525 dependencies: [crypto_ss.dependencies()],
2526 name_suffix: 'fa',
2527 build_by_default: false)
2528
2529crypto = declare_dependency(link_whole: libcrypto,
2530 dependencies: [authz, qom])
2531
f78536b1
PMD
2532io_ss = io_ss.apply(config_host, strict: false)
2533libio = static_library('io', io_ss.sources() + genh,
2534 dependencies: [io_ss.dependencies()],
2535 link_with: libqemuutil,
2536 name_suffix: 'fa',
2537 build_by_default: false)
2538
2539io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
2540
7e6edef3
PMD
2541libmigration = static_library('migration', sources: migration_files + genh,
2542 name_suffix: 'fa',
2543 build_by_default: false)
2544migration = declare_dependency(link_with: libmigration,
2545 dependencies: [zlib, qom, io])
2546softmmu_ss.add(migration)
2547
5e5733e5
MAL
2548block_ss = block_ss.apply(config_host, strict: false)
2549libblock = static_library('block', block_ss.sources() + genh,
2550 dependencies: block_ss.dependencies(),
2551 link_depends: block_syms,
2552 name_suffix: 'fa',
2553 build_by_default: false)
2554
2555block = declare_dependency(link_whole: [libblock],
b7c70bf2
MAL
2556 link_args: '@block.syms',
2557 dependencies: [crypto, io])
5e5733e5 2558
4fb9071f
SH
2559blockdev_ss = blockdev_ss.apply(config_host, strict: false)
2560libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
2561 dependencies: blockdev_ss.dependencies(),
2562 name_suffix: 'fa',
2563 build_by_default: false)
2564
2565blockdev = declare_dependency(link_whole: [libblockdev],
2566 dependencies: [block])
2567
ff219dca
PB
2568qmp_ss = qmp_ss.apply(config_host, strict: false)
2569libqmp = static_library('qmp', qmp_ss.sources() + genh,
2570 dependencies: qmp_ss.dependencies(),
2571 name_suffix: 'fa',
2572 build_by_default: false)
2573
2574qmp = declare_dependency(link_whole: [libqmp])
2575
c2306d71
PMD
2576libchardev = static_library('chardev', chardev_ss.sources() + genh,
2577 name_suffix: 'fa',
3eacf70b 2578 dependencies: [gnutls],
c2306d71
PMD
2579 build_by_default: false)
2580
2581chardev = declare_dependency(link_whole: libchardev)
2582
e28ab096
PMD
2583libhwcore = static_library('hwcore', sources: hwcore_files + genh,
2584 name_suffix: 'fa',
2585 build_by_default: false)
2586hwcore = declare_dependency(link_whole: libhwcore)
2587common_ss.add(hwcore)
2588
064f8ee7
PMD
2589###########
2590# Targets #
2591###########
2592
3154fee4
MAL
2593foreach m : block_mods + softmmu_mods
2594 shared_module(m.name(),
2595 name_prefix: '',
2596 link_whole: m,
2597 install: true,
16bf7a33 2598 install_dir: qemu_moddir)
3154fee4
MAL
2599endforeach
2600
4fb9071f 2601softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp)
64ed6f92
PB
2602common_ss.add(qom, qemuutil)
2603
2604common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
2becc36a
PB
2605common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
2606
2607common_all = common_ss.apply(config_all, strict: false)
2608common_all = static_library('common',
2609 build_by_default: false,
2610 sources: common_all.sources() + genh,
75eebe0b 2611 implicit_include_directories: false,
2becc36a
PB
2612 dependencies: common_all.dependencies(),
2613 name_suffix: 'fa')
2614
c9322ab5
MAL
2615feature_to_c = find_program('scripts/feature_to_c.sh')
2616
fd5eef85 2617emulators = {}
2becc36a
PB
2618foreach target : target_dirs
2619 config_target = config_target_mak[target]
2620 target_name = config_target['TARGET_NAME']
2621 arch = config_target['TARGET_BASE_ARCH']
859aef02 2622 arch_srcs = [config_target_h[target]]
64ed6f92
PB
2623 arch_deps = []
2624 c_args = ['-DNEED_CPU_H',
2625 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
2626 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
b6c7cfd4 2627 link_args = emulator_link_args
2becc36a 2628
859aef02 2629 config_target += config_host
2becc36a
PB
2630 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
2631 if targetos == 'linux'
2632 target_inc += include_directories('linux-headers', is_system: true)
2633 endif
2634 if target.endswith('-softmmu')
2635 qemu_target_name = 'qemu-system-' + target_name
2636 target_type='system'
abff1abf
PB
2637 t = target_softmmu_arch[arch].apply(config_target, strict: false)
2638 arch_srcs += t.sources()
64ed6f92 2639 arch_deps += t.dependencies()
abff1abf 2640
2c44220d
MAL
2641 hw_dir = target_name == 'sparc64' ? 'sparc64' : arch
2642 hw = hw_arch[hw_dir].apply(config_target, strict: false)
2643 arch_srcs += hw.sources()
64ed6f92 2644 arch_deps += hw.dependencies()
2c44220d 2645
2becc36a 2646 arch_srcs += config_devices_h[target]
64ed6f92 2647 link_args += ['@block.syms', '@qemu.syms']
2becc36a 2648 else
3a30446a 2649 abi = config_target['TARGET_ABI_DIR']
2becc36a
PB
2650 target_type='user'
2651 qemu_target_name = 'qemu-' + target_name
46369b50
PMD
2652 if arch in target_user_arch
2653 t = target_user_arch[arch].apply(config_target, strict: false)
2654 arch_srcs += t.sources()
2655 arch_deps += t.dependencies()
2656 endif
2becc36a
PB
2657 if 'CONFIG_LINUX_USER' in config_target
2658 base_dir = 'linux-user'
2659 target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
e2a74729
WL
2660 endif
2661 if 'CONFIG_BSD_USER' in config_target
2becc36a 2662 base_dir = 'bsd-user'
e2a74729
WL
2663 target_inc += include_directories('bsd-user/' / targetos)
2664 dir = base_dir / abi
2665 arch_srcs += files(dir / 'target_arch_cpu.c')
2becc36a
PB
2666 endif
2667 target_inc += include_directories(
2668 base_dir,
3a30446a 2669 base_dir / abi,
2becc36a 2670 )
3a30446a
MAL
2671 if 'CONFIG_LINUX_USER' in config_target
2672 dir = base_dir / abi
2673 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
2674 if config_target.has_key('TARGET_SYSTBL_ABI')
2675 arch_srcs += \
2676 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
2677 extra_args : config_target['TARGET_SYSTBL_ABI'])
2678 endif
2679 endif
2becc36a
PB
2680 endif
2681
c9322ab5
MAL
2682 if 'TARGET_XML_FILES' in config_target
2683 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
2684 output: target + '-gdbstub-xml.c',
2685 input: files(config_target['TARGET_XML_FILES'].split()),
2686 command: [feature_to_c, '@INPUT@'],
2687 capture: true)
2688 arch_srcs += gdbstub_xml
2689 endif
2690
abff1abf
PB
2691 t = target_arch[arch].apply(config_target, strict: false)
2692 arch_srcs += t.sources()
64ed6f92 2693 arch_deps += t.dependencies()
abff1abf 2694
2becc36a
PB
2695 target_common = common_ss.apply(config_target, strict: false)
2696 objects = common_all.extract_objects(target_common.sources())
64ed6f92 2697 deps = target_common.dependencies()
2becc36a 2698
2becc36a
PB
2699 target_specific = specific_ss.apply(config_target, strict: false)
2700 arch_srcs += target_specific.sources()
64ed6f92 2701 arch_deps += target_specific.dependencies()
2becc36a 2702
64ed6f92 2703 lib = static_library('qemu-' + target,
859aef02 2704 sources: arch_srcs + genh,
b7612f45 2705 dependencies: arch_deps,
2becc36a
PB
2706 objects: objects,
2707 include_directories: target_inc,
64ed6f92
PB
2708 c_args: c_args,
2709 build_by_default: false,
2becc36a 2710 name_suffix: 'fa')
64ed6f92
PB
2711
2712 if target.endswith('-softmmu')
2713 execs = [{
2714 'name': 'qemu-system-' + target_name,
654d6b04 2715 'win_subsystem': 'console',
64ed6f92
PB
2716 'sources': files('softmmu/main.c'),
2717 'dependencies': []
2718 }]
35be72ba 2719 if targetos == 'windows' and (sdl.found() or gtk.found())
64ed6f92
PB
2720 execs += [{
2721 'name': 'qemu-system-' + target_name + 'w',
654d6b04 2722 'win_subsystem': 'windows',
64ed6f92
PB
2723 'sources': files('softmmu/main.c'),
2724 'dependencies': []
2725 }]
2726 endif
2727 if config_host.has_key('CONFIG_FUZZ')
2728 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
2729 execs += [{
2730 'name': 'qemu-fuzz-' + target_name,
654d6b04 2731 'win_subsystem': 'console',
64ed6f92
PB
2732 'sources': specific_fuzz.sources(),
2733 'dependencies': specific_fuzz.dependencies(),
64ed6f92
PB
2734 }]
2735 endif
2736 else
2737 execs = [{
2738 'name': 'qemu-' + target_name,
654d6b04 2739 'win_subsystem': 'console',
64ed6f92
PB
2740 'sources': [],
2741 'dependencies': []
2742 }]
2743 endif
2744 foreach exe: execs
8a74ce61 2745 exe_name = exe['name']
3983a767 2746 if targetos == 'darwin'
8a74ce61
AG
2747 exe_name += '-unsigned'
2748 endif
2749
2750 emulator = executable(exe_name, exe['sources'],
237377ac 2751 install: true,
64ed6f92
PB
2752 c_args: c_args,
2753 dependencies: arch_deps + deps + exe['dependencies'],
2754 objects: lib.extract_all_objects(recursive: true),
2755 link_language: link_language,
2756 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
2757 link_args: link_args,
654d6b04 2758 win_subsystem: exe['win_subsystem'])
8a74ce61 2759
3983a767 2760 if targetos == 'darwin'
411ad8dd
AO
2761 icon = 'pc-bios/qemu.rsrc'
2762 build_input = [emulator, files(icon)]
2763 install_input = [
2764 get_option('bindir') / exe_name,
2765 meson.current_source_dir() / icon
2766 ]
2767 if 'CONFIG_HVF' in config_target
2768 entitlements = 'accel/hvf/entitlements.plist'
2769 build_input += files(entitlements)
2770 install_input += meson.current_source_dir() / entitlements
2771 endif
2772
8a74ce61 2773 emulators += {exe['name'] : custom_target(exe['name'],
411ad8dd 2774 input: build_input,
8a74ce61
AG
2775 output: exe['name'],
2776 command: [
411ad8dd
AO
2777 files('scripts/entitlement.sh'),
2778 '@OUTPUT@',
2779 '@INPUT@'
8a74ce61
AG
2780 ])
2781 }
237377ac
AO
2782
2783 meson.add_install_script('scripts/entitlement.sh', '--install',
237377ac 2784 get_option('bindir') / exe['name'],
411ad8dd 2785 install_input)
8a74ce61
AG
2786 else
2787 emulators += {exe['name']: emulator}
2788 endif
10e1d263
MAL
2789
2790 if 'CONFIG_TRACE_SYSTEMTAP' in config_host
2791 foreach stp: [
bd5f973a
SH
2792 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
2793 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
10e1d263
MAL
2794 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
2795 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
2796 ]
bd5f973a 2797 custom_target(exe['name'] + stp['ext'],
10e1d263 2798 input: trace_events_all,
bd5f973a 2799 output: exe['name'] + stp['ext'],
10e1d263 2800 install: stp['install'],
16bf7a33 2801 install_dir: get_option('datadir') / 'systemtap/tapset',
10e1d263
MAL
2802 command: [
2803 tracetool, '--group=all', '--format=' + stp['fmt'],
2804 '--binary=' + stp['bin'],
2805 '--target-name=' + target_name,
2806 '--target-type=' + target_type,
2807 '--probe-prefix=qemu.' + target_type + '.' + target_name,
c05012a3 2808 '@INPUT@', '@OUTPUT@'
0572d6cd
SH
2809 ],
2810 depend_files: tracetool_depends)
10e1d263
MAL
2811 endforeach
2812 endif
64ed6f92 2813 endforeach
2becc36a
PB
2814endforeach
2815
931049b4 2816# Other build targets
897b5afa 2817
f556b4a1
PB
2818if 'CONFIG_PLUGIN' in config_host
2819 install_headers('include/qemu/qemu-plugin.h')
2820endif
2821
f15bff25
PB
2822if 'CONFIG_GUEST_AGENT' in config_host
2823 subdir('qga')
b846ab7c
PB
2824elif get_option('guest_agent_msi').enabled()
2825 error('Guest agent MSI requested, but the guest agent is not being built')
f15bff25
PB
2826endif
2827
9755c94a
LV
2828# Don't build qemu-keymap if xkbcommon is not explicitly enabled
2829# when we don't build tools or system
4113f4cf 2830if xkbcommon.found()
28742467
MAL
2831 # used for the update-keymaps target, so include rules even if !have_tools
2832 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
2833 dependencies: [qemuutil, xkbcommon], install: have_tools)
2834endif
2835
931049b4 2836if have_tools
b7c70bf2
MAL
2837 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
2838 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
2839 qemu_io = executable('qemu-io', files('qemu-io.c'),
2840 dependencies: [block, qemuutil], install: true)
eb705985 2841 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
3eacf70b 2842 dependencies: [blockdev, qemuutil, gnutls], install: true)
b7c70bf2 2843
7c58bb76 2844 subdir('storage-daemon')
a9c9727c 2845 subdir('contrib/rdmacm-mux')
1d7bb6ab 2846 subdir('contrib/elf2dmp')
a9c9727c 2847
157e7b13
MAL
2848 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
2849 dependencies: qemuutil,
2850 install: true)
2851
931049b4 2852 if 'CONFIG_VHOST_USER' in config_host
2d7ac0af 2853 subdir('contrib/vhost-user-blk')
b7612f45 2854 subdir('contrib/vhost-user-gpu')
32fcc624 2855 subdir('contrib/vhost-user-input')
99650b62 2856 subdir('contrib/vhost-user-scsi')
931049b4 2857 endif
8f51e01c
MAL
2858
2859 if targetos == 'linux'
2860 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
2861 dependencies: [qemuutil, libcap_ng],
2862 install: true,
2863 install_dir: get_option('libexecdir'))
897b5afa
MAL
2864
2865 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
2866 dependencies: [authz, crypto, io, qom, qemuutil,
6ec0e15d 2867 libcap_ng, mpathpersist],
897b5afa 2868 install: true)
8f51e01c
MAL
2869 endif
2870
ccd250aa 2871 if have_ivshmem
5ee24e78
MAL
2872 subdir('contrib/ivshmem-client')
2873 subdir('contrib/ivshmem-server')
2874 endif
931049b4
PB
2875endif
2876
f5aa6320 2877subdir('scripts')
3f99cf57 2878subdir('tools')
bdcbea7a 2879subdir('pc-bios')
f8aa24ea 2880subdir('docs')
e3667660 2881subdir('tests')
1b695471 2882if gtk.found()
e8f3bd71
MAL
2883 subdir('po')
2884endif
3f99cf57 2885
8adfeba9
MAL
2886if host_machine.system() == 'windows'
2887 nsis_cmd = [
2888 find_program('scripts/nsis.py'),
2889 '@OUTPUT@',
2890 get_option('prefix'),
2891 meson.current_source_dir(),
24bdcc96 2892 host_machine.cpu(),
8adfeba9
MAL
2893 '--',
2894 '-DDISPLAYVERSION=' + meson.project_version(),
2895 ]
2896 if build_docs
2897 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
2898 endif
1b695471 2899 if gtk.found()
8adfeba9
MAL
2900 nsis_cmd += '-DCONFIG_GTK=y'
2901 endif
2902
2903 nsis = custom_target('nsis',
2904 output: 'qemu-setup-' + meson.project_version() + '.exe',
2905 input: files('qemu.nsi'),
2906 build_always_stale: true,
2907 command: nsis_cmd + ['@INPUT@'])
2908 alias_target('installer', nsis)
2909endif
2910
a0c9162c
PB
2911#########################
2912# Configuration summary #
2913#########################
2914
983d0a75 2915# Directories
f9332757 2916summary_info = {}
16bf7a33
PB
2917summary_info += {'Install prefix': get_option('prefix')}
2918summary_info += {'BIOS directory': qemu_datadir}
2919summary_info += {'firmware path': get_option('qemu_firmwarepath')}
2920summary_info += {'binary directory': get_option('bindir')}
2921summary_info += {'library directory': get_option('libdir')}
2922summary_info += {'module directory': qemu_moddir}
2923summary_info += {'libexec directory': get_option('libexecdir')}
2924summary_info += {'include directory': get_option('includedir')}
2925summary_info += {'config directory': get_option('sysconfdir')}
f9332757 2926if targetos != 'windows'
16bf7a33 2927 summary_info += {'local state directory': get_option('localstatedir')}
b81efab7 2928 summary_info += {'Manual directory': get_option('mandir')}
f9332757
PB
2929else
2930 summary_info += {'local state directory': 'queried at runtime'}
2931endif
491e74c1 2932summary_info += {'Doc directory': get_option('docdir')}
f9332757
PB
2933summary_info += {'Build directory': meson.current_build_dir()}
2934summary_info += {'Source path': meson.current_source_dir()}
f9332757 2935summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
983d0a75
PMD
2936summary(summary_info, bool_yn: true, section: 'Directories')
2937
e11a0e17
PMD
2938# Host binaries
2939summary_info = {}
2940summary_info += {'git': config_host['GIT']}
2941summary_info += {'make': config_host['MAKE']}
2942summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
bb647c49 2943summary_info += {'sphinx-build': sphinx_build}
e11a0e17
PMD
2944if config_host.has_key('HAVE_GDB_BIN')
2945 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
2946endif
2947summary_info += {'genisoimage': config_host['GENISOIMAGE']}
2948if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
bb647c49 2949 summary_info += {'wixl': wixl}
e11a0e17 2950endif
b8e0c493 2951if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
e11a0e17
PMD
2952 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
2953endif
2954summary(summary_info, bool_yn: true, section: 'Host binaries')
2955
1d718865
PMD
2956# Configurable features
2957summary_info = {}
2958summary_info += {'Documentation': build_docs}
aa3ca634
PMD
2959summary_info += {'system-mode emulation': have_system}
2960summary_info += {'user-mode emulation': have_user}
813803aa 2961summary_info += {'block layer': have_block}
1d718865
PMD
2962summary_info += {'Install blobs': get_option('install_blobs')}
2963summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
2964if config_host.has_key('CONFIG_MODULES')
2965 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
2966endif
1d718865
PMD
2967summary_info += {'fuzzing support': config_host.has_key('CONFIG_FUZZ')}
2968if have_system
87430d5b 2969 summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)}
1d718865
PMD
2970endif
2971summary_info += {'Trace backends': config_host['TRACE_BACKENDS']}
2972if config_host['TRACE_BACKENDS'].split().contains('simple')
2973 summary_info += {'Trace output file': config_host['CONFIG_TRACE_FILE'] + '-<pid>'}
2974endif
2975summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
2976summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
2977summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
2978summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
2979summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
2980summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
2981summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
2982summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
2983summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
2984summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
2985summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
2986summary(summary_info, bool_yn: true, section: 'Configurable features')
2987
2e864b8b 2988# Compilation information
983d0a75 2989summary_info = {}
2e864b8b
PMD
2990summary_info += {'host CPU': cpu}
2991summary_info += {'host endianness': build_machine.endian()}
63de9353
AB
2992summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())}
2993summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())}
f9332757 2994if link_language == 'cpp'
63de9353 2995 summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())}
f9332757
PB
2996else
2997 summary_info += {'C++ compiler': false}
2998endif
2999if targetos == 'darwin'
63de9353 3000 summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
f9332757 3001endif
2e864b8b
PMD
3002if targetos == 'windows'
3003 if 'WIN_SDK' in config_host
3004 summary_info += {'Windows SDK': config_host['WIN_SDK']}
3005 endif
3006endif
47b30835
PB
3007summary_info += {'CFLAGS': ' '.join(get_option('c_args')
3008 + ['-O' + get_option('optimization')]
3009 + (get_option('debug') ? ['-g'] : []))}
3010if link_language == 'cpp'
3011 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
3012 + ['-O' + get_option('optimization')]
3013 + (get_option('debug') ? ['-g'] : []))}
3014endif
3015link_args = get_option(link_language + '_link_args')
3016if link_args.length() > 0
3017 summary_info += {'LDFLAGS': ' '.join(link_args)}
3018endif
f9332757
PB
3019summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
3020summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
f9332757 3021summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
cdad781d 3022summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
2e864b8b 3023summary_info += {'PIE': get_option('b_pie')}
3e8529dd 3024summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
2e864b8b
PMD
3025summary_info += {'malloc trim support': has_malloc_trim}
3026summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
2e864b8b
PMD
3027summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
3028summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
3029summary_info += {'memory allocator': get_option('malloc')}
3030summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
3031summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
3032summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
3033summary_info += {'gcov': get_option('b_coverage')}
3034summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
3035summary_info += {'CFI support': get_option('cfi')}
3036if get_option('cfi')
3037 summary_info += {'CFI debug support': get_option('cfi_debug')}
3038endif
3039summary_info += {'strip binaries': get_option('strip')}
bb647c49 3040summary_info += {'sparse': sparse}
2e864b8b 3041summary_info += {'mingw32 support': targetos == 'windows'}
49e8565b
AB
3042
3043# snarf the cross-compilation information for tests
3044foreach target: target_dirs
3045 tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak'
3046 if fs.exists(tcg_mak)
3047 config_cross_tcg = keyval.load(tcg_mak)
3048 target = config_cross_tcg['TARGET_NAME']
3049 compiler = ''
3050 if 'DOCKER_CROSS_CC_GUEST' in config_cross_tcg
3051 summary_info += {target + ' tests': config_cross_tcg['DOCKER_CROSS_CC_GUEST'] +
3052 ' via ' + config_cross_tcg['DOCKER_IMAGE']}
3053 elif 'CROSS_CC_GUEST' in config_cross_tcg
3054 summary_info += {target + ' tests'
3055 : config_cross_tcg['CROSS_CC_GUEST'] }
3056 endif
3057 endif
3058endforeach
3059
2e864b8b
PMD
3060summary(summary_info, bool_yn: true, section: 'Compilation')
3061
aa3ca634 3062# Targets and accelerators
2e864b8b 3063summary_info = {}
aa3ca634
PMD
3064if have_system
3065 summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
3066 summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
3067 summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
3068 summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
74a414a1 3069 summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
aa3ca634
PMD
3070 summary_info += {'Xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
3071 if config_host.has_key('CONFIG_XEN_BACKEND')
3072 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
3073 endif
3074endif
3075summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
3076if config_all.has_key('CONFIG_TCG')
39687aca
PMD
3077 if get_option('tcg_interpreter')
3078 summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, experimental and slow)'}
3079 else
3080 summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
3081 endif
029aa68f 3082 summary_info += {'TCG plugins': config_host.has_key('CONFIG_PLUGIN')}
aa3ca634 3083 summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
aa3ca634 3084endif
2e864b8b 3085summary_info += {'target list': ' '.join(target_dirs)}
aa3ca634
PMD
3086if have_system
3087 summary_info += {'default devices': get_option('default_devices')}
106ad1f9 3088 summary_info += {'out of process emulation': multiprocess_allowed}
aa3ca634
PMD
3089endif
3090summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
3091
813803aa
PMD
3092# Block layer
3093summary_info = {}
3094summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
3095summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
3096if have_block
3097 summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
3098 summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
e5f05f8c 3099 summary_info += {'Use block whitelist in tools': config_host.has_key('CONFIG_BDRV_WHITELIST_TOOLS')}
813803aa
PMD
3100 summary_info += {'VirtFS support': have_virtfs}
3101 summary_info += {'build virtiofs daemon': have_virtiofsd}
3102 summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
3103 summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
3104 summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
3105 summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
3106 summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
3107 summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
3108 summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
3109 summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
3110 summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
3111 summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
bb647c49 3112 summary_info += {'FUSE exports': fuse}
813803aa
PMD
3113endif
3114summary(summary_info, bool_yn: true, section: 'Block layer support')
3115
aa58028a 3116# Crypto
aa3ca634 3117summary_info = {}
f9332757 3118summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
bb647c49
PB
3119summary_info += {'GNUTLS support': gnutls}
3120if gnutls.found()
3121 summary_info += {' GNUTLS crypto': gnutls_crypto.found()}
3122endif
3123summary_info += {'libgcrypt': gcrypt}
3124summary_info += {'nettle': nettle}
57612511
PB
3125if nettle.found()
3126 summary_info += {' XTS': xts != 'private'}
f9332757 3127endif
aa58028a
PMD
3128summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
3129summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
3130summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
3131summary(summary_info, bool_yn: true, section: 'Crypto')
3132
69a78cce 3133# Libraries
aa58028a
PMD
3134summary_info = {}
3135if targetos == 'darwin'
bb647c49
PB
3136 summary_info += {'Cocoa support': cocoa}
3137endif
3138summary_info += {'SDL support': sdl}
3139summary_info += {'SDL image support': sdl_image}
3140summary_info += {'GTK support': gtk}
3141summary_info += {'pixman': pixman}
3142summary_info += {'VTE support': vte}
3143summary_info += {'slirp support': slirp_opt == 'internal' ? slirp_opt : slirp}
3144summary_info += {'libtasn1': tasn1}
3145summary_info += {'PAM': pam}
3146summary_info += {'iconv support': iconv}
3147summary_info += {'curses support': curses}
3148summary_info += {'virgl support': virgl}
3149summary_info += {'curl support': curl}
3150summary_info += {'Multipath support': mpathpersist}
3151summary_info += {'VNC support': vnc}
a0b93237 3152if vnc.found()
bb647c49
PB
3153 summary_info += {'VNC SASL support': sasl}
3154 summary_info += {'VNC JPEG support': jpeg}
3155 summary_info += {'VNC PNG support': png}
f9332757 3156endif
87430d5b
PB
3157if targetos not in ['darwin', 'haiku', 'windows']
3158 summary_info += {'OSS support': oss}
3159elif targetos == 'darwin'
3160 summary_info += {'CoreAudio support': coreaudio}
3161elif targetos == 'windows'
3162 summary_info += {'DirectSound support': dsound}
3163endif
3164if targetos == 'linux'
3165 summary_info += {'ALSA support': alsa}
3166 summary_info += {'PulseAudio support': pulse}
3167endif
3168summary_info += {'JACK support': jack}
bb647c49 3169summary_info += {'brlapi support': brlapi}
f9332757
PB
3170summary_info += {'vde support': config_host.has_key('CONFIG_VDE')}
3171summary_info += {'netmap support': config_host.has_key('CONFIG_NETMAP')}
3172summary_info += {'Linux AIO support': config_host.has_key('CONFIG_LINUX_AIO')}
bb647c49
PB
3173summary_info += {'Linux io_uring support': linux_io_uring}
3174summary_info += {'ATTR/XATTR support': libattr}
f9332757
PB
3175summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
3176summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
fbb4121d 3177summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
bb647c49
PB
3178summary_info += {'libcap-ng support': libcap_ng}
3179summary_info += {'bpf support': libbpf}
f9332757
PB
3180# TODO: add back protocol and server version
3181summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
bb647c49 3182summary_info += {'rbd support': rbd}
f9332757 3183summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
bb647c49
PB
3184summary_info += {'smartcard support': cacard}
3185summary_info += {'U2F support': u2f}
3186summary_info += {'libusb': libusb}
3187summary_info += {'usb net redir': usbredir}
f9332757 3188summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
bb647c49
PB
3189summary_info += {'GBM': gbm}
3190summary_info += {'libiscsi support': libiscsi}
3191summary_info += {'libnfs support': libnfs}
f9332757 3192if targetos == 'windows'
b846ab7c
PB
3193 if config_host.has_key('CONFIG_GUEST_AGENT')
3194 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
3195 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
b846ab7c 3196 endif
f9332757 3197endif
bb647c49
PB
3198summary_info += {'seccomp support': seccomp}
3199summary_info += {'GlusterFS support': glusterfs}
f9332757
PB
3200summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
3201summary_info += {'libssh support': config_host.has_key('CONFIG_LIBSSH')}
bb647c49
PB
3202summary_info += {'lzo support': lzo}
3203summary_info += {'snappy support': snappy}
3204summary_info += {'bzip2 support': libbzip2}
3205summary_info += {'lzfse support': liblzfse}
3206summary_info += {'zstd support': zstd}
f9332757 3207summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
bb647c49
PB
3208summary_info += {'libxml2': libxml2}
3209summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
3210summary_info += {'libpmem support': libpmem}
3211summary_info += {'libdaxctl support': libdaxctl}
3212summary_info += {'libudev': libudev}
3213# Dummy dependency, keep .found()
df4ea709 3214summary_info += {'FUSE lseek': fuse_lseek.found()}
69a78cce 3215summary(summary_info, bool_yn: true, section: 'Dependencies')
f9332757
PB
3216
3217if not supported_cpus.contains(cpu)
3218 message()
3219 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
3220 message()
3221 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
3222 message('The QEMU project intends to remove support for this host CPU in')
3223 message('a future release if nobody volunteers to maintain it and to')
3224 message('provide a build host for our continuous integration setup.')
3225 message('configure has succeeded and you can continue to build, but')
3226 message('if you care about QEMU on this platform you should contact')
3227 message('us upstream at qemu-devel@nongnu.org.')
3228endif
3229
3230if not supported_oses.contains(targetos)
3231 message()
3232 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
3233 message()
3234 message('Host OS ' + targetos + 'support is not currently maintained.')
3235 message('The QEMU project intends to remove support for this host OS in')
3236 message('a future release if nobody volunteers to maintain it and to')
3237 message('provide a build host for our continuous integration setup.')
3238 message('configure has succeeded and you can continue to build, but')
3239 message('if you care about QEMU on this platform you should contact')
3240 message('us upstream at qemu-devel@nongnu.org.')
3241endif