1 project('qemu', ['c'], meson_version: '>=0.55.0',
2 default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11',
4 version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
6 not_found = dependency('', required: false)
7 if meson.version().version_compare('>=0.56.0')
8 keyval = import('keyval')
10 keyval = import('unstable-keyval')
12 ss = import('sourceset')
15 sh = find_program('sh')
16 cc = meson.get_compiler('c')
17 config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
18 enable_modules = 'CONFIG_MODULES' in config_host
19 enable_static = 'CONFIG_STATIC' in config_host
20 build_docs = 'BUILD_DOCS' in config_host
22 if get_option('qemu_suffix').startswith('/')
23 error('qemu_suffix cannot start with a /')
26 qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
27 qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
28 config_host_data = configuration_data()
31 target_dirs = config_host['TARGET_DIRS'].split()
34 foreach target : target_dirs
35 have_user = have_user or target.endswith('-user')
36 have_system = have_system or target.endswith('-softmmu')
38 have_tools = 'CONFIG_TOOLS' in config_host
39 have_block = have_system or have_tools
41 python = import('python').find_installation()
43 supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
44 supported_cpus = ['ppc', 'ppc64', 's390x', 'sparc64', 'riscv32', 'riscv64', 'x86', 'x86_64',
45 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
47 cpu = host_machine.cpu_family()
48 targetos = host_machine.system()
50 configure_file(input: files('scripts/ninjatool.py'),
52 configuration: config_host)
54 if cpu in ['x86', 'x86_64']
55 kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
57 kvm_targets = ['aarch64-softmmu']
59 kvm_targets = ['s390x-softmmu']
60 elif cpu in ['ppc', 'ppc64']
61 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
66 accelerator_targets = { 'CONFIG_KVM': kvm_targets }
67 if cpu in ['x86', 'x86_64']
68 accelerator_targets += {
69 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
70 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
71 'CONFIG_HVF': ['x86_64-softmmu'],
72 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
80 # Specify linker-script with add_project_link_arguments so that it is not placed
81 # within a linker --start-group/--end-group pair
82 if 'CONFIG_FUZZ' in config_host
83 add_project_link_arguments(['-Wl,-T,',
84 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
85 native: false, language: ['c', 'cpp', 'objc'])
88 add_project_arguments(config_host['QEMU_CFLAGS'].split(),
89 native: false, language: ['c', 'objc'])
90 add_project_arguments(config_host['QEMU_CXXFLAGS'].split(),
91 native: false, language: 'cpp')
92 add_project_link_arguments(config_host['QEMU_LDFLAGS'].split(),
93 native: false, language: ['c', 'cpp', 'objc'])
94 add_project_arguments(config_host['QEMU_INCLUDES'].split(),
95 language: ['c', 'cpp', 'objc'])
98 link_language = meson.get_external_property('link_language', 'cpp')
99 if link_language == 'cpp'
100 add_languages('cpp', required: true, native: false)
102 if host_machine.system() == 'darwin'
103 add_languages('objc', required: false, native: false)
106 sparse = find_program('cgcc', required: get_option('sparse'))
109 command: [find_program('scripts/check_sparse.py'),
110 'compile_commands.json', sparse.full_path(), '-Wbitwise',
111 '-Wno-transparent-union', '-Wno-old-initializer',
112 '-Wno-non-pointer-null'])
115 ###########################################
116 # Target-specific checks and dependencies #
117 ###########################################
119 if targetos != 'linux' and get_option('mpath').enabled()
120 error('Multipath is supported only on Linux')
123 m = cc.find_library('m', required: false)
124 util = cc.find_library('util', required: false)
130 emulator_link_args = []
133 if targetos == 'windows'
134 socket = cc.find_library('ws2_32')
135 winmm = cc.find_library('winmm')
137 win = import('windows')
138 version_res = win.compile_resources('version.rc',
139 depend_files: files('pc-bios/qemu-nsis.ico'),
140 include_directories: include_directories('.'))
141 elif targetos == 'darwin'
142 coref = dependency('appleframeworks', modules: 'CoreFoundation')
143 iokit = dependency('appleframeworks', modules: 'IOKit')
144 cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
145 elif targetos == 'sunos'
146 socket = [cc.find_library('socket'),
147 cc.find_library('nsl'),
148 cc.find_library('resolv')]
149 elif targetos == 'haiku'
150 socket = [cc.find_library('posix_error_mapper'),
151 cc.find_library('network'),
152 cc.find_library('bsd')]
153 elif targetos == 'openbsd'
154 if not get_option('tcg').disabled() and target_dirs.length() > 0
155 # Disable OpenBSD W^X if available
156 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
161 if not get_option('kvm').disabled() and targetos == 'linux'
162 accelerators += 'CONFIG_KVM'
164 if not get_option('xen').disabled() and 'CONFIG_XEN_BACKEND' in config_host
165 accelerators += 'CONFIG_XEN'
166 have_xen_pci_passthrough = not get_option('xen_pci_passthrough').disabled() and targetos == 'linux'
168 have_xen_pci_passthrough = false
170 if not get_option('whpx').disabled() and targetos == 'windows'
171 if get_option('whpx').enabled() and cpu != 'x86_64'
172 error('WHPX requires 64-bit host')
173 elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
174 cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
175 accelerators += 'CONFIG_WHPX'
178 if not get_option('hvf').disabled()
179 hvf = dependency('appleframeworks', modules: 'Hypervisor',
180 required: get_option('hvf'))
182 accelerators += 'CONFIG_HVF'
185 if not get_option('hax').disabled()
186 if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
187 accelerators += 'CONFIG_HAX'
190 if not get_option('tcg').disabled()
191 if cpu not in supported_cpus
192 if 'CONFIG_TCG_INTERPRETER' in config_host
193 warning('Unsupported CPU @0@, will use TCG with TCI (experimental)'.format(cpu))
195 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
198 accelerators += 'CONFIG_TCG'
199 config_host += { 'CONFIG_TCG': 'y' }
202 if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
203 error('KVM not available on this platform')
205 if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
206 error('HVF not available on this platform')
208 if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
209 error('WHPX not available on this platform')
211 if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
212 if 'CONFIG_XEN' in accelerators
213 error('Xen PCI passthrough not available on this platform')
215 error('Xen PCI passthrough requested but Xen not enabled')
218 if not cocoa.found() and get_option('cocoa').enabled()
219 error('Cocoa not available on this platform')
226 # The path to glib.h is added to all compilation commands. This was
227 # grandfathered in from the QEMU Makefiles.
228 add_project_arguments(config_host['GLIB_CFLAGS'].split(),
229 native: false, language: ['c', 'cpp', 'objc'])
230 glib = declare_dependency(link_args: config_host['GLIB_LIBS'].split())
232 if 'CONFIG_GIO' in config_host
233 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
234 link_args: config_host['GIO_LIBS'].split())
237 if 'CONFIG_TRACE_UST' in config_host
238 lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
241 if 'CONFIG_TRACE_UST' in config_host
242 urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split())
245 if 'CONFIG_GCRYPT' in config_host
246 gcrypt = declare_dependency(compile_args: config_host['GCRYPT_CFLAGS'].split(),
247 link_args: config_host['GCRYPT_LIBS'].split())
250 if 'CONFIG_NETTLE' in config_host
251 nettle = declare_dependency(compile_args: config_host['NETTLE_CFLAGS'].split(),
252 link_args: config_host['NETTLE_LIBS'].split())
255 if 'CONFIG_GNUTLS' in config_host
256 gnutls = declare_dependency(compile_args: config_host['GNUTLS_CFLAGS'].split(),
257 link_args: config_host['GNUTLS_LIBS'].split())
260 if have_system or have_tools
261 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
262 method: 'pkg-config', static: enable_static)
265 if 'CONFIG_AUTH_PAM' in config_host
266 pam = cc.find_library('pam')
268 libaio = cc.find_library('aio', required: false)
269 zlib = dependency('zlib', required: true, static: enable_static)
270 linux_io_uring = not_found
271 if 'CONFIG_LINUX_IO_URING' in config_host
272 linux_io_uring = declare_dependency(compile_args: config_host['LINUX_IO_URING_CFLAGS'].split(),
273 link_args: config_host['LINUX_IO_URING_LIBS'].split())
276 if 'CONFIG_LIBXML2' in config_host
277 libxml2 = declare_dependency(compile_args: config_host['LIBXML2_CFLAGS'].split(),
278 link_args: config_host['LIBXML2_LIBS'].split())
281 if 'CONFIG_LIBNFS' in config_host
282 libnfs = declare_dependency(link_args: config_host['LIBNFS_LIBS'].split())
285 if 'CONFIG_ATTR' in config_host
286 libattr = declare_dependency(link_args: config_host['LIBATTR_LIBS'].split())
289 if 'CONFIG_SECCOMP' in config_host
290 seccomp = declare_dependency(compile_args: config_host['SECCOMP_CFLAGS'].split(),
291 link_args: config_host['SECCOMP_LIBS'].split())
293 libcap_ng = not_found
294 if 'CONFIG_LIBCAP_NG' in config_host
295 libcap_ng = declare_dependency(link_args: config_host['LIBCAP_NG_LIBS'].split())
297 if get_option('xkbcommon').auto() and not have_system and not have_tools
298 xkbcommon = not_found
300 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
301 method: 'pkg-config', static: enable_static)
304 if config_host.has_key('CONFIG_SLIRP')
305 slirp = declare_dependency(compile_args: config_host['SLIRP_CFLAGS'].split(),
306 link_args: config_host['SLIRP_LIBS'].split())
309 if config_host.has_key('CONFIG_VDE')
310 vde = declare_dependency(link_args: config_host['VDE_LIBS'].split())
313 if 'CONFIG_LIBPULSE' in config_host
314 pulse = declare_dependency(compile_args: config_host['PULSE_CFLAGS'].split(),
315 link_args: config_host['PULSE_LIBS'].split())
318 if 'CONFIG_ALSA' in config_host
319 alsa = declare_dependency(compile_args: config_host['ALSA_CFLAGS'].split(),
320 link_args: config_host['ALSA_LIBS'].split())
323 if 'CONFIG_LIBJACK' in config_host
324 jack = declare_dependency(link_args: config_host['JACK_LIBS'].split())
327 if 'CONFIG_SPICE' in config_host
328 spice = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split(),
329 link_args: config_host['SPICE_LIBS'].split())
331 rt = cc.find_library('rt', required: false)
333 if 'CONFIG_PLUGIN' in config_host
334 libdl = cc.find_library('dl', required: true)
337 if 'CONFIG_LIBISCSI' in config_host
338 libiscsi = declare_dependency(compile_args: config_host['LIBISCSI_CFLAGS'].split(),
339 link_args: config_host['LIBISCSI_LIBS'].split())
342 if 'CONFIG_ZSTD' in config_host
343 zstd = declare_dependency(compile_args: config_host['ZSTD_CFLAGS'].split(),
344 link_args: config_host['ZSTD_LIBS'].split())
347 if 'CONFIG_GBM' in config_host
348 gbm = declare_dependency(compile_args: config_host['GBM_CFLAGS'].split(),
349 link_args: config_host['GBM_LIBS'].split())
352 if 'CONFIG_VIRGL' in config_host
353 virgl = declare_dependency(compile_args: config_host['VIRGL_CFLAGS'].split(),
354 link_args: config_host['VIRGL_LIBS'].split())
357 if 'CONFIG_CURL' in config_host
358 curl = declare_dependency(compile_args: config_host['CURL_CFLAGS'].split(),
359 link_args: config_host['CURL_LIBS'].split())
362 if targetos == 'linux' and (have_system or have_tools)
363 libudev = dependency('libudev',
364 required: get_option('mpath').enabled(),
365 static: enable_static)
368 mpathpersist = not_found
369 mpathpersist_new_api = false
370 if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
371 mpath_test_source_new = '''
373 #include <mpath_persist.h>
374 unsigned mpath_mx_alloc_len = 1024;
376 static struct config *multipath_conf;
377 extern struct udev *udev;
378 extern struct config *get_multipath_config(void);
379 extern void put_multipath_config(struct config *conf);
381 struct config *get_multipath_config(void) { return multipath_conf; }
382 void put_multipath_config(struct config *conf) { }
385 multipath_conf = mpath_lib_init();
388 mpath_test_source_old = '''
390 #include <mpath_persist.h>
391 unsigned mpath_mx_alloc_len = 1024;
394 struct udev *udev = udev_new();
395 mpath_lib_init(udev);
398 mpathlibs = [libudev]
400 mpathlibs += cc.find_library('devmapper',
401 required: get_option('mpath'),
402 static: enable_static)
404 mpathlibs += cc.find_library('multipath',
405 required: get_option('mpath'),
406 static: enable_static)
407 mpathlibs += cc.find_library('mpathpersist',
408 required: get_option('mpath'),
409 static: enable_static)
410 foreach lib: mpathlibs
416 if mpathlibs.length() > 0
417 if cc.links(mpath_test_source_new, dependencies: mpathlibs)
418 mpathpersist = declare_dependency(dependencies: mpathlibs)
419 mpathpersist_new_api = true
420 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
421 mpathpersist = declare_dependency(dependencies: mpathlibs)
423 if get_option('mpath').enabled()
424 error('Cannot detect libmpathpersist API')
426 warning('Cannot detect libmpathpersist API, disabling')
433 if 'CONFIG_BRLAPI' in config_host
434 brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
439 sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static)
440 sdl_image = not_found
443 # work around 2.0.8 bug
444 sdl = declare_dependency(compile_args: '-Wno-undef',
446 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
447 method: 'pkg-config', static: enable_static)
449 if get_option('sdl_image').enabled()
450 error('sdl-image required, but SDL was @0@'.format(
451 get_option('sdl').disabled() ? 'disabled' : 'not found'))
453 sdl_image = not_found
457 if 'CONFIG_RBD' in config_host
458 rbd = declare_dependency(link_args: config_host['RBD_LIBS'].split())
460 glusterfs = not_found
461 if 'CONFIG_GLUSTERFS' in config_host
462 glusterfs = declare_dependency(compile_args: config_host['GLUSTERFS_CFLAGS'].split(),
463 link_args: config_host['GLUSTERFS_LIBS'].split())
466 if 'CONFIG_LIBSSH' in config_host
467 libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
468 link_args: config_host['LIBSSH_LIBS'].split())
471 if 'CONFIG_BZIP2' in config_host
472 libbzip2 = declare_dependency(link_args: config_host['BZIP2_LIBS'].split())
475 if 'CONFIG_LZFSE' in config_host
476 liblzfse = declare_dependency(link_args: config_host['LZFSE_LIBS'].split())
479 if 'CONFIG_AUDIO_OSS' in config_host
480 oss = declare_dependency(link_args: config_host['OSS_LIBS'].split())
483 if 'CONFIG_AUDIO_DSOUND' in config_host
484 dsound = declare_dependency(link_args: config_host['DSOUND_LIBS'].split())
486 coreaudio = not_found
487 if 'CONFIG_AUDIO_COREAUDIO' in config_host
488 coreaudio = declare_dependency(link_args: config_host['COREAUDIO_LIBS'].split())
491 if 'CONFIG_OPENGL' in config_host
492 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
493 link_args: config_host['OPENGL_LIBS'].split())
496 if 'CONFIG_GTK' in config_host
497 gtk = declare_dependency(compile_args: config_host['GTK_CFLAGS'].split(),
498 link_args: config_host['GTK_LIBS'].split())
501 if 'CONFIG_VTE' in config_host
502 vte = declare_dependency(compile_args: config_host['VTE_CFLAGS'].split(),
503 link_args: config_host['VTE_LIBS'].split())
506 if 'CONFIG_X11' in config_host
507 x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
508 link_args: config_host['X11_LIBS'].split())
511 if 'CONFIG_CURSES' in config_host
512 curses = declare_dependency(compile_args: config_host['CURSES_CFLAGS'].split(),
513 link_args: config_host['CURSES_LIBS'].split())
516 if 'CONFIG_ICONV' in config_host
517 iconv = declare_dependency(compile_args: config_host['ICONV_CFLAGS'].split(),
518 link_args: config_host['ICONV_LIBS'].split())
524 if get_option('vnc').enabled()
525 vnc = declare_dependency() # dummy dependency
526 png = dependency('libpng', required: get_option('vnc_png'),
527 method: 'pkg-config', static: enable_static)
528 jpeg = cc.find_library('jpeg', has_headers: ['jpeglib.h'],
529 required: get_option('vnc_jpeg'),
530 static: enable_static)
531 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
532 required: get_option('vnc_sasl'),
533 static: enable_static)
535 sasl = declare_dependency(dependencies: sasl,
536 compile_args: '-DSTRUCT_IOVEC_DEFINED')
540 if 'CONFIG_FDT' in config_host
541 fdt = declare_dependency(compile_args: config_host['FDT_CFLAGS'].split(),
542 link_args: config_host['FDT_LIBS'].split())
545 if 'CONFIG_SNAPPY' in config_host
546 snappy = declare_dependency(link_args: config_host['SNAPPY_LIBS'].split())
549 if 'CONFIG_LZO' in config_host
550 lzo = declare_dependency(link_args: config_host['LZO_LIBS'].split())
553 if 'CONFIG_RDMA' in config_host
554 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
557 if 'CONFIG_NUMA' in config_host
558 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
561 if 'CONFIG_XEN_BACKEND' in config_host
562 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
563 link_args: config_host['XEN_LIBS'].split())
566 if 'CONFIG_SMARTCARD' in config_host
567 cacard = declare_dependency(compile_args: config_host['SMARTCARD_CFLAGS'].split(),
568 link_args: config_host['SMARTCARD_LIBS'].split())
572 u2f = dependency('u2f-emu', required: get_option('u2f'),
573 method: 'pkg-config',
574 static: enable_static)
577 if 'CONFIG_USB_REDIR' in config_host
578 usbredir = declare_dependency(compile_args: config_host['USB_REDIR_CFLAGS'].split(),
579 link_args: config_host['USB_REDIR_LIBS'].split())
582 if 'CONFIG_USB_LIBUSB' in config_host
583 libusb = declare_dependency(compile_args: config_host['LIBUSB_CFLAGS'].split(),
584 link_args: config_host['LIBUSB_LIBS'].split())
587 if 'CONFIG_LIBPMEM' in config_host
588 libpmem = declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS'].split(),
589 link_args: config_host['LIBPMEM_LIBS'].split())
591 libdaxctl = not_found
592 if 'CONFIG_LIBDAXCTL' in config_host
593 libdaxctl = declare_dependency(link_args: config_host['LIBDAXCTL_LIBS'].split())
596 if 'CONFIG_TASN1' in config_host
597 tasn1 = declare_dependency(compile_args: config_host['TASN1_CFLAGS'].split(),
598 link_args: config_host['TASN1_LIBS'].split())
600 keyutils = dependency('libkeyutils', required: false,
601 method: 'pkg-config', static: enable_static)
603 has_gettid = cc.has_function('gettid')
608 if get_option('malloc') == 'system'
610 not get_option('malloc_trim').disabled() and \
611 cc.links('''#include <malloc.h>
612 int main(void) { malloc_trim(0); return 0; }''')
614 has_malloc_trim = false
615 malloc = cc.find_library(get_option('malloc'), required: true)
617 if not has_malloc_trim and get_option('malloc_trim').enabled()
618 if get_option('malloc') == 'system'
619 error('malloc_trim not available on this platform.')
621 error('malloc_trim not available with non-libc memory allocator')
625 # Create config-host.h
627 config_host_data.set('CONFIG_COCOA', cocoa.found())
628 config_host_data.set('CONFIG_LIBUDEV', libudev.found())
629 config_host_data.set('CONFIG_MPATH', mpathpersist.found())
630 config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
631 config_host_data.set('CONFIG_SDL', sdl.found())
632 config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
633 config_host_data.set('CONFIG_VNC', vnc.found())
634 config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
635 config_host_data.set('CONFIG_VNC_PNG', png.found())
636 config_host_data.set('CONFIG_VNC_SASL', sasl.found())
637 config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
638 config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
639 config_host_data.set('CONFIG_GETTID', has_gettid)
640 config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
641 config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
642 config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
643 config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
644 config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
646 ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target
647 arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
648 strings = ['HOST_DSOSUF', 'CONFIG_IASL', 'bindir', 'prefix', 'qemu_confdir', 'qemu_datadir',
649 'qemu_moddir', 'qemu_localstatedir', 'qemu_helperdir', 'qemu_localedir',
650 'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath', 'sysconfdir']
651 foreach k, v: config_host
652 if ignored.contains(k)
654 elif arrays.contains(k)
656 v = '"' + '", "'.join(v.split()) + '", '
658 config_host_data.set(k, v)
660 config_host_data.set('HOST_' + v.to_upper(), 1)
661 elif strings.contains(k)
662 if not k.startswith('CONFIG_')
663 k = 'CONFIG_' + k.to_upper()
665 config_host_data.set_quoted(k, v)
666 elif k.startswith('CONFIG_') or k.startswith('HAVE_') or k.startswith('HOST_')
667 config_host_data.set(k, v == 'y' ? 1 : v)
671 minikconf = find_program('scripts/minikconf.py')
673 config_all_devices = {}
674 config_all_disas = {}
675 config_devices_mak_list = []
676 config_devices_h = {}
678 config_target_mak = {}
681 'alpha' : ['CONFIG_ALPHA_DIS'],
682 'arm' : ['CONFIG_ARM_DIS'],
683 'avr' : ['CONFIG_AVR_DIS'],
684 'cris' : ['CONFIG_CRIS_DIS'],
685 'hppa' : ['CONFIG_HPPA_DIS'],
686 'i386' : ['CONFIG_I386_DIS'],
687 'x86_64' : ['CONFIG_I386_DIS'],
688 'x32' : ['CONFIG_I386_DIS'],
689 'lm32' : ['CONFIG_LM32_DIS'],
690 'm68k' : ['CONFIG_M68K_DIS'],
691 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
692 'mips' : ['CONFIG_MIPS_DIS'],
693 'moxie' : ['CONFIG_MOXIE_DIS'],
694 'nios2' : ['CONFIG_NIOS2_DIS'],
695 'or1k' : ['CONFIG_OPENRISC_DIS'],
696 'ppc' : ['CONFIG_PPC_DIS'],
697 'riscv' : ['CONFIG_RISCV_DIS'],
698 'rx' : ['CONFIG_RX_DIS'],
699 's390' : ['CONFIG_S390_DIS'],
700 'sh4' : ['CONFIG_SH4_DIS'],
701 'sparc' : ['CONFIG_SPARC_DIS'],
702 'xtensa' : ['CONFIG_XTENSA_DIS'],
704 if link_language == 'cpp'
706 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
707 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
708 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
712 kconfig_external_symbols = [
722 'CONFIG_VHOST_KERNEL',
727 ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
729 default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
730 actual_target_dirs = []
731 foreach target : target_dirs
732 config_target = { 'TARGET_NAME': target.split('-')[0] }
733 if target.endswith('linux-user')
734 if targetos != 'linux'
738 error('Target @0@ is only available on a Linux host'.format(target))
740 config_target += { 'CONFIG_LINUX_USER': 'y' }
741 elif target.endswith('bsd-user')
742 if 'CONFIG_BSD' not in config_host
746 error('Target @0@ is only available on a BSD host'.format(target))
748 config_target += { 'CONFIG_BSD_USER': 'y' }
749 elif target.endswith('softmmu')
750 config_target += { 'CONFIG_SOFTMMU': 'y' }
752 if target.endswith('-user')
754 'CONFIG_USER_ONLY': 'y',
755 'CONFIG_QEMU_INTERP_PREFIX':
756 config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
761 foreach sym: accelerators
762 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
763 config_target += { sym: 'y' }
764 config_all += { sym: 'y' }
765 if sym == 'CONFIG_XEN' and have_xen_pci_passthrough
766 config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
775 error('No accelerator available for target @0@'.format(target))
778 actual_target_dirs += target
779 config_target += keyval.load('default-configs/targets' / target + '.mak')
780 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
783 if 'TARGET_BASE_ARCH' not in config_target
784 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
786 if 'TARGET_ABI_DIR' not in config_target
787 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
790 foreach k, v: disassemblers
791 if config_host['ARCH'].startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
793 config_target += { sym: 'y' }
794 config_all_disas += { sym: 'y' }
799 config_target_data = configuration_data()
800 foreach k, v: config_target
801 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
803 elif ignored.contains(k)
805 elif k == 'TARGET_BASE_ARCH'
806 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
807 # not used to select files from sourcesets.
808 config_target_data.set('TARGET_' + v.to_upper(), 1)
809 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
810 config_target_data.set_quoted(k, v)
812 config_target_data.set(k, 1)
814 config_target_data.set(k, v)
817 config_target_h += {target: configure_file(output: target + '-config-target.h',
818 configuration: config_target_data)}
820 if target.endswith('-softmmu')
822 foreach sym : kconfig_external_symbols
823 if sym in config_target or sym in config_host
824 base_kconfig += '@0@=y'.format(sym)
828 config_devices_mak = target + '-config-devices.mak'
829 config_devices_mak = configure_file(
830 input: ['default-configs/devices' / target + '.mak', 'Kconfig'],
831 output: config_devices_mak,
832 depfile: config_devices_mak + '.d',
834 command: [minikconf, config_host['CONFIG_MINIKCONF_MODE'],
835 config_devices_mak, '@DEPFILE@', '@INPUT@',
838 config_devices_data = configuration_data()
839 config_devices = keyval.load(config_devices_mak)
840 foreach k, v: config_devices
841 config_devices_data.set(k, 1)
843 config_devices_mak_list += config_devices_mak
844 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
845 configuration: config_devices_data)}
846 config_target += config_devices
847 config_all_devices += config_devices
849 config_target_mak += {target: config_target}
851 target_dirs = actual_target_dirs
853 # This configuration is used to build files that are shared by
854 # multiple binaries, and then extracted out of the "common"
855 # static_library target.
857 # We do not use all_sources()/all_dependencies(), because it would
858 # build literally all source files, including devices only used by
859 # targets that are not built for this compilation. The CONFIG_ALL
860 # pseudo symbol replaces it.
862 config_all += config_all_devices
863 config_all += config_host
864 config_all += config_all_disas
866 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
867 'CONFIG_SOFTMMU': have_system,
868 'CONFIG_USER_ONLY': have_user,
875 capstone_opt = get_option('capstone')
876 if capstone_opt in ['enabled', 'auto', 'system']
877 have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
878 capstone = dependency('capstone', version: '>=4.0',
879 static: enable_static, method: 'pkg-config',
880 required: capstone_opt == 'system' or
881 capstone_opt == 'enabled' and not have_internal)
883 capstone_opt = 'system'
885 capstone_opt = 'internal'
887 capstone_opt = 'disabled'
890 if capstone_opt == 'internal'
891 capstone_data = configuration_data()
892 capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
894 capstone_files = files(
897 'capstone/MCInstrDesc.c',
898 'capstone/MCRegisterInfo.c',
899 'capstone/SStream.c',
903 if 'CONFIG_ARM_DIS' in config_all_disas
904 capstone_data.set('CAPSTONE_HAS_ARM', '1')
905 capstone_files += files(
906 'capstone/arch/ARM/ARMDisassembler.c',
907 'capstone/arch/ARM/ARMInstPrinter.c',
908 'capstone/arch/ARM/ARMMapping.c',
909 'capstone/arch/ARM/ARMModule.c'
913 # FIXME: This config entry currently depends on a c++ compiler.
914 # Which is needed for building libvixl, but not for capstone.
915 if 'CONFIG_ARM_A64_DIS' in config_all_disas
916 capstone_data.set('CAPSTONE_HAS_ARM64', '1')
917 capstone_files += files(
918 'capstone/arch/AArch64/AArch64BaseInfo.c',
919 'capstone/arch/AArch64/AArch64Disassembler.c',
920 'capstone/arch/AArch64/AArch64InstPrinter.c',
921 'capstone/arch/AArch64/AArch64Mapping.c',
922 'capstone/arch/AArch64/AArch64Module.c'
926 if 'CONFIG_PPC_DIS' in config_all_disas
927 capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
928 capstone_files += files(
929 'capstone/arch/PowerPC/PPCDisassembler.c',
930 'capstone/arch/PowerPC/PPCInstPrinter.c',
931 'capstone/arch/PowerPC/PPCMapping.c',
932 'capstone/arch/PowerPC/PPCModule.c'
936 if 'CONFIG_S390_DIS' in config_all_disas
937 capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
938 capstone_files += files(
939 'capstone/arch/SystemZ/SystemZDisassembler.c',
940 'capstone/arch/SystemZ/SystemZInstPrinter.c',
941 'capstone/arch/SystemZ/SystemZMapping.c',
942 'capstone/arch/SystemZ/SystemZModule.c',
943 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
947 if 'CONFIG_I386_DIS' in config_all_disas
948 capstone_data.set('CAPSTONE_HAS_X86', 1)
949 capstone_files += files(
950 'capstone/arch/X86/X86Disassembler.c',
951 'capstone/arch/X86/X86DisassemblerDecoder.c',
952 'capstone/arch/X86/X86ATTInstPrinter.c',
953 'capstone/arch/X86/X86IntelInstPrinter.c',
954 'capstone/arch/X86/X86InstPrinterCommon.c',
955 'capstone/arch/X86/X86Mapping.c',
956 'capstone/arch/X86/X86Module.c'
960 configure_file(output: 'capstone-defs.h', configuration: capstone_data)
963 # FIXME: There does not seem to be a way to completely replace the c_args
964 # that come from add_project_arguments() -- we can only add to them.
965 # So: disable all warnings with a big hammer.
968 # Include all configuration defines via a header file, which will wind up
969 # as a dependency on the object file, and thus changes here will result
971 '-include', 'capstone-defs.h'
974 libcapstone = static_library('capstone',
975 sources: capstone_files,
976 c_args: capstone_cargs,
977 include_directories: 'capstone/include')
978 capstone = declare_dependency(link_with: libcapstone,
979 include_directories: 'capstone/include/capstone')
981 config_host_data.set('CONFIG_CAPSTONE', capstone.found())
983 genh += configure_file(output: 'config-host.h', configuration: config_host_data)
987 hxtool = find_program('scripts/hxtool')
988 shaderinclude = find_program('scripts/shaderinclude.pl')
989 qapi_gen = find_program('scripts/qapi-gen.py')
990 qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py',
991 meson.source_root() / 'scripts/qapi/commands.py',
992 meson.source_root() / 'scripts/qapi/common.py',
993 meson.source_root() / 'scripts/qapi/error.py',
994 meson.source_root() / 'scripts/qapi/events.py',
995 meson.source_root() / 'scripts/qapi/expr.py',
996 meson.source_root() / 'scripts/qapi/gen.py',
997 meson.source_root() / 'scripts/qapi/introspect.py',
998 meson.source_root() / 'scripts/qapi/parser.py',
999 meson.source_root() / 'scripts/qapi/schema.py',
1000 meson.source_root() / 'scripts/qapi/source.py',
1001 meson.source_root() / 'scripts/qapi/types.py',
1002 meson.source_root() / 'scripts/qapi/visit.py',
1003 meson.source_root() / 'scripts/qapi/common.py',
1004 meson.source_root() / 'scripts/qapi-gen.py'
1008 python, files('scripts/tracetool.py'),
1009 '--backend=' + config_host['TRACE_BACKENDS']
1012 qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
1013 meson.current_source_dir(),
1014 config_host['PKGVERSION'], meson.project_version()]
1015 qemu_version = custom_target('qemu-version.h',
1016 output: 'qemu-version.h',
1017 command: qemu_version_cmd,
1019 build_by_default: true,
1020 build_always_stale: true)
1021 genh += qemu_version
1025 ['qemu-options.hx', 'qemu-options.def'],
1026 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
1030 ['hmp-commands.hx', 'hmp-commands.h'],
1031 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
1034 foreach d : hx_headers
1035 hxdep += custom_target(d[1],
1039 build_by_default: true, # to be removed when added to a target
1040 command: [hxtool, '-h', '@INPUT0@'])
1044 SPHINX_ARGS = [config_host['SPHINX_BUILD'],
1045 '-Dversion=' + meson.project_version(),
1046 '-Drelease=' + config_host['PKGVERSION']]
1048 if get_option('werror')
1049 SPHINX_ARGS += [ '-W' ]
1052 sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
1053 meson.source_root() / 'docs/sphinx/hxtool.py',
1054 meson.source_root() / 'docs/sphinx/kerneldoc.py',
1055 meson.source_root() / 'docs/sphinx/kernellog.py',
1056 meson.source_root() / 'docs/sphinx/qapidoc.py',
1057 meson.source_root() / 'docs/sphinx/qmp_lexer.py',
1060 # Collect sourcesets.
1062 util_ss = ss.source_set()
1063 stub_ss = ss.source_set()
1064 trace_ss = ss.source_set()
1065 block_ss = ss.source_set()
1066 blockdev_ss = ss.source_set()
1067 qmp_ss = ss.source_set()
1068 common_ss = ss.source_set()
1069 softmmu_ss = ss.source_set()
1070 user_ss = ss.source_set()
1071 bsd_user_ss = ss.source_set()
1072 linux_user_ss = ss.source_set()
1073 specific_ss = ss.source_set()
1074 specific_fuzz_ss = ss.source_set()
1079 target_softmmu_arch = {}
1085 # TODO: add each directory to the subdirs from its own meson.build, once
1087 trace_events_subdirs = [
1094 trace_events_subdirs += [ 'linux-user' ]
1097 trace_events_subdirs += [
1106 trace_events_subdirs += [
1117 'hw/block/dataplane',
1162 trace_events_subdirs += [
1189 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
1190 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
1193 # Build targets from sourcesets
1195 stub_ss = stub_ss.apply(config_all, strict: false)
1197 util_ss.add_all(trace_ss)
1198 util_ss = util_ss.apply(config_all, strict: false)
1199 libqemuutil = static_library('qemuutil',
1200 sources: util_ss.sources() + stub_ss.sources() + genh,
1201 dependencies: [util_ss.dependencies(), m, glib, socket, malloc])
1202 qemuutil = declare_dependency(link_with: libqemuutil,
1203 sources: genh + version_res)
1205 decodetree = generator(find_program('scripts/decodetree.py'),
1206 output: 'decode-@BASENAME@.c.inc',
1207 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
1213 subdir('libdecnumber')
1224 block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
1230 blockdev_ss.add(files(
1236 # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
1237 # os-win32.c does not
1238 blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
1239 softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
1241 softmmu_ss.add_all(blockdev_ss)
1242 softmmu_ss.add(files(
1248 softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c'))
1249 softmmu_ss.add(when: 'CONFIG_SECCOMP', if_true: [files('qemu-seccomp.c'), seccomp])
1250 softmmu_ss.add(when: ['CONFIG_FDT', fdt], if_true: [files('device_tree.c')])
1252 common_ss.add(files('cpus-common.c'))
1256 common_ss.add(capstone)
1257 specific_ss.add(files('disas.c', 'exec.c', 'gdbstub.c'), capstone, libpmem, libdaxctl)
1258 specific_ss.add(files('exec-vary.c'))
1259 specific_ss.add(when: 'CONFIG_TCG', if_true: files(
1263 'tcg/tcg-op-gvec.c',
1268 specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('disas/tci.c', 'tcg/tci.c'))
1280 subdir('linux-user')
1282 bsd_user_ss.add(files('gdbstub.c'))
1283 specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
1285 linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
1286 specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
1288 # needed for fuzzing binaries
1289 subdir('tests/qtest/libqos')
1290 subdir('tests/qtest/fuzz')
1294 foreach d, list : modules
1295 foreach m, module_ss : list
1296 if enable_modules and targetos != 'windows'
1297 module_ss = module_ss.apply(config_all, strict: false)
1298 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
1299 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
1307 block_ss.add_all(module_ss)
1309 softmmu_ss.add_all(module_ss)
1315 nm = find_program('nm')
1316 undefsym = find_program('scripts/undefsym.py')
1317 block_syms = custom_target('block.syms', output: 'block.syms',
1318 input: [libqemuutil, block_mods],
1320 command: [undefsym, nm, '@INPUT@'])
1321 qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
1322 input: [libqemuutil, softmmu_mods],
1324 command: [undefsym, nm, '@INPUT@'])
1326 block_ss = block_ss.apply(config_host, strict: false)
1327 libblock = static_library('block', block_ss.sources() + genh,
1328 dependencies: block_ss.dependencies(),
1329 link_depends: block_syms,
1331 build_by_default: false)
1333 block = declare_dependency(link_whole: [libblock],
1334 link_args: '@block.syms',
1335 dependencies: [crypto, io])
1337 qmp_ss = qmp_ss.apply(config_host, strict: false)
1338 libqmp = static_library('qmp', qmp_ss.sources() + genh,
1339 dependencies: qmp_ss.dependencies(),
1341 build_by_default: false)
1343 qmp = declare_dependency(link_whole: [libqmp])
1345 foreach m : block_mods + softmmu_mods
1346 shared_module(m.name(),
1350 install_dir: config_host['qemu_moddir'])
1353 softmmu_ss.add(authz, block, chardev, crypto, io, qmp)
1354 common_ss.add(qom, qemuutil)
1356 common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
1357 common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
1359 common_all = common_ss.apply(config_all, strict: false)
1360 common_all = static_library('common',
1361 build_by_default: false,
1362 sources: common_all.sources() + genh,
1363 dependencies: common_all.dependencies(),
1366 feature_to_c = find_program('scripts/feature_to_c.sh')
1369 foreach target : target_dirs
1370 config_target = config_target_mak[target]
1371 target_name = config_target['TARGET_NAME']
1372 arch = config_target['TARGET_BASE_ARCH']
1373 arch_srcs = [config_target_h[target]]
1375 c_args = ['-DNEED_CPU_H',
1376 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
1377 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
1378 link_args = emulator_link_args
1380 config_target += config_host
1381 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
1382 if targetos == 'linux'
1383 target_inc += include_directories('linux-headers', is_system: true)
1385 if target.endswith('-softmmu')
1386 qemu_target_name = 'qemu-system-' + target_name
1387 target_type='system'
1388 t = target_softmmu_arch[arch].apply(config_target, strict: false)
1389 arch_srcs += t.sources()
1390 arch_deps += t.dependencies()
1392 hw_dir = target_name == 'sparc64' ? 'sparc64' : arch
1393 hw = hw_arch[hw_dir].apply(config_target, strict: false)
1394 arch_srcs += hw.sources()
1395 arch_deps += hw.dependencies()
1397 arch_srcs += config_devices_h[target]
1398 link_args += ['@block.syms', '@qemu.syms']
1400 abi = config_target['TARGET_ABI_DIR']
1402 qemu_target_name = 'qemu-' + target_name
1403 if 'CONFIG_LINUX_USER' in config_target
1404 base_dir = 'linux-user'
1405 target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
1407 base_dir = 'bsd-user'
1409 target_inc += include_directories(
1413 if 'CONFIG_LINUX_USER' in config_target
1414 dir = base_dir / abi
1415 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
1416 if config_target.has_key('TARGET_SYSTBL_ABI')
1418 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
1419 extra_args : config_target['TARGET_SYSTBL_ABI'])
1424 if 'TARGET_XML_FILES' in config_target
1425 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
1426 output: target + '-gdbstub-xml.c',
1427 input: files(config_target['TARGET_XML_FILES'].split()),
1428 command: [feature_to_c, '@INPUT@'],
1430 arch_srcs += gdbstub_xml
1433 t = target_arch[arch].apply(config_target, strict: false)
1434 arch_srcs += t.sources()
1435 arch_deps += t.dependencies()
1437 target_common = common_ss.apply(config_target, strict: false)
1438 objects = common_all.extract_objects(target_common.sources())
1439 deps = target_common.dependencies()
1441 target_specific = specific_ss.apply(config_target, strict: false)
1442 arch_srcs += target_specific.sources()
1443 arch_deps += target_specific.dependencies()
1445 lib = static_library('qemu-' + target,
1446 sources: arch_srcs + genh,
1447 dependencies: arch_deps,
1449 include_directories: target_inc,
1451 build_by_default: false,
1454 if target.endswith('-softmmu')
1456 'name': 'qemu-system-' + target_name,
1458 'sources': files('softmmu/main.c'),
1461 if targetos == 'windows' and (sdl.found() or gtk.found())
1463 'name': 'qemu-system-' + target_name + 'w',
1465 'sources': files('softmmu/main.c'),
1469 if config_host.has_key('CONFIG_FUZZ')
1470 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
1472 'name': 'qemu-fuzz-' + target_name,
1474 'sources': specific_fuzz.sources(),
1475 'dependencies': specific_fuzz.dependencies(),
1480 'name': 'qemu-' + target_name,
1487 emulators += {exe['name']:
1488 executable(exe['name'], exe['sources'],
1491 dependencies: arch_deps + deps + exe['dependencies'],
1492 objects: lib.extract_all_objects(recursive: true),
1493 link_language: link_language,
1494 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
1495 link_args: link_args,
1496 gui_app: exe['gui'])
1499 if 'CONFIG_TRACE_SYSTEMTAP' in config_host
1501 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
1502 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
1503 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
1504 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
1506 custom_target(exe['name'] + stp['ext'],
1507 input: trace_events_all,
1508 output: exe['name'] + stp['ext'],
1510 install: stp['install'],
1511 install_dir: qemu_datadir / '../systemtap/tapset',
1513 tracetool, '--group=all', '--format=' + stp['fmt'],
1514 '--binary=' + stp['bin'],
1515 '--target-name=' + target_name,
1516 '--target-type=' + target_type,
1517 '--probe-prefix=qemu.' + target_type + '.' + target_name,
1525 # Other build targets
1527 if 'CONFIG_PLUGIN' in config_host
1528 install_headers('include/qemu/qemu-plugin.h')
1531 if 'CONFIG_GUEST_AGENT' in config_host
1535 # Don't build qemu-keymap if xkbcommon is not explicitly enabled
1536 # when we don't build tools or system
1537 if xkbcommon.found()
1538 # used for the update-keymaps target, so include rules even if !have_tools
1539 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
1540 dependencies: [qemuutil, xkbcommon], install: have_tools)
1544 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
1545 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
1546 qemu_io = executable('qemu-io', files('qemu-io.c'),
1547 dependencies: [block, qemuutil], install: true)
1548 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
1549 dependencies: [block, qemuutil], install: true)
1551 subdir('storage-daemon')
1552 subdir('contrib/rdmacm-mux')
1553 subdir('contrib/elf2dmp')
1555 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
1556 dependencies: qemuutil,
1559 if 'CONFIG_VHOST_USER' in config_host
1560 subdir('contrib/libvhost-user')
1561 subdir('contrib/vhost-user-blk')
1562 subdir('contrib/vhost-user-gpu')
1563 subdir('contrib/vhost-user-input')
1564 subdir('contrib/vhost-user-scsi')
1567 if targetos == 'linux'
1568 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
1569 dependencies: [qemuutil, libcap_ng],
1571 install_dir: get_option('libexecdir'))
1573 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
1574 dependencies: [authz, crypto, io, qom, qemuutil,
1575 libcap_ng, mpathpersist],
1579 if 'CONFIG_IVSHMEM' in config_host
1580 subdir('contrib/ivshmem-client')
1581 subdir('contrib/ivshmem-server')
1590 if 'CONFIG_GTK' in config_host
1594 if host_machine.system() == 'windows'
1596 find_program('scripts/nsis.py'),
1598 get_option('prefix'),
1599 meson.current_source_dir(),
1600 host_machine.cpu_family(),
1602 '-DDISPLAYVERSION=' + meson.project_version(),
1605 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
1607 if 'CONFIG_GTK' in config_host
1608 nsis_cmd += '-DCONFIG_GTK=y'
1611 nsis = custom_target('nsis',
1612 output: 'qemu-setup-' + meson.project_version() + '.exe',
1613 input: files('qemu.nsi'),
1614 build_always_stale: true,
1615 command: nsis_cmd + ['@INPUT@'])
1616 alias_target('installer', nsis)
1620 summary_info += {'Install prefix': config_host['prefix']}
1621 summary_info += {'BIOS directory': config_host['qemu_datadir']}
1622 summary_info += {'firmware path': config_host['qemu_firmwarepath']}
1623 summary_info += {'binary directory': config_host['bindir']}
1624 summary_info += {'library directory': config_host['libdir']}
1625 summary_info += {'module directory': config_host['qemu_moddir']}
1626 summary_info += {'libexec directory': config_host['libexecdir']}
1627 summary_info += {'include directory': config_host['includedir']}
1628 summary_info += {'config directory': config_host['sysconfdir']}
1629 if targetos != 'windows'
1630 summary_info += {'local state directory': config_host['qemu_localstatedir']}
1631 summary_info += {'Manual directory': get_option('mandir')}
1633 summary_info += {'local state directory': 'queried at runtime'}
1635 summary_info += {'Doc directory': get_option('docdir')}
1636 summary_info += {'Build directory': meson.current_build_dir()}
1637 summary_info += {'Source path': meson.current_source_dir()}
1638 summary_info += {'GIT binary': config_host['GIT']}
1639 summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
1640 summary_info += {'C compiler': meson.get_compiler('c').cmd_array()[0]}
1641 summary_info += {'Host C compiler': meson.get_compiler('c', native: true).cmd_array()[0]}
1642 if link_language == 'cpp'
1643 summary_info += {'C++ compiler': meson.get_compiler('cpp').cmd_array()[0]}
1645 summary_info += {'C++ compiler': false}
1647 if targetos == 'darwin'
1648 summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]}
1650 summary_info += {'ARFLAGS': config_host['ARFLAGS']}
1651 summary_info += {'CFLAGS': config_host['CFLAGS']}
1652 summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
1653 summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
1654 summary_info += {'make': config_host['MAKE']}
1655 summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
1656 summary_info += {'sphinx-build': config_host['SPHINX_BUILD']}
1657 summary_info += {'genisoimage': config_host['GENISOIMAGE']}
1658 # TODO: add back version
1659 summary_info += {'slirp support': config_host.has_key('CONFIG_SLIRP')}
1660 if config_host.has_key('CONFIG_SLIRP')
1661 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
1663 summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
1664 if config_host.has_key('CONFIG_MODULES')
1665 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
1667 summary_info += {'host CPU': cpu}
1668 summary_info += {'host endianness': build_machine.endian()}
1669 summary_info += {'target list': ' '.join(target_dirs)}
1670 summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
1671 summary_info += {'sparse enabled': sparse.found()}
1672 summary_info += {'strip binaries': get_option('strip')}
1673 summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
1674 summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
1675 if targetos == 'darwin'
1676 summary_info += {'Cocoa support': config_host.has_key('CONFIG_COCOA')}
1678 # TODO: add back version
1679 summary_info += {'SDL support': sdl.found()}
1680 summary_info += {'SDL image support': sdl_image.found()}
1681 # TODO: add back version
1682 summary_info += {'GTK support': config_host.has_key('CONFIG_GTK')}
1683 summary_info += {'GTK GL support': config_host.has_key('CONFIG_GTK_GL')}
1684 summary_info += {'pixman': pixman.found()}
1685 # TODO: add back version
1686 summary_info += {'VTE support': config_host.has_key('CONFIG_VTE')}
1687 summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
1688 summary_info += {'GNUTLS support': config_host.has_key('CONFIG_GNUTLS')}
1689 # TODO: add back version
1690 summary_info += {'libgcrypt': config_host.has_key('CONFIG_GCRYPT')}
1691 if config_host.has_key('CONFIG_GCRYPT')
1692 summary_info += {' hmac': config_host.has_key('CONFIG_GCRYPT_HMAC')}
1693 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
1695 # TODO: add back version
1696 summary_info += {'nettle': config_host.has_key('CONFIG_NETTLE')}
1697 if config_host.has_key('CONFIG_NETTLE')
1698 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
1700 summary_info += {'libtasn1': config_host.has_key('CONFIG_TASN1')}
1701 summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
1702 summary_info += {'iconv support': config_host.has_key('CONFIG_ICONV')}
1703 summary_info += {'curses support': config_host.has_key('CONFIG_CURSES')}
1704 # TODO: add back version
1705 summary_info += {'virgl support': config_host.has_key('CONFIG_VIRGL')}
1706 summary_info += {'curl support': config_host.has_key('CONFIG_CURL')}
1707 summary_info += {'mingw32 support': targetos == 'windows'}
1708 summary_info += {'Audio drivers': config_host['CONFIG_AUDIO_DRIVERS']}
1709 summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
1710 summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
1711 summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
1712 summary_info += {'Multipath support': mpathpersist.found()}
1713 summary_info += {'VNC support': vnc.found()}
1715 summary_info += {'VNC SASL support': sasl.found()}
1716 summary_info += {'VNC JPEG support': jpeg.found()}
1717 summary_info += {'VNC PNG support': png.found()}
1719 summary_info += {'xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
1720 if config_host.has_key('CONFIG_XEN_BACKEND')
1721 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
1723 summary_info += {'brlapi support': config_host.has_key('CONFIG_BRLAPI')}
1724 summary_info += {'Documentation': config_host.has_key('BUILD_DOCS')}
1725 summary_info += {'PIE': get_option('b_pie')}
1726 summary_info += {'vde support': config_host.has_key('CONFIG_VDE')}
1727 summary_info += {'netmap support': config_host.has_key('CONFIG_NETMAP')}
1728 summary_info += {'Linux AIO support': config_host.has_key('CONFIG_LINUX_AIO')}
1729 summary_info += {'Linux io_uring support': config_host.has_key('CONFIG_LINUX_IO_URING')}
1730 summary_info += {'ATTR/XATTR support': config_host.has_key('CONFIG_ATTR')}
1731 summary_info += {'Install blobs': config_host.has_key('INSTALL_BLOBS')}
1732 summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
1733 summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
1734 summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
1735 summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
1736 summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
1737 if config_all.has_key('CONFIG_TCG')
1738 summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
1739 summary_info += {'TCG interpreter': config_host.has_key('CONFIG_TCG_INTERPRETER')}
1741 summary_info += {'malloc trim support': has_malloc_trim}
1742 summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
1743 summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
1744 summary_info += {'fdt support': config_host.has_key('CONFIG_FDT')}
1745 summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
1746 summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')}
1747 summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')}
1748 summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')}
1749 summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
1750 summary_info += {'posix_memalign': config_host.has_key('CONFIG_POSIX_MEMALIGN')}
1751 summary_info += {'libcap-ng support': config_host.has_key('CONFIG_LIBCAP_NG')}
1752 summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
1753 summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
1754 summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
1755 summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
1756 summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_KERNEL')}
1757 summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
1758 summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
1759 summary_info += {'Trace backends': config_host['TRACE_BACKENDS']}
1760 if config_host['TRACE_BACKENDS'].split().contains('simple')
1761 summary_info += {'Trace output file': config_host['CONFIG_TRACE_FILE'] + '-<pid>'}
1763 # TODO: add back protocol and server version
1764 summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
1765 summary_info += {'rbd support': config_host.has_key('CONFIG_RBD')}
1766 summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
1767 summary_info += {'smartcard support': config_host.has_key('CONFIG_SMARTCARD')}
1768 summary_info += {'U2F support': u2f.found()}
1769 summary_info += {'libusb': config_host.has_key('CONFIG_USB_LIBUSB')}
1770 summary_info += {'usb net redir': config_host.has_key('CONFIG_USB_REDIR')}
1771 summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
1772 summary_info += {'OpenGL dmabufs': config_host.has_key('CONFIG_OPENGL_DMABUF')}
1773 summary_info += {'libiscsi support': config_host.has_key('CONFIG_LIBISCSI')}
1774 summary_info += {'libnfs support': config_host.has_key('CONFIG_LIBNFS')}
1775 summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
1776 if targetos == 'windows'
1777 if 'WIN_SDK' in config_host
1778 summary_info += {'Windows SDK': config_host['WIN_SDK']}
1780 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
1781 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
1782 summary_info += {'QGA MSI support': config_host.has_key('CONFIG_QGA_MSI')}
1784 summary_info += {'seccomp support': config_host.has_key('CONFIG_SECCOMP')}
1785 summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
1786 summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
1787 summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
1788 summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
1789 summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
1790 summary_info += {'GlusterFS support': config_host.has_key('CONFIG_GLUSTERFS')}
1791 summary_info += {'gcov': get_option('b_coverage')}
1792 summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
1793 summary_info += {'libssh support': config_host.has_key('CONFIG_LIBSSH')}
1794 summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
1795 summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
1796 summary_info += {'lzo support': config_host.has_key('CONFIG_LZO')}
1797 summary_info += {'snappy support': config_host.has_key('CONFIG_SNAPPY')}
1798 summary_info += {'bzip2 support': config_host.has_key('CONFIG_BZIP2')}
1799 summary_info += {'lzfse support': config_host.has_key('CONFIG_LZFSE')}
1800 summary_info += {'zstd support': config_host.has_key('CONFIG_ZSTD')}
1801 summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
1802 summary_info += {'libxml2': config_host.has_key('CONFIG_LIBXML2')}
1803 summary_info += {'memory allocator': get_option('malloc')}
1804 summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
1805 summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
1806 summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
1807 summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
1808 summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
1809 summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
1810 summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
1811 summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
1812 summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
1813 summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
1814 summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
1815 summary_info += {'sheepdog support': config_host.has_key('CONFIG_SHEEPDOG')}
1816 summary_info += {'capstone': capstone_opt == 'disabled' ? false : capstone_opt}
1817 summary_info += {'libpmem support': config_host.has_key('CONFIG_LIBPMEM')}
1818 summary_info += {'libdaxctl support': config_host.has_key('CONFIG_LIBDAXCTL')}
1819 summary_info += {'libudev': libudev.found()}
1820 summary_info += {'default devices': config_host['CONFIG_MINIKCONF_MODE'] == '--defconfig'}
1821 summary_info += {'plugin support': config_host.has_key('CONFIG_PLUGIN')}
1822 summary_info += {'fuzzing support': config_host.has_key('CONFIG_FUZZ')}
1823 if config_host.has_key('HAVE_GDB_BIN')
1824 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
1826 summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
1827 summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
1828 summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
1829 summary(summary_info, bool_yn: true)
1831 if not supported_cpus.contains(cpu)
1833 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
1835 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
1836 message('The QEMU project intends to remove support for this host CPU in')
1837 message('a future release if nobody volunteers to maintain it and to')
1838 message('provide a build host for our continuous integration setup.')
1839 message('configure has succeeded and you can continue to build, but')
1840 message('if you care about QEMU on this platform you should contact')
1841 message('us upstream at qemu-devel@nongnu.org.')
1844 if not supported_oses.contains(targetos)
1846 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
1848 message('Host OS ' + targetos + 'support is not currently maintained.')
1849 message('The QEMU project intends to remove support for this host OS in')
1850 message('a future release if nobody volunteers to maintain it and to')
1851 message('provide a build host for our continuous integration setup.')
1852 message('configure has succeeded and you can continue to build, but')
1853 message('if you care about QEMU on this platform you should contact')
1854 message('us upstream at qemu-devel@nongnu.org.')