pc-bios/s390-ccw/Makefile: Compile with -std=gnu99, -fwrapv and -fno-common
[qemu/ar7.git] / meson.build
bloba02c7437942bcd0b5025fc7266efb98e157cf765
1 project('qemu', ['c'], meson_version: '>=0.55.0',
2         default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11',
3                           'b_colorout=auto'],
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')
9 else
10   keyval = import('unstable-keyval')
11 endif
12 ss = import('sourceset')
13 fs = import('fs')
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 /')
24 endif
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()
29 genh = []
31 target_dirs = config_host['TARGET_DIRS'].split()
32 have_user = false
33 have_system = false
34 foreach target : target_dirs
35   have_user = have_user or target.endswith('-user')
36   have_system = have_system or target.endswith('-softmmu')
37 endforeach
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'),
51                output: 'ninjatool',
52                configuration: config_host)
54 if cpu in ['x86', 'x86_64']
55   kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
56 elif cpu == 'aarch64'
57   kvm_targets = ['aarch64-softmmu']
58 elif cpu == 's390x'
59   kvm_targets = ['s390x-softmmu']
60 elif cpu in ['ppc', 'ppc64']
61   kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
62 else
63   kvm_targets = []
64 endif
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'],
73   }
74 endif
76 ##################
77 # Compiler flags #
78 ##################
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'])
86 endif
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)
101 endif
102 if host_machine.system() == 'darwin'
103   add_languages('objc', required: false, native: false)
104 endif
106 sparse = find_program('cgcc', required: get_option('sparse'))
107 if sparse.found()
108   run_target('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'])
113 endif
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')
121 endif
123 m = cc.find_library('m', required: false)
124 util = cc.find_library('util', required: false)
125 winmm = []
126 socket = []
127 version_res = []
128 coref = []
129 iokit = []
130 emulator_link_args = []
131 cocoa = not_found
132 hvf = not_found
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')
157   endif
158 endif
160 accelerators = []
161 if not get_option('kvm').disabled() and targetos == 'linux'
162   accelerators += 'CONFIG_KVM'
163 endif
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'
167 else
168   have_xen_pci_passthrough = false
169 endif
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'
176   endif
177 endif
178 if not get_option('hvf').disabled()
179   hvf = dependency('appleframeworks', modules: 'Hypervisor',
180                    required: get_option('hvf'))
181   if hvf.found()
182     accelerators += 'CONFIG_HVF'
183   endif
184 endif
185 if not get_option('hax').disabled()
186   if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
187     accelerators += 'CONFIG_HAX'
188   endif
189 endif
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))
194     else
195       error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
196     endif
197   endif
198   accelerators += 'CONFIG_TCG'
199   config_host += { 'CONFIG_TCG': 'y' }
200 endif
202 if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
203   error('KVM not available on this platform')
204 endif
205 if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
206   error('HVF not available on this platform')
207 endif
208 if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
209   error('WHPX not available on this platform')
210 endif
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')
214   else
215     error('Xen PCI passthrough requested but Xen not enabled')
216   endif
217 endif
218 if not cocoa.found() and get_option('cocoa').enabled()
219   error('Cocoa not available on this platform')
220 endif
222 ################
223 # Dependencies #
224 ################
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())
231 gio = not_found
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())
235 endif
236 lttng = not_found
237 if 'CONFIG_TRACE_UST' in config_host
238   lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
239 endif
240 urcubp = not_found
241 if 'CONFIG_TRACE_UST' in config_host
242   urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split())
243 endif
244 gcrypt = not_found
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())
248 endif
249 nettle = not_found
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())
253 endif
254 gnutls = not_found
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())
258 endif
259 pixman = not_found
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)
263 endif
264 pam = not_found
265 if 'CONFIG_AUTH_PAM' in config_host
266   pam = cc.find_library('pam')
267 endif
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())
274 endif
275 libxml2 = not_found
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())
279 endif
280 libnfs = not_found
281 if 'CONFIG_LIBNFS' in config_host
282   libnfs = declare_dependency(link_args: config_host['LIBNFS_LIBS'].split())
283 endif
284 libattr = not_found
285 if 'CONFIG_ATTR' in config_host
286   libattr = declare_dependency(link_args: config_host['LIBATTR_LIBS'].split())
287 endif
288 seccomp = not_found
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())
292 endif
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())
296 endif
297 if get_option('xkbcommon').auto() and not have_system and not have_tools
298   xkbcommon = not_found
299 else
300   xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
301                          method: 'pkg-config', static: enable_static)
302 endif
303 slirp = not_found
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())
307 endif
308 vde = not_found
309 if config_host.has_key('CONFIG_VDE')
310   vde = declare_dependency(link_args: config_host['VDE_LIBS'].split())
311 endif
312 pulse = not_found
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())
316 endif
317 alsa = not_found
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())
321 endif
322 jack = not_found
323 if 'CONFIG_LIBJACK' in config_host
324   jack = declare_dependency(link_args: config_host['JACK_LIBS'].split())
325 endif
326 spice = not_found
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())
330 endif
331 rt = cc.find_library('rt', required: false)
332 libdl = not_found
333 if 'CONFIG_PLUGIN' in config_host
334   libdl = cc.find_library('dl', required: true)
335 endif
336 libiscsi = not_found
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())
340 endif
341 zstd = not_found
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())
345 endif
346 gbm = not_found
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())
350 endif
351 virgl = not_found
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())
355 endif
356 curl = not_found
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())
360 endif
361 libudev = not_found
362 if targetos == 'linux' and (have_system or have_tools)
363   libudev = dependency('libudev',
364                        required: get_option('mpath').enabled(),
365                        static: enable_static)
366 endif
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 = '''
372     #include <libudev.h>
373     #include <mpath_persist.h>
374     unsigned mpath_mx_alloc_len = 1024;
375     int logsink;
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);
380     struct udev *udev;
381     struct config *get_multipath_config(void) { return multipath_conf; }
382     void put_multipath_config(struct config *conf) { }
383     int main(void) {
384         udev = udev_new();
385         multipath_conf = mpath_lib_init();
386         return 0;
387     }'''
388   mpath_test_source_old = '''
389       #include <libudev.h>
390       #include <mpath_persist.h>
391       unsigned mpath_mx_alloc_len = 1024;
392       int logsink;
393       int main(void) {
394           struct udev *udev = udev_new();
395           mpath_lib_init(udev);
396           return 0;
397       }'''
398   mpathlibs = [libudev]
399   if enable_static
400     mpathlibs += cc.find_library('devmapper',
401                                    required: get_option('mpath'),
402                                    static: enable_static)
403   endif
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
411     if not lib.found()
412       mpathlibs = []
413       break
414     endif
415   endforeach
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)
422     else
423       if get_option('mpath').enabled()
424         error('Cannot detect libmpathpersist API')
425       else
426         warning('Cannot detect libmpathpersist API, disabling')
427       endif
428     endif
429   endif
430 endif
432 brlapi = not_found
433 if 'CONFIG_BRLAPI' in config_host
434   brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
435 endif
437 sdl = not_found
438 if have_system
439   sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static)
440   sdl_image = not_found
441 endif
442 if sdl.found()
443   # work around 2.0.8 bug
444   sdl = declare_dependency(compile_args: '-Wno-undef',
445                            dependencies: sdl)
446   sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
447                          method: 'pkg-config', static: enable_static)
448 else
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'))
452   endif
453   sdl_image = not_found
454 endif
456 rbd = not_found
457 if 'CONFIG_RBD' in config_host
458   rbd = declare_dependency(link_args: config_host['RBD_LIBS'].split())
459 endif
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())
464 endif
465 libssh = not_found
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())
469 endif
470 libbzip2 = not_found
471 if 'CONFIG_BZIP2' in config_host
472   libbzip2 = declare_dependency(link_args: config_host['BZIP2_LIBS'].split())
473 endif
474 liblzfse = not_found
475 if 'CONFIG_LZFSE' in config_host
476   liblzfse = declare_dependency(link_args: config_host['LZFSE_LIBS'].split())
477 endif
478 oss = not_found
479 if 'CONFIG_AUDIO_OSS' in config_host
480   oss = declare_dependency(link_args: config_host['OSS_LIBS'].split())
481 endif
482 dsound = not_found
483 if 'CONFIG_AUDIO_DSOUND' in config_host
484   dsound = declare_dependency(link_args: config_host['DSOUND_LIBS'].split())
485 endif
486 coreaudio = not_found
487 if 'CONFIG_AUDIO_COREAUDIO' in config_host
488   coreaudio = declare_dependency(link_args: config_host['COREAUDIO_LIBS'].split())
489 endif
490 opengl = not_found
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())
494 endif
495 gtk = not_found
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())
499 endif
500 vte = not_found
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())
504 endif
505 x11 = not_found
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())
509 endif
510 curses = not_found
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())
514 endif
515 iconv = not_found
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())
519 endif
520 vnc = not_found
521 png = not_found
522 jpeg = not_found
523 sasl = not_found
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)
534   if sasl.found()
535     sasl = declare_dependency(dependencies: sasl,
536                               compile_args: '-DSTRUCT_IOVEC_DEFINED')
537   endif
538 endif
539 fdt = not_found
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())
543 endif
544 snappy = not_found
545 if 'CONFIG_SNAPPY' in config_host
546   snappy = declare_dependency(link_args: config_host['SNAPPY_LIBS'].split())
547 endif
548 lzo = not_found
549 if 'CONFIG_LZO' in config_host
550   lzo = declare_dependency(link_args: config_host['LZO_LIBS'].split())
551 endif
552 rdma = not_found
553 if 'CONFIG_RDMA' in config_host
554   rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
555 endif
556 numa = not_found
557 if 'CONFIG_NUMA' in config_host
558   numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
559 endif
560 xen = not_found
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())
564 endif
565 cacard = not_found
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())
569 endif
570 u2f = not_found
571 if have_system
572   u2f = dependency('u2f-emu', required: get_option('u2f'),
573                    method: 'pkg-config',
574                    static: enable_static)
575 endif
576 usbredir = not_found
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())
580 endif
581 libusb = not_found
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())
585 endif
586 libpmem = not_found
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())
590 endif
591 libdaxctl = not_found
592 if 'CONFIG_LIBDAXCTL' in config_host
593   libdaxctl = declare_dependency(link_args: config_host['LIBDAXCTL_LIBS'].split())
594 endif
595 tasn1 = not_found
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())
599 endif
600 keyutils = dependency('libkeyutils', required: false,
601                       method: 'pkg-config', static: enable_static)
603 has_gettid = cc.has_function('gettid')
605 # Malloc tests
607 malloc = []
608 if get_option('malloc') == 'system'
609   has_malloc_trim = \
610     not get_option('malloc_trim').disabled() and \
611     cc.links('''#include <malloc.h>
612                 int main(void) { malloc_trim(0); return 0; }''')
613 else
614   has_malloc_trim = false
615   malloc = cc.find_library(get_option('malloc'), required: true)
616 endif
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.')
620   else
621     error('malloc_trim not available with non-libc memory allocator')
622   endif
623 endif
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)
653     # do nothing
654   elif arrays.contains(k)
655     if v != ''
656       v = '"' + '", "'.join(v.split()) + '", '
657     endif
658     config_host_data.set(k, v)
659   elif k == 'ARCH'
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()
664     endif
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)
668   endif
669 endforeach
671 minikconf = find_program('scripts/minikconf.py')
672 config_all = {}
673 config_all_devices = {}
674 config_all_disas = {}
675 config_devices_mak_list = []
676 config_devices_h = {}
677 config_target_h = {}
678 config_target_mak = {}
680 disassemblers = {
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'
705   disassemblers += {
706     'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
707     'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
708     'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
709   }
710 endif
712 kconfig_external_symbols = [
713   'CONFIG_KVM',
714   'CONFIG_XEN',
715   'CONFIG_TPM',
716   'CONFIG_SPICE',
717   'CONFIG_IVSHMEM',
718   'CONFIG_OPENGL',
719   'CONFIG_X11',
720   'CONFIG_VHOST_USER',
721   'CONFIG_VHOST_VDPA',
722   'CONFIG_VHOST_KERNEL',
723   'CONFIG_VIRTFS',
724   'CONFIG_LINUX',
725   'CONFIG_PVRDMA',
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'
735       if default_targets
736         continue
737       endif
738       error('Target @0@ is only available on a Linux host'.format(target))
739     endif
740     config_target += { 'CONFIG_LINUX_USER': 'y' }
741   elif target.endswith('bsd-user')
742     if 'CONFIG_BSD' not in config_host
743       if default_targets
744         continue
745       endif
746       error('Target @0@ is only available on a BSD host'.format(target))
747     endif
748     config_target += { 'CONFIG_BSD_USER': 'y' }
749   elif target.endswith('softmmu')
750     config_target += { 'CONFIG_SOFTMMU': 'y' }
751   endif
752   if target.endswith('-user')
753     config_target += {
754       'CONFIG_USER_ONLY': 'y',
755       'CONFIG_QEMU_INTERP_PREFIX':
756         config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
757     }
758   endif
760   have_accel = false
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' }
767       endif
768       have_accel = true
769     endif
770   endforeach
771   if not have_accel
772     if default_targets
773       continue
774     endif
775     error('No accelerator available for target @0@'.format(target))
776   endif
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' }
782   # Add default keys
783   if 'TARGET_BASE_ARCH' not in config_target
784     config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
785   endif
786   if 'TARGET_ABI_DIR' not in config_target
787     config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
788   endif
790   foreach k, v: disassemblers
791     if config_host['ARCH'].startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
792       foreach sym: v
793         config_target += { sym: 'y' }
794         config_all_disas += { sym: 'y' }
795       endforeach
796     endif
797   endforeach
799   config_target_data = configuration_data()
800   foreach k, v: config_target
801     if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
802       # do nothing
803     elif ignored.contains(k)
804       # do nothing
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)
811     elif v == 'y'
812       config_target_data.set(k, 1)
813     else
814       config_target_data.set(k, v)
815     endif
816   endforeach
817   config_target_h += {target: configure_file(output: target + '-config-target.h',
818                                                configuration: config_target_data)}
820   if target.endswith('-softmmu')
821     base_kconfig = []
822     foreach sym : kconfig_external_symbols
823       if sym in config_target or sym in config_host
824         base_kconfig += '@0@=y'.format(sym)
825       endif
826     endforeach
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',
833       capture: true,
834       command: [minikconf, config_host['CONFIG_MINIKCONF_MODE'],
835                 config_devices_mak, '@DEPFILE@', '@INPUT@',
836                 base_kconfig])
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)
842     endforeach
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
848   endif
849   config_target_mak += {target: config_target}
850 endforeach
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
865 config_all += {
866   'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
867   'CONFIG_SOFTMMU': have_system,
868   'CONFIG_USER_ONLY': have_user,
869   'CONFIG_ALL': true,
872 # Submodules
874 capstone = not_found
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)
882   if capstone.found()
883     capstone_opt = 'system'
884   elif have_internal
885     capstone_opt = 'internal'
886   else
887     capstone_opt = 'disabled'
888   endif
889 endif
890 if capstone_opt == 'internal'
891   capstone_data = configuration_data()
892   capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
894   capstone_files = files(
895     'capstone/cs.c',
896     'capstone/MCInst.c',
897     'capstone/MCInstrDesc.c',
898     'capstone/MCRegisterInfo.c',
899     'capstone/SStream.c',
900     'capstone/utils.c'
901   )
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'
910     )
911   endif
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'
923     )
924   endif
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'
933     )
934   endif
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'
944     )
945   endif
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'
957     )
958   endif
960   configure_file(output: 'capstone-defs.h', configuration: capstone_data)
962   capstone_cargs = [
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.
966     '-Wno-error', '-w',
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
970     # in a rebuild.
971     '-include', 'capstone-defs.h'
972   ]
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')
980 endif
981 config_host_data.set('CONFIG_CAPSTONE', capstone.found())
983 genh += configure_file(output: 'config-host.h', configuration: config_host_data)
985 # Generators
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'
1007 tracetool = [
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,
1018                              capture: true,
1019                              build_by_default: true,
1020                              build_always_stale: true)
1021 genh += qemu_version
1023 hxdep = []
1024 hx_headers = [
1025   ['qemu-options.hx', 'qemu-options.def'],
1026   ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
1028 if have_system
1029   hx_headers += [
1030     ['hmp-commands.hx', 'hmp-commands.h'],
1031     ['hmp-commands-info.hx', 'hmp-commands-info.h'],
1032   ]
1033 endif
1034 foreach d : hx_headers
1035   hxdep += custom_target(d[1],
1036                 input: files(d[0]),
1037                 output: d[1],
1038                 capture: true,
1039                 build_by_default: true, # to be removed when added to a target
1040                 command: [hxtool, '-h', '@INPUT0@'])
1041 endforeach
1042 genh += hxdep
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' ]
1050 endif
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',
1058                         qapi_gen_depends ]
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()
1076 modules = {}
1077 hw_arch = {}
1078 target_arch = {}
1079 target_softmmu_arch = {}
1081 ###############
1082 # Trace files #
1083 ###############
1085 # TODO: add each directory to the subdirs from its own meson.build, once
1086 # we have those
1087 trace_events_subdirs = [
1088   'accel/kvm',
1089   'accel/tcg',
1090   'crypto',
1091   'monitor',
1093 if have_user
1094   trace_events_subdirs += [ 'linux-user' ]
1095 endif
1096 if have_block
1097   trace_events_subdirs += [
1098     'authz',
1099     'block',
1100     'io',
1101     'nbd',
1102     'scsi',
1103   ]
1104 endif
1105 if have_system
1106   trace_events_subdirs += [
1107     'audio',
1108     'backends',
1109     'backends/tpm',
1110     'chardev',
1111     'hw/9pfs',
1112     'hw/acpi',
1113     'hw/alpha',
1114     'hw/arm',
1115     'hw/audio',
1116     'hw/block',
1117     'hw/block/dataplane',
1118     'hw/char',
1119     'hw/display',
1120     'hw/dma',
1121     'hw/hppa',
1122     'hw/hyperv',
1123     'hw/i2c',
1124     'hw/i386',
1125     'hw/i386/xen',
1126     'hw/ide',
1127     'hw/input',
1128     'hw/intc',
1129     'hw/isa',
1130     'hw/mem',
1131     'hw/mips',
1132     'hw/misc',
1133     'hw/misc/macio',
1134     'hw/net',
1135     'hw/nvram',
1136     'hw/pci',
1137     'hw/pci-host',
1138     'hw/ppc',
1139     'hw/rdma',
1140     'hw/rdma/vmw',
1141     'hw/rtc',
1142     'hw/s390x',
1143     'hw/scsi',
1144     'hw/sd',
1145     'hw/sparc',
1146     'hw/sparc64',
1147     'hw/ssi',
1148     'hw/timer',
1149     'hw/tpm',
1150     'hw/usb',
1151     'hw/vfio',
1152     'hw/virtio',
1153     'hw/watchdog',
1154     'hw/xen',
1155     'hw/gpio',
1156     'migration',
1157     'net',
1158     'softmmu',
1159     'ui',
1160   ]
1161 endif
1162 trace_events_subdirs += [
1163   'hw/core',
1164   'qapi',
1165   'qom',
1166   'target/arm',
1167   'target/hppa',
1168   'target/i386',
1169   'target/mips',
1170   'target/ppc',
1171   'target/riscv',
1172   'target/s390x',
1173   'target/sparc',
1174   'util',
1177 subdir('qapi')
1178 subdir('qobject')
1179 subdir('stubs')
1180 subdir('trace')
1181 subdir('util')
1182 subdir('qom')
1183 subdir('authz')
1184 subdir('crypto')
1185 subdir('ui')
1188 if enable_modules
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')
1191 endif
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@'])
1209 subdir('audio')
1210 subdir('io')
1211 subdir('chardev')
1212 subdir('fsdev')
1213 subdir('libdecnumber')
1214 subdir('target')
1215 subdir('dump')
1217 block_ss.add(files(
1218   'block.c',
1219   'blockdev-nbd.c',
1220   'blockjob.c',
1221   'job.c',
1222   'qemu-io-cmds.c',
1224 block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
1226 subdir('nbd')
1227 subdir('scsi')
1228 subdir('block')
1230 blockdev_ss.add(files(
1231   'blockdev.c',
1232   'iothread.c',
1233   'job-qmp.c',
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(
1243   'bootdevice.c',
1244   'dma-helpers.c',
1245   'qdev-monitor.c',
1246 ), sdl)
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'))
1254 subdir('softmmu')
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(
1260   'fpu/softfloat.c',
1261   'tcg/optimize.c',
1262   'tcg/tcg-common.c',
1263   'tcg/tcg-op-gvec.c',
1264   'tcg/tcg-op-vec.c',
1265   'tcg/tcg-op.c',
1266   'tcg/tcg.c',
1268 specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('disas/tci.c', 'tcg/tci.c'))
1270 subdir('backends')
1271 subdir('disas')
1272 subdir('migration')
1273 subdir('monitor')
1274 subdir('net')
1275 subdir('replay')
1276 subdir('hw')
1277 subdir('accel')
1278 subdir('plugins')
1279 subdir('bsd-user')
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')
1292 block_mods = []
1293 softmmu_mods = []
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)
1300       if d == 'block'
1301         block_mods += sl
1302       else
1303         softmmu_mods += sl
1304       endif
1305     else
1306       if d == 'block'
1307         block_ss.add_all(module_ss)
1308       else
1309         softmmu_ss.add_all(module_ss)
1310       endif
1311     endif
1312   endforeach
1313 endforeach
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],
1319                              capture: true,
1320                              command: [undefsym, nm, '@INPUT@'])
1321 qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
1322                              input: [libqemuutil, softmmu_mods],
1323                              capture: true,
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,
1330                           name_suffix: 'fa',
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(),
1340                         name_suffix: 'fa',
1341                         build_by_default: false)
1343 qmp = declare_dependency(link_whole: [libqmp])
1345 foreach m : block_mods + softmmu_mods
1346   shared_module(m.name(),
1347                 name_prefix: '',
1348                 link_whole: m,
1349                 install: true,
1350                 install_dir: config_host['qemu_moddir'])
1351 endforeach
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(),
1364                             name_suffix: 'fa')
1366 feature_to_c = find_program('scripts/feature_to_c.sh')
1368 emulators = {}
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]]
1374   arch_deps = []
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)
1384   endif
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']
1399   else
1400     abi = config_target['TARGET_ABI_DIR']
1401     target_type='user'
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'])
1406     else
1407       base_dir = 'bsd-user'
1408     endif
1409     target_inc += include_directories(
1410       base_dir,
1411       base_dir / abi,
1412     )
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')
1417         arch_srcs += \
1418           syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
1419                                              extra_args : config_target['TARGET_SYSTBL_ABI'])
1420       endif
1421     endif
1422   endif
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@'],
1429                                 capture: true)
1430     arch_srcs += gdbstub_xml
1431   endif
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,
1448                  objects: objects,
1449                  include_directories: target_inc,
1450                  c_args: c_args,
1451                  build_by_default: false,
1452                  name_suffix: 'fa')
1454   if target.endswith('-softmmu')
1455     execs = [{
1456       'name': 'qemu-system-' + target_name,
1457       'gui': false,
1458       'sources': files('softmmu/main.c'),
1459       'dependencies': []
1460     }]
1461     if targetos == 'windows' and (sdl.found() or gtk.found())
1462       execs += [{
1463         'name': 'qemu-system-' + target_name + 'w',
1464         'gui': true,
1465         'sources': files('softmmu/main.c'),
1466         'dependencies': []
1467       }]
1468     endif
1469     if config_host.has_key('CONFIG_FUZZ')
1470       specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
1471       execs += [{
1472         'name': 'qemu-fuzz-' + target_name,
1473         'gui': false,
1474         'sources': specific_fuzz.sources(),
1475         'dependencies': specific_fuzz.dependencies(),
1476       }]
1477     endif
1478   else
1479     execs = [{
1480       'name': 'qemu-' + target_name,
1481       'gui': false,
1482       'sources': [],
1483       'dependencies': []
1484     }]
1485   endif
1486   foreach exe: execs
1487     emulators += {exe['name']:
1488          executable(exe['name'], exe['sources'],
1489                install: true,
1490                c_args: c_args,
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'])
1497     }
1499     if 'CONFIG_TRACE_SYSTEMTAP' in config_host
1500       foreach stp: [
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},
1505       ]
1506         custom_target(exe['name'] + stp['ext'],
1507                       input: trace_events_all,
1508                       output: exe['name'] + stp['ext'],
1509                       capture: true,
1510                       install: stp['install'],
1511                       install_dir: qemu_datadir / '../systemtap/tapset',
1512                       command: [
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,
1518                         '@INPUT@',
1519                       ])
1520       endforeach
1521     endif
1522   endforeach
1523 endforeach
1525 # Other build targets
1527 if 'CONFIG_PLUGIN' in config_host
1528   install_headers('include/qemu/qemu-plugin.h')
1529 endif
1531 if 'CONFIG_GUEST_AGENT' in config_host
1532   subdir('qga')
1533 endif
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)
1541 endif
1543 if 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,
1557              install: true)
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')
1565   endif
1567   if targetos == 'linux'
1568     executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
1569                dependencies: [qemuutil, libcap_ng],
1570                install: true,
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],
1576                install: true)
1577   endif
1579   if 'CONFIG_IVSHMEM' in config_host
1580     subdir('contrib/ivshmem-client')
1581     subdir('contrib/ivshmem-server')
1582   endif
1583 endif
1585 subdir('scripts')
1586 subdir('tools')
1587 subdir('pc-bios')
1588 subdir('tests')
1589 subdir('docs')
1590 if 'CONFIG_GTK' in config_host
1591   subdir('po')
1592 endif
1594 if host_machine.system() == 'windows'
1595   nsis_cmd = [
1596     find_program('scripts/nsis.py'),
1597     '@OUTPUT@',
1598     get_option('prefix'),
1599     meson.current_source_dir(),
1600     host_machine.cpu_family(),
1601     '--',
1602     '-DDISPLAYVERSION=' + meson.project_version(),
1603   ]
1604   if build_docs
1605     nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
1606   endif
1607   if 'CONFIG_GTK' in config_host
1608     nsis_cmd += '-DCONFIG_GTK=y'
1609   endif
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)
1617 endif
1619 summary_info = {}
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')}
1632 else
1633   summary_info += {'local state directory': 'queried at runtime'}
1634 endif
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]}
1644 else
1645   summary_info += {'C++ compiler':      false}
1646 endif
1647 if targetos == 'darwin'
1648   summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]}
1649 endif
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']}
1662 endif
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')}
1666 endif
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')}
1677 endif
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')}
1694 endif
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')}
1699 endif
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()}
1714 if 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()}
1718 endif
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']}
1722 endif
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')}
1740 endif
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>'}
1762 endif
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']}
1779   endif
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')}
1783 endif
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']}
1825 endif
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)
1832   message()
1833   warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
1834   message()
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.')
1842 endif
1844 if not supported_oses.contains(targetos)
1845   message()
1846   warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
1847   message()
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.')
1855 endif