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