]> git.proxmox.com Git - mirror_qemu.git/blame - meson.build
meson: Detect libfuse
[mirror_qemu.git] / meson.build
CommitLineData
a5665051 1project('qemu', ['c'], meson_version: '>=0.55.0',
a5cb7c5a
PB
2 default_options: ['warning_level=1', 'c_std=gnu99', 'cpp_std=gnu++11', 'b_colorout=auto'] +
3 (meson.version().version_compare('>=0.56.0') ? [ 'b_staticpic=false' ] : []),
a5665051
PB
4 version: run_command('head', meson.source_root() / 'VERSION').stdout().strip())
5
6not_found = dependency('', required: false)
b29b40f4
PB
7if meson.version().version_compare('>=0.56.0')
8 keyval = import('keyval')
9else
10 keyval = import('unstable-keyval')
11endif
a81df1b6 12ss = import('sourceset')
8b18cdbf 13fs = import('fs')
a81df1b6 14
ce1c1e7a 15sh = find_program('sh')
a81df1b6 16cc = meson.get_compiler('c')
a5665051 17config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
3154fee4 18enable_modules = 'CONFIG_MODULES' in config_host
35be72ba 19enable_static = 'CONFIG_STATIC' in config_host
e3667660
YL
20
21# Temporary directory used for files created while
22# configure runs. Since it is in the build directory
23# we can safely blow away any previous version of it
24# (and we need not jump through hoops to try to delete
25# it when configure exits.)
26tmpdir = meson.current_build_dir() / 'meson-private/temp'
8fe11232
MAL
27
28if get_option('qemu_suffix').startswith('/')
29 error('qemu_suffix cannot start with a /')
30endif
31
16bf7a33 32qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
ab4c0996 33qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
491e74c1 34qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
16bf7a33
PB
35qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
36
37qemu_desktopdir = get_option('datadir') / 'applications'
38qemu_icondir = get_option('datadir') / 'icons'
39
859aef02
PB
40config_host_data = configuration_data()
41genh = []
a5665051 42
760e4327
PB
43target_dirs = config_host['TARGET_DIRS'].split()
44have_user = false
45have_system = false
46foreach target : target_dirs
47 have_user = have_user or target.endswith('-user')
48 have_system = have_system or target.endswith('-softmmu')
49endforeach
50have_tools = 'CONFIG_TOOLS' in config_host
51have_block = have_system or have_tools
52
201e8ed7
PB
53python = import('python').find_installation()
54
55supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
6125673e 56supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv32', 'riscv64', 'x86', 'x86_64',
201e8ed7
PB
57 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
58
59cpu = host_machine.cpu_family()
60targetos = host_machine.system()
61
8a19980e
PB
62if cpu in ['x86', 'x86_64']
63 kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
64elif cpu == 'aarch64'
65 kvm_targets = ['aarch64-softmmu']
66elif cpu == 's390x'
67 kvm_targets = ['s390x-softmmu']
68elif cpu in ['ppc', 'ppc64']
69 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
fbc5884c
HC
70elif cpu in ['mips', 'mips64']
71 kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
8a19980e
PB
72else
73 kvm_targets = []
74endif
75
76accelerator_targets = { 'CONFIG_KVM': kvm_targets }
0c3e41d4
AB
77if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
78 # i368 emulator provides xenpv machine type for multiple architectures
79 accelerator_targets += {
80 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
81 }
82endif
8a19980e
PB
83if cpu in ['x86', 'x86_64']
84 accelerator_targets += {
85 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
8a19980e
PB
86 'CONFIG_HVF': ['x86_64-softmmu'],
87 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
88 }
89endif
90
201e8ed7
PB
91##################
92# Compiler flags #
93##################
94
ff9ed62b
AB
95# Specify linker-script with add_project_link_arguments so that it is not placed
96# within a linker --start-group/--end-group pair
97if 'CONFIG_FUZZ' in config_host
98 add_project_link_arguments(['-Wl,-T,',
99 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
100 native: false, language: ['c', 'cpp', 'objc'])
101endif
102
a5665051
PB
103add_project_arguments(config_host['QEMU_CFLAGS'].split(),
104 native: false, language: ['c', 'objc'])
105add_project_arguments(config_host['QEMU_CXXFLAGS'].split(),
106 native: false, language: 'cpp')
107add_project_link_arguments(config_host['QEMU_LDFLAGS'].split(),
108 native: false, language: ['c', 'cpp', 'objc'])
a5665051 109
1e6e616d
PB
110if targetos == 'linux'
111 add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
112 '-isystem', 'linux-headers',
113 language: ['c', 'cpp'])
114endif
115
116if 'CONFIG_TCG_INTERPRETER' in config_host
117 tcg_arch = 'tci'
118elif config_host['ARCH'] == 'sparc64'
119 tcg_arch = 'sparc'
120elif config_host['ARCH'] == 's390x'
121 tcg_arch = 's390'
122elif config_host['ARCH'] in ['x86_64', 'x32']
123 tcg_arch = 'i386'
124elif config_host['ARCH'] == 'ppc64'
125 tcg_arch = 'ppc'
126elif config_host['ARCH'] in ['riscv32', 'riscv64']
127 tcg_arch = 'riscv'
128else
129 tcg_arch = config_host['ARCH']
130endif
131add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
132 '-iquote', '.',
133 '-iquote', meson.current_source_dir(),
134 '-iquote', meson.current_source_dir() / 'accel/tcg',
135 '-iquote', meson.current_source_dir() / 'include',
136 '-iquote', meson.current_source_dir() / 'disas/libvixl',
137 language: ['c', 'cpp', 'objc'])
c46f76d1 138
fc929892
MAL
139link_language = meson.get_external_property('link_language', 'cpp')
140if link_language == 'cpp'
141 add_languages('cpp', required: true, native: false)
142endif
a5665051
PB
143if host_machine.system() == 'darwin'
144 add_languages('objc', required: false, native: false)
145endif
146
deb62371
PB
147sparse = find_program('cgcc', required: get_option('sparse'))
148if sparse.found()
968b4db3
PB
149 run_target('sparse',
150 command: [find_program('scripts/check_sparse.py'),
deb62371
PB
151 'compile_commands.json', sparse.full_path(), '-Wbitwise',
152 '-Wno-transparent-union', '-Wno-old-initializer',
153 '-Wno-non-pointer-null'])
968b4db3
PB
154endif
155
6ec0e15d
PB
156###########################################
157# Target-specific checks and dependencies #
158###########################################
159
160if targetos != 'linux' and get_option('mpath').enabled()
161 error('Multipath is supported only on Linux')
162endif
163
a81df1b6
PB
164m = cc.find_library('m', required: false)
165util = cc.find_library('util', required: false)
4a96337d 166winmm = []
a81df1b6 167socket = []
04c6f1e7 168version_res = []
d92989aa
MAL
169coref = []
170iokit = []
b6c7cfd4 171emulator_link_args = []
b4e312e9 172cocoa = not_found
8a19980e 173hvf = not_found
a81df1b6
PB
174if targetos == 'windows'
175 socket = cc.find_library('ws2_32')
4a96337d 176 winmm = cc.find_library('winmm')
04c6f1e7
MAL
177
178 win = import('windows')
179 version_res = win.compile_resources('version.rc',
180 depend_files: files('pc-bios/qemu-nsis.ico'),
181 include_directories: include_directories('.'))
d92989aa
MAL
182elif targetos == 'darwin'
183 coref = dependency('appleframeworks', modules: 'CoreFoundation')
184 iokit = dependency('appleframeworks', modules: 'IOKit')
b4e312e9 185 cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
cfad62f1
PB
186elif targetos == 'sunos'
187 socket = [cc.find_library('socket'),
188 cc.find_library('nsl'),
189 cc.find_library('resolv')]
190elif targetos == 'haiku'
191 socket = [cc.find_library('posix_error_mapper'),
192 cc.find_library('network'),
193 cc.find_library('bsd')]
b6c7cfd4
PB
194elif targetos == 'openbsd'
195 if not get_option('tcg').disabled() and target_dirs.length() > 0
196 # Disable OpenBSD W^X if available
197 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
198 endif
a81df1b6 199endif
6ec0e15d 200
8a19980e
PB
201accelerators = []
202if not get_option('kvm').disabled() and targetos == 'linux'
203 accelerators += 'CONFIG_KVM'
204endif
205if not get_option('xen').disabled() and 'CONFIG_XEN_BACKEND' in config_host
206 accelerators += 'CONFIG_XEN'
207 have_xen_pci_passthrough = not get_option('xen_pci_passthrough').disabled() and targetos == 'linux'
208else
209 have_xen_pci_passthrough = false
210endif
211if not get_option('whpx').disabled() and targetos == 'windows'
57e2a1f8 212 if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
8a19980e
PB
213 error('WHPX requires 64-bit host')
214 elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
215 cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
216 accelerators += 'CONFIG_WHPX'
217 endif
218endif
219if not get_option('hvf').disabled()
220 hvf = dependency('appleframeworks', modules: 'Hypervisor',
221 required: get_option('hvf'))
222 if hvf.found()
223 accelerators += 'CONFIG_HVF'
224 endif
225endif
226if not get_option('hax').disabled()
227 if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
228 accelerators += 'CONFIG_HAX'
229 endif
230endif
231if not get_option('tcg').disabled()
232 if cpu not in supported_cpus
233 if 'CONFIG_TCG_INTERPRETER' in config_host
234 warning('Unsupported CPU @0@, will use TCG with TCI (experimental)'.format(cpu))
235 else
236 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
237 endif
238 endif
239 accelerators += 'CONFIG_TCG'
240 config_host += { 'CONFIG_TCG': 'y' }
241endif
242
243if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
244 error('KVM not available on this platform')
245endif
246if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
247 error('HVF not available on this platform')
248endif
249if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
250 error('WHPX not available on this platform')
251endif
252if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
253 if 'CONFIG_XEN' in accelerators
254 error('Xen PCI passthrough not available on this platform')
255 else
256 error('Xen PCI passthrough requested but Xen not enabled')
257 endif
258endif
b4e312e9
PB
259if not cocoa.found() and get_option('cocoa').enabled()
260 error('Cocoa not available on this platform')
261endif
262
6ec0e15d
PB
263################
264# Dependencies #
265################
266
215b0c2f
PB
267# The path to glib.h is added to all compilation commands. This was
268# grandfathered in from the QEMU Makefiles.
269add_project_arguments(config_host['GLIB_CFLAGS'].split(),
270 native: false, language: ['c', 'cpp', 'objc'])
271glib = declare_dependency(link_args: config_host['GLIB_LIBS'].split())
a81df1b6
PB
272gio = not_found
273if 'CONFIG_GIO' in config_host
274 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
275 link_args: config_host['GIO_LIBS'].split())
276endif
277lttng = not_found
278if 'CONFIG_TRACE_UST' in config_host
279 lttng = declare_dependency(link_args: config_host['LTTNG_UST_LIBS'].split())
280endif
281urcubp = not_found
282if 'CONFIG_TRACE_UST' in config_host
283 urcubp = declare_dependency(link_args: config_host['URCU_BP_LIBS'].split())
284endif
46859d93
DB
285gcrypt = not_found
286if 'CONFIG_GCRYPT' in config_host
287 gcrypt = declare_dependency(compile_args: config_host['GCRYPT_CFLAGS'].split(),
288 link_args: config_host['GCRYPT_LIBS'].split())
289endif
a81df1b6
PB
290nettle = not_found
291if 'CONFIG_NETTLE' in config_host
292 nettle = declare_dependency(compile_args: config_host['NETTLE_CFLAGS'].split(),
293 link_args: config_host['NETTLE_LIBS'].split())
294endif
295gnutls = not_found
296if 'CONFIG_GNUTLS' in config_host
297 gnutls = declare_dependency(compile_args: config_host['GNUTLS_CFLAGS'].split(),
298 link_args: config_host['GNUTLS_LIBS'].split())
299endif
b7612f45
PB
300pixman = not_found
301if have_system or have_tools
302 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
1a94933f 303 method: 'pkg-config', static: enable_static)
b7612f45 304endif
5e7fbd25
MAL
305pam = not_found
306if 'CONFIG_AUTH_PAM' in config_host
307 pam = cc.find_library('pam')
308endif
5e5733e5 309libaio = cc.find_library('aio', required: false)
1ffb3bbb 310zlib = dependency('zlib', required: true, static: enable_static)
5e5733e5
MAL
311linux_io_uring = not_found
312if 'CONFIG_LINUX_IO_URING' in config_host
313 linux_io_uring = declare_dependency(compile_args: config_host['LINUX_IO_URING_CFLAGS'].split(),
314 link_args: config_host['LINUX_IO_URING_LIBS'].split())
315endif
316libxml2 = not_found
317if 'CONFIG_LIBXML2' in config_host
318 libxml2 = declare_dependency(compile_args: config_host['LIBXML2_CFLAGS'].split(),
319 link_args: config_host['LIBXML2_LIBS'].split())
320endif
321libnfs = not_found
322if 'CONFIG_LIBNFS' in config_host
323 libnfs = declare_dependency(link_args: config_host['LIBNFS_LIBS'].split())
324endif
ec0d5893
MAL
325libattr = not_found
326if 'CONFIG_ATTR' in config_host
327 libattr = declare_dependency(link_args: config_host['LIBATTR_LIBS'].split())
328endif
3f99cf57
PB
329seccomp = not_found
330if 'CONFIG_SECCOMP' in config_host
331 seccomp = declare_dependency(compile_args: config_host['SECCOMP_CFLAGS'].split(),
332 link_args: config_host['SECCOMP_LIBS'].split())
333endif
334libcap_ng = not_found
335if 'CONFIG_LIBCAP_NG' in config_host
336 libcap_ng = declare_dependency(link_args: config_host['LIBCAP_NG_LIBS'].split())
337endif
1917ec6d
PB
338if get_option('xkbcommon').auto() and not have_system and not have_tools
339 xkbcommon = not_found
340else
341 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
1a94933f 342 method: 'pkg-config', static: enable_static)
ade60d4f 343endif
cdaf0722
MAL
344vde = not_found
345if config_host.has_key('CONFIG_VDE')
346 vde = declare_dependency(link_args: config_host['VDE_LIBS'].split())
347endif
478e943f
PB
348pulse = not_found
349if 'CONFIG_LIBPULSE' in config_host
350 pulse = declare_dependency(compile_args: config_host['PULSE_CFLAGS'].split(),
351 link_args: config_host['PULSE_LIBS'].split())
352endif
353alsa = not_found
354if 'CONFIG_ALSA' in config_host
355 alsa = declare_dependency(compile_args: config_host['ALSA_CFLAGS'].split(),
356 link_args: config_host['ALSA_LIBS'].split())
357endif
358jack = not_found
359if 'CONFIG_LIBJACK' in config_host
360 jack = declare_dependency(link_args: config_host['JACK_LIBS'].split())
361endif
2634733c 362spice = not_found
d72c34cc 363spice_headers = not_found
2634733c
PB
364if 'CONFIG_SPICE' in config_host
365 spice = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split(),
366 link_args: config_host['SPICE_LIBS'].split())
d72c34cc 367 spice_headers = declare_dependency(compile_args: config_host['SPICE_CFLAGS'].split())
2634733c 368endif
5ee24e78 369rt = cc.find_library('rt', required: false)
ccf7afa5
PB
370libdl = not_found
371if 'CONFIG_PLUGIN' in config_host
372 libdl = cc.find_library('dl', required: true)
373endif
99650b62
PB
374libiscsi = not_found
375if 'CONFIG_LIBISCSI' in config_host
376 libiscsi = declare_dependency(compile_args: config_host['LIBISCSI_CFLAGS'].split(),
377 link_args: config_host['LIBISCSI_LIBS'].split())
378endif
5e5733e5
MAL
379zstd = not_found
380if 'CONFIG_ZSTD' in config_host
381 zstd = declare_dependency(compile_args: config_host['ZSTD_CFLAGS'].split(),
382 link_args: config_host['ZSTD_LIBS'].split())
383endif
ea458960
MAL
384gbm = not_found
385if 'CONFIG_GBM' in config_host
386 gbm = declare_dependency(compile_args: config_host['GBM_CFLAGS'].split(),
387 link_args: config_host['GBM_LIBS'].split())
388endif
389virgl = not_found
390if 'CONFIG_VIRGL' in config_host
391 virgl = declare_dependency(compile_args: config_host['VIRGL_CFLAGS'].split(),
392 link_args: config_host['VIRGL_LIBS'].split())
393endif
1d7bb6ab
MAL
394curl = not_found
395if 'CONFIG_CURL' in config_host
396 curl = declare_dependency(compile_args: config_host['CURL_CFLAGS'].split(),
397 link_args: config_host['CURL_LIBS'].split())
398endif
f15bff25 399libudev = not_found
f01496a3 400if targetos == 'linux' and (have_system or have_tools)
6ec0e15d 401 libudev = dependency('libudev',
5c53015a 402 required: get_option('libudev'),
6ec0e15d
PB
403 static: enable_static)
404endif
405
5c53015a 406mpathlibs = [libudev]
6ec0e15d
PB
407mpathpersist = not_found
408mpathpersist_new_api = false
409if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
410 mpath_test_source_new = '''
411 #include <libudev.h>
412 #include <mpath_persist.h>
413 unsigned mpath_mx_alloc_len = 1024;
414 int logsink;
415 static struct config *multipath_conf;
416 extern struct udev *udev;
417 extern struct config *get_multipath_config(void);
418 extern void put_multipath_config(struct config *conf);
419 struct udev *udev;
420 struct config *get_multipath_config(void) { return multipath_conf; }
421 void put_multipath_config(struct config *conf) { }
422 int main(void) {
423 udev = udev_new();
424 multipath_conf = mpath_lib_init();
425 return 0;
426 }'''
427 mpath_test_source_old = '''
428 #include <libudev.h>
429 #include <mpath_persist.h>
430 unsigned mpath_mx_alloc_len = 1024;
431 int logsink;
432 int main(void) {
433 struct udev *udev = udev_new();
434 mpath_lib_init(udev);
435 return 0;
436 }'''
5c53015a
PB
437 libmpathpersist = cc.find_library('mpathpersist',
438 required: get_option('mpath'),
439 static: enable_static)
440 if libmpathpersist.found()
441 mpathlibs += libmpathpersist
442 if enable_static
443 mpathlibs += cc.find_library('devmapper',
444 required: get_option('mpath'),
445 static: enable_static)
43b43a40 446 endif
5c53015a
PB
447 mpathlibs += cc.find_library('multipath',
448 required: get_option('mpath'),
449 static: enable_static)
450 foreach lib: mpathlibs
451 if not lib.found()
452 mpathlibs = []
453 break
454 endif
455 endforeach
456 if mpathlibs.length() == 0
457 msg = 'Dependencies missing for libmpathpersist'
458 elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
6ec0e15d
PB
459 mpathpersist = declare_dependency(dependencies: mpathlibs)
460 mpathpersist_new_api = true
461 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
462 mpathpersist = declare_dependency(dependencies: mpathlibs)
463 else
5c53015a
PB
464 msg = 'Cannot detect libmpathpersist API'
465 endif
466 if not mpathpersist.found()
6ec0e15d 467 if get_option('mpath').enabled()
5c53015a 468 error(msg)
6ec0e15d 469 else
5c53015a 470 warning(msg + ', disabling')
6ec0e15d
PB
471 endif
472 endif
473 endif
f15bff25 474endif
6ec0e15d 475
5285e593 476iconv = not_found
5285e593 477curses = not_found
30fe76b1 478if have_system and not get_option('curses').disabled()
925a40df
PB
479 curses_test = '''
480 #include <locale.h>
481 #include <curses.h>
482 #include <wchar.h>
483 int main(void) {
484 wchar_t wch = L'w';
485 setlocale(LC_ALL, "");
486 resize_term(0, 0);
487 addwstr(L"wide chars\n");
488 addnwstr(&wch, 1);
489 add_wch(WACS_DEGREE);
490 return 0;
491 }'''
492
ca31e307
YL
493 curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
494 foreach curses_dep : curses_dep_list
495 if not curses.found()
496 curses = dependency(curses_dep,
497 required: false,
498 method: 'pkg-config',
499 static: enable_static)
500 endif
501 endforeach
925a40df
PB
502 msg = get_option('curses').enabled() ? 'curses library not found' : ''
503 if curses.found()
504 if cc.links(curses_test, dependencies: [curses])
505 curses = declare_dependency(compile_args: '-DNCURSES_WIDECHAR', dependencies: [curses])
506 else
507 msg = 'curses package not usable'
508 curses = not_found
5285e593
YL
509 endif
510 endif
925a40df
PB
511 if not curses.found()
512 curses_compile_args = ['-DNCURSES_WIDECHAR']
513 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
514 if targetos != 'windows' and not has_curses_h
515 message('Trying with /usr/include/ncursesw')
516 curses_compile_args += ['-I/usr/include/ncursesw']
517 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
518 endif
519 if has_curses_h
520 curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
521 foreach curses_libname : curses_libname_list
5285e593
YL
522 libcurses = cc.find_library(curses_libname,
523 required: false,
5285e593 524 static: enable_static)
925a40df
PB
525 if libcurses.found()
526 if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
527 curses = declare_dependency(compile_args: curses_compile_args,
528 dependencies: [libcurses])
529 break
530 else
531 msg = 'curses library not usable'
532 endif
5285e593 533 endif
925a40df
PB
534 endforeach
535 endif
536 endif
537 if not get_option('iconv').disabled()
538 foreach link_args : [ ['-liconv'], [] ]
539 # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
540 # We need to use libiconv if available because mixing libiconv's headers with
541 # the system libc does not work.
542 # However, without adding glib to the dependencies -L/usr/local/lib will not be
543 # included in the command line and libiconv will not be found.
544 if cc.links('''
545 #include <iconv.h>
546 int main(void) {
547 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
548 return conv != (iconv_t) -1;
549 }''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
550 iconv = declare_dependency(link_args: link_args, dependencies: glib)
551 break
5285e593 552 endif
30fe76b1
PB
553 endforeach
554 endif
925a40df
PB
555 if curses.found() and not iconv.found()
556 if get_option('iconv').enabled()
557 error('iconv not available')
558 endif
559 msg = 'iconv required for curses UI but not available'
560 curses = not_found
561 endif
562 if not curses.found() and msg != ''
563 if get_option('curses').enabled()
564 error(msg)
30fe76b1 565 else
925a40df 566 warning(msg + ', disabling')
30fe76b1 567 endif
5285e593
YL
568 endif
569endif
570
2634733c
PB
571brlapi = not_found
572if 'CONFIG_BRLAPI' in config_host
573 brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
574endif
35be72ba 575
760e4327
PB
576sdl = not_found
577if have_system
363743da 578 sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static)
760e4327
PB
579 sdl_image = not_found
580endif
35be72ba
PB
581if sdl.found()
582 # work around 2.0.8 bug
583 sdl = declare_dependency(compile_args: '-Wno-undef',
584 dependencies: sdl)
7161a433 585 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
1a94933f 586 method: 'pkg-config', static: enable_static)
35be72ba
PB
587else
588 if get_option('sdl_image').enabled()
a8dc2ace
ST
589 error('sdl-image required, but SDL was @0@'.format(
590 get_option('sdl').disabled() ? 'disabled' : 'not found'))
35be72ba
PB
591 endif
592 sdl_image = not_found
2634733c 593endif
35be72ba 594
5e5733e5
MAL
595rbd = not_found
596if 'CONFIG_RBD' in config_host
597 rbd = declare_dependency(link_args: config_host['RBD_LIBS'].split())
598endif
599glusterfs = not_found
600if 'CONFIG_GLUSTERFS' in config_host
601 glusterfs = declare_dependency(compile_args: config_host['GLUSTERFS_CFLAGS'].split(),
602 link_args: config_host['GLUSTERFS_LIBS'].split())
603endif
604libssh = not_found
605if 'CONFIG_LIBSSH' in config_host
606 libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
607 link_args: config_host['LIBSSH_LIBS'].split())
608endif
609libbzip2 = not_found
610if 'CONFIG_BZIP2' in config_host
611 libbzip2 = declare_dependency(link_args: config_host['BZIP2_LIBS'].split())
612endif
613liblzfse = not_found
614if 'CONFIG_LZFSE' in config_host
615 liblzfse = declare_dependency(link_args: config_host['LZFSE_LIBS'].split())
616endif
478e943f
PB
617oss = not_found
618if 'CONFIG_AUDIO_OSS' in config_host
619 oss = declare_dependency(link_args: config_host['OSS_LIBS'].split())
620endif
621dsound = not_found
622if 'CONFIG_AUDIO_DSOUND' in config_host
623 dsound = declare_dependency(link_args: config_host['DSOUND_LIBS'].split())
624endif
625coreaudio = not_found
626if 'CONFIG_AUDIO_COREAUDIO' in config_host
627 coreaudio = declare_dependency(link_args: config_host['COREAUDIO_LIBS'].split())
2b1ccdf4
MAL
628endif
629opengl = not_found
630if 'CONFIG_OPENGL' in config_host
de2d3005
PB
631 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
632 link_args: config_host['OPENGL_LIBS'].split())
2b1ccdf4
MAL
633endif
634gtk = not_found
635if 'CONFIG_GTK' in config_host
636 gtk = declare_dependency(compile_args: config_host['GTK_CFLAGS'].split(),
637 link_args: config_host['GTK_LIBS'].split())
638endif
639vte = not_found
640if 'CONFIG_VTE' in config_host
641 vte = declare_dependency(compile_args: config_host['VTE_CFLAGS'].split(),
642 link_args: config_host['VTE_LIBS'].split())
643endif
644x11 = not_found
645if 'CONFIG_X11' in config_host
646 x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
647 link_args: config_host['X11_LIBS'].split())
648endif
a0b93237 649vnc = not_found
2b1ccdf4 650png = not_found
2b1ccdf4 651jpeg = not_found
2b1ccdf4 652sasl = not_found
a0b93237
PB
653if get_option('vnc').enabled()
654 vnc = declare_dependency() # dummy dependency
655 png = dependency('libpng', required: get_option('vnc_png'),
1a94933f 656 method: 'pkg-config', static: enable_static)
8e242b3c
PB
657 jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
658 method: 'pkg-config', static: enable_static)
a0b93237
PB
659 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
660 required: get_option('vnc_sasl'),
661 static: enable_static)
662 if sasl.found()
663 sasl = declare_dependency(dependencies: sasl,
664 compile_args: '-DSTRUCT_IOVEC_DEFINED')
665 endif
478e943f 666endif
708eab42
MAL
667snappy = not_found
668if 'CONFIG_SNAPPY' in config_host
669 snappy = declare_dependency(link_args: config_host['SNAPPY_LIBS'].split())
670endif
671lzo = not_found
672if 'CONFIG_LZO' in config_host
673 lzo = declare_dependency(link_args: config_host['LZO_LIBS'].split())
674endif
55166230
MAL
675rdma = not_found
676if 'CONFIG_RDMA' in config_host
677 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
678endif
ab318051
MAL
679numa = not_found
680if 'CONFIG_NUMA' in config_host
681 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
682endif
582ea95f
MAL
683xen = not_found
684if 'CONFIG_XEN_BACKEND' in config_host
685 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
686 link_args: config_host['XEN_LIBS'].split())
687endif
06677ce1
PB
688cacard = not_found
689if 'CONFIG_SMARTCARD' in config_host
690 cacard = declare_dependency(compile_args: config_host['SMARTCARD_CFLAGS'].split(),
691 link_args: config_host['SMARTCARD_LIBS'].split())
692endif
0a40bcb7
CB
693u2f = not_found
694if have_system
695 u2f = dependency('u2f-emu', required: get_option('u2f'),
696 method: 'pkg-config',
697 static: enable_static)
698endif
06677ce1
PB
699usbredir = not_found
700if 'CONFIG_USB_REDIR' in config_host
701 usbredir = declare_dependency(compile_args: config_host['USB_REDIR_CFLAGS'].split(),
702 link_args: config_host['USB_REDIR_LIBS'].split())
703endif
704libusb = not_found
705if 'CONFIG_USB_LIBUSB' in config_host
706 libusb = declare_dependency(compile_args: config_host['LIBUSB_CFLAGS'].split(),
707 link_args: config_host['LIBUSB_LIBS'].split())
708endif
c9322ab5
MAL
709libpmem = not_found
710if 'CONFIG_LIBPMEM' in config_host
711 libpmem = declare_dependency(compile_args: config_host['LIBPMEM_CFLAGS'].split(),
712 link_args: config_host['LIBPMEM_LIBS'].split())
713endif
c7c91a74
BR
714libdaxctl = not_found
715if 'CONFIG_LIBDAXCTL' in config_host
716 libdaxctl = declare_dependency(link_args: config_host['LIBDAXCTL_LIBS'].split())
717endif
8ce0a45f
MAL
718tasn1 = not_found
719if 'CONFIG_TASN1' in config_host
720 tasn1 = declare_dependency(compile_args: config_host['TASN1_CFLAGS'].split(),
721 link_args: config_host['TASN1_LIBS'].split())
722endif
af04e89d
MAL
723keyutils = dependency('libkeyutils', required: false,
724 method: 'pkg-config', static: enable_static)
a81df1b6 725
3909def8
MAL
726has_gettid = cc.has_function('gettid')
727
aa087962
PB
728# Malloc tests
729
730malloc = []
731if get_option('malloc') == 'system'
732 has_malloc_trim = \
733 not get_option('malloc_trim').disabled() and \
734 cc.links('''#include <malloc.h>
735 int main(void) { malloc_trim(0); return 0; }''')
736else
737 has_malloc_trim = false
738 malloc = cc.find_library(get_option('malloc'), required: true)
739endif
740if not has_malloc_trim and get_option('malloc_trim').enabled()
741 if get_option('malloc') == 'system'
742 error('malloc_trim not available on this platform.')
743 else
744 error('malloc_trim not available with non-libc memory allocator')
745 endif
746endif
747
84e319a5
HR
748# Check whether the glibc provides statx()
749
750statx_test = '''
751 #ifndef _GNU_SOURCE
752 #define _GNU_SOURCE
753 #endif
754 #include <sys/stat.h>
755 int main(void) {
756 struct statx statxbuf;
757 statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
758 return 0;
759 }'''
760
761has_statx = cc.links(statx_test)
762
eb6a3886
SH
763have_vhost_user_blk_server = (targetos == 'linux' and
764 'CONFIG_VHOST_USER' in config_host)
e5e856c1
SH
765
766if get_option('vhost_user_blk_server').enabled()
767 if targetos != 'linux'
768 error('vhost_user_blk_server requires linux')
eb6a3886
SH
769 elif 'CONFIG_VHOST_USER' not in config_host
770 error('vhost_user_blk_server requires vhost-user support')
e5e856c1
SH
771 endif
772elif get_option('vhost_user_blk_server').disabled() or not have_system
773 have_vhost_user_blk_server = false
774endif
775
a484a719
HR
776fuse = dependency('fuse3', required: get_option('fuse'),
777 version: '>=3.1', method: 'pkg-config',
778 static: enable_static)
779
a0c9162c
PB
780#################
781# config-host.h #
782#################
859aef02 783
16bf7a33
PB
784config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
785config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
786config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
787config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
788config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
789config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
790config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
791config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
792config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
793config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
794config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
795config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
796
b4e312e9 797config_host_data.set('CONFIG_COCOA', cocoa.found())
f01496a3 798config_host_data.set('CONFIG_LIBUDEV', libudev.found())
6ec0e15d
PB
799config_host_data.set('CONFIG_MPATH', mpathpersist.found())
800config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
5285e593 801config_host_data.set('CONFIG_CURSES', curses.found())
35be72ba
PB
802config_host_data.set('CONFIG_SDL', sdl.found())
803config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
e5e856c1 804config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
a0b93237
PB
805config_host_data.set('CONFIG_VNC', vnc.found())
806config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
807config_host_data.set('CONFIG_VNC_PNG', png.found())
808config_host_data.set('CONFIG_VNC_SASL', sasl.found())
4113f4cf 809config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
af04e89d 810config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
3909def8 811config_host_data.set('CONFIG_GETTID', has_gettid)
aa087962 812config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
84e319a5 813config_host_data.set('CONFIG_STATX', has_statx)
a484a719 814config_host_data.set('CONFIG_FUSE', fuse.found())
859aef02
PB
815config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
816config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
817config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
818config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
819
ded5d78c
TH
820config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
821
765686d6 822ignored = ['CONFIG_QEMU_INTERP_PREFIX'] # actually per-target
859aef02 823arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
16bf7a33 824strings = ['HOST_DSOSUF', 'CONFIG_IASL']
859aef02 825foreach k, v: config_host
765686d6
PB
826 if ignored.contains(k)
827 # do nothing
828 elif arrays.contains(k)
859aef02
PB
829 if v != ''
830 v = '"' + '", "'.join(v.split()) + '", '
831 endif
832 config_host_data.set(k, v)
833 elif k == 'ARCH'
834 config_host_data.set('HOST_' + v.to_upper(), 1)
835 elif strings.contains(k)
836 if not k.startswith('CONFIG_')
837 k = 'CONFIG_' + k.to_upper()
838 endif
839 config_host_data.set_quoted(k, v)
840 elif k.startswith('CONFIG_') or k.startswith('HAVE_') or k.startswith('HOST_')
841 config_host_data.set(k, v == 'y' ? 1 : v)
842 endif
843endforeach
859aef02 844
a0c9162c
PB
845########################
846# Target configuration #
847########################
848
2becc36a 849minikconf = find_program('scripts/minikconf.py')
05512f55 850config_all = {}
a98006bc 851config_all_devices = {}
ca0fc784 852config_all_disas = {}
2becc36a
PB
853config_devices_mak_list = []
854config_devices_h = {}
859aef02 855config_target_h = {}
2becc36a 856config_target_mak = {}
ca0fc784
PB
857
858disassemblers = {
859 'alpha' : ['CONFIG_ALPHA_DIS'],
860 'arm' : ['CONFIG_ARM_DIS'],
861 'avr' : ['CONFIG_AVR_DIS'],
862 'cris' : ['CONFIG_CRIS_DIS'],
863 'hppa' : ['CONFIG_HPPA_DIS'],
864 'i386' : ['CONFIG_I386_DIS'],
865 'x86_64' : ['CONFIG_I386_DIS'],
866 'x32' : ['CONFIG_I386_DIS'],
867 'lm32' : ['CONFIG_LM32_DIS'],
868 'm68k' : ['CONFIG_M68K_DIS'],
869 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
870 'mips' : ['CONFIG_MIPS_DIS'],
871 'moxie' : ['CONFIG_MOXIE_DIS'],
872 'nios2' : ['CONFIG_NIOS2_DIS'],
873 'or1k' : ['CONFIG_OPENRISC_DIS'],
874 'ppc' : ['CONFIG_PPC_DIS'],
875 'riscv' : ['CONFIG_RISCV_DIS'],
876 'rx' : ['CONFIG_RX_DIS'],
877 's390' : ['CONFIG_S390_DIS'],
878 'sh4' : ['CONFIG_SH4_DIS'],
879 'sparc' : ['CONFIG_SPARC_DIS'],
880 'xtensa' : ['CONFIG_XTENSA_DIS'],
881}
882if link_language == 'cpp'
883 disassemblers += {
884 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
885 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
886 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
887 }
888endif
889
2becc36a
PB
890kconfig_external_symbols = [
891 'CONFIG_KVM',
892 'CONFIG_XEN',
893 'CONFIG_TPM',
894 'CONFIG_SPICE',
895 'CONFIG_IVSHMEM',
896 'CONFIG_OPENGL',
897 'CONFIG_X11',
898 'CONFIG_VHOST_USER',
40bc0ca9 899 'CONFIG_VHOST_VDPA',
2becc36a
PB
900 'CONFIG_VHOST_KERNEL',
901 'CONFIG_VIRTFS',
902 'CONFIG_LINUX',
903 'CONFIG_PVRDMA',
904]
a9a74907 905ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
05512f55 906
fdb75aef
PB
907default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
908actual_target_dirs = []
fbb4121d 909fdt_required = []
a81df1b6 910foreach target : target_dirs
765686d6
PB
911 config_target = { 'TARGET_NAME': target.split('-')[0] }
912 if target.endswith('linux-user')
fdb75aef
PB
913 if targetos != 'linux'
914 if default_targets
915 continue
916 endif
917 error('Target @0@ is only available on a Linux host'.format(target))
918 endif
765686d6
PB
919 config_target += { 'CONFIG_LINUX_USER': 'y' }
920 elif target.endswith('bsd-user')
fdb75aef
PB
921 if 'CONFIG_BSD' not in config_host
922 if default_targets
923 continue
924 endif
925 error('Target @0@ is only available on a BSD host'.format(target))
926 endif
765686d6
PB
927 config_target += { 'CONFIG_BSD_USER': 'y' }
928 elif target.endswith('softmmu')
929 config_target += { 'CONFIG_SOFTMMU': 'y' }
930 endif
931 if target.endswith('-user')
932 config_target += {
933 'CONFIG_USER_ONLY': 'y',
934 'CONFIG_QEMU_INTERP_PREFIX':
935 config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
936 }
937 endif
859aef02 938
8a19980e
PB
939 have_accel = false
940 foreach sym: accelerators
941 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
942 config_target += { sym: 'y' }
943 config_all += { sym: 'y' }
944 if sym == 'CONFIG_XEN' and have_xen_pci_passthrough
945 config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
946 endif
947 have_accel = true
948 endif
949 endforeach
fdb75aef
PB
950 if not have_accel
951 if default_targets
952 continue
953 endif
954 error('No accelerator available for target @0@'.format(target))
955 endif
8a19980e 956
fdb75aef 957 actual_target_dirs += target
765686d6 958 config_target += keyval.load('default-configs/targets' / target + '.mak')
a9a74907 959 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
765686d6 960
fbb4121d
PB
961 if 'TARGET_NEED_FDT' in config_target
962 fdt_required += target
963 endif
964
fa73168b
PB
965 # Add default keys
966 if 'TARGET_BASE_ARCH' not in config_target
967 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
968 endif
969 if 'TARGET_ABI_DIR' not in config_target
970 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
971 endif
859aef02 972
ca0fc784
PB
973 foreach k, v: disassemblers
974 if config_host['ARCH'].startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
975 foreach sym: v
976 config_target += { sym: 'y' }
977 config_all_disas += { sym: 'y' }
978 endforeach
979 endif
980 endforeach
981
859aef02
PB
982 config_target_data = configuration_data()
983 foreach k, v: config_target
984 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
985 # do nothing
986 elif ignored.contains(k)
987 # do nothing
988 elif k == 'TARGET_BASE_ARCH'
a9a74907
PB
989 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
990 # not used to select files from sourcesets.
859aef02 991 config_target_data.set('TARGET_' + v.to_upper(), 1)
765686d6 992 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
859aef02
PB
993 config_target_data.set_quoted(k, v)
994 elif v == 'y'
995 config_target_data.set(k, 1)
996 else
997 config_target_data.set(k, v)
998 endif
999 endforeach
1000 config_target_h += {target: configure_file(output: target + '-config-target.h',
1001 configuration: config_target_data)}
2becc36a
PB
1002
1003 if target.endswith('-softmmu')
2becc36a
PB
1004 base_kconfig = []
1005 foreach sym : kconfig_external_symbols
859aef02 1006 if sym in config_target or sym in config_host
2becc36a
PB
1007 base_kconfig += '@0@=y'.format(sym)
1008 endif
1009 endforeach
1010
1011 config_devices_mak = target + '-config-devices.mak'
1012 config_devices_mak = configure_file(
1bb4cb1c 1013 input: ['default-configs/devices' / target + '.mak', 'Kconfig'],
2becc36a
PB
1014 output: config_devices_mak,
1015 depfile: config_devices_mak + '.d',
1016 capture: true,
1017 command: [minikconf, config_host['CONFIG_MINIKCONF_MODE'],
1018 config_devices_mak, '@DEPFILE@', '@INPUT@',
1019 base_kconfig])
859aef02
PB
1020
1021 config_devices_data = configuration_data()
1022 config_devices = keyval.load(config_devices_mak)
1023 foreach k, v: config_devices
1024 config_devices_data.set(k, 1)
1025 endforeach
2becc36a 1026 config_devices_mak_list += config_devices_mak
859aef02
PB
1027 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
1028 configuration: config_devices_data)}
1029 config_target += config_devices
a98006bc 1030 config_all_devices += config_devices
2becc36a
PB
1031 endif
1032 config_target_mak += {target: config_target}
a81df1b6 1033endforeach
fdb75aef 1034target_dirs = actual_target_dirs
a81df1b6 1035
2becc36a
PB
1036# This configuration is used to build files that are shared by
1037# multiple binaries, and then extracted out of the "common"
1038# static_library target.
1039#
1040# We do not use all_sources()/all_dependencies(), because it would
1041# build literally all source files, including devices only used by
1042# targets that are not built for this compilation. The CONFIG_ALL
1043# pseudo symbol replaces it.
1044
05512f55 1045config_all += config_all_devices
2becc36a
PB
1046config_all += config_host
1047config_all += config_all_disas
1048config_all += {
1049 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
1050 'CONFIG_SOFTMMU': have_system,
1051 'CONFIG_USER_ONLY': have_user,
1052 'CONFIG_ALL': true,
1053}
1054
a0c9162c
PB
1055##############
1056# Submodules #
1057##############
8b18cdbf
RH
1058
1059capstone = not_found
1060capstone_opt = get_option('capstone')
1061if capstone_opt in ['enabled', 'auto', 'system']
1062 have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
bcf36862
RH
1063 capstone = dependency('capstone', version: '>=4.0',
1064 static: enable_static, method: 'pkg-config',
8b18cdbf
RH
1065 required: capstone_opt == 'system' or
1066 capstone_opt == 'enabled' and not have_internal)
1067 if capstone.found()
1068 capstone_opt = 'system'
1069 elif have_internal
1070 capstone_opt = 'internal'
1071 else
1072 capstone_opt = 'disabled'
1073 endif
1074endif
1075if capstone_opt == 'internal'
1076 capstone_data = configuration_data()
1077 capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
1078
1079 capstone_files = files(
1080 'capstone/cs.c',
1081 'capstone/MCInst.c',
1082 'capstone/MCInstrDesc.c',
1083 'capstone/MCRegisterInfo.c',
1084 'capstone/SStream.c',
1085 'capstone/utils.c'
1086 )
1087
1088 if 'CONFIG_ARM_DIS' in config_all_disas
1089 capstone_data.set('CAPSTONE_HAS_ARM', '1')
1090 capstone_files += files(
1091 'capstone/arch/ARM/ARMDisassembler.c',
1092 'capstone/arch/ARM/ARMInstPrinter.c',
1093 'capstone/arch/ARM/ARMMapping.c',
1094 'capstone/arch/ARM/ARMModule.c'
1095 )
1096 endif
1097
1098 # FIXME: This config entry currently depends on a c++ compiler.
1099 # Which is needed for building libvixl, but not for capstone.
1100 if 'CONFIG_ARM_A64_DIS' in config_all_disas
1101 capstone_data.set('CAPSTONE_HAS_ARM64', '1')
1102 capstone_files += files(
1103 'capstone/arch/AArch64/AArch64BaseInfo.c',
1104 'capstone/arch/AArch64/AArch64Disassembler.c',
1105 'capstone/arch/AArch64/AArch64InstPrinter.c',
1106 'capstone/arch/AArch64/AArch64Mapping.c',
1107 'capstone/arch/AArch64/AArch64Module.c'
1108 )
1109 endif
1110
1111 if 'CONFIG_PPC_DIS' in config_all_disas
1112 capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
1113 capstone_files += files(
1114 'capstone/arch/PowerPC/PPCDisassembler.c',
1115 'capstone/arch/PowerPC/PPCInstPrinter.c',
1116 'capstone/arch/PowerPC/PPCMapping.c',
1117 'capstone/arch/PowerPC/PPCModule.c'
1118 )
1119 endif
1120
3d562845
RH
1121 if 'CONFIG_S390_DIS' in config_all_disas
1122 capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
1123 capstone_files += files(
1124 'capstone/arch/SystemZ/SystemZDisassembler.c',
1125 'capstone/arch/SystemZ/SystemZInstPrinter.c',
1126 'capstone/arch/SystemZ/SystemZMapping.c',
1127 'capstone/arch/SystemZ/SystemZModule.c',
1128 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
1129 )
1130 endif
1131
8b18cdbf
RH
1132 if 'CONFIG_I386_DIS' in config_all_disas
1133 capstone_data.set('CAPSTONE_HAS_X86', 1)
1134 capstone_files += files(
1135 'capstone/arch/X86/X86Disassembler.c',
1136 'capstone/arch/X86/X86DisassemblerDecoder.c',
1137 'capstone/arch/X86/X86ATTInstPrinter.c',
1138 'capstone/arch/X86/X86IntelInstPrinter.c',
eef20e40 1139 'capstone/arch/X86/X86InstPrinterCommon.c',
8b18cdbf
RH
1140 'capstone/arch/X86/X86Mapping.c',
1141 'capstone/arch/X86/X86Module.c'
1142 )
1143 endif
1144
1145 configure_file(output: 'capstone-defs.h', configuration: capstone_data)
1146
1147 capstone_cargs = [
1148 # FIXME: There does not seem to be a way to completely replace the c_args
1149 # that come from add_project_arguments() -- we can only add to them.
1150 # So: disable all warnings with a big hammer.
1151 '-Wno-error', '-w',
1152
1153 # Include all configuration defines via a header file, which will wind up
1154 # as a dependency on the object file, and thus changes here will result
1155 # in a rebuild.
1156 '-include', 'capstone-defs.h'
1157 ]
1158
1159 libcapstone = static_library('capstone',
1160 sources: capstone_files,
1161 c_args: capstone_cargs,
1162 include_directories: 'capstone/include')
1163 capstone = declare_dependency(link_with: libcapstone,
eef20e40 1164 include_directories: 'capstone/include/capstone')
8b18cdbf 1165endif
4d34a86b
PB
1166
1167slirp = not_found
1168slirp_opt = 'disabled'
1169if have_system
1170 slirp_opt = get_option('slirp')
1171 if slirp_opt in ['enabled', 'auto', 'system']
1172 have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
1173 slirp = dependency('slirp', static: enable_static,
1174 method: 'pkg-config',
1175 required: slirp_opt == 'system' or
1176 slirp_opt == 'enabled' and not have_internal)
1177 if slirp.found()
1178 slirp_opt = 'system'
1179 elif have_internal
1180 slirp_opt = 'internal'
1181 else
1182 slirp_opt = 'disabled'
1183 endif
1184 endif
1185 if slirp_opt == 'internal'
1186 slirp_deps = []
1187 if targetos == 'windows'
1188 slirp_deps = cc.find_library('iphlpapi')
1189 endif
1190 slirp_conf = configuration_data()
1191 slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
1192 slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
1193 slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
1194 slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
1195 slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
1196 slirp_files = [
1197 'slirp/src/arp_table.c',
1198 'slirp/src/bootp.c',
1199 'slirp/src/cksum.c',
1200 'slirp/src/dhcpv6.c',
1201 'slirp/src/dnssearch.c',
1202 'slirp/src/if.c',
1203 'slirp/src/ip6_icmp.c',
1204 'slirp/src/ip6_input.c',
1205 'slirp/src/ip6_output.c',
1206 'slirp/src/ip_icmp.c',
1207 'slirp/src/ip_input.c',
1208 'slirp/src/ip_output.c',
1209 'slirp/src/mbuf.c',
1210 'slirp/src/misc.c',
1211 'slirp/src/ncsi.c',
1212 'slirp/src/ndp_table.c',
1213 'slirp/src/sbuf.c',
1214 'slirp/src/slirp.c',
1215 'slirp/src/socket.c',
1216 'slirp/src/state.c',
1217 'slirp/src/stream.c',
1218 'slirp/src/tcp_input.c',
1219 'slirp/src/tcp_output.c',
1220 'slirp/src/tcp_subr.c',
1221 'slirp/src/tcp_timer.c',
1222 'slirp/src/tftp.c',
1223 'slirp/src/udp.c',
1224 'slirp/src/udp6.c',
1225 'slirp/src/util.c',
1226 'slirp/src/version.c',
1227 'slirp/src/vmstate.c',
1228 ]
1229
1230 configure_file(
1231 input : 'slirp/src/libslirp-version.h.in',
1232 output : 'libslirp-version.h',
1233 configuration: slirp_conf)
1234
1235 slirp_inc = include_directories('slirp', 'slirp/src')
1236 libslirp = static_library('slirp',
1237 sources: slirp_files,
1238 c_args: slirp_cargs,
1239 include_directories: slirp_inc)
1240 slirp = declare_dependency(link_with: libslirp,
1241 dependencies: slirp_deps,
1242 include_directories: slirp_inc)
1243 endif
1244endif
1245
fbb4121d
PB
1246fdt = not_found
1247fdt_opt = get_option('fdt')
1248if have_system
1249 if fdt_opt in ['enabled', 'auto', 'system']
1250 have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
1251 fdt = cc.find_library('fdt', static: enable_static,
1252 required: fdt_opt == 'system' or
1253 fdt_opt == 'enabled' and not have_internal)
1254 if fdt.found() and cc.links('''
1255 #include <libfdt.h>
1256 #include <libfdt_env.h>
1257 int main(void) { fdt_check_full(NULL, 0); return 0; }''',
1258 dependencies: fdt)
1259 fdt_opt = 'system'
1260 elif have_internal
1261 fdt_opt = 'internal'
1262 else
1263 fdt_opt = 'disabled'
1264 endif
1265 endif
1266 if fdt_opt == 'internal'
1267 fdt_files = files(
1268 'dtc/libfdt/fdt.c',
1269 'dtc/libfdt/fdt_ro.c',
1270 'dtc/libfdt/fdt_wip.c',
1271 'dtc/libfdt/fdt_sw.c',
1272 'dtc/libfdt/fdt_rw.c',
1273 'dtc/libfdt/fdt_strerror.c',
1274 'dtc/libfdt/fdt_empty_tree.c',
1275 'dtc/libfdt/fdt_addresses.c',
1276 'dtc/libfdt/fdt_overlay.c',
1277 'dtc/libfdt/fdt_check.c',
1278 )
1279
1280 fdt_inc = include_directories('dtc/libfdt')
1281 libfdt = static_library('fdt',
1282 sources: fdt_files,
1283 include_directories: fdt_inc)
1284 fdt = declare_dependency(link_with: libfdt,
1285 include_directories: fdt_inc)
1286 endif
1287endif
1288if not fdt.found() and fdt_required.length() > 0
1289 error('fdt not available but required by targets ' + ', '.join(fdt_required))
1290endif
1291
8b18cdbf 1292config_host_data.set('CONFIG_CAPSTONE', capstone.found())
fbb4121d 1293config_host_data.set('CONFIG_FDT', fdt.found())
4d34a86b 1294config_host_data.set('CONFIG_SLIRP', slirp.found())
8b18cdbf 1295
a0c9162c
PB
1296#####################
1297# Generated sources #
1298#####################
8b18cdbf 1299
a0c9162c 1300genh += configure_file(output: 'config-host.h', configuration: config_host_data)
a81df1b6 1301
3f885659 1302hxtool = find_program('scripts/hxtool')
650b5d54 1303shaderinclude = find_program('scripts/shaderinclude.pl')
a81df1b6
PB
1304qapi_gen = find_program('scripts/qapi-gen.py')
1305qapi_gen_depends = [ meson.source_root() / 'scripts/qapi/__init__.py',
1306 meson.source_root() / 'scripts/qapi/commands.py',
1307 meson.source_root() / 'scripts/qapi/common.py',
a81df1b6
PB
1308 meson.source_root() / 'scripts/qapi/error.py',
1309 meson.source_root() / 'scripts/qapi/events.py',
1310 meson.source_root() / 'scripts/qapi/expr.py',
1311 meson.source_root() / 'scripts/qapi/gen.py',
1312 meson.source_root() / 'scripts/qapi/introspect.py',
1313 meson.source_root() / 'scripts/qapi/parser.py',
1314 meson.source_root() / 'scripts/qapi/schema.py',
1315 meson.source_root() / 'scripts/qapi/source.py',
1316 meson.source_root() / 'scripts/qapi/types.py',
1317 meson.source_root() / 'scripts/qapi/visit.py',
1318 meson.source_root() / 'scripts/qapi/common.py',
a81df1b6
PB
1319 meson.source_root() / 'scripts/qapi-gen.py'
1320]
1321
1322tracetool = [
1323 python, files('scripts/tracetool.py'),
1324 '--backend=' + config_host['TRACE_BACKENDS']
1325]
1326
2c273f32
MAL
1327qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
1328 meson.current_source_dir(),
859aef02 1329 config_host['PKGVERSION'], meson.project_version()]
2c273f32
MAL
1330qemu_version = custom_target('qemu-version.h',
1331 output: 'qemu-version.h',
1332 command: qemu_version_cmd,
1333 capture: true,
1334 build_by_default: true,
1335 build_always_stale: true)
1336genh += qemu_version
1337
3f885659
MAL
1338hxdep = []
1339hx_headers = [
1340 ['qemu-options.hx', 'qemu-options.def'],
1341 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
1342]
1343if have_system
1344 hx_headers += [
1345 ['hmp-commands.hx', 'hmp-commands.h'],
1346 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
1347 ]
1348endif
1349foreach d : hx_headers
b7c70bf2 1350 hxdep += custom_target(d[1],
3f885659
MAL
1351 input: files(d[0]),
1352 output: d[1],
1353 capture: true,
1354 build_by_default: true, # to be removed when added to a target
1355 command: [hxtool, '-h', '@INPUT0@'])
1356endforeach
1357genh += hxdep
1358
a0c9162c
PB
1359###################
1360# Collect sources #
1361###################
a81df1b6 1362
55567891 1363authz_ss = ss.source_set()
4a96337d 1364blockdev_ss = ss.source_set()
7e2b888f 1365block_ss = ss.source_set()
2becc36a 1366bsd_user_ss = ss.source_set()
c2306d71 1367chardev_ss = ss.source_set()
7e2b888f 1368common_ss = ss.source_set()
2389304a 1369crypto_ss = ss.source_set()
f78536b1 1370io_ss = ss.source_set()
2becc36a 1371linux_user_ss = ss.source_set()
7e2b888f 1372qmp_ss = ss.source_set()
da33fc09 1373qom_ss = ss.source_set()
7e2b888f 1374softmmu_ss = ss.source_set()
64ed6f92 1375specific_fuzz_ss = ss.source_set()
7e2b888f
PMD
1376specific_ss = ss.source_set()
1377stub_ss = ss.source_set()
1378trace_ss = ss.source_set()
1379user_ss = ss.source_set()
1380util_ss = ss.source_set()
2becc36a 1381
3154fee4 1382modules = {}
2becc36a
PB
1383hw_arch = {}
1384target_arch = {}
1385target_softmmu_arch = {}
a81df1b6
PB
1386
1387###############
1388# Trace files #
1389###############
1390
c9322ab5
MAL
1391# TODO: add each directory to the subdirs from its own meson.build, once
1392# we have those
a81df1b6
PB
1393trace_events_subdirs = [
1394 'accel/kvm',
1395 'accel/tcg',
1396 'crypto',
1397 'monitor',
1398]
1399if have_user
1400 trace_events_subdirs += [ 'linux-user' ]
1401endif
1402if have_block
1403 trace_events_subdirs += [
1404 'authz',
1405 'block',
1406 'io',
1407 'nbd',
1408 'scsi',
1409 ]
1410endif
1411if have_system
1412 trace_events_subdirs += [
1413 'audio',
1414 'backends',
1415 'backends/tpm',
1416 'chardev',
1417 'hw/9pfs',
1418 'hw/acpi',
1419 'hw/alpha',
1420 'hw/arm',
1421 'hw/audio',
1422 'hw/block',
1423 'hw/block/dataplane',
1424 'hw/char',
1425 'hw/display',
1426 'hw/dma',
1427 'hw/hppa',
1428 'hw/hyperv',
1429 'hw/i2c',
1430 'hw/i386',
1431 'hw/i386/xen',
1432 'hw/ide',
1433 'hw/input',
1434 'hw/intc',
1435 'hw/isa',
1436 'hw/mem',
1437 'hw/mips',
1438 'hw/misc',
1439 'hw/misc/macio',
1440 'hw/net',
98e5d7a2 1441 'hw/net/can',
a81df1b6
PB
1442 'hw/nvram',
1443 'hw/pci',
1444 'hw/pci-host',
1445 'hw/ppc',
1446 'hw/rdma',
1447 'hw/rdma/vmw',
1448 'hw/rtc',
1449 'hw/s390x',
1450 'hw/scsi',
1451 'hw/sd',
1452 'hw/sparc',
1453 'hw/sparc64',
1454 'hw/ssi',
1455 'hw/timer',
1456 'hw/tpm',
1457 'hw/usb',
1458 'hw/vfio',
1459 'hw/virtio',
1460 'hw/watchdog',
1461 'hw/xen',
1462 'hw/gpio',
a81df1b6
PB
1463 'migration',
1464 'net',
8b7a5507 1465 'softmmu',
a81df1b6
PB
1466 'ui',
1467 ]
1468endif
1469trace_events_subdirs += [
1470 'hw/core',
1471 'qapi',
1472 'qom',
1473 'target/arm',
1474 'target/hppa',
1475 'target/i386',
1476 'target/mips',
1477 'target/ppc',
1478 'target/riscv',
1479 'target/s390x',
1480 'target/sparc',
1481 'util',
1482]
1483
0df750e9
MAL
1484vhost_user = not_found
1485if 'CONFIG_VHOST_USER' in config_host
1486 libvhost_user = subproject('libvhost-user')
1487 vhost_user = libvhost_user.get_variable('vhost_user_dep')
1488endif
1489
a81df1b6
PB
1490subdir('qapi')
1491subdir('qobject')
1492subdir('stubs')
1493subdir('trace')
1494subdir('util')
5582c58f
MAL
1495subdir('qom')
1496subdir('authz')
a81df1b6 1497subdir('crypto')
2d78b56e 1498subdir('ui')
a81df1b6 1499
3154fee4
MAL
1500
1501if enable_modules
1502 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
1503 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
1504endif
1505
2becc36a 1506stub_ss = stub_ss.apply(config_all, strict: false)
a81df1b6
PB
1507
1508util_ss.add_all(trace_ss)
2becc36a 1509util_ss = util_ss.apply(config_all, strict: false)
a81df1b6
PB
1510libqemuutil = static_library('qemuutil',
1511 sources: util_ss.sources() + stub_ss.sources() + genh,
aa087962 1512 dependencies: [util_ss.dependencies(), m, glib, socket, malloc])
a81df1b6 1513qemuutil = declare_dependency(link_with: libqemuutil,
04c6f1e7 1514 sources: genh + version_res)
a81df1b6 1515
abff1abf
PB
1516decodetree = generator(find_program('scripts/decodetree.py'),
1517 output: 'decode-@BASENAME@.c.inc',
1518 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
1519
478e943f 1520subdir('audio')
7fcfd456 1521subdir('io')
848e8ff6 1522subdir('chardev')
ec0d5893 1523subdir('fsdev')
abff1abf 1524subdir('libdecnumber')
d3b18480 1525subdir('target')
708eab42 1526subdir('dump')
ec0d5893 1527
5e5733e5
MAL
1528block_ss.add(files(
1529 'block.c',
1530 'blockjob.c',
1531 'job.c',
1532 'qemu-io-cmds.c',
1533))
1534block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
1535
1536subdir('nbd')
1537subdir('scsi')
1538subdir('block')
1539
4a96337d
PB
1540blockdev_ss.add(files(
1541 'blockdev.c',
cbc20bfb 1542 'blockdev-nbd.c',
4a96337d
PB
1543 'iothread.c',
1544 'job-qmp.c',
1545))
1546
1547# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
1548# os-win32.c does not
1549blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
1550softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
4a96337d
PB
1551
1552common_ss.add(files('cpus-common.c'))
1553
5d3ea0e1 1554subdir('softmmu')
c9322ab5 1555
f343346b 1556common_ss.add(capstone)
d9f24bf5 1557specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
c9322ab5
MAL
1558specific_ss.add(files('exec-vary.c'))
1559specific_ss.add(when: 'CONFIG_TCG', if_true: files(
1560 'fpu/softfloat.c',
1561 'tcg/optimize.c',
1562 'tcg/tcg-common.c',
1563 'tcg/tcg-op-gvec.c',
1564 'tcg/tcg-op-vec.c',
1565 'tcg/tcg-op.c',
1566 'tcg/tcg.c',
1567))
1568specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('disas/tci.c', 'tcg/tci.c'))
1569
ab318051 1570subdir('backends')
c574e161 1571subdir('disas')
55166230 1572subdir('migration')
ff219dca 1573subdir('monitor')
cdaf0722 1574subdir('net')
17ef2af6 1575subdir('replay')
582ea95f 1576subdir('hw')
1a82878a 1577subdir('accel')
f556b4a1 1578subdir('plugins')
b309c321 1579subdir('bsd-user')
3a30446a
MAL
1580subdir('linux-user')
1581
b309c321
MAL
1582bsd_user_ss.add(files('gdbstub.c'))
1583specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss)
1584
3a30446a
MAL
1585linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
1586specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
5d3ea0e1 1587
a2ce7dbd
PB
1588# needed for fuzzing binaries
1589subdir('tests/qtest/libqos')
64ed6f92 1590subdir('tests/qtest/fuzz')
a2ce7dbd 1591
a0c9162c
PB
1592########################
1593# Library dependencies #
1594########################
1595
3154fee4
MAL
1596block_mods = []
1597softmmu_mods = []
1598foreach d, list : modules
1599 foreach m, module_ss : list
1600 if enable_modules and targetos != 'windows'
3e292c51 1601 module_ss = module_ss.apply(config_all, strict: false)
3154fee4
MAL
1602 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
1603 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
1604 if d == 'block'
1605 block_mods += sl
1606 else
1607 softmmu_mods += sl
1608 endif
1609 else
1610 if d == 'block'
1611 block_ss.add_all(module_ss)
1612 else
1613 softmmu_ss.add_all(module_ss)
1614 endif
1615 endif
1616 endforeach
1617endforeach
1618
1619nm = find_program('nm')
604f3e4e 1620undefsym = find_program('scripts/undefsym.py')
3154fee4
MAL
1621block_syms = custom_target('block.syms', output: 'block.syms',
1622 input: [libqemuutil, block_mods],
1623 capture: true,
1624 command: [undefsym, nm, '@INPUT@'])
1625qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
1626 input: [libqemuutil, softmmu_mods],
1627 capture: true,
1628 command: [undefsym, nm, '@INPUT@'])
1629
da33fc09
PMD
1630qom_ss = qom_ss.apply(config_host, strict: false)
1631libqom = static_library('qom', qom_ss.sources() + genh,
1632 dependencies: [qom_ss.dependencies()],
1633 name_suffix: 'fa')
1634
1635qom = declare_dependency(link_whole: libqom)
1636
55567891
PMD
1637authz_ss = authz_ss.apply(config_host, strict: false)
1638libauthz = static_library('authz', authz_ss.sources() + genh,
1639 dependencies: [authz_ss.dependencies()],
1640 name_suffix: 'fa',
1641 build_by_default: false)
1642
1643authz = declare_dependency(link_whole: libauthz,
1644 dependencies: qom)
1645
2389304a
PMD
1646crypto_ss = crypto_ss.apply(config_host, strict: false)
1647libcrypto = static_library('crypto', crypto_ss.sources() + genh,
1648 dependencies: [crypto_ss.dependencies()],
1649 name_suffix: 'fa',
1650 build_by_default: false)
1651
1652crypto = declare_dependency(link_whole: libcrypto,
1653 dependencies: [authz, qom])
1654
f78536b1
PMD
1655io_ss = io_ss.apply(config_host, strict: false)
1656libio = static_library('io', io_ss.sources() + genh,
1657 dependencies: [io_ss.dependencies()],
1658 link_with: libqemuutil,
1659 name_suffix: 'fa',
1660 build_by_default: false)
1661
1662io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
1663
7e6edef3
PMD
1664libmigration = static_library('migration', sources: migration_files + genh,
1665 name_suffix: 'fa',
1666 build_by_default: false)
1667migration = declare_dependency(link_with: libmigration,
1668 dependencies: [zlib, qom, io])
1669softmmu_ss.add(migration)
1670
5e5733e5
MAL
1671block_ss = block_ss.apply(config_host, strict: false)
1672libblock = static_library('block', block_ss.sources() + genh,
1673 dependencies: block_ss.dependencies(),
1674 link_depends: block_syms,
1675 name_suffix: 'fa',
1676 build_by_default: false)
1677
1678block = declare_dependency(link_whole: [libblock],
b7c70bf2
MAL
1679 link_args: '@block.syms',
1680 dependencies: [crypto, io])
5e5733e5 1681
4fb9071f
SH
1682blockdev_ss = blockdev_ss.apply(config_host, strict: false)
1683libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
1684 dependencies: blockdev_ss.dependencies(),
1685 name_suffix: 'fa',
1686 build_by_default: false)
1687
1688blockdev = declare_dependency(link_whole: [libblockdev],
1689 dependencies: [block])
1690
ff219dca
PB
1691qmp_ss = qmp_ss.apply(config_host, strict: false)
1692libqmp = static_library('qmp', qmp_ss.sources() + genh,
1693 dependencies: qmp_ss.dependencies(),
1694 name_suffix: 'fa',
1695 build_by_default: false)
1696
1697qmp = declare_dependency(link_whole: [libqmp])
1698
c2306d71
PMD
1699libchardev = static_library('chardev', chardev_ss.sources() + genh,
1700 name_suffix: 'fa',
1701 build_by_default: false)
1702
1703chardev = declare_dependency(link_whole: libchardev)
1704
e28ab096
PMD
1705libhwcore = static_library('hwcore', sources: hwcore_files + genh,
1706 name_suffix: 'fa',
1707 build_by_default: false)
1708hwcore = declare_dependency(link_whole: libhwcore)
1709common_ss.add(hwcore)
1710
064f8ee7
PMD
1711###########
1712# Targets #
1713###########
1714
3154fee4
MAL
1715foreach m : block_mods + softmmu_mods
1716 shared_module(m.name(),
1717 name_prefix: '',
1718 link_whole: m,
1719 install: true,
16bf7a33 1720 install_dir: qemu_moddir)
3154fee4
MAL
1721endforeach
1722
4fb9071f 1723softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp)
64ed6f92
PB
1724common_ss.add(qom, qemuutil)
1725
1726common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
2becc36a
PB
1727common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
1728
1729common_all = common_ss.apply(config_all, strict: false)
1730common_all = static_library('common',
1731 build_by_default: false,
1732 sources: common_all.sources() + genh,
1733 dependencies: common_all.dependencies(),
1734 name_suffix: 'fa')
1735
c9322ab5
MAL
1736feature_to_c = find_program('scripts/feature_to_c.sh')
1737
fd5eef85 1738emulators = {}
2becc36a
PB
1739foreach target : target_dirs
1740 config_target = config_target_mak[target]
1741 target_name = config_target['TARGET_NAME']
1742 arch = config_target['TARGET_BASE_ARCH']
859aef02 1743 arch_srcs = [config_target_h[target]]
64ed6f92
PB
1744 arch_deps = []
1745 c_args = ['-DNEED_CPU_H',
1746 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
1747 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
b6c7cfd4 1748 link_args = emulator_link_args
2becc36a 1749
859aef02 1750 config_target += config_host
2becc36a
PB
1751 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
1752 if targetos == 'linux'
1753 target_inc += include_directories('linux-headers', is_system: true)
1754 endif
1755 if target.endswith('-softmmu')
1756 qemu_target_name = 'qemu-system-' + target_name
1757 target_type='system'
abff1abf
PB
1758 t = target_softmmu_arch[arch].apply(config_target, strict: false)
1759 arch_srcs += t.sources()
64ed6f92 1760 arch_deps += t.dependencies()
abff1abf 1761
2c44220d
MAL
1762 hw_dir = target_name == 'sparc64' ? 'sparc64' : arch
1763 hw = hw_arch[hw_dir].apply(config_target, strict: false)
1764 arch_srcs += hw.sources()
64ed6f92 1765 arch_deps += hw.dependencies()
2c44220d 1766
2becc36a 1767 arch_srcs += config_devices_h[target]
64ed6f92 1768 link_args += ['@block.syms', '@qemu.syms']
2becc36a 1769 else
3a30446a 1770 abi = config_target['TARGET_ABI_DIR']
2becc36a
PB
1771 target_type='user'
1772 qemu_target_name = 'qemu-' + target_name
1773 if 'CONFIG_LINUX_USER' in config_target
1774 base_dir = 'linux-user'
1775 target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
1776 else
1777 base_dir = 'bsd-user'
1778 endif
1779 target_inc += include_directories(
1780 base_dir,
3a30446a 1781 base_dir / abi,
2becc36a 1782 )
3a30446a
MAL
1783 if 'CONFIG_LINUX_USER' in config_target
1784 dir = base_dir / abi
1785 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
1786 if config_target.has_key('TARGET_SYSTBL_ABI')
1787 arch_srcs += \
1788 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
1789 extra_args : config_target['TARGET_SYSTBL_ABI'])
1790 endif
1791 endif
2becc36a
PB
1792 endif
1793
c9322ab5
MAL
1794 if 'TARGET_XML_FILES' in config_target
1795 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
1796 output: target + '-gdbstub-xml.c',
1797 input: files(config_target['TARGET_XML_FILES'].split()),
1798 command: [feature_to_c, '@INPUT@'],
1799 capture: true)
1800 arch_srcs += gdbstub_xml
1801 endif
1802
abff1abf
PB
1803 t = target_arch[arch].apply(config_target, strict: false)
1804 arch_srcs += t.sources()
64ed6f92 1805 arch_deps += t.dependencies()
abff1abf 1806
2becc36a
PB
1807 target_common = common_ss.apply(config_target, strict: false)
1808 objects = common_all.extract_objects(target_common.sources())
64ed6f92 1809 deps = target_common.dependencies()
2becc36a 1810
2becc36a
PB
1811 target_specific = specific_ss.apply(config_target, strict: false)
1812 arch_srcs += target_specific.sources()
64ed6f92 1813 arch_deps += target_specific.dependencies()
2becc36a 1814
64ed6f92 1815 lib = static_library('qemu-' + target,
859aef02 1816 sources: arch_srcs + genh,
b7612f45 1817 dependencies: arch_deps,
2becc36a
PB
1818 objects: objects,
1819 include_directories: target_inc,
64ed6f92
PB
1820 c_args: c_args,
1821 build_by_default: false,
2becc36a 1822 name_suffix: 'fa')
64ed6f92
PB
1823
1824 if target.endswith('-softmmu')
1825 execs = [{
1826 'name': 'qemu-system-' + target_name,
1827 'gui': false,
1828 'sources': files('softmmu/main.c'),
1829 'dependencies': []
1830 }]
35be72ba 1831 if targetos == 'windows' and (sdl.found() or gtk.found())
64ed6f92
PB
1832 execs += [{
1833 'name': 'qemu-system-' + target_name + 'w',
1834 'gui': true,
1835 'sources': files('softmmu/main.c'),
1836 'dependencies': []
1837 }]
1838 endif
1839 if config_host.has_key('CONFIG_FUZZ')
1840 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
1841 execs += [{
1842 'name': 'qemu-fuzz-' + target_name,
1843 'gui': false,
1844 'sources': specific_fuzz.sources(),
1845 'dependencies': specific_fuzz.dependencies(),
64ed6f92
PB
1846 }]
1847 endif
1848 else
1849 execs = [{
1850 'name': 'qemu-' + target_name,
1851 'gui': false,
1852 'sources': [],
1853 'dependencies': []
1854 }]
1855 endif
1856 foreach exe: execs
fd5eef85
PB
1857 emulators += {exe['name']:
1858 executable(exe['name'], exe['sources'],
64ed6f92
PB
1859 install: true,
1860 c_args: c_args,
1861 dependencies: arch_deps + deps + exe['dependencies'],
1862 objects: lib.extract_all_objects(recursive: true),
1863 link_language: link_language,
1864 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
1865 link_args: link_args,
1866 gui_app: exe['gui'])
fd5eef85 1867 }
10e1d263
MAL
1868
1869 if 'CONFIG_TRACE_SYSTEMTAP' in config_host
1870 foreach stp: [
bd5f973a
SH
1871 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
1872 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
10e1d263
MAL
1873 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
1874 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
1875 ]
bd5f973a 1876 custom_target(exe['name'] + stp['ext'],
10e1d263 1877 input: trace_events_all,
bd5f973a 1878 output: exe['name'] + stp['ext'],
10e1d263
MAL
1879 capture: true,
1880 install: stp['install'],
16bf7a33 1881 install_dir: get_option('datadir') / 'systemtap/tapset',
10e1d263
MAL
1882 command: [
1883 tracetool, '--group=all', '--format=' + stp['fmt'],
1884 '--binary=' + stp['bin'],
1885 '--target-name=' + target_name,
1886 '--target-type=' + target_type,
1887 '--probe-prefix=qemu.' + target_type + '.' + target_name,
1888 '@INPUT@',
1889 ])
1890 endforeach
1891 endif
64ed6f92 1892 endforeach
2becc36a
PB
1893endforeach
1894
931049b4 1895# Other build targets
897b5afa 1896
f556b4a1
PB
1897if 'CONFIG_PLUGIN' in config_host
1898 install_headers('include/qemu/qemu-plugin.h')
1899endif
1900
f15bff25
PB
1901if 'CONFIG_GUEST_AGENT' in config_host
1902 subdir('qga')
1903endif
1904
9755c94a
LV
1905# Don't build qemu-keymap if xkbcommon is not explicitly enabled
1906# when we don't build tools or system
4113f4cf 1907if xkbcommon.found()
28742467
MAL
1908 # used for the update-keymaps target, so include rules even if !have_tools
1909 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
1910 dependencies: [qemuutil, xkbcommon], install: have_tools)
1911endif
1912
931049b4 1913if have_tools
b7c70bf2
MAL
1914 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
1915 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
1916 qemu_io = executable('qemu-io', files('qemu-io.c'),
1917 dependencies: [block, qemuutil], install: true)
eb705985 1918 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
cbc20bfb 1919 dependencies: [blockdev, qemuutil], install: true)
b7c70bf2 1920
7c58bb76 1921 subdir('storage-daemon')
a9c9727c 1922 subdir('contrib/rdmacm-mux')
1d7bb6ab 1923 subdir('contrib/elf2dmp')
a9c9727c 1924
157e7b13
MAL
1925 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
1926 dependencies: qemuutil,
1927 install: true)
1928
931049b4 1929 if 'CONFIG_VHOST_USER' in config_host
2d7ac0af 1930 subdir('contrib/vhost-user-blk')
b7612f45 1931 subdir('contrib/vhost-user-gpu')
32fcc624 1932 subdir('contrib/vhost-user-input')
99650b62 1933 subdir('contrib/vhost-user-scsi')
931049b4 1934 endif
8f51e01c
MAL
1935
1936 if targetos == 'linux'
1937 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
1938 dependencies: [qemuutil, libcap_ng],
1939 install: true,
1940 install_dir: get_option('libexecdir'))
897b5afa
MAL
1941
1942 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
1943 dependencies: [authz, crypto, io, qom, qemuutil,
6ec0e15d 1944 libcap_ng, mpathpersist],
897b5afa 1945 install: true)
8f51e01c
MAL
1946 endif
1947
5ee24e78
MAL
1948 if 'CONFIG_IVSHMEM' in config_host
1949 subdir('contrib/ivshmem-client')
1950 subdir('contrib/ivshmem-server')
1951 endif
931049b4
PB
1952endif
1953
f5aa6320 1954subdir('scripts')
3f99cf57 1955subdir('tools')
bdcbea7a 1956subdir('pc-bios')
f8aa24ea 1957subdir('docs')
e3667660 1958subdir('tests')
e8f3bd71
MAL
1959if 'CONFIG_GTK' in config_host
1960 subdir('po')
1961endif
3f99cf57 1962
8adfeba9
MAL
1963if host_machine.system() == 'windows'
1964 nsis_cmd = [
1965 find_program('scripts/nsis.py'),
1966 '@OUTPUT@',
1967 get_option('prefix'),
1968 meson.current_source_dir(),
24bdcc96 1969 host_machine.cpu(),
8adfeba9
MAL
1970 '--',
1971 '-DDISPLAYVERSION=' + meson.project_version(),
1972 ]
1973 if build_docs
1974 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
1975 endif
1976 if 'CONFIG_GTK' in config_host
1977 nsis_cmd += '-DCONFIG_GTK=y'
1978 endif
1979
1980 nsis = custom_target('nsis',
1981 output: 'qemu-setup-' + meson.project_version() + '.exe',
1982 input: files('qemu.nsi'),
1983 build_always_stale: true,
1984 command: nsis_cmd + ['@INPUT@'])
1985 alias_target('installer', nsis)
1986endif
1987
a0c9162c
PB
1988#########################
1989# Configuration summary #
1990#########################
1991
f9332757 1992summary_info = {}
16bf7a33
PB
1993summary_info += {'Install prefix': get_option('prefix')}
1994summary_info += {'BIOS directory': qemu_datadir}
1995summary_info += {'firmware path': get_option('qemu_firmwarepath')}
1996summary_info += {'binary directory': get_option('bindir')}
1997summary_info += {'library directory': get_option('libdir')}
1998summary_info += {'module directory': qemu_moddir}
1999summary_info += {'libexec directory': get_option('libexecdir')}
2000summary_info += {'include directory': get_option('includedir')}
2001summary_info += {'config directory': get_option('sysconfdir')}
f9332757 2002if targetos != 'windows'
16bf7a33 2003 summary_info += {'local state directory': get_option('localstatedir')}
b81efab7 2004 summary_info += {'Manual directory': get_option('mandir')}
f9332757
PB
2005else
2006 summary_info += {'local state directory': 'queried at runtime'}
2007endif
491e74c1 2008summary_info += {'Doc directory': get_option('docdir')}
f9332757
PB
2009summary_info += {'Build directory': meson.current_build_dir()}
2010summary_info += {'Source path': meson.current_source_dir()}
2011summary_info += {'GIT binary': config_host['GIT']}
2012summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
2013summary_info += {'C compiler': meson.get_compiler('c').cmd_array()[0]}
2014summary_info += {'Host C compiler': meson.get_compiler('c', native: true).cmd_array()[0]}
2015if link_language == 'cpp'
2016 summary_info += {'C++ compiler': meson.get_compiler('cpp').cmd_array()[0]}
2017else
2018 summary_info += {'C++ compiler': false}
2019endif
2020if targetos == 'darwin'
2021 summary_info += {'Objective-C compiler': meson.get_compiler('objc').cmd_array()[0]}
2022endif
2023summary_info += {'ARFLAGS': config_host['ARFLAGS']}
47b30835
PB
2024summary_info += {'CFLAGS': ' '.join(get_option('c_args')
2025 + ['-O' + get_option('optimization')]
2026 + (get_option('debug') ? ['-g'] : []))}
2027if link_language == 'cpp'
2028 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
2029 + ['-O' + get_option('optimization')]
2030 + (get_option('debug') ? ['-g'] : []))}
2031endif
2032link_args = get_option(link_language + '_link_args')
2033if link_args.length() > 0
2034 summary_info += {'LDFLAGS': ' '.join(link_args)}
2035endif
f9332757
PB
2036summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
2037summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
2038summary_info += {'make': config_host['MAKE']}
f9332757 2039summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
e3667660 2040summary_info += {'sphinx-build': sphinx_build.found()}
f9332757
PB
2041summary_info += {'genisoimage': config_host['GENISOIMAGE']}
2042# TODO: add back version
4d34a86b
PB
2043summary_info += {'slirp support': slirp_opt == 'disabled' ? false : slirp_opt}
2044if slirp_opt != 'disabled'
f9332757
PB
2045 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
2046endif
2047summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
2048if config_host.has_key('CONFIG_MODULES')
2049 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
2050endif
2051summary_info += {'host CPU': cpu}
2052summary_info += {'host endianness': build_machine.endian()}
fdb75aef 2053summary_info += {'target list': ' '.join(target_dirs)}
f9332757 2054summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
deb62371 2055summary_info += {'sparse enabled': sparse.found()}
f9332757
PB
2056summary_info += {'strip binaries': get_option('strip')}
2057summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
3e8529dd 2058summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
f9332757
PB
2059if targetos == 'darwin'
2060 summary_info += {'Cocoa support': config_host.has_key('CONFIG_COCOA')}
2061endif
2062# TODO: add back version
35be72ba
PB
2063summary_info += {'SDL support': sdl.found()}
2064summary_info += {'SDL image support': sdl_image.found()}
f9332757
PB
2065# TODO: add back version
2066summary_info += {'GTK support': config_host.has_key('CONFIG_GTK')}
2067summary_info += {'GTK GL support': config_host.has_key('CONFIG_GTK_GL')}
b7612f45 2068summary_info += {'pixman': pixman.found()}
f9332757
PB
2069# TODO: add back version
2070summary_info += {'VTE support': config_host.has_key('CONFIG_VTE')}
2071summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
2072summary_info += {'GNUTLS support': config_host.has_key('CONFIG_GNUTLS')}
2073# TODO: add back version
2074summary_info += {'libgcrypt': config_host.has_key('CONFIG_GCRYPT')}
2075if config_host.has_key('CONFIG_GCRYPT')
2076 summary_info += {' hmac': config_host.has_key('CONFIG_GCRYPT_HMAC')}
2077 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
2078endif
2079# TODO: add back version
2080summary_info += {'nettle': config_host.has_key('CONFIG_NETTLE')}
2081if config_host.has_key('CONFIG_NETTLE')
2082 summary_info += {' XTS': not config_host.has_key('CONFIG_QEMU_PRIVATE_XTS')}
2083endif
2084summary_info += {'libtasn1': config_host.has_key('CONFIG_TASN1')}
2085summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
5285e593
YL
2086summary_info += {'iconv support': iconv.found()}
2087summary_info += {'curses support': curses.found()}
f9332757
PB
2088# TODO: add back version
2089summary_info += {'virgl support': config_host.has_key('CONFIG_VIRGL')}
2090summary_info += {'curl support': config_host.has_key('CONFIG_CURL')}
2091summary_info += {'mingw32 support': targetos == 'windows'}
2092summary_info += {'Audio drivers': config_host['CONFIG_AUDIO_DRIVERS']}
2093summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
2094summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
2095summary_info += {'VirtFS support': config_host.has_key('CONFIG_VIRTFS')}
cece116c 2096summary_info += {'build virtiofs daemon': have_virtiofsd}
6ec0e15d 2097summary_info += {'Multipath support': mpathpersist.found()}
a0b93237
PB
2098summary_info += {'VNC support': vnc.found()}
2099if vnc.found()
2100 summary_info += {'VNC SASL support': sasl.found()}
2101 summary_info += {'VNC JPEG support': jpeg.found()}
2102 summary_info += {'VNC PNG support': png.found()}
f9332757
PB
2103endif
2104summary_info += {'xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
2105if config_host.has_key('CONFIG_XEN_BACKEND')
2106 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
2107endif
2108summary_info += {'brlapi support': config_host.has_key('CONFIG_BRLAPI')}
e3667660 2109summary_info += {'Documentation': build_docs}
f9332757
PB
2110summary_info += {'PIE': get_option('b_pie')}
2111summary_info += {'vde support': config_host.has_key('CONFIG_VDE')}
2112summary_info += {'netmap support': config_host.has_key('CONFIG_NETMAP')}
2113summary_info += {'Linux AIO support': config_host.has_key('CONFIG_LINUX_AIO')}
2114summary_info += {'Linux io_uring support': config_host.has_key('CONFIG_LINUX_IO_URING')}
2115summary_info += {'ATTR/XATTR support': config_host.has_key('CONFIG_ATTR')}
c8d5450b 2116summary_info += {'Install blobs': get_option('install_blobs')}
05512f55
PB
2117summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
2118summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
2119summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
2120summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
2121summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
2122if config_all.has_key('CONFIG_TCG')
2123 summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
2124 summary_info += {'TCG interpreter': config_host.has_key('CONFIG_TCG_INTERPRETER')}
2125endif
aa087962 2126summary_info += {'malloc trim support': has_malloc_trim}
f9332757
PB
2127summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
2128summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
fbb4121d 2129summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
f9332757
PB
2130summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
2131summary_info += {'preadv support': config_host.has_key('CONFIG_PREADV')}
2132summary_info += {'fdatasync': config_host.has_key('CONFIG_FDATASYNC')}
2133summary_info += {'madvise': config_host.has_key('CONFIG_MADVISE')}
2134summary_info += {'posix_madvise': config_host.has_key('CONFIG_POSIX_MADVISE')}
2135summary_info += {'posix_memalign': config_host.has_key('CONFIG_POSIX_MEMALIGN')}
2136summary_info += {'libcap-ng support': config_host.has_key('CONFIG_LIBCAP_NG')}
b54b82df 2137summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
f9332757
PB
2138summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
2139summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
2140summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
2141summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
b54b82df 2142summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
e5e856c1 2143summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
f9332757
PB
2144summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
2145summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
2146summary_info += {'Trace backends': config_host['TRACE_BACKENDS']}
2147if config_host['TRACE_BACKENDS'].split().contains('simple')
2148 summary_info += {'Trace output file': config_host['CONFIG_TRACE_FILE'] + '-<pid>'}
2149endif
2150# TODO: add back protocol and server version
2151summary_info += {'spice support': config_host.has_key('CONFIG_SPICE')}
2152summary_info += {'rbd support': config_host.has_key('CONFIG_RBD')}
2153summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
2154summary_info += {'smartcard support': config_host.has_key('CONFIG_SMARTCARD')}
0a40bcb7 2155summary_info += {'U2F support': u2f.found()}
f9332757
PB
2156summary_info += {'libusb': config_host.has_key('CONFIG_USB_LIBUSB')}
2157summary_info += {'usb net redir': config_host.has_key('CONFIG_USB_REDIR')}
2158summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
2159summary_info += {'OpenGL dmabufs': config_host.has_key('CONFIG_OPENGL_DMABUF')}
2160summary_info += {'libiscsi support': config_host.has_key('CONFIG_LIBISCSI')}
2161summary_info += {'libnfs support': config_host.has_key('CONFIG_LIBNFS')}
2162summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
2163if targetos == 'windows'
2164 if 'WIN_SDK' in config_host
2165 summary_info += {'Windows SDK': config_host['WIN_SDK']}
2166 endif
2167 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
2168 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
4bad7c3b 2169 summary_info += {'QGA MSI support': config_host.has_key('CONFIG_QGA_MSI')}
f9332757
PB
2170endif
2171summary_info += {'seccomp support': config_host.has_key('CONFIG_SECCOMP')}
2172summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
2173summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
2174summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
2175summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
2176summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
2177summary_info += {'GlusterFS support': config_host.has_key('CONFIG_GLUSTERFS')}
bf0e56a3 2178summary_info += {'gcov': get_option('b_coverage')}
f9332757
PB
2179summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
2180summary_info += {'libssh support': config_host.has_key('CONFIG_LIBSSH')}
2181summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
2182summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
2183summary_info += {'lzo support': config_host.has_key('CONFIG_LZO')}
2184summary_info += {'snappy support': config_host.has_key('CONFIG_SNAPPY')}
2185summary_info += {'bzip2 support': config_host.has_key('CONFIG_BZIP2')}
2186summary_info += {'lzfse support': config_host.has_key('CONFIG_LZFSE')}
2187summary_info += {'zstd support': config_host.has_key('CONFIG_ZSTD')}
2188summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
2189summary_info += {'libxml2': config_host.has_key('CONFIG_LIBXML2')}
aa087962 2190summary_info += {'memory allocator': get_option('malloc')}
f9332757
PB
2191summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
2192summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
2193summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
2194summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
2195summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
2196summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
2197summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
2198summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
2199summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
2200summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
2201summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
2202summary_info += {'sheepdog support': config_host.has_key('CONFIG_SHEEPDOG')}
8b18cdbf 2203summary_info += {'capstone': capstone_opt == 'disabled' ? false : capstone_opt}
f9332757
PB
2204summary_info += {'libpmem support': config_host.has_key('CONFIG_LIBPMEM')}
2205summary_info += {'libdaxctl support': config_host.has_key('CONFIG_LIBDAXCTL')}
f01496a3 2206summary_info += {'libudev': libudev.found()}
f9332757
PB
2207summary_info += {'default devices': config_host['CONFIG_MINIKCONF_MODE'] == '--defconfig'}
2208summary_info += {'plugin support': config_host.has_key('CONFIG_PLUGIN')}
2209summary_info += {'fuzzing support': config_host.has_key('CONFIG_FUZZ')}
2210if config_host.has_key('HAVE_GDB_BIN')
2211 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
2212endif
2213summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
2214summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
2215summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
a484a719 2216summary_info += {'FUSE exports': fuse.found()}
f9332757
PB
2217summary(summary_info, bool_yn: true)
2218
2219if not supported_cpus.contains(cpu)
2220 message()
2221 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
2222 message()
2223 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
2224 message('The QEMU project intends to remove support for this host CPU in')
2225 message('a future release if nobody volunteers to maintain it and to')
2226 message('provide a build host for our continuous integration setup.')
2227 message('configure has succeeded and you can continue to build, but')
2228 message('if you care about QEMU on this platform you should contact')
2229 message('us upstream at qemu-devel@nongnu.org.')
2230endif
2231
2232if not supported_oses.contains(targetos)
2233 message()
2234 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
2235 message()
2236 message('Host OS ' + targetos + 'support is not currently maintained.')
2237 message('The QEMU project intends to remove support for this host OS in')
2238 message('a future release if nobody volunteers to maintain it and to')
2239 message('provide a build host for our continuous integration setup.')
2240 message('configure has succeeded and you can continue to build, but')
2241 message('if you care about QEMU on this platform you should contact')
2242 message('us upstream at qemu-devel@nongnu.org.')
2243endif