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