blob: 333c61deba76d44f8defa98fe0290e10915d774d [file] [log] [blame]
Paolo Bonzini654d6b02021-02-09 14:59:26 +01001project('qemu', ['c'], meson_version: '>=0.58.2',
2 default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
Paolo Bonzini3d2f73e2021-02-11 06:15:12 -05003 'b_staticpic=false', 'stdsplit=false'],
Paolo Bonzini654d6b02021-02-09 14:59:26 +01004 version: files('VERSION'))
Paolo Bonzinia5665052019-06-10 12:05:14 +02005
Paolo Bonzini3d2f73e2021-02-11 06:15:12 -05006add_test_setup('quick', exclude_suites: 'slow', is_default: true)
7add_test_setup('slow', env: ['G_TEST_SLOW=1', 'SPEED=slow'])
8
Paolo Bonzinia5665052019-06-10 12:05:14 +02009not_found = dependency('', required: false)
Paolo Bonzini654d6b02021-02-09 14:59:26 +010010keyval = import('keyval')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040011ss = import('sourceset')
Richard Henderson8b18cdb2020-09-13 12:19:25 -070012fs = import('fs')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040013
Paolo Bonzinice1c1e72020-01-28 16:41:44 +010014sh = find_program('sh')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040015cc = meson.get_compiler('c')
Paolo Bonzinia5665052019-06-10 12:05:14 +020016config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
Marc-André Lureau3154fee2019-08-29 22:07:01 +040017enable_modules = 'CONFIG_MODULES' in config_host
Paolo Bonzini35be72b2020-02-06 14:17:15 +010018enable_static = 'CONFIG_STATIC' in config_host
Yonggang Luoe3667662020-10-16 06:06:25 +080019
Paolo Bonzinid7dedf42021-01-26 11:15:33 +010020# Allow both shared and static libraries unless --enable-static
21static_kwargs = enable_static ? {'static': true} : {}
22
Yonggang Luoe3667662020-10-16 06:06:25 +080023# Temporary directory used for files created while
24# configure runs. Since it is in the build directory
25# we can safely blow away any previous version of it
26# (and we need not jump through hoops to try to delete
27# it when configure exits.)
28tmpdir = meson.current_build_dir() / 'meson-private/temp'
Marc-André Lureau8fe11232020-09-11 14:42:48 +020029
30if get_option('qemu_suffix').startswith('/')
31 error('qemu_suffix cannot start with a /')
32endif
33
Paolo Bonzini16bf7a32020-10-16 03:19:14 -040034qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
Marc-André Lureauab4c0992020-08-26 15:04:16 +040035qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
Marc-André Lureau491e74c2020-08-26 15:04:17 +040036qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
Paolo Bonzini16bf7a32020-10-16 03:19:14 -040037qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
38
39qemu_desktopdir = get_option('datadir') / 'applications'
40qemu_icondir = get_option('datadir') / 'icons'
41
Paolo Bonzini859aef02020-08-04 18:14:26 +020042config_host_data = configuration_data()
43genh = []
Paolo Bonzinia5665052019-06-10 12:05:14 +020044
Paolo Bonzini760e4322020-08-26 08:09:48 +020045target_dirs = config_host['TARGET_DIRS'].split()
Warner Loshdda2da62021-10-08 16:47:37 -060046have_linux_user = false
47have_bsd_user = false
Paolo Bonzini760e4322020-08-26 08:09:48 +020048have_system = false
49foreach target : target_dirs
Warner Loshdda2da62021-10-08 16:47:37 -060050 have_linux_user = have_linux_user or target.endswith('linux-user')
51 have_bsd_user = have_bsd_user or target.endswith('bsd-user')
Paolo Bonzini760e4322020-08-26 08:09:48 +020052 have_system = have_system or target.endswith('-softmmu')
53endforeach
Warner Loshdda2da62021-10-08 16:47:37 -060054have_user = have_linux_user or have_bsd_user
Paolo Bonzini760e4322020-08-26 08:09:48 +020055have_tools = 'CONFIG_TOOLS' in config_host
56have_block = have_system or have_tools
57
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040058python = import('python').find_installation()
59
60supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
Richard Hendersonba0e7332021-09-17 11:08:09 -070061supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64',
WANG Xueruidfcf9002021-12-21 13:41:04 +080062 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc', 'sparc64']
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040063
64cpu = host_machine.cpu_family()
Richard Hendersonc94c2392021-11-16 10:50:42 +010065
66# Unify riscv* to a single family.
67if cpu in ['riscv32', 'riscv64']
68 cpu = 'riscv'
69endif
70
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040071targetos = host_machine.system()
72
Paolo Bonzini823eb012021-11-08 14:18:17 +010073if cpu not in supported_cpus
74 host_arch = 'unknown'
75elif cpu == 'x86'
76 host_arch = 'i386'
Richard Henderson0e3ed772021-12-31 05:25:11 +000077elif cpu == 'mips64'
78 host_arch = 'mips'
Paolo Bonzini823eb012021-11-08 14:18:17 +010079else
80 host_arch = cpu
81endif
82
Paolo Bonzini8a199802020-09-18 05:37:01 -040083if cpu in ['x86', 'x86_64']
84 kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
85elif cpu == 'aarch64'
86 kvm_targets = ['aarch64-softmmu']
87elif cpu == 's390x'
88 kvm_targets = ['s390x-softmmu']
89elif cpu in ['ppc', 'ppc64']
90 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
Huacai Chenfbc58842020-10-07 16:39:28 +080091elif cpu in ['mips', 'mips64']
92 kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
Paolo Bonzini8a199802020-09-18 05:37:01 -040093else
94 kvm_targets = []
95endif
96
Igor Mammedov44d3d892021-10-27 11:10:12 -040097kvm_targets_c = '""'
Igor Mammedove741aff2021-09-02 07:35:38 -040098if not get_option('kvm').disabled() and targetos == 'linux'
99 kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
100endif
101config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
102
Paolo Bonzini8a199802020-09-18 05:37:01 -0400103accelerator_targets = { 'CONFIG_KVM': kvm_targets }
Alexander Graf844a06b2021-09-16 17:54:02 +0200104
105if cpu in ['aarch64']
106 accelerator_targets += {
107 'CONFIG_HVF': ['aarch64-softmmu']
108 }
109endif
110
Alex Bennée0c3e41d2020-11-10 19:23:09 +0000111if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
Marc-André Lureau2a2d51b2021-09-14 16:30:45 +0400112 # i386 emulator provides xenpv machine type for multiple architectures
Alex Bennée0c3e41d2020-11-10 19:23:09 +0000113 accelerator_targets += {
114 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
115 }
116endif
Paolo Bonzini8a199802020-09-18 05:37:01 -0400117if cpu in ['x86', 'x86_64']
118 accelerator_targets += {
119 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
Paolo Bonzini8a199802020-09-18 05:37:01 -0400120 'CONFIG_HVF': ['x86_64-softmmu'],
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200121 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
Paolo Bonzini8a199802020-09-18 05:37:01 -0400122 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
123 }
124endif
125
Paolo Bonzinia1b176f2021-07-12 14:22:08 +0200126modular_tcg = []
127# Darwin does not support references to thread-local variables in modules
128if targetos != 'darwin'
129 modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
130endif
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +0200131
Philippe Mathieu-Daudéeae9a1d2021-01-14 18:45:08 +0100132edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
Paolo Bonzinie49c0ef2021-09-23 06:55:28 -0400133unpack_edk2_blobs = false
134foreach target : edk2_targets
135 if target in target_dirs
136 bzip2 = find_program('bzip2', required: get_option('install_blobs'))
137 unpack_edk2_blobs = bzip2.found()
138 break
139 endif
140endforeach
Philippe Mathieu-Daudé45b545d2021-01-14 18:45:09 +0100141
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200142dtrace = not_found
143stap = not_found
144if 'dtrace' in get_option('trace_backends')
145 dtrace = find_program('dtrace', required: true)
146 stap = find_program('stap', required: false)
147 if stap.found()
148 # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
149 # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
150 # instead. QEMU --enable-modules depends on this because the SystemTap
151 # semaphores are linked into the main binary and not the module's shared
152 # object.
153 add_global_arguments('-DSTAP_SDT_V2',
154 native: false, language: ['c', 'cpp', 'objc'])
155 endif
156endif
157
Paolo Bonzini201e8ed2020-09-01 07:45:54 -0400158##################
159# Compiler flags #
160##################
161
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400162# Specify linker-script with add_project_link_arguments so that it is not placed
163# within a linker --start-group/--end-group pair
Paolo Bonzini537b7242021-10-07 15:08:12 +0200164if get_option('fuzzing')
165 add_project_link_arguments(['-Wl,-T,',
166 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
167 native: false, language: ['c', 'cpp', 'objc'])
168
169 # Specify a filter to only instrument code that is directly related to
170 # virtual-devices.
171 configure_file(output: 'instrumentation-filter',
172 input: 'scripts/oss-fuzz/instrumentation-filter-template',
173 copy: true)
174 add_global_arguments(
175 cc.get_supported_arguments('-fsanitize-coverage-allowlist=instrumentation-filter'),
176 native: false, language: ['c', 'cpp', 'objc'])
177
178 if get_option('fuzzing_engine') == ''
179 # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
180 # compiled code. To build non-fuzzer binaries with --enable-fuzzing, link
181 # everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be
182 # unable to bind the fuzzer-related callbacks added by instrumentation.
183 add_global_arguments('-fsanitize=fuzzer-no-link',
184 native: false, language: ['c', 'cpp', 'objc'])
185 add_global_link_arguments('-fsanitize=fuzzer-no-link',
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400186 native: false, language: ['c', 'cpp', 'objc'])
Paolo Bonzini537b7242021-10-07 15:08:12 +0200187 # For the actual fuzzer binaries, we need to link against the libfuzzer
188 # library. They need to be configurable, to support OSS-Fuzz
189 fuzz_exe_ldflags = ['-fsanitize=fuzzer']
190 else
191 # LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and
192 # the needed CFLAGS have already been provided
193 fuzz_exe_ldflags = get_option('fuzzing_engine').split()
194 endif
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400195endif
196
Marc-André Lureau5fc06172021-01-14 16:56:02 +0400197add_global_arguments(config_host['QEMU_CFLAGS'].split(),
198 native: false, language: ['c', 'objc'])
199add_global_arguments(config_host['QEMU_CXXFLAGS'].split(),
200 native: false, language: 'cpp')
201add_global_link_arguments(config_host['QEMU_LDFLAGS'].split(),
202 native: false, language: ['c', 'cpp', 'objc'])
Paolo Bonzinia5665052019-06-10 12:05:14 +0200203
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400204if targetos == 'linux'
205 add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
206 '-isystem', 'linux-headers',
207 language: ['c', 'cpp'])
208endif
209
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100210add_project_arguments('-iquote', '.',
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400211 '-iquote', meson.current_source_dir(),
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400212 '-iquote', meson.current_source_dir() / 'include',
213 '-iquote', meson.current_source_dir() / 'disas/libvixl',
214 language: ['c', 'cpp', 'objc'])
Alexander Bulekovc46f76d2020-09-02 13:36:50 -0400215
Marc-André Lureaufc929892019-07-13 01:47:54 +0400216link_language = meson.get_external_property('link_language', 'cpp')
217if link_language == 'cpp'
218 add_languages('cpp', required: true, native: false)
Paolo Bonzini565174d2021-11-04 14:35:14 +0100219 cxx = meson.get_compiler('cpp')
220 linker = cxx
221else
222 linker = cc
Marc-André Lureaufc929892019-07-13 01:47:54 +0400223endif
Paolo Bonzinia5665052019-06-10 12:05:14 +0200224if host_machine.system() == 'darwin'
225 add_languages('objc', required: false, native: false)
226endif
227
Paolo Bonzinideb62372020-09-01 07:51:16 -0400228sparse = find_program('cgcc', required: get_option('sparse'))
229if sparse.found()
Paolo Bonzini968b4db2020-02-03 14:45:33 +0100230 run_target('sparse',
231 command: [find_program('scripts/check_sparse.py'),
Paolo Bonzinideb62372020-09-01 07:51:16 -0400232 'compile_commands.json', sparse.full_path(), '-Wbitwise',
233 '-Wno-transparent-union', '-Wno-old-initializer',
234 '-Wno-non-pointer-null'])
Paolo Bonzini968b4db2020-02-03 14:45:33 +0100235endif
236
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200237###########################################
238# Target-specific checks and dependencies #
239###########################################
240
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100241# Fuzzing
Paolo Bonzini537b7242021-10-07 15:08:12 +0200242if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
243 not cc.links('''
244 #include <stdint.h>
245 #include <sys/types.h>
246 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
247 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
248 ''',
249 args: ['-Werror', '-fsanitize=fuzzer'])
250 error('Your compiler does not support -fsanitize=fuzzer')
251endif
252
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100253# Tracing backends
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200254if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
255 error('ftrace is supported only on Linux')
256endif
257if 'syslog' in get_option('trace_backends') and not cc.compiles('''
258 #include <syslog.h>
259 int main(void) {
260 openlog("qemu", LOG_PID, LOG_DAEMON);
261 syslog(LOG_INFO, "configure");
262 return 0;
263 }''')
264 error('syslog is not supported on this system')
265endif
266
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100267# Miscellaneous Linux-only features
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200268if targetos != 'linux' and get_option('mpath').enabled()
269 error('Multipath is supported only on Linux')
270endif
271
Paolo Bonzini106ad1f2021-02-17 16:24:25 +0100272if targetos != 'linux' and get_option('multiprocess').enabled()
273 error('Multiprocess QEMU is supported only on Linux')
274endif
275multiprocess_allowed = targetos == 'linux' and not get_option('multiprocess').disabled()
276
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100277# Target-specific libraries and flags
Paolo Bonzini7fa1c632021-06-01 10:00:48 +0200278libm = cc.find_library('m', required: false)
Paolo Bonzini6d7c7c22021-06-03 15:01:35 +0200279threads = dependency('threads')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400280util = cc.find_library('util', required: false)
Paolo Bonzini4a963372020-08-03 16:22:28 +0200281winmm = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400282socket = []
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400283version_res = []
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400284coref = []
285iokit = []
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -0400286emulator_link_args = []
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200287nvmm =not_found
Paolo Bonzini8a199802020-09-18 05:37:01 -0400288hvf = not_found
Paolo Bonzinia6305082021-10-07 15:08:15 +0200289host_dsosuf = '.so'
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400290if targetos == 'windows'
291 socket = cc.find_library('ws2_32')
Paolo Bonzini4a963372020-08-03 16:22:28 +0200292 winmm = cc.find_library('winmm')
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400293
294 win = import('windows')
295 version_res = win.compile_resources('version.rc',
296 depend_files: files('pc-bios/qemu-nsis.ico'),
297 include_directories: include_directories('.'))
Paolo Bonzinia6305082021-10-07 15:08:15 +0200298 host_dsosuf = '.dll'
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400299elif targetos == 'darwin'
300 coref = dependency('appleframeworks', modules: 'CoreFoundation')
Joelle van Dyne14176c82021-03-15 11:03:38 -0700301 iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
Paolo Bonzinia6305082021-10-07 15:08:15 +0200302 host_dsosuf = '.dylib'
Paolo Bonzinicfad62f2020-08-09 23:47:45 +0200303elif targetos == 'sunos'
304 socket = [cc.find_library('socket'),
305 cc.find_library('nsl'),
306 cc.find_library('resolv')]
307elif targetos == 'haiku'
308 socket = [cc.find_library('posix_error_mapper'),
309 cc.find_library('network'),
310 cc.find_library('bsd')]
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -0400311elif targetos == 'openbsd'
312 if not get_option('tcg').disabled() and target_dirs.length() > 0
313 # Disable OpenBSD W^X if available
314 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
315 endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400316endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200317
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100318# Target-specific configuration of accelerators
Paolo Bonzini8a199802020-09-18 05:37:01 -0400319accelerators = []
320if not get_option('kvm').disabled() and targetos == 'linux'
321 accelerators += 'CONFIG_KVM'
322endif
323if not get_option('xen').disabled() and 'CONFIG_XEN_BACKEND' in config_host
324 accelerators += 'CONFIG_XEN'
325 have_xen_pci_passthrough = not get_option('xen_pci_passthrough').disabled() and targetos == 'linux'
326else
327 have_xen_pci_passthrough = false
328endif
329if not get_option('whpx').disabled() and targetos == 'windows'
Sunil Muthuswamy57e2a1f2020-10-22 00:27:55 +0000330 if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
Paolo Bonzini8a199802020-09-18 05:37:01 -0400331 error('WHPX requires 64-bit host')
332 elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
333 cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
334 accelerators += 'CONFIG_WHPX'
335 endif
336endif
337if not get_option('hvf').disabled()
338 hvf = dependency('appleframeworks', modules: 'Hypervisor',
339 required: get_option('hvf'))
340 if hvf.found()
341 accelerators += 'CONFIG_HVF'
342 endif
343endif
344if not get_option('hax').disabled()
345 if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
346 accelerators += 'CONFIG_HAX'
347 endif
348endif
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200349if targetos == 'netbsd'
nia0cc49652021-10-13 13:54:17 +0000350 nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200351 if nvmm.found()
352 accelerators += 'CONFIG_NVMM'
353 endif
354endif
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100355
Paolo Bonzini823eb012021-11-08 14:18:17 +0100356tcg_arch = host_arch
Paolo Bonzini8a199802020-09-18 05:37:01 -0400357if not get_option('tcg').disabled()
Paolo Bonzini823eb012021-11-08 14:18:17 +0100358 if host_arch == 'unknown'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100359 if get_option('tcg_interpreter')
Philippe Mathieu-Daudéf1f727a2021-11-06 12:14:57 +0100360 warning('Unsupported CPU @0@, will use TCG with TCI (slow)'.format(cpu))
Paolo Bonzini8a199802020-09-18 05:37:01 -0400361 else
362 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
363 endif
Philippe Mathieu-Daudéfa2f7b02021-01-25 15:45:30 +0100364 elif get_option('tcg_interpreter')
Philippe Mathieu-Daudé1c282da2021-05-21 12:34:23 +0200365 warning('Use of the TCG interpreter is not recommended on this host')
Philippe Mathieu-Daudéfa2f7b02021-01-25 15:45:30 +0100366 warning('architecture. There is a native TCG execution backend available')
367 warning('which provides substantially better performance and reliability.')
368 warning('It is strongly recommended to remove the --enable-tcg-interpreter')
369 warning('configuration option on this architecture to use the native')
370 warning('backend.')
Paolo Bonzini8a199802020-09-18 05:37:01 -0400371 endif
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100372 if get_option('tcg_interpreter')
373 tcg_arch = 'tci'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100374 elif host_arch == 'sparc64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100375 tcg_arch = 'sparc'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100376 elif host_arch == 'x86_64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100377 tcg_arch = 'i386'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100378 elif host_arch == 'ppc64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100379 tcg_arch = 'ppc'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100380 endif
381 add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100382 language: ['c', 'cpp', 'objc'])
383
Paolo Bonzini8a199802020-09-18 05:37:01 -0400384 accelerators += 'CONFIG_TCG'
385 config_host += { 'CONFIG_TCG': 'y' }
386endif
387
388if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
389 error('KVM not available on this platform')
390endif
391if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
392 error('HVF not available on this platform')
393endif
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200394if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
395 error('NVMM not available on this platform')
396endif
Paolo Bonzini8a199802020-09-18 05:37:01 -0400397if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
398 error('WHPX not available on this platform')
399endif
400if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
401 if 'CONFIG_XEN' in accelerators
402 error('Xen PCI passthrough not available on this platform')
403 else
404 error('Xen PCI passthrough requested but Xen not enabled')
405 endif
406endif
Paolo Bonzinib4e312e2020-09-01 11:28:59 -0400407
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200408################
409# Dependencies #
410################
411
Paolo Bonzini215b0c22020-09-01 08:41:17 -0400412# The path to glib.h is added to all compilation commands. This was
413# grandfathered in from the QEMU Makefiles.
414add_project_arguments(config_host['GLIB_CFLAGS'].split(),
415 native: false, language: ['c', 'cpp', 'objc'])
Marc-André Lureau953d5a92020-12-15 12:03:19 +0400416glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
Marc-André Lureaud83acfd2021-10-09 17:37:40 +0400417 link_args: config_host['GLIB_LIBS'].split(),
418 version: config_host['GLIB_VERSION'])
Marc-André Lureau953d5a92020-12-15 12:03:19 +0400419# override glib dep with the configure results (for subprojects)
420meson.override_dependency('glib-2.0', glib)
421
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400422gio = not_found
423if 'CONFIG_GIO' in config_host
424 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
Marc-André Lureaud83acfd2021-10-09 17:37:40 +0400425 link_args: config_host['GIO_LIBS'].split(),
426 version: config_host['GLIB_VERSION'])
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400427endif
428lttng = not_found
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200429if 'ust' in get_option('trace_backends')
430 lttng = dependency('lttng-ust', required: true, method: 'pkg-config',
431 kwargs: static_kwargs)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400432endif
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200433pixman = not_found
434if have_system or have_tools
435 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100436 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200437endif
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100438zlib = dependency('zlib', required: true, kwargs: static_kwargs)
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200439
Paolo Bonziniff66f3e2021-10-07 15:08:20 +0200440libaio = not_found
441if not get_option('linux_aio').auto() or have_block
442 libaio = cc.find_library('aio', has_headers: ['libaio.h'],
443 required: get_option('linux_aio'),
444 kwargs: static_kwargs)
445endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400446linux_io_uring = not_found
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200447if not get_option('linux_io_uring').auto() or have_block
Daniel P. Berrangéa41b4fd2022-01-05 13:49:38 +0000448 linux_io_uring = dependency('liburing', version: '>=0.3',
449 required: get_option('linux_io_uring'),
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200450 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400451endif
452libxml2 = not_found
Paolo Bonzinic5b36c22021-06-03 11:31:35 +0200453if not get_option('libxml2').auto() or have_block
454 libxml2 = dependency('libxml-2.0', required: get_option('libxml2'),
455 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400456endif
457libnfs = not_found
Paolo Bonzini30045c02020-11-17 13:11:25 +0100458if not get_option('libnfs').auto() or have_block
459 libnfs = dependency('libnfs', version: '>=1.9.3',
460 required: get_option('libnfs'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100461 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400462endif
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100463
464libattr_test = '''
465 #include <stddef.h>
466 #include <sys/types.h>
467 #ifdef CONFIG_LIBATTR
468 #include <attr/xattr.h>
469 #else
470 #include <sys/xattr.h>
471 #endif
472 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
473
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400474libattr = not_found
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100475have_old_libattr = false
476if not get_option('attr').disabled()
477 if cc.links(libattr_test)
478 libattr = declare_dependency()
479 else
480 libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
481 required: get_option('attr'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100482 kwargs: static_kwargs)
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100483 if libattr.found() and not \
484 cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
485 libattr = not_found
486 if get_option('attr').enabled()
487 error('could not link libattr')
488 else
489 warning('could not link libattr, disabling')
490 endif
491 else
492 have_old_libattr = libattr.found()
493 endif
494 endif
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400495endif
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100496
Paolo Bonzinic1ec4942021-01-07 14:04:00 +0100497cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
498if cocoa.found() and get_option('sdl').enabled()
499 error('Cocoa and SDL cannot be enabled at the same time')
500endif
501if cocoa.found() and get_option('gtk').enabled()
502 error('Cocoa and GTK+ cannot be enabled at the same time')
503endif
504
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100505seccomp = not_found
Paolo Bonzini90835c22020-11-17 14:22:24 +0100506if not get_option('seccomp').auto() or have_system or have_tools
507 seccomp = dependency('libseccomp', version: '>=2.3.0',
508 required: get_option('seccomp'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100509 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100510endif
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100511
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100512libcap_ng = not_found
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100513if not get_option('cap_ng').auto() or have_system or have_tools
514 libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
515 required: get_option('cap_ng'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100516 kwargs: static_kwargs)
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100517endif
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100518if libcap_ng.found() and not cc.links('''
519 #include <cap-ng.h>
520 int main(void)
521 {
522 capng_capability_to_name(CAPNG_EFFECTIVE);
523 return 0;
524 }''', dependencies: libcap_ng)
525 libcap_ng = not_found
526 if get_option('cap_ng').enabled()
527 error('could not link libcap-ng')
528 else
529 warning('could not link libcap-ng, disabling')
530 endif
531endif
532
Paolo Bonzini1917ec62020-08-26 03:24:11 -0400533if get_option('xkbcommon').auto() and not have_system and not have_tools
534 xkbcommon = not_found
535else
536 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100537 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureauade60d42019-07-15 14:48:31 +0400538endif
Paolo Bonzinie1723992021-10-07 15:08:21 +0200539
Marc-André Lureaucdaf0722019-07-22 23:47:50 +0400540vde = not_found
Paolo Bonzinie1723992021-10-07 15:08:21 +0200541if not get_option('vde').auto() or have_system or have_tools
542 vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'],
543 required: get_option('vde'),
544 kwargs: static_kwargs)
545endif
546if vde.found() and not cc.links('''
547 #include <libvdeplug.h>
548 int main(void)
549 {
550 struct vde_open_args a = {0, 0, 0};
551 char s[] = "";
552 vde_open(s, s, &a);
553 return 0;
554 }''', dependencies: vde)
555 vde = not_found
556 if get_option('cap_ng').enabled()
557 error('could not link libvdeplug')
558 else
559 warning('could not link libvdeplug, disabling')
560 endif
Marc-André Lureaucdaf0722019-07-22 23:47:50 +0400561endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200562
Paolo Bonzini478e9432020-08-17 12:47:55 +0200563pulse = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200564if not get_option('pa').auto() or (targetos == 'linux' and have_system)
565 pulse = dependency('libpulse', required: get_option('pa'),
566 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200567endif
568alsa = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200569if not get_option('alsa').auto() or (targetos == 'linux' and have_system)
570 alsa = dependency('alsa', required: get_option('alsa'),
571 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200572endif
573jack = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200574if not get_option('jack').auto() or have_system
575 jack = dependency('jack', required: get_option('jack'),
576 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200577endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200578
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +0200579spice_protocol = not_found
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200580if not get_option('spice_protocol').auto() or have_system
581 spice_protocol = dependency('spice-protocol', version: '>=0.12.3',
582 required: get_option('spice_protocol'),
583 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini26347332019-07-29 15:40:07 +0200584endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200585spice = not_found
586if not get_option('spice').auto() or have_system
587 spice = dependency('spice-server', version: '>=0.12.5',
588 required: get_option('spice'),
589 method: 'pkg-config', kwargs: static_kwargs)
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +0200590endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200591spice_headers = spice.partial_dependency(compile_args: true, includes: true)
592
Marc-André Lureau5ee24e72019-07-12 23:16:54 +0400593rt = cc.find_library('rt', required: false)
Paolo Bonzinia399f912021-11-15 14:29:13 +0000594
Paolo Bonzini99650b62019-06-10 12:21:14 +0200595libiscsi = not_found
Paolo Bonzini9db405a2020-11-17 13:11:25 +0100596if not get_option('libiscsi').auto() or have_block
597 libiscsi = dependency('libiscsi', version: '>=1.9.0',
598 required: get_option('libiscsi'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100599 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini99650b62019-06-10 12:21:14 +0200600endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400601zstd = not_found
Paolo Bonzinib1def332020-11-17 13:37:39 +0100602if not get_option('zstd').auto() or have_block
603 zstd = dependency('libzstd', version: '>=1.4.0',
604 required: get_option('zstd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100605 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400606endif
Marc-André Lureauea458962019-07-12 22:23:46 +0400607virgl = not_found
Paolo Bonzini587d59d2021-06-03 11:31:35 +0200608if not get_option('virglrenderer').auto() or have_system
609 virgl = dependency('virglrenderer',
610 method: 'pkg-config',
611 required: get_option('virglrenderer'),
612 kwargs: static_kwargs)
Marc-André Lureauea458962019-07-12 22:23:46 +0400613endif
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +0400614curl = not_found
Paolo Bonzinif9cd86f2020-11-17 12:43:15 +0100615if not get_option('curl').auto() or have_block
616 curl = dependency('libcurl', version: '>=7.29.0',
617 method: 'pkg-config',
618 required: get_option('curl'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100619 kwargs: static_kwargs)
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +0400620endif
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200621libudev = not_found
Paolo Bonzinif01496a2020-09-16 17:54:14 +0200622if targetos == 'linux' and (have_system or have_tools)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200623 libudev = dependency('libudev',
Paolo Bonzinia0fbbb62020-11-17 12:36:15 +0100624 method: 'pkg-config',
Paolo Bonzini5c530152020-10-15 06:09:27 -0400625 required: get_option('libudev'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100626 kwargs: static_kwargs)
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200627endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200628
Paolo Bonzini5c530152020-10-15 06:09:27 -0400629mpathlibs = [libudev]
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200630mpathpersist = not_found
631mpathpersist_new_api = false
632if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
633 mpath_test_source_new = '''
634 #include <libudev.h>
635 #include <mpath_persist.h>
636 unsigned mpath_mx_alloc_len = 1024;
637 int logsink;
638 static struct config *multipath_conf;
639 extern struct udev *udev;
640 extern struct config *get_multipath_config(void);
641 extern void put_multipath_config(struct config *conf);
642 struct udev *udev;
643 struct config *get_multipath_config(void) { return multipath_conf; }
644 void put_multipath_config(struct config *conf) { }
645 int main(void) {
646 udev = udev_new();
647 multipath_conf = mpath_lib_init();
648 return 0;
649 }'''
650 mpath_test_source_old = '''
651 #include <libudev.h>
652 #include <mpath_persist.h>
653 unsigned mpath_mx_alloc_len = 1024;
654 int logsink;
655 int main(void) {
656 struct udev *udev = udev_new();
657 mpath_lib_init(udev);
658 return 0;
659 }'''
Paolo Bonzini5c530152020-10-15 06:09:27 -0400660 libmpathpersist = cc.find_library('mpathpersist',
661 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100662 kwargs: static_kwargs)
Paolo Bonzini5c530152020-10-15 06:09:27 -0400663 if libmpathpersist.found()
664 mpathlibs += libmpathpersist
665 if enable_static
666 mpathlibs += cc.find_library('devmapper',
667 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100668 kwargs: static_kwargs)
Paolo Bonzini43b43a42020-09-17 12:25:09 +0200669 endif
Paolo Bonzini5c530152020-10-15 06:09:27 -0400670 mpathlibs += cc.find_library('multipath',
671 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100672 kwargs: static_kwargs)
Paolo Bonzini5c530152020-10-15 06:09:27 -0400673 foreach lib: mpathlibs
674 if not lib.found()
675 mpathlibs = []
676 break
677 endif
678 endforeach
679 if mpathlibs.length() == 0
680 msg = 'Dependencies missing for libmpathpersist'
681 elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200682 mpathpersist = declare_dependency(dependencies: mpathlibs)
683 mpathpersist_new_api = true
684 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
685 mpathpersist = declare_dependency(dependencies: mpathlibs)
686 else
Paolo Bonzini5c530152020-10-15 06:09:27 -0400687 msg = 'Cannot detect libmpathpersist API'
688 endif
689 if not mpathpersist.found()
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200690 if get_option('mpath').enabled()
Paolo Bonzini5c530152020-10-15 06:09:27 -0400691 error(msg)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200692 else
Paolo Bonzini5c530152020-10-15 06:09:27 -0400693 warning(msg + ', disabling')
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200694 endif
695 endif
696 endif
697endif
698
Yonggang Luo5285e592020-10-13 07:43:48 +0800699iconv = not_found
Yonggang Luo5285e592020-10-13 07:43:48 +0800700curses = not_found
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400701if have_system and not get_option('curses').disabled()
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400702 curses_test = '''
Stefan Weilfbab8cc2021-11-17 21:53:55 +0100703 #if defined(__APPLE__) || defined(__OpenBSD__)
704 #define _XOPEN_SOURCE_EXTENDED 1
705 #endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400706 #include <locale.h>
707 #include <curses.h>
708 #include <wchar.h>
709 int main(void) {
710 wchar_t wch = L'w';
711 setlocale(LC_ALL, "");
712 resize_term(0, 0);
713 addwstr(L"wide chars\n");
714 addnwstr(&wch, 1);
715 add_wch(WACS_DEGREE);
716 return 0;
717 }'''
718
Yonggang Luoca31e302020-11-17 05:31:06 +0800719 curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
720 foreach curses_dep : curses_dep_list
721 if not curses.found()
722 curses = dependency(curses_dep,
723 required: false,
724 method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100725 kwargs: static_kwargs)
Yonggang Luoca31e302020-11-17 05:31:06 +0800726 endif
727 endforeach
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400728 msg = get_option('curses').enabled() ? 'curses library not found' : ''
Stefan Weilfbab8cc2021-11-17 21:53:55 +0100729 curses_compile_args = ['-DNCURSES_WIDECHAR=1']
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400730 if curses.found()
Paolo Bonzini0dbce6e2020-11-30 08:07:48 -0500731 if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
732 curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses])
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400733 else
734 msg = 'curses package not usable'
735 curses = not_found
Yonggang Luo5285e592020-10-13 07:43:48 +0800736 endif
737 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400738 if not curses.found()
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400739 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
740 if targetos != 'windows' and not has_curses_h
741 message('Trying with /usr/include/ncursesw')
742 curses_compile_args += ['-I/usr/include/ncursesw']
743 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
744 endif
745 if has_curses_h
746 curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
747 foreach curses_libname : curses_libname_list
Yonggang Luo5285e592020-10-13 07:43:48 +0800748 libcurses = cc.find_library(curses_libname,
749 required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100750 kwargs: static_kwargs)
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400751 if libcurses.found()
752 if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
753 curses = declare_dependency(compile_args: curses_compile_args,
754 dependencies: [libcurses])
755 break
756 else
757 msg = 'curses library not usable'
758 endif
Yonggang Luo5285e592020-10-13 07:43:48 +0800759 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400760 endforeach
761 endif
762 endif
763 if not get_option('iconv').disabled()
764 foreach link_args : [ ['-liconv'], [] ]
765 # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
766 # We need to use libiconv if available because mixing libiconv's headers with
767 # the system libc does not work.
768 # However, without adding glib to the dependencies -L/usr/local/lib will not be
769 # included in the command line and libiconv will not be found.
770 if cc.links('''
771 #include <iconv.h>
772 int main(void) {
773 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
774 return conv != (iconv_t) -1;
775 }''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
776 iconv = declare_dependency(link_args: link_args, dependencies: glib)
777 break
Yonggang Luo5285e592020-10-13 07:43:48 +0800778 endif
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400779 endforeach
780 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400781 if curses.found() and not iconv.found()
782 if get_option('iconv').enabled()
783 error('iconv not available')
784 endif
785 msg = 'iconv required for curses UI but not available'
786 curses = not_found
787 endif
788 if not curses.found() and msg != ''
789 if get_option('curses').enabled()
790 error(msg)
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400791 else
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400792 warning(msg + ', disabling')
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400793 endif
Yonggang Luo5285e592020-10-13 07:43:48 +0800794 endif
795endif
796
Paolo Bonzini26347332019-07-29 15:40:07 +0200797brlapi = not_found
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +0100798if not get_option('brlapi').auto() or have_system
799 brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
800 required: get_option('brlapi'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100801 kwargs: static_kwargs)
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +0100802 if brlapi.found() and not cc.links('''
803 #include <brlapi.h>
804 #include <stddef.h>
805 int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
806 brlapi = not_found
807 if get_option('brlapi').enabled()
808 error('could not link brlapi')
809 else
810 warning('could not link brlapi, disabling')
811 endif
812 endif
Paolo Bonzini26347332019-07-29 15:40:07 +0200813endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100814
Paolo Bonzini760e4322020-08-26 08:09:48 +0200815sdl = not_found
Paolo Bonzinic1ec4942021-01-07 14:04:00 +0100816if not get_option('sdl').auto() or (have_system and not cocoa.found())
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100817 sdl = dependency('sdl2', required: get_option('sdl'), kwargs: static_kwargs)
Paolo Bonzini760e4322020-08-26 08:09:48 +0200818 sdl_image = not_found
819endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100820if sdl.found()
821 # work around 2.0.8 bug
822 sdl = declare_dependency(compile_args: '-Wno-undef',
823 dependencies: sdl)
Volker Rümelin7161a432020-08-29 12:41:58 +0200824 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100825 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100826else
827 if get_option('sdl_image').enabled()
Sergei Trofimovicha8dc2ac2020-09-08 08:40:16 +0100828 error('sdl-image required, but SDL was @0@'.format(
829 get_option('sdl').disabled() ? 'disabled' : 'not found'))
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100830 endif
831 sdl_image = not_found
Paolo Bonzini26347332019-07-29 15:40:07 +0200832endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100833
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400834rbd = not_found
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100835if not get_option('rbd').auto() or have_block
836 librados = cc.find_library('rados', required: get_option('rbd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100837 kwargs: static_kwargs)
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100838 librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
839 required: get_option('rbd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100840 kwargs: static_kwargs)
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100841 if librados.found() and librbd.found()
842 if cc.links('''
843 #include <stdio.h>
844 #include <rbd/librbd.h>
845 int main(void) {
846 rados_t cluster;
847 rados_create(&cluster, NULL);
Peter Lieven48672ac2021-07-02 19:23:51 +0200848 #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0)
849 #error
850 #endif
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100851 return 0;
852 }''', dependencies: [librbd, librados])
853 rbd = declare_dependency(dependencies: [librbd, librados])
854 elif get_option('rbd').enabled()
Peter Lieven48672ac2021-07-02 19:23:51 +0200855 error('librbd >= 1.12.0 required')
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100856 else
Peter Lieven48672ac2021-07-02 19:23:51 +0200857 warning('librbd >= 1.12.0 not found, disabling')
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100858 endif
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100859 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400860endif
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100861
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400862glusterfs = not_found
Paolo Bonzini08821ca2020-11-17 13:01:26 +0100863glusterfs_ftruncate_has_stat = false
864glusterfs_iocb_has_stat = false
865if not get_option('glusterfs').auto() or have_block
866 glusterfs = dependency('glusterfs-api', version: '>=3',
867 required: get_option('glusterfs'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100868 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini08821ca2020-11-17 13:01:26 +0100869 if glusterfs.found()
870 glusterfs_ftruncate_has_stat = cc.links('''
871 #include <glusterfs/api/glfs.h>
872
873 int
874 main(void)
875 {
876 /* new glfs_ftruncate() passes two additional args */
877 return glfs_ftruncate(NULL, 0, NULL, NULL);
878 }
879 ''', dependencies: glusterfs)
880 glusterfs_iocb_has_stat = cc.links('''
881 #include <glusterfs/api/glfs.h>
882
883 /* new glfs_io_cbk() passes two additional glfs_stat structs */
884 static void
885 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
886 {}
887
888 int
889 main(void)
890 {
891 glfs_io_cbk iocb = &glusterfs_iocb;
892 iocb(NULL, 0 , NULL, NULL, NULL);
893 return 0;
894 }
895 ''', dependencies: glusterfs)
896 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400897endif
Thomas Huthe6a52b32021-12-09 15:48:01 +0100898
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400899libssh = not_found
Thomas Huthe6a52b32021-12-09 15:48:01 +0100900if not get_option('libssh').auto() or have_block
901 libssh = dependency('libssh', version: '>=0.8.7',
902 method: 'pkg-config',
903 required: get_option('libssh'),
904 kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400905endif
Thomas Huthe6a52b32021-12-09 15:48:01 +0100906
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400907libbzip2 = not_found
Paolo Bonzini29ba6112020-11-17 13:07:52 +0100908if not get_option('bzip2').auto() or have_block
909 libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
910 required: get_option('bzip2'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100911 kwargs: static_kwargs)
Paolo Bonzini29ba6112020-11-17 13:07:52 +0100912 if libbzip2.found() and not cc.links('''
913 #include <bzlib.h>
914 int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
915 libbzip2 = not_found
916 if get_option('bzip2').enabled()
917 error('could not link libbzip2')
918 else
919 warning('could not link libbzip2, disabling')
920 endif
921 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400922endif
Paolo Bonziniecea3692020-11-17 13:35:28 +0100923
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400924liblzfse = not_found
Paolo Bonziniecea3692020-11-17 13:35:28 +0100925if not get_option('lzfse').auto() or have_block
926 liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
927 required: get_option('lzfse'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100928 kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400929endif
Paolo Bonziniecea3692020-11-17 13:35:28 +0100930if liblzfse.found() and not cc.links('''
931 #include <lzfse.h>
932 int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
933 liblzfse = not_found
934 if get_option('lzfse').enabled()
935 error('could not link liblzfse')
936 else
937 warning('could not link liblzfse, disabling')
938 endif
939endif
940
Paolo Bonzini478e9432020-08-17 12:47:55 +0200941oss = not_found
Thomas Huthab486f12021-11-02 11:58:22 +0100942if have_system and not get_option('oss').disabled()
Paolo Bonzini87430d52021-10-07 15:06:09 +0200943 if not cc.has_header('sys/soundcard.h')
944 # not found
945 elif targetos == 'netbsd'
946 oss = cc.find_library('ossaudio', required: get_option('oss'),
947 kwargs: static_kwargs)
948 else
949 oss = declare_dependency()
950 endif
951
952 if not oss.found()
953 if get_option('oss').enabled()
954 error('OSS not found')
Paolo Bonzini87430d52021-10-07 15:06:09 +0200955 endif
956 endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200957endif
958dsound = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200959if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
960 if cc.has_header('dsound.h')
961 dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
962 endif
963
964 if not dsound.found()
965 if get_option('dsound').enabled()
966 error('DirectSound not found')
Paolo Bonzini87430d52021-10-07 15:06:09 +0200967 endif
968 endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200969endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200970
Paolo Bonzini478e9432020-08-17 12:47:55 +0200971coreaudio = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200972if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
973 coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
974 required: get_option('coreaudio'))
Paolo Bonzini478e9432020-08-17 12:47:55 +0200975endif
Thomas Huth8bc51842021-07-13 13:09:02 +0200976
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400977opengl = not_found
978if 'CONFIG_OPENGL' in config_host
Paolo Bonzinide2d3002020-09-01 08:41:17 -0400979 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
980 link_args: config_host['OPENGL_LIBS'].split())
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400981endif
Thomas Huth8bc51842021-07-13 13:09:02 +0200982gbm = not_found
983if (have_system or have_tools) and (virgl.found() or opengl.found())
984 gbm = dependency('gbm', method: 'pkg-config', required: false,
985 kwargs: static_kwargs)
986endif
Paolo Bonzini1b695472021-01-07 14:02:29 +0100987
Paolo Bonzini57612512021-06-03 11:15:26 +0200988gnutls = not_found
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +0100989gnutls_crypto = not_found
Alyssa Rossabc14fd2021-08-06 14:49:47 +0000990if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +0100991 # For general TLS support our min gnutls matches
992 # that implied by our platform support matrix
993 #
994 # For the crypto backends, we look for a newer
995 # gnutls:
996 #
997 # Version 3.6.8 is needed to get XTS
998 # Version 3.6.13 is needed to get PBKDF
999 # Version 3.6.14 is needed to get HW accelerated XTS
1000 #
1001 # If newer enough gnutls isn't available, we can
1002 # still use a different crypto backend to satisfy
1003 # the platform support requirements
1004 gnutls_crypto = dependency('gnutls', version: '>=3.6.14',
1005 method: 'pkg-config',
1006 required: false,
1007 kwargs: static_kwargs)
1008 if gnutls_crypto.found()
1009 gnutls = gnutls_crypto
1010 else
1011 # Our min version if all we need is TLS
1012 gnutls = dependency('gnutls', version: '>=3.5.18',
1013 method: 'pkg-config',
1014 required: get_option('gnutls'),
1015 kwargs: static_kwargs)
1016 endif
Paolo Bonzini57612512021-06-03 11:15:26 +02001017endif
1018
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001019# We prefer use of gnutls for crypto, unless the options
1020# explicitly asked for nettle or gcrypt.
1021#
1022# If gnutls isn't available for crypto, then we'll prefer
1023# gcrypt over nettle for performance reasons.
Paolo Bonzini57612512021-06-03 11:15:26 +02001024gcrypt = not_found
1025nettle = not_found
Daniel P. Berrangé68014042021-07-02 17:00:32 +01001026xts = 'none'
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001027
Paolo Bonzini57612512021-06-03 11:15:26 +02001028if get_option('nettle').enabled() and get_option('gcrypt').enabled()
1029 error('Only one of gcrypt & nettle can be enabled')
Paolo Bonzini57612512021-06-03 11:15:26 +02001030endif
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001031
1032# Explicit nettle/gcrypt request, so ignore gnutls for crypto
1033if get_option('nettle').enabled() or get_option('gcrypt').enabled()
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +01001034 gnutls_crypto = not_found
1035endif
Paolo Bonzini57612512021-06-03 11:15:26 +02001036
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001037if not gnutls_crypto.found()
1038 if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
1039 gcrypt = dependency('libgcrypt', version: '>=1.8',
1040 method: 'config-tool',
1041 required: get_option('gcrypt'),
1042 kwargs: static_kwargs)
1043 # Debian has removed -lgpg-error from libgcrypt-config
1044 # as it "spreads unnecessary dependencies" which in
1045 # turn breaks static builds...
1046 if gcrypt.found() and enable_static
1047 gcrypt = declare_dependency(dependencies: [
1048 gcrypt,
1049 cc.find_library('gpg-error', required: true, kwargs: static_kwargs)])
1050 endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001051 endif
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001052 if (not get_option('nettle').auto() or have_system) and not gcrypt.found()
1053 nettle = dependency('nettle', version: '>=3.4',
1054 method: 'pkg-config',
1055 required: get_option('nettle'),
1056 kwargs: static_kwargs)
1057 if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle)
1058 xts = 'private'
1059 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001060 endif
1061endif
1062
1063gtk = not_found
Paolo Bonzini1b695472021-01-07 14:02:29 +01001064gtkx11 = not_found
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001065vte = not_found
Paolo Bonzinic1ec4942021-01-07 14:04:00 +01001066if not get_option('gtk').auto() or (have_system and not cocoa.found())
Paolo Bonzini1b695472021-01-07 14:02:29 +01001067 gtk = dependency('gtk+-3.0', version: '>=3.22.0',
1068 method: 'pkg-config',
1069 required: get_option('gtk'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001070 kwargs: static_kwargs)
Paolo Bonzini1b695472021-01-07 14:02:29 +01001071 if gtk.found()
1072 gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
1073 method: 'pkg-config',
1074 required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001075 kwargs: static_kwargs)
Paolo Bonzini1b695472021-01-07 14:02:29 +01001076 gtk = declare_dependency(dependencies: [gtk, gtkx11])
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001077
1078 if not get_option('vte').auto() or have_system
1079 vte = dependency('vte-2.91',
1080 method: 'pkg-config',
1081 required: get_option('vte'),
1082 kwargs: static_kwargs)
1083 endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001084 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001085endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001086
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001087x11 = not_found
Markus Armbruster9d49bcf2021-05-03 10:40:33 +02001088if gtkx11.found()
Paolo Bonzini1b695472021-01-07 14:02:29 +01001089 x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001090 kwargs: static_kwargs)
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001091endif
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001092vnc = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001093png = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001094jpeg = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001095sasl = not_found
Thomas Huth95e22892021-09-06 17:39:39 +02001096if have_system and not get_option('vnc').disabled()
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001097 vnc = declare_dependency() # dummy dependency
1098 png = dependency('libpng', required: get_option('vnc_png'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001099 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini8e242b32020-11-23 13:34:02 -05001100 jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001101 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001102 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
1103 required: get_option('vnc_sasl'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001104 kwargs: static_kwargs)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001105 if sasl.found()
1106 sasl = declare_dependency(dependencies: sasl,
1107 compile_args: '-DSTRUCT_IOVEC_DEFINED')
1108 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001109endif
Paolo Bonzini241611e2020-11-17 13:32:34 +01001110
Paolo Bonzini05e391a2021-06-03 11:15:26 +02001111pam = not_found
1112if not get_option('auth_pam').auto() or have_system
1113 pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
1114 required: get_option('auth_pam'),
1115 kwargs: static_kwargs)
1116endif
1117if pam.found() and not cc.links('''
1118 #include <stddef.h>
1119 #include <security/pam_appl.h>
1120 int main(void) {
1121 const char *service_name = "qemu";
1122 const char *user = "frank";
1123 const struct pam_conv pam_conv = { 0 };
1124 pam_handle_t *pamh = NULL;
1125 pam_start(service_name, user, &pam_conv, &pamh);
1126 return 0;
1127 }''', dependencies: pam)
1128 pam = not_found
1129 if get_option('auth_pam').enabled()
1130 error('could not link libpam')
1131 else
1132 warning('could not link libpam, disabling')
1133 endif
1134endif
1135
Marc-André Lureau708eab42019-09-03 16:59:33 +04001136snappy = not_found
Paolo Bonzini241611e2020-11-17 13:32:34 +01001137if not get_option('snappy').auto() or have_system
1138 snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
1139 required: get_option('snappy'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001140 kwargs: static_kwargs)
Marc-André Lureau708eab42019-09-03 16:59:33 +04001141endif
Paolo Bonzini565174d2021-11-04 14:35:14 +01001142if snappy.found() and not linker.links('''
Paolo Bonzini241611e2020-11-17 13:32:34 +01001143 #include <snappy-c.h>
1144 int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
1145 snappy = not_found
1146 if get_option('snappy').enabled()
1147 error('could not link libsnappy')
1148 else
1149 warning('could not link libsnappy, disabling')
1150 endif
Marc-André Lureau708eab42019-09-03 16:59:33 +04001151endif
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001152
Marc-André Lureau708eab42019-09-03 16:59:33 +04001153lzo = not_found
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001154if not get_option('lzo').auto() or have_system
1155 lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
1156 required: get_option('lzo'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001157 kwargs: static_kwargs)
Marc-André Lureau708eab42019-09-03 16:59:33 +04001158endif
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001159if lzo.found() and not cc.links('''
1160 #include <lzo/lzo1x.h>
1161 int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
1162 lzo = not_found
1163 if get_option('lzo').enabled()
1164 error('could not link liblzo2')
1165 else
1166 warning('could not link liblzo2, disabling')
1167 endif
1168endif
1169
Marc-André Lureau55166232019-07-24 19:16:22 +04001170rdma = not_found
1171if 'CONFIG_RDMA' in config_host
1172 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
1173endif
Marc-André Lureauab318052019-07-24 19:23:16 +04001174numa = not_found
1175if 'CONFIG_NUMA' in config_host
1176 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
1177endif
Marc-André Lureau582ea952019-08-15 15:15:32 +04001178xen = not_found
1179if 'CONFIG_XEN_BACKEND' in config_host
1180 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
1181 link_args: config_host['XEN_LIBS'].split())
1182endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001183cacard = not_found
Paolo Bonzini5f364c52021-06-03 11:15:26 +02001184if not get_option('smartcard').auto() or have_system
1185 cacard = dependency('libcacard', required: get_option('smartcard'),
1186 version: '>=2.5.1', method: 'pkg-config',
1187 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001188endif
César Belley0a40bcb2020-08-26 13:42:04 +02001189u2f = not_found
1190if have_system
1191 u2f = dependency('u2f-emu', required: get_option('u2f'),
1192 method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001193 kwargs: static_kwargs)
César Belley0a40bcb2020-08-26 13:42:04 +02001194endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001195usbredir = not_found
Paolo Bonzini18f31e62021-06-03 11:15:26 +02001196if not get_option('usb_redir').auto() or have_system
1197 usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
1198 version: '>=0.6', method: 'pkg-config',
1199 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001200endif
1201libusb = not_found
Paolo Bonzini90540f32021-06-03 11:15:26 +02001202if not get_option('libusb').auto() or have_system
1203 libusb = dependency('libusb-1.0', required: get_option('libusb'),
1204 version: '>=1.0.13', method: 'pkg-config',
1205 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001206endif
Paolo Bonzini90540f32021-06-03 11:15:26 +02001207
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001208libpmem = not_found
Paolo Bonzinie36e8c72021-06-03 11:31:35 +02001209if not get_option('libpmem').auto() or have_system
1210 libpmem = dependency('libpmem', required: get_option('libpmem'),
1211 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001212endif
Bruce Rogersc7c91a72020-08-24 09:52:12 -06001213libdaxctl = not_found
Paolo Bonzini83ef1682021-06-03 11:31:35 +02001214if not get_option('libdaxctl').auto() or have_system
1215 libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'),
1216 version: '>=57', method: 'pkg-config',
1217 kwargs: static_kwargs)
Bruce Rogersc7c91a72020-08-24 09:52:12 -06001218endif
Marc-André Lureau8ce0a452020-08-28 15:07:20 +04001219tasn1 = not_found
Paolo Bonziniba7ed402021-06-03 11:15:26 +02001220if gnutls.found()
1221 tasn1 = dependency('libtasn1',
1222 method: 'pkg-config',
1223 kwargs: static_kwargs)
Marc-André Lureau8ce0a452020-08-28 15:07:20 +04001224endif
Marc-André Lureauaf04e892020-08-28 15:07:25 +04001225keyutils = dependency('libkeyutils', required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001226 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001227
Marc-André Lureau3909def2020-08-28 15:07:33 +04001228has_gettid = cc.has_function('gettid')
1229
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06001230# libselinux
1231selinux = dependency('libselinux',
1232 required: get_option('selinux'),
1233 method: 'pkg-config', kwargs: static_kwargs)
1234
Paolo Bonziniaa087962020-09-01 11:15:30 -04001235# Malloc tests
1236
1237malloc = []
1238if get_option('malloc') == 'system'
1239 has_malloc_trim = \
1240 not get_option('malloc_trim').disabled() and \
1241 cc.links('''#include <malloc.h>
1242 int main(void) { malloc_trim(0); return 0; }''')
1243else
1244 has_malloc_trim = false
1245 malloc = cc.find_library(get_option('malloc'), required: true)
1246endif
1247if not has_malloc_trim and get_option('malloc_trim').enabled()
1248 if get_option('malloc') == 'system'
1249 error('malloc_trim not available on this platform.')
1250 else
1251 error('malloc_trim not available with non-libc memory allocator')
1252 endif
1253endif
1254
Max Reitz84e319a2020-11-02 17:18:55 +01001255# Check whether the glibc provides statx()
1256
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001257gnu_source_prefix = '''
Max Reitz84e319a2020-11-02 17:18:55 +01001258 #ifndef _GNU_SOURCE
1259 #define _GNU_SOURCE
1260 #endif
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001261'''
1262statx_test = gnu_source_prefix + '''
Max Reitz84e319a2020-11-02 17:18:55 +01001263 #include <sys/stat.h>
1264 int main(void) {
1265 struct statx statxbuf;
1266 statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
1267 return 0;
1268 }'''
1269
1270has_statx = cc.links(statx_test)
1271
Stefan Hajnoczieb6a3882020-11-10 17:11:20 +00001272have_vhost_user_blk_server = (targetos == 'linux' and
1273 'CONFIG_VHOST_USER' in config_host)
Stefan Hajnoczie5e856c2020-11-10 17:11:19 +00001274
1275if get_option('vhost_user_blk_server').enabled()
1276 if targetos != 'linux'
1277 error('vhost_user_blk_server requires linux')
Stefan Hajnoczieb6a3882020-11-10 17:11:20 +00001278 elif 'CONFIG_VHOST_USER' not in config_host
1279 error('vhost_user_blk_server requires vhost-user support')
Stefan Hajnoczie5e856c2020-11-10 17:11:19 +00001280 endif
1281elif get_option('vhost_user_blk_server').disabled() or not have_system
1282 have_vhost_user_blk_server = false
1283endif
1284
Daniele Buono9e62ba42020-12-04 18:06:14 -05001285
Max Reitzdf4ea702020-10-27 20:05:46 +01001286if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
1287 error('Cannot enable fuse-lseek while fuse is disabled')
1288endif
1289
Max Reitza484a712020-10-27 20:05:41 +01001290fuse = dependency('fuse3', required: get_option('fuse'),
1291 version: '>=3.1', method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001292 kwargs: static_kwargs)
Max Reitza484a712020-10-27 20:05:41 +01001293
Max Reitzdf4ea702020-10-27 20:05:46 +01001294fuse_lseek = not_found
1295if not get_option('fuse_lseek').disabled()
1296 if fuse.version().version_compare('>=3.8')
1297 # Dummy dependency
1298 fuse_lseek = declare_dependency()
1299 elif get_option('fuse_lseek').enabled()
1300 if fuse.found()
1301 error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
1302 else
1303 error('fuse-lseek requires libfuse, which was not found')
1304 endif
1305 endif
1306endif
1307
Andrew Melnychenko46627f42021-05-14 14:48:32 +03001308# libbpf
1309libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config')
1310if libbpf.found() and not cc.links('''
1311 #include <bpf/libbpf.h>
1312 int main(void)
1313 {
1314 bpf_object__destroy_skeleton(NULL);
1315 return 0;
1316 }''', dependencies: libbpf)
1317 libbpf = not_found
1318 if get_option('bpf').enabled()
1319 error('libbpf skeleton test failed')
1320 else
1321 warning('libbpf skeleton test failed, disabling')
1322 endif
1323endif
1324
Paolo Bonzini87430d52021-10-07 15:06:09 +02001325#################
1326# config-host.h #
1327#################
1328
1329audio_drivers_selected = []
1330if have_system
1331 audio_drivers_available = {
1332 'alsa': alsa.found(),
1333 'coreaudio': coreaudio.found(),
1334 'dsound': dsound.found(),
1335 'jack': jack.found(),
1336 'oss': oss.found(),
1337 'pa': pulse.found(),
1338 'sdl': sdl.found(),
1339 }
Paolo Bonzinie5424a22021-10-07 15:06:10 +02001340 foreach k, v: audio_drivers_available
1341 config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
1342 endforeach
Paolo Bonzini87430d52021-10-07 15:06:09 +02001343
1344 # Default to native drivers first, OSS second, SDL third
1345 audio_drivers_priority = \
1346 [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \
1347 (targetos == 'linux' ? [] : [ 'sdl' ])
1348 audio_drivers_default = []
1349 foreach k: audio_drivers_priority
1350 if audio_drivers_available[k]
1351 audio_drivers_default += k
1352 endif
1353 endforeach
1354
1355 foreach k: get_option('audio_drv_list')
1356 if k == 'default'
1357 audio_drivers_selected += audio_drivers_default
1358 elif not audio_drivers_available[k]
1359 error('Audio driver "@0@" not available.'.format(k))
1360 else
1361 audio_drivers_selected += k
1362 endif
1363 endforeach
1364endif
Paolo Bonzini87430d52021-10-07 15:06:09 +02001365config_host_data.set('CONFIG_AUDIO_DRIVERS',
1366 '"' + '", "'.join(audio_drivers_selected) + '", ')
1367
Daniele Buono9e62ba42020-12-04 18:06:14 -05001368if get_option('cfi')
1369 cfi_flags=[]
1370 # Check for dependency on LTO
1371 if not get_option('b_lto')
1372 error('Selected Control-Flow Integrity but LTO is disabled')
1373 endif
1374 if config_host.has_key('CONFIG_MODULES')
1375 error('Selected Control-Flow Integrity is not compatible with modules')
1376 endif
1377 # Check for cfi flags. CFI requires LTO so we can't use
1378 # get_supported_arguments, but need a more complex "compiles" which allows
1379 # custom arguments
1380 if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
1381 args: ['-flto', '-fsanitize=cfi-icall'] )
1382 cfi_flags += '-fsanitize=cfi-icall'
1383 else
1384 error('-fsanitize=cfi-icall is not supported by the compiler')
1385 endif
1386 if cc.compiles('int main () { return 0; }',
1387 name: '-fsanitize-cfi-icall-generalize-pointers',
1388 args: ['-flto', '-fsanitize=cfi-icall',
1389 '-fsanitize-cfi-icall-generalize-pointers'] )
1390 cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
1391 else
1392 error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
1393 endif
1394 if get_option('cfi_debug')
1395 if cc.compiles('int main () { return 0; }',
1396 name: '-fno-sanitize-trap=cfi-icall',
1397 args: ['-flto', '-fsanitize=cfi-icall',
1398 '-fno-sanitize-trap=cfi-icall'] )
1399 cfi_flags += '-fno-sanitize-trap=cfi-icall'
1400 else
1401 error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
1402 endif
1403 endif
Marc-André Lureau5fc06172021-01-14 16:56:02 +04001404 add_global_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
1405 add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
Daniele Buono9e62ba42020-12-04 18:06:14 -05001406endif
1407
Joelle van Dyne14176c82021-03-15 11:03:38 -07001408have_host_block_device = (targetos != 'darwin' or
1409 cc.has_header('IOKit/storage/IOMedia.h'))
1410
Marc-André Lureau142ca622021-07-15 11:53:53 +04001411dbus_display = false
1412if not get_option('dbus_display').disabled()
1413 # FIXME enable_modules shouldn't be necessary, but: https://github.com/mesonbuild/meson/issues/8333
1414 dbus_display = gio.version().version_compare('>=2.64') and config_host.has_key('GDBUS_CODEGEN') and enable_modules
1415 if get_option('dbus_display').enabled() and not dbus_display
1416 error('Requirements missing to enable -display dbus (glib>=2.64 && --enable-modules)')
1417 endif
1418endif
1419
Paolo Bonzini69202b42020-11-17 14:46:21 +01001420have_virtfs = (targetos == 'linux' and
1421 have_system and
1422 libattr.found() and
1423 libcap_ng.found())
1424
Philippe Mathieu-Daudé3a489d32021-01-20 16:15:39 +01001425have_virtfs_proxy_helper = have_virtfs and have_tools
1426
Paolo Bonzini69202b42020-11-17 14:46:21 +01001427if get_option('virtfs').enabled()
1428 if not have_virtfs
1429 if targetos != 'linux'
1430 error('virtio-9p (virtfs) requires Linux')
1431 elif not libcap_ng.found() or not libattr.found()
1432 error('virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel')
1433 elif not have_system
1434 error('virtio-9p (virtfs) needs system emulation support')
1435 endif
1436 endif
1437elif get_option('virtfs').disabled()
1438 have_virtfs = false
1439endif
1440
Paolo Bonzini9c29b742021-10-07 15:08:14 +02001441foreach k : get_option('trace_backends')
1442 config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
1443endforeach
1444config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'))
1445
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04001446config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
1447config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
1448config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
1449config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
1450config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
1451config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
1452config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
1453config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
1454config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
1455config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
1456config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
1457config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
1458
Paolo Bonzini823eb012021-11-08 14:18:17 +01001459config_host_data.set('HOST_' + host_arch.to_upper(), 1)
1460
Paolo Bonzinif7f2d652020-11-17 14:45:24 +01001461config_host_data.set('CONFIG_ATTR', libattr.found())
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +01001462config_host_data.set('CONFIG_BRLAPI', brlapi.found())
Paolo Bonzinib4e312e2020-09-01 11:28:59 -04001463config_host_data.set('CONFIG_COCOA', cocoa.found())
Paolo Bonzini537b7242021-10-07 15:08:12 +02001464config_host_data.set('CONFIG_FUZZ', get_option('fuzzing'))
Paolo Bonziniaf2bb992021-10-07 15:08:17 +02001465config_host_data.set('CONFIG_GCOV', get_option('b_coverage'))
Paolo Bonzinif01496a2020-09-16 17:54:14 +02001466config_host_data.set('CONFIG_LIBUDEV', libudev.found())
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001467config_host_data.set('CONFIG_LZO', lzo.found())
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02001468config_host_data.set('CONFIG_MPATH', mpathpersist.found())
1469config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
Paolo Bonzinif9cd86f2020-11-17 12:43:15 +01001470config_host_data.set('CONFIG_CURL', curl.found())
Yonggang Luo5285e592020-10-13 07:43:48 +08001471config_host_data.set('CONFIG_CURSES', curses.found())
Thomas Huth8bc51842021-07-13 13:09:02 +02001472config_host_data.set('CONFIG_GBM', gbm.found())
Paolo Bonzini08821ca2020-11-17 13:01:26 +01001473config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
1474if glusterfs.found()
1475 config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
1476 config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5'))
1477 config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6'))
1478 config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
1479 config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
1480 config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
1481endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001482config_host_data.set('CONFIG_GTK', gtk.found())
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001483config_host_data.set('CONFIG_VTE', vte.found())
Paolo Bonzinif7f2d652020-11-17 14:45:24 +01001484config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
Paolo Bonzini727c8bb2020-11-17 14:46:58 +01001485config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
Andrew Melnychenko46627f42021-05-14 14:48:32 +03001486config_host_data.set('CONFIG_EBPF', libbpf.found())
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001487config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
Paolo Bonzini9db405a2020-11-17 13:11:25 +01001488config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
Paolo Bonzini30045c02020-11-17 13:11:25 +01001489config_host_data.set('CONFIG_LIBNFS', libnfs.found())
Thomas Huthe6a52b32021-12-09 15:48:01 +01001490config_host_data.set('CONFIG_LIBSSH', libssh.found())
Paolo Bonziniff66f3e2021-10-07 15:08:20 +02001491config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001492config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
1493config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
Paolo Bonzinifabd1e92020-11-17 13:11:25 +01001494config_host_data.set('CONFIG_RBD', rbd.found())
Paolo Bonzini35be72b2020-02-06 14:17:15 +01001495config_host_data.set('CONFIG_SDL', sdl.found())
1496config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
Paolo Bonzini90835c22020-11-17 14:22:24 +01001497config_host_data.set('CONFIG_SECCOMP', seccomp.found())
Paolo Bonzini241611e2020-11-17 13:32:34 +01001498config_host_data.set('CONFIG_SNAPPY', snappy.found())
Paolo Bonzini90540f32021-06-03 11:15:26 +02001499config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
Paolo Bonzinie1723992021-10-07 15:08:21 +02001500config_host_data.set('CONFIG_VDE', vde.found())
Stefan Hajnoczie5e856c2020-11-10 17:11:19 +00001501config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001502config_host_data.set('CONFIG_VNC', vnc.found())
1503config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
1504config_host_data.set('CONFIG_VNC_PNG', png.found())
1505config_host_data.set('CONFIG_VNC_SASL', sasl.found())
Paolo Bonzini69202b42020-11-17 14:46:21 +01001506config_host_data.set('CONFIG_VIRTFS', have_virtfs)
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001507config_host_data.set('CONFIG_VTE', vte.found())
Laurent Vivier4113f4c2020-08-24 17:24:29 +02001508config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
Marc-André Lureauaf04e892020-08-28 15:07:25 +04001509config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
Marc-André Lureau3909def2020-08-28 15:07:33 +04001510config_host_data.set('CONFIG_GETTID', has_gettid)
Paolo Bonzini57612512021-06-03 11:15:26 +02001511config_host_data.set('CONFIG_GNUTLS', gnutls.found())
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +01001512config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found())
Paolo Bonzini57612512021-06-03 11:15:26 +02001513config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
1514config_host_data.set('CONFIG_NETTLE', nettle.found())
1515config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private')
Paolo Bonziniaa087962020-09-01 11:15:30 -04001516config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
Max Reitz84e319a2020-11-02 17:18:55 +01001517config_host_data.set('CONFIG_STATX', has_statx)
Paolo Bonzinib1def332020-11-17 13:37:39 +01001518config_host_data.set('CONFIG_ZSTD', zstd.found())
Max Reitza484a712020-10-27 20:05:41 +01001519config_host_data.set('CONFIG_FUSE', fuse.found())
Max Reitzdf4ea702020-10-27 20:05:46 +01001520config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001521config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found())
Marc-André Lureauddece462021-10-06 14:18:09 +04001522if spice_protocol.found()
1523config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version().split('.')[0])
1524config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version().split('.')[1])
1525config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version().split('.')[2])
1526endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001527config_host_data.set('CONFIG_SPICE', spice.found())
Paolo Bonzini9d710372021-01-07 13:54:22 +01001528config_host_data.set('CONFIG_X11', x11.found())
Marc-André Lureau142ca622021-07-15 11:53:53 +04001529config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display)
Daniele Buono9e62ba42020-12-04 18:06:14 -05001530config_host_data.set('CONFIG_CFI', get_option('cfi'))
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06001531config_host_data.set('CONFIG_SELINUX', selinux.found())
Paolo Bonzini859aef02020-08-04 18:14:26 +02001532config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
1533config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
1534config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
1535config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
1536
Paolo Bonzinia6305082021-10-07 15:08:15 +02001537config_host_data.set_quoted('CONFIG_HOST_DSOSUF', host_dsosuf)
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001538config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
Paolo Bonzini269506d2021-10-07 15:08:16 +02001539config_host_data.set('HOST_WORDS_BIGENDIAN', host_machine.endian() == 'big')
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001540
1541# has_header
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001542config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h'))
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001543config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h'))
1544config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h'))
Thomas Huth48f670e2020-11-18 18:10:52 +01001545config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
Thomas Huth2964be52020-11-18 18:10:49 +01001546config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
Thomas Huth2802d912020-11-18 18:10:48 +01001547config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001548config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
Thomas Huthded5d782020-11-14 11:10:11 +01001549config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
Thomas Huth4a9d5f82020-11-18 18:10:51 +01001550config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
Thomas Huthded5d782020-11-14 11:10:11 +01001551
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001552# has_function
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001553config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001554config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
1555config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
1556config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate'))
1557config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001558config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001559config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
Peter Maydell2b9f74e2021-01-26 15:58:46 +00001560config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001561config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001562config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile'))
1563config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare'))
1564config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
1565config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
1566config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001567config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001568config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001569config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001570config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
Li Zhijian911965a2021-09-10 15:02:55 +08001571if rdma.found()
1572 config_host_data.set('HAVE_IBV_ADVISE_MR',
1573 cc.has_function('ibv_advise_mr',
1574 args: config_host['RDMA_LIBS'].split(),
1575 prefix: '#include <infiniband/verbs.h>'))
1576endif
Peter Maydell2b9f74e2021-01-26 15:58:46 +00001577
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001578# has_header_symbol
1579config_host_data.set('CONFIG_BYTESWAP_H',
1580 cc.has_header_symbol('byteswap.h', 'bswap_32'))
1581config_host_data.set('CONFIG_EPOLL_CREATE1',
1582 cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001583config_host_data.set('CONFIG_HAS_ENVIRON',
1584 cc.has_header_symbol('unistd.h', 'environ', prefix: gnu_source_prefix))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001585config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
1586 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and
1587 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE'))
1588config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE',
1589 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE'))
1590config_host_data.set('CONFIG_FIEMAP',
1591 cc.has_header('linux/fiemap.h') and
1592 cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001593config_host_data.set('CONFIG_GETRANDOM',
1594 cc.has_function('getrandom') and
1595 cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK'))
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001596config_host_data.set('CONFIG_INOTIFY',
1597 cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
1598config_host_data.set('CONFIG_INOTIFY1',
1599 cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001600config_host_data.set('CONFIG_MACHINE_BSWAP_H',
1601 cc.has_header_symbol('machine/bswap.h', 'bswap32',
1602 prefix: '''#include <sys/endian.h>
1603 #include <sys/types.h>'''))
1604config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
1605 cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001606config_host_data.set('CONFIG_RTNETLINK',
1607 cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN'))
1608config_host_data.set('CONFIG_SYSMACROS',
1609 cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001610config_host_data.set('HAVE_OPTRESET',
1611 cc.has_header_symbol('getopt.h', 'optreset'))
Marc-André Lureau653163f2021-09-07 16:19:13 +04001612config_host_data.set('HAVE_IPPROTO_MPTCP',
1613 cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001614
1615# has_member
1616config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
1617 cc.has_member('struct sigevent', 'sigev_notify_thread_id',
1618 prefix: '#include <signal.h>'))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001619config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM',
1620 cc.has_member('struct stat', 'st_atim',
1621 prefix: '#include <sys/stat.h>'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001622
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001623# has_type
1624config_host_data.set('CONFIG_IOVEC',
1625 cc.has_type('struct iovec',
1626 prefix: '#include <sys/uio.h>'))
1627config_host_data.set('HAVE_UTMPX',
1628 cc.has_type('struct utmpx',
1629 prefix: '#include <utmpx.h>'))
1630
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001631config_host_data.set('CONFIG_EVENTFD', cc.links('''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001632 #include <sys/eventfd.h>
1633 int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001634config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001635 #include <unistd.h>
1636 int main(void) {
1637 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
1638 return fdatasync(0);
1639 #else
1640 #error Not supported
1641 #endif
1642 }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001643config_host_data.set('CONFIG_MADVISE', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001644 #include <sys/types.h>
1645 #include <sys/mman.h>
1646 #include <stddef.h>
1647 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001648config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001649 #include <sys/mman.h>
1650 int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001651config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001652 #include <fcntl.h>
1653 #if !defined(AT_EMPTY_PATH)
1654 # error missing definition
1655 #else
1656 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
1657 #endif'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001658config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + '''
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001659 #include <unistd.h>
1660 #include <fcntl.h>
1661
1662 int main(void)
1663 {
1664 int pipefd[2];
1665 return pipe2(pipefd, O_CLOEXEC);
1666 }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001667config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001668 #include <sys/mman.h>
1669 #include <stddef.h>
1670 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }'''))
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001671
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001672config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + '''
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001673 #include <pthread.h>
1674
1675 static void *f(void *p) { return NULL; }
1676 int main(void)
1677 {
1678 pthread_t thread;
1679 pthread_create(&thread, 0, f, 0);
1680 pthread_setname_np(thread, "QEMU");
1681 return 0;
1682 }''', dependencies: threads))
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001683config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + '''
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001684 #include <pthread.h>
1685
1686 static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
1687 int main(void)
1688 {
1689 pthread_t thread;
1690 pthread_create(&thread, 0, f, 0);
1691 return 0;
1692 }''', dependencies: threads))
1693
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001694config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
Kacper Słomiński6bd17dc2021-09-05 03:16:22 +02001695 #include <sys/signalfd.h>
1696 #include <stddef.h>
1697 int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001698config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + '''
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001699 #include <unistd.h>
1700 #include <fcntl.h>
1701 #include <limits.h>
1702
1703 int main(void)
1704 {
1705 int len, fd = 0;
1706 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1707 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1708 return 0;
1709 }'''))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001710
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001711config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + '''
1712 #include <sys/mman.h>
1713 int main(int argc, char *argv[]) {
1714 return mlockall(MCL_FUTURE);
1715 }'''))
1716
Thomas Hutheea94532021-10-28 20:59:08 +02001717have_l2tpv3 = false
1718if not get_option('l2tpv3').disabled() and have_system
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001719 have_l2tpv3 = cc.has_type('struct mmsghdr',
1720 prefix: gnu_source_prefix + '''
1721 #include <sys/socket.h>
1722 #include <linux/ip.h>''')
Thomas Hutheea94532021-10-28 20:59:08 +02001723endif
1724config_host_data.set('CONFIG_L2TPV3', have_l2tpv3)
1725
Paolo Bonzini837b84b2021-10-07 15:08:22 +02001726have_netmap = false
1727if not get_option('netmap').disabled() and have_system
1728 have_netmap = cc.compiles('''
1729 #include <inttypes.h>
1730 #include <net/if.h>
1731 #include <net/netmap.h>
1732 #include <net/netmap_user.h>
1733 #if (NETMAP_API < 11) || (NETMAP_API > 15)
1734 #error
1735 #endif
1736 int main(void) { return 0; }''')
1737 if not have_netmap and get_option('netmap').enabled()
1738 error('Netmap headers not available')
1739 endif
1740endif
1741config_host_data.set('CONFIG_NETMAP', have_netmap)
1742
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001743# Work around a system header bug with some kernel/XFS header
1744# versions where they both try to define 'struct fsxattr':
1745# xfs headers will not try to redefine structs from linux headers
1746# if this macro is set.
1747config_host_data.set('HAVE_FSXATTR', cc.links('''
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001748 #include <linux/fs.h>
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001749 struct fsxattr foo;
1750 int main(void) {
1751 return 0;
1752 }'''))
1753
Paolo Bonzinie46bd552021-06-03 11:57:04 +02001754# Some versions of Mac OS X incorrectly define SIZE_MAX
1755config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
1756 #include <stdint.h>
1757 #include <stdio.h>
1758 int main(int argc, char *argv[]) {
1759 return printf("%zu", SIZE_MAX);
1760 }''', args: ['-Werror']))
1761
Paolo Bonzinibd87a362021-10-07 15:08:25 +02001762# See if 64-bit atomic operations are supported.
1763# Note that without __atomic builtins, we can only
1764# assume atomic loads/stores max at pointer size.
1765config_host_data.set('CONFIG_ATOMIC64', cc.links('''
1766 #include <stdint.h>
1767 int main(void)
1768 {
1769 uint64_t x = 0, y = 0;
1770 y = __atomic_load_n(&x, __ATOMIC_RELAXED);
1771 __atomic_store_n(&x, y, __ATOMIC_RELAXED);
1772 __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
1773 __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
1774 __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
1775 return 0;
1776 }'''))
1777
1778config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
1779 #include <sys/auxv.h>
1780 int main(void) {
1781 return getauxval(AT_HWCAP) == 0;
1782 }'''))
1783
1784config_host_data.set('CONFIG_AF_VSOCK', cc.compiles(gnu_source_prefix + '''
1785 #include <errno.h>
1786 #include <sys/types.h>
1787 #include <sys/socket.h>
1788 #if !defined(AF_VSOCK)
1789 # error missing AF_VSOCK flag
1790 #endif
1791 #include <linux/vm_sockets.h>
1792 int main(void) {
1793 int sock, ret;
1794 struct sockaddr_vm svm;
1795 socklen_t len = sizeof(svm);
1796 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
1797 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
1798 if ((ret == -1) && (errno == ENOTCONN)) {
1799 return 0;
1800 }
1801 return -1;
1802 }'''))
1803
Paolo Bonzinia76a1f62021-10-13 10:04:24 +02001804ignored = ['CONFIG_QEMU_INTERP_PREFIX', # actually per-target
1805 'HAVE_GDB_BIN']
Paolo Bonzini87430d52021-10-07 15:06:09 +02001806arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
Paolo Bonzinia6305082021-10-07 15:08:15 +02001807strings = ['CONFIG_IASL']
Paolo Bonzini859aef02020-08-04 18:14:26 +02001808foreach k, v: config_host
Paolo Bonzini765686d2020-09-18 06:37:21 -04001809 if ignored.contains(k)
1810 # do nothing
1811 elif arrays.contains(k)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001812 if v != ''
1813 v = '"' + '", "'.join(v.split()) + '", '
1814 endif
1815 config_host_data.set(k, v)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001816 elif strings.contains(k)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001817 config_host_data.set_quoted(k, v)
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001818 elif k.startswith('CONFIG_')
Paolo Bonzini859aef02020-08-04 18:14:26 +02001819 config_host_data.set(k, v == 'y' ? 1 : v)
1820 endif
1821endforeach
Paolo Bonzini859aef02020-08-04 18:14:26 +02001822
Paolo Bonzinia0c91622020-10-07 11:01:51 -04001823########################
1824# Target configuration #
1825########################
1826
Paolo Bonzini2becc362020-02-03 11:42:03 +01001827minikconf = find_program('scripts/minikconf.py')
Paolo Bonzini05512f52020-09-16 15:31:11 -04001828config_all = {}
Paolo Bonzinia98006b2020-09-01 05:32:23 -04001829config_all_devices = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001830config_all_disas = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001831config_devices_mak_list = []
1832config_devices_h = {}
Paolo Bonzini859aef02020-08-04 18:14:26 +02001833config_target_h = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001834config_target_mak = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001835
1836disassemblers = {
1837 'alpha' : ['CONFIG_ALPHA_DIS'],
1838 'arm' : ['CONFIG_ARM_DIS'],
1839 'avr' : ['CONFIG_AVR_DIS'],
1840 'cris' : ['CONFIG_CRIS_DIS'],
Taylor Simpson3e7a84e2021-02-07 23:46:24 -06001841 'hexagon' : ['CONFIG_HEXAGON_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001842 'hppa' : ['CONFIG_HPPA_DIS'],
1843 'i386' : ['CONFIG_I386_DIS'],
1844 'x86_64' : ['CONFIG_I386_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001845 'm68k' : ['CONFIG_M68K_DIS'],
1846 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
1847 'mips' : ['CONFIG_MIPS_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001848 'nios2' : ['CONFIG_NIOS2_DIS'],
1849 'or1k' : ['CONFIG_OPENRISC_DIS'],
1850 'ppc' : ['CONFIG_PPC_DIS'],
1851 'riscv' : ['CONFIG_RISCV_DIS'],
1852 'rx' : ['CONFIG_RX_DIS'],
1853 's390' : ['CONFIG_S390_DIS'],
1854 'sh4' : ['CONFIG_SH4_DIS'],
1855 'sparc' : ['CONFIG_SPARC_DIS'],
1856 'xtensa' : ['CONFIG_XTENSA_DIS'],
1857}
1858if link_language == 'cpp'
1859 disassemblers += {
1860 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
1861 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
1862 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
1863 }
1864endif
1865
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001866have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
Paolo Bonzini0a189112020-11-17 14:58:32 +01001867host_kconfig = \
Paolo Bonzini537b7242021-10-07 15:08:12 +02001868 (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001869 ('CONFIG_TPM' in config_host ? ['CONFIG_TPM=y'] : []) + \
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001870 (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
Paolo Bonziniccd250a2021-06-03 12:50:17 +02001871 (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001872 ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
Paolo Bonzini9d710372021-01-07 13:54:22 +01001873 (x11.found() ? ['CONFIG_X11=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001874 ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
1875 ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
1876 ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
Paolo Bonzini69202b42020-11-17 14:46:21 +01001877 (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001878 ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
Jagannathan Raman3090de62021-01-29 11:46:05 -05001879 ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
Paolo Bonzini106ad1f2021-02-17 16:24:25 +01001880 (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : [])
Paolo Bonzini0a189112020-11-17 14:58:32 +01001881
Paolo Bonzinia9a74902020-09-21 05:11:01 -04001882ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001883
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001884default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
1885actual_target_dirs = []
Paolo Bonzinifbb41212020-10-05 11:31:15 +02001886fdt_required = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001887foreach target : target_dirs
Paolo Bonzini765686d2020-09-18 06:37:21 -04001888 config_target = { 'TARGET_NAME': target.split('-')[0] }
1889 if target.endswith('linux-user')
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001890 if targetos != 'linux'
1891 if default_targets
1892 continue
1893 endif
1894 error('Target @0@ is only available on a Linux host'.format(target))
1895 endif
Paolo Bonzini765686d2020-09-18 06:37:21 -04001896 config_target += { 'CONFIG_LINUX_USER': 'y' }
1897 elif target.endswith('bsd-user')
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001898 if 'CONFIG_BSD' not in config_host
1899 if default_targets
1900 continue
1901 endif
1902 error('Target @0@ is only available on a BSD host'.format(target))
1903 endif
Paolo Bonzini765686d2020-09-18 06:37:21 -04001904 config_target += { 'CONFIG_BSD_USER': 'y' }
1905 elif target.endswith('softmmu')
1906 config_target += { 'CONFIG_SOFTMMU': 'y' }
1907 endif
1908 if target.endswith('-user')
1909 config_target += {
1910 'CONFIG_USER_ONLY': 'y',
1911 'CONFIG_QEMU_INTERP_PREFIX':
1912 config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
1913 }
1914 endif
Paolo Bonzini859aef02020-08-04 18:14:26 +02001915
Paolo Bonzini0a189112020-11-17 14:58:32 +01001916 accel_kconfig = []
Paolo Bonzini8a199802020-09-18 05:37:01 -04001917 foreach sym: accelerators
1918 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
1919 config_target += { sym: 'y' }
1920 config_all += { sym: 'y' }
Paolo Bonzini23a77b22020-12-14 12:01:45 +01001921 if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
1922 config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
1923 elif sym == 'CONFIG_XEN' and have_xen_pci_passthrough
Paolo Bonzini8a199802020-09-18 05:37:01 -04001924 config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
1925 endif
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02001926 if target in modular_tcg
1927 config_target += { 'CONFIG_TCG_MODULAR': 'y' }
1928 else
1929 config_target += { 'CONFIG_TCG_BUILTIN': 'y' }
1930 endif
Paolo Bonzini0a189112020-11-17 14:58:32 +01001931 accel_kconfig += [ sym + '=y' ]
Paolo Bonzini8a199802020-09-18 05:37:01 -04001932 endif
1933 endforeach
Paolo Bonzini0a189112020-11-17 14:58:32 +01001934 if accel_kconfig.length() == 0
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001935 if default_targets
1936 continue
1937 endif
1938 error('No accelerator available for target @0@'.format(target))
1939 endif
Paolo Bonzini8a199802020-09-18 05:37:01 -04001940
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001941 actual_target_dirs += target
Alex Bennée812b31d2021-07-07 14:17:43 +01001942 config_target += keyval.load('configs/targets' / target + '.mak')
Paolo Bonzinia9a74902020-09-21 05:11:01 -04001943 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
Paolo Bonzini765686d2020-09-18 06:37:21 -04001944
Paolo Bonzinifbb41212020-10-05 11:31:15 +02001945 if 'TARGET_NEED_FDT' in config_target
1946 fdt_required += target
1947 endif
1948
Paolo Bonzinifa731682020-09-21 05:19:07 -04001949 # Add default keys
1950 if 'TARGET_BASE_ARCH' not in config_target
1951 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
1952 endif
1953 if 'TARGET_ABI_DIR' not in config_target
1954 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
1955 endif
Paolo Bonzini859aef02020-08-04 18:14:26 +02001956
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001957 foreach k, v: disassemblers
Paolo Bonzini823eb012021-11-08 14:18:17 +01001958 if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001959 foreach sym: v
1960 config_target += { sym: 'y' }
1961 config_all_disas += { sym: 'y' }
1962 endforeach
1963 endif
1964 endforeach
1965
Paolo Bonzini859aef02020-08-04 18:14:26 +02001966 config_target_data = configuration_data()
1967 foreach k, v: config_target
1968 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
1969 # do nothing
1970 elif ignored.contains(k)
1971 # do nothing
1972 elif k == 'TARGET_BASE_ARCH'
Paolo Bonzinia9a74902020-09-21 05:11:01 -04001973 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
1974 # not used to select files from sourcesets.
Paolo Bonzini859aef02020-08-04 18:14:26 +02001975 config_target_data.set('TARGET_' + v.to_upper(), 1)
Paolo Bonzini765686d2020-09-18 06:37:21 -04001976 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
Paolo Bonzini859aef02020-08-04 18:14:26 +02001977 config_target_data.set_quoted(k, v)
1978 elif v == 'y'
1979 config_target_data.set(k, 1)
1980 else
1981 config_target_data.set(k, v)
1982 endif
1983 endforeach
Peter Maydellcb2c5532021-07-30 11:59:43 +01001984 config_target_data.set('QEMU_ARCH',
1985 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
Paolo Bonzini859aef02020-08-04 18:14:26 +02001986 config_target_h += {target: configure_file(output: target + '-config-target.h',
1987 configuration: config_target_data)}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001988
1989 if target.endswith('-softmmu')
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01001990 config_input = meson.get_external_property(target, 'default')
Paolo Bonzini2becc362020-02-03 11:42:03 +01001991 config_devices_mak = target + '-config-devices.mak'
1992 config_devices_mak = configure_file(
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01001993 input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'],
Paolo Bonzini2becc362020-02-03 11:42:03 +01001994 output: config_devices_mak,
1995 depfile: config_devices_mak + '.d',
1996 capture: true,
Paolo Bonzini7bc3ca72020-11-20 08:38:22 +01001997 command: [minikconf,
1998 get_option('default_devices') ? '--defconfig' : '--allnoconfig',
Paolo Bonzini2becc362020-02-03 11:42:03 +01001999 config_devices_mak, '@DEPFILE@', '@INPUT@',
Philippe Mathieu-Daudéf4063f92021-07-07 14:17:40 +01002000 host_kconfig, accel_kconfig,
2001 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
Paolo Bonzini859aef02020-08-04 18:14:26 +02002002
2003 config_devices_data = configuration_data()
2004 config_devices = keyval.load(config_devices_mak)
2005 foreach k, v: config_devices
2006 config_devices_data.set(k, 1)
2007 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +01002008 config_devices_mak_list += config_devices_mak
Paolo Bonzini859aef02020-08-04 18:14:26 +02002009 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
2010 configuration: config_devices_data)}
2011 config_target += config_devices
Paolo Bonzinia98006b2020-09-01 05:32:23 -04002012 config_all_devices += config_devices
Paolo Bonzini2becc362020-02-03 11:42:03 +01002013 endif
2014 config_target_mak += {target: config_target}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002015endforeach
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002016target_dirs = actual_target_dirs
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002017
Paolo Bonzini2becc362020-02-03 11:42:03 +01002018# This configuration is used to build files that are shared by
2019# multiple binaries, and then extracted out of the "common"
2020# static_library target.
2021#
2022# We do not use all_sources()/all_dependencies(), because it would
2023# build literally all source files, including devices only used by
2024# targets that are not built for this compilation. The CONFIG_ALL
2025# pseudo symbol replaces it.
2026
Paolo Bonzini05512f52020-09-16 15:31:11 -04002027config_all += config_all_devices
Paolo Bonzini2becc362020-02-03 11:42:03 +01002028config_all += config_host
2029config_all += config_all_disas
2030config_all += {
2031 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
2032 'CONFIG_SOFTMMU': have_system,
2033 'CONFIG_USER_ONLY': have_user,
2034 'CONFIG_ALL': true,
2035}
2036
Paolo Bonzinieed56e92021-11-10 11:01:26 +01002037target_configs_h = []
2038foreach target: target_dirs
2039 target_configs_h += config_target_h[target]
2040 target_configs_h += config_devices_h.get(target, [])
2041endforeach
2042genh += custom_target('config-poison.h',
2043 input: [target_configs_h],
2044 output: 'config-poison.h',
2045 capture: true,
2046 command: [find_program('scripts/make-config-poison.sh'),
2047 target_configs_h])
2048
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002049##############
2050# Submodules #
2051##############
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002052
2053capstone = not_found
2054capstone_opt = get_option('capstone')
2055if capstone_opt in ['enabled', 'auto', 'system']
2056 have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
Richard Hendersonbcf36862020-09-21 09:46:16 -07002057 capstone = dependency('capstone', version: '>=4.0',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002058 kwargs: static_kwargs, method: 'pkg-config',
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002059 required: capstone_opt == 'system' or
2060 capstone_opt == 'enabled' and not have_internal)
Daniel P. Berrangé8f4aea72021-07-09 15:29:31 +01002061
2062 # Some versions of capstone have broken pkg-config file
2063 # that reports a wrong -I path, causing the #include to
2064 # fail later. If the system has such a broken version
2065 # do not use it.
2066 if capstone.found() and not cc.compiles('#include <capstone.h>',
2067 dependencies: [capstone])
2068 capstone = not_found
2069 if capstone_opt == 'system'
2070 error('system capstone requested, it does not appear to work')
2071 endif
2072 endif
2073
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002074 if capstone.found()
2075 capstone_opt = 'system'
2076 elif have_internal
2077 capstone_opt = 'internal'
2078 else
2079 capstone_opt = 'disabled'
2080 endif
2081endif
2082if capstone_opt == 'internal'
2083 capstone_data = configuration_data()
2084 capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
2085
2086 capstone_files = files(
2087 'capstone/cs.c',
2088 'capstone/MCInst.c',
2089 'capstone/MCInstrDesc.c',
2090 'capstone/MCRegisterInfo.c',
2091 'capstone/SStream.c',
2092 'capstone/utils.c'
2093 )
2094
2095 if 'CONFIG_ARM_DIS' in config_all_disas
2096 capstone_data.set('CAPSTONE_HAS_ARM', '1')
2097 capstone_files += files(
2098 'capstone/arch/ARM/ARMDisassembler.c',
2099 'capstone/arch/ARM/ARMInstPrinter.c',
2100 'capstone/arch/ARM/ARMMapping.c',
2101 'capstone/arch/ARM/ARMModule.c'
2102 )
2103 endif
2104
2105 # FIXME: This config entry currently depends on a c++ compiler.
2106 # Which is needed for building libvixl, but not for capstone.
2107 if 'CONFIG_ARM_A64_DIS' in config_all_disas
2108 capstone_data.set('CAPSTONE_HAS_ARM64', '1')
2109 capstone_files += files(
2110 'capstone/arch/AArch64/AArch64BaseInfo.c',
2111 'capstone/arch/AArch64/AArch64Disassembler.c',
2112 'capstone/arch/AArch64/AArch64InstPrinter.c',
2113 'capstone/arch/AArch64/AArch64Mapping.c',
2114 'capstone/arch/AArch64/AArch64Module.c'
2115 )
2116 endif
2117
2118 if 'CONFIG_PPC_DIS' in config_all_disas
2119 capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
2120 capstone_files += files(
2121 'capstone/arch/PowerPC/PPCDisassembler.c',
2122 'capstone/arch/PowerPC/PPCInstPrinter.c',
2123 'capstone/arch/PowerPC/PPCMapping.c',
2124 'capstone/arch/PowerPC/PPCModule.c'
2125 )
2126 endif
2127
Richard Henderson3d562842020-01-04 07:24:59 +10002128 if 'CONFIG_S390_DIS' in config_all_disas
2129 capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
2130 capstone_files += files(
2131 'capstone/arch/SystemZ/SystemZDisassembler.c',
2132 'capstone/arch/SystemZ/SystemZInstPrinter.c',
2133 'capstone/arch/SystemZ/SystemZMapping.c',
2134 'capstone/arch/SystemZ/SystemZModule.c',
2135 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
2136 )
2137 endif
2138
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002139 if 'CONFIG_I386_DIS' in config_all_disas
2140 capstone_data.set('CAPSTONE_HAS_X86', 1)
2141 capstone_files += files(
2142 'capstone/arch/X86/X86Disassembler.c',
2143 'capstone/arch/X86/X86DisassemblerDecoder.c',
2144 'capstone/arch/X86/X86ATTInstPrinter.c',
2145 'capstone/arch/X86/X86IntelInstPrinter.c',
Richard Hendersoneef20e42020-09-14 16:02:02 -07002146 'capstone/arch/X86/X86InstPrinterCommon.c',
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002147 'capstone/arch/X86/X86Mapping.c',
2148 'capstone/arch/X86/X86Module.c'
2149 )
2150 endif
2151
2152 configure_file(output: 'capstone-defs.h', configuration: capstone_data)
2153
2154 capstone_cargs = [
2155 # FIXME: There does not seem to be a way to completely replace the c_args
2156 # that come from add_project_arguments() -- we can only add to them.
2157 # So: disable all warnings with a big hammer.
2158 '-Wno-error', '-w',
2159
2160 # Include all configuration defines via a header file, which will wind up
2161 # as a dependency on the object file, and thus changes here will result
2162 # in a rebuild.
2163 '-include', 'capstone-defs.h'
2164 ]
2165
2166 libcapstone = static_library('capstone',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002167 build_by_default: false,
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002168 sources: capstone_files,
2169 c_args: capstone_cargs,
2170 include_directories: 'capstone/include')
2171 capstone = declare_dependency(link_with: libcapstone,
Richard Hendersoneef20e42020-09-14 16:02:02 -07002172 include_directories: 'capstone/include/capstone')
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002173endif
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002174
2175slirp = not_found
2176slirp_opt = 'disabled'
2177if have_system
2178 slirp_opt = get_option('slirp')
2179 if slirp_opt in ['enabled', 'auto', 'system']
2180 have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002181 slirp = dependency('slirp', kwargs: static_kwargs,
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002182 method: 'pkg-config',
2183 required: slirp_opt == 'system' or
2184 slirp_opt == 'enabled' and not have_internal)
2185 if slirp.found()
2186 slirp_opt = 'system'
2187 elif have_internal
2188 slirp_opt = 'internal'
2189 else
2190 slirp_opt = 'disabled'
2191 endif
2192 endif
2193 if slirp_opt == 'internal'
2194 slirp_deps = []
2195 if targetos == 'windows'
2196 slirp_deps = cc.find_library('iphlpapi')
Marc-André Lureau43f547b2021-05-18 19:51:11 +04002197 elif targetos == 'darwin'
2198 slirp_deps = cc.find_library('resolv')
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002199 endif
2200 slirp_conf = configuration_data()
2201 slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
2202 slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
2203 slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
2204 slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
2205 slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
2206 slirp_files = [
2207 'slirp/src/arp_table.c',
2208 'slirp/src/bootp.c',
2209 'slirp/src/cksum.c',
2210 'slirp/src/dhcpv6.c',
2211 'slirp/src/dnssearch.c',
2212 'slirp/src/if.c',
2213 'slirp/src/ip6_icmp.c',
2214 'slirp/src/ip6_input.c',
2215 'slirp/src/ip6_output.c',
2216 'slirp/src/ip_icmp.c',
2217 'slirp/src/ip_input.c',
2218 'slirp/src/ip_output.c',
2219 'slirp/src/mbuf.c',
2220 'slirp/src/misc.c',
2221 'slirp/src/ncsi.c',
2222 'slirp/src/ndp_table.c',
2223 'slirp/src/sbuf.c',
2224 'slirp/src/slirp.c',
2225 'slirp/src/socket.c',
2226 'slirp/src/state.c',
2227 'slirp/src/stream.c',
2228 'slirp/src/tcp_input.c',
2229 'slirp/src/tcp_output.c',
2230 'slirp/src/tcp_subr.c',
2231 'slirp/src/tcp_timer.c',
2232 'slirp/src/tftp.c',
2233 'slirp/src/udp.c',
2234 'slirp/src/udp6.c',
2235 'slirp/src/util.c',
2236 'slirp/src/version.c',
2237 'slirp/src/vmstate.c',
2238 ]
2239
2240 configure_file(
2241 input : 'slirp/src/libslirp-version.h.in',
2242 output : 'libslirp-version.h',
2243 configuration: slirp_conf)
2244
2245 slirp_inc = include_directories('slirp', 'slirp/src')
2246 libslirp = static_library('slirp',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002247 build_by_default: false,
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002248 sources: slirp_files,
2249 c_args: slirp_cargs,
2250 include_directories: slirp_inc)
2251 slirp = declare_dependency(link_with: libslirp,
2252 dependencies: slirp_deps,
2253 include_directories: slirp_inc)
2254 endif
2255endif
2256
Daniele Buonoc7153432021-03-03 21:59:38 -05002257# For CFI, we need to compile slirp as a static library together with qemu.
2258# This is because we register slirp functions as callbacks for QEMU Timers.
2259# When using a system-wide shared libslirp, the type information for the
2260# callback is missing and the timer call produces a false positive with CFI.
2261#
2262# Now that slirp_opt has been defined, check if the selected slirp is compatible
2263# with control-flow integrity.
2264if get_option('cfi') and slirp_opt == 'system'
2265 error('Control-Flow Integrity is not compatible with system-wide slirp.' \
2266 + ' Please configure with --enable-slirp=git')
2267endif
2268
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002269fdt = not_found
2270fdt_opt = get_option('fdt')
2271if have_system
2272 if fdt_opt in ['enabled', 'auto', 'system']
2273 have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002274 fdt = cc.find_library('fdt', kwargs: static_kwargs,
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002275 required: fdt_opt == 'system' or
2276 fdt_opt == 'enabled' and not have_internal)
2277 if fdt.found() and cc.links('''
2278 #include <libfdt.h>
2279 #include <libfdt_env.h>
2280 int main(void) { fdt_check_full(NULL, 0); return 0; }''',
2281 dependencies: fdt)
2282 fdt_opt = 'system'
Thomas Huth6c228532021-08-27 14:09:00 +02002283 elif fdt_opt == 'system'
2284 error('system libfdt requested, but it is too old (1.5.1 or newer required)')
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002285 elif have_internal
2286 fdt_opt = 'internal'
2287 else
2288 fdt_opt = 'disabled'
Thomas Huth87daf892021-08-27 14:08:59 +02002289 fdt = not_found
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002290 endif
2291 endif
2292 if fdt_opt == 'internal'
2293 fdt_files = files(
2294 'dtc/libfdt/fdt.c',
2295 'dtc/libfdt/fdt_ro.c',
2296 'dtc/libfdt/fdt_wip.c',
2297 'dtc/libfdt/fdt_sw.c',
2298 'dtc/libfdt/fdt_rw.c',
2299 'dtc/libfdt/fdt_strerror.c',
2300 'dtc/libfdt/fdt_empty_tree.c',
2301 'dtc/libfdt/fdt_addresses.c',
2302 'dtc/libfdt/fdt_overlay.c',
2303 'dtc/libfdt/fdt_check.c',
2304 )
2305
2306 fdt_inc = include_directories('dtc/libfdt')
2307 libfdt = static_library('fdt',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002308 build_by_default: false,
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002309 sources: fdt_files,
2310 include_directories: fdt_inc)
2311 fdt = declare_dependency(link_with: libfdt,
2312 include_directories: fdt_inc)
2313 endif
2314endif
2315if not fdt.found() and fdt_required.length() > 0
2316 error('fdt not available but required by targets ' + ', '.join(fdt_required))
2317endif
2318
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002319config_host_data.set('CONFIG_CAPSTONE', capstone.found())
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002320config_host_data.set('CONFIG_FDT', fdt.found())
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002321config_host_data.set('CONFIG_SLIRP', slirp.found())
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002322
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002323#####################
2324# Generated sources #
2325#####################
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002326
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002327genh += configure_file(output: 'config-host.h', configuration: config_host_data)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002328
Marc-André Lureau3f885652019-07-15 18:06:04 +04002329hxtool = find_program('scripts/hxtool')
Marc-André Lureau650b5d52019-07-15 17:36:47 +04002330shaderinclude = find_program('scripts/shaderinclude.pl')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002331qapi_gen = find_program('scripts/qapi-gen.py')
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002332qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
2333 meson.current_source_dir() / 'scripts/qapi/commands.py',
2334 meson.current_source_dir() / 'scripts/qapi/common.py',
2335 meson.current_source_dir() / 'scripts/qapi/error.py',
2336 meson.current_source_dir() / 'scripts/qapi/events.py',
2337 meson.current_source_dir() / 'scripts/qapi/expr.py',
2338 meson.current_source_dir() / 'scripts/qapi/gen.py',
2339 meson.current_source_dir() / 'scripts/qapi/introspect.py',
2340 meson.current_source_dir() / 'scripts/qapi/parser.py',
2341 meson.current_source_dir() / 'scripts/qapi/schema.py',
2342 meson.current_source_dir() / 'scripts/qapi/source.py',
2343 meson.current_source_dir() / 'scripts/qapi/types.py',
2344 meson.current_source_dir() / 'scripts/qapi/visit.py',
2345 meson.current_source_dir() / 'scripts/qapi/common.py',
2346 meson.current_source_dir() / 'scripts/qapi-gen.py'
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002347]
2348
2349tracetool = [
2350 python, files('scripts/tracetool.py'),
Paolo Bonzini9c29b742021-10-07 15:08:14 +02002351 '--backend=' + ','.join(get_option('trace_backends'))
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002352]
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00002353tracetool_depends = files(
2354 'scripts/tracetool/backend/log.py',
2355 'scripts/tracetool/backend/__init__.py',
2356 'scripts/tracetool/backend/dtrace.py',
2357 'scripts/tracetool/backend/ftrace.py',
2358 'scripts/tracetool/backend/simple.py',
2359 'scripts/tracetool/backend/syslog.py',
2360 'scripts/tracetool/backend/ust.py',
2361 'scripts/tracetool/format/tcg_h.py',
2362 'scripts/tracetool/format/ust_events_c.py',
2363 'scripts/tracetool/format/ust_events_h.py',
2364 'scripts/tracetool/format/__init__.py',
2365 'scripts/tracetool/format/d.py',
2366 'scripts/tracetool/format/tcg_helper_c.py',
2367 'scripts/tracetool/format/simpletrace_stap.py',
2368 'scripts/tracetool/format/c.py',
2369 'scripts/tracetool/format/h.py',
2370 'scripts/tracetool/format/tcg_helper_h.py',
2371 'scripts/tracetool/format/log_stap.py',
2372 'scripts/tracetool/format/stap.py',
2373 'scripts/tracetool/format/tcg_helper_wrapper_h.py',
2374 'scripts/tracetool/__init__.py',
2375 'scripts/tracetool/transform.py',
2376 'scripts/tracetool/vcpu.py'
2377)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002378
Marc-André Lureau2c273f32019-07-15 17:10:19 +04002379qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
2380 meson.current_source_dir(),
Paolo Bonzini859aef02020-08-04 18:14:26 +02002381 config_host['PKGVERSION'], meson.project_version()]
Marc-André Lureau2c273f32019-07-15 17:10:19 +04002382qemu_version = custom_target('qemu-version.h',
2383 output: 'qemu-version.h',
2384 command: qemu_version_cmd,
2385 capture: true,
2386 build_by_default: true,
2387 build_always_stale: true)
2388genh += qemu_version
2389
Marc-André Lureau3f885652019-07-15 18:06:04 +04002390hxdep = []
2391hx_headers = [
2392 ['qemu-options.hx', 'qemu-options.def'],
2393 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
2394]
2395if have_system
2396 hx_headers += [
2397 ['hmp-commands.hx', 'hmp-commands.h'],
2398 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
2399 ]
2400endif
2401foreach d : hx_headers
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04002402 hxdep += custom_target(d[1],
Marc-André Lureau3f885652019-07-15 18:06:04 +04002403 input: files(d[0]),
2404 output: d[1],
2405 capture: true,
2406 build_by_default: true, # to be removed when added to a target
2407 command: [hxtool, '-h', '@INPUT0@'])
2408endforeach
2409genh += hxdep
2410
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002411###################
2412# Collect sources #
2413###################
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002414
Philippe Mathieu-Daudé55567892020-10-06 14:56:01 +02002415authz_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002416blockdev_ss = ss.source_set()
2417block_ss = ss.source_set()
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002418chardev_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002419common_ss = ss.source_set()
Philippe Mathieu-Daudé23893042020-10-06 14:56:00 +02002420crypto_ss = ss.source_set()
Philippe Mathieu-Daudéf73fb062021-10-28 16:34:19 +02002421hwcore_ss = ss.source_set()
Philippe Mathieu-Daudéf78536b2020-10-06 14:55:59 +02002422io_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002423qmp_ss = ss.source_set()
Philippe Mathieu-Daudéda33fc02020-10-06 14:56:02 +02002424qom_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002425softmmu_ss = ss.source_set()
2426specific_fuzz_ss = ss.source_set()
2427specific_ss = ss.source_set()
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002428stub_ss = ss.source_set()
2429trace_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002430user_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002431util_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002432
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002433# accel modules
2434qtest_module_ss = ss.source_set()
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02002435tcg_module_ss = ss.source_set()
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002436
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002437modules = {}
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002438target_modules = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01002439hw_arch = {}
2440target_arch = {}
2441target_softmmu_arch = {}
Philippe Mathieu-Daudé46369b52021-04-13 11:27:09 +02002442target_user_arch = {}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002443
2444###############
2445# Trace files #
2446###############
2447
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002448# TODO: add each directory to the subdirs from its own meson.build, once
2449# we have those
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002450trace_events_subdirs = [
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002451 'crypto',
Philippe Mathieu-Daudé69ff4d02021-01-22 21:44:35 +01002452 'qapi',
2453 'qom',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002454 'monitor',
Philippe Mathieu-Daudé69ff4d02021-01-22 21:44:35 +01002455 'util',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002456]
2457if have_user
2458 trace_events_subdirs += [ 'linux-user' ]
2459endif
2460if have_block
2461 trace_events_subdirs += [
2462 'authz',
2463 'block',
2464 'io',
2465 'nbd',
2466 'scsi',
2467 ]
2468endif
2469if have_system
2470 trace_events_subdirs += [
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002471 'accel/kvm',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002472 'audio',
2473 'backends',
2474 'backends/tpm',
2475 'chardev',
Andrew Melnychenko46627f42021-05-14 14:48:32 +03002476 'ebpf',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002477 'hw/9pfs',
2478 'hw/acpi',
Hao Wu77c05b02021-01-08 11:09:42 -08002479 'hw/adc',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002480 'hw/alpha',
2481 'hw/arm',
2482 'hw/audio',
2483 'hw/block',
2484 'hw/block/dataplane',
2485 'hw/char',
2486 'hw/display',
2487 'hw/dma',
2488 'hw/hppa',
2489 'hw/hyperv',
2490 'hw/i2c',
2491 'hw/i386',
2492 'hw/i386/xen',
2493 'hw/ide',
2494 'hw/input',
2495 'hw/intc',
2496 'hw/isa',
2497 'hw/mem',
2498 'hw/mips',
2499 'hw/misc',
2500 'hw/misc/macio',
2501 'hw/net',
Vikram Garhwal98e5d7a2020-11-18 11:48:43 -08002502 'hw/net/can',
Mark Cave-Aylandce0e6a22021-09-24 08:37:55 +01002503 'hw/nubus',
Klaus Jensen88eea452021-04-14 22:14:30 +02002504 'hw/nvme',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002505 'hw/nvram',
2506 'hw/pci',
2507 'hw/pci-host',
2508 'hw/ppc',
2509 'hw/rdma',
2510 'hw/rdma/vmw',
2511 'hw/rtc',
2512 'hw/s390x',
2513 'hw/scsi',
2514 'hw/sd',
BALATON Zoltanad52cfc2021-10-29 23:02:09 +02002515 'hw/sh4',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002516 'hw/sparc',
2517 'hw/sparc64',
2518 'hw/ssi',
2519 'hw/timer',
2520 'hw/tpm',
2521 'hw/usb',
2522 'hw/vfio',
2523 'hw/virtio',
2524 'hw/watchdog',
2525 'hw/xen',
2526 'hw/gpio',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002527 'migration',
2528 'net',
Philippe Mathieu-Daudé8b7a5502020-08-05 15:02:20 +02002529 'softmmu',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002530 'ui',
Elena Ufimtsevaad22c302021-01-29 11:46:10 -05002531 'hw/remote',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002532 ]
2533endif
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002534if have_system or have_user
2535 trace_events_subdirs += [
2536 'accel/tcg',
2537 'hw/core',
2538 'target/arm',
Alexander Grafa1477da2021-09-16 17:53:58 +02002539 'target/arm/hvf',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002540 'target/hppa',
2541 'target/i386',
2542 'target/i386/kvm',
Philippe Mathieu-Daudé34b8ff22021-05-30 09:02:16 +02002543 'target/mips/tcg',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002544 'target/ppc',
2545 'target/riscv',
2546 'target/s390x',
Cho, Yu-Chen67043602021-07-07 18:53:23 +08002547 'target/s390x/kvm',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002548 'target/sparc',
2549 ]
2550endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002551
Marc-André Lureau0df750e2020-11-25 14:06:37 +04002552vhost_user = not_found
2553if 'CONFIG_VHOST_USER' in config_host
2554 libvhost_user = subproject('libvhost-user')
2555 vhost_user = libvhost_user.get_variable('vhost_user_dep')
2556endif
2557
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002558subdir('qapi')
2559subdir('qobject')
2560subdir('stubs')
2561subdir('trace')
2562subdir('util')
Marc-André Lureau5582c582019-07-16 19:28:54 +04002563subdir('qom')
2564subdir('authz')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002565subdir('crypto')
Marc-André Lureau2d78b562019-07-15 16:00:36 +04002566subdir('ui')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002567
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002568
2569if enable_modules
2570 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
2571 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
2572endif
2573
Paolo Bonzini2becc362020-02-03 11:42:03 +01002574stub_ss = stub_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002575
2576util_ss.add_all(trace_ss)
Paolo Bonzini2becc362020-02-03 11:42:03 +01002577util_ss = util_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002578libqemuutil = static_library('qemuutil',
2579 sources: util_ss.sources() + stub_ss.sources() + genh,
Paolo Bonzini6d7c7c22021-06-03 15:01:35 +02002580 dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman])
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002581qemuutil = declare_dependency(link_with: libqemuutil,
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +04002582 sources: genh + version_res)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002583
Philippe Mathieu-Daudé957b31f2021-01-22 21:44:37 +01002584if have_system or have_user
2585 decodetree = generator(find_program('scripts/decodetree.py'),
2586 output: 'decode-@BASENAME@.c.inc',
2587 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
2588 subdir('libdecnumber')
2589 subdir('target')
2590endif
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002591
Paolo Bonzini478e9432020-08-17 12:47:55 +02002592subdir('audio')
Marc-André Lureau7fcfd452019-07-16 19:33:55 +04002593subdir('io')
Marc-André Lureau848e8ff2019-07-15 23:18:07 +04002594subdir('chardev')
Marc-André Lureauec0d5892019-07-15 15:04:49 +04002595subdir('fsdev')
Marc-André Lureau708eab42019-09-03 16:59:33 +04002596subdir('dump')
Marc-André Lureauec0d5892019-07-15 15:04:49 +04002597
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002598if have_block
2599 block_ss.add(files(
2600 'block.c',
2601 'blockjob.c',
2602 'job.c',
2603 'qemu-io-cmds.c',
2604 ))
2605 block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002606
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002607 subdir('nbd')
2608 subdir('scsi')
2609 subdir('block')
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002610
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002611 blockdev_ss.add(files(
2612 'blockdev.c',
2613 'blockdev-nbd.c',
2614 'iothread.c',
2615 'job-qmp.c',
2616 ), gnutls)
Paolo Bonzini4a963372020-08-03 16:22:28 +02002617
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002618 # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
2619 # os-win32.c does not
2620 blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
2621 softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
2622endif
Paolo Bonzini4a963372020-08-03 16:22:28 +02002623
2624common_ss.add(files('cpus-common.c'))
2625
Paolo Bonzini5d3ea0e2020-08-06 13:40:26 +02002626subdir('softmmu')
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002627
Richard Hendersonf3433462020-09-12 10:47:33 -07002628common_ss.add(capstone)
Paolo Bonzinid9f24bf2020-10-06 09:05:29 +02002629specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002630
Richard Henderson44b99a62021-03-22 12:24:26 +01002631# Work around a gcc bug/misfeature wherein constant propagation looks
2632# through an alias:
2633# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696
2634# to guess that a const variable is always zero. Without lto, this is
2635# impossible, as the alias is restricted to page-vary-common.c. Indeed,
2636# without lto, not even the alias is required -- we simply use different
2637# declarations in different compilation units.
2638pagevary = files('page-vary-common.c')
2639if get_option('b_lto')
2640 pagevary_flags = ['-fno-lto']
2641 if get_option('cfi')
2642 pagevary_flags += '-fno-sanitize=cfi-icall'
2643 endif
2644 pagevary = static_library('page-vary-common', sources: pagevary,
2645 c_args: pagevary_flags)
2646 pagevary = declare_dependency(link_with: pagevary)
2647endif
2648common_ss.add(pagevary)
Richard Henderson6670d4d2021-03-22 12:24:24 +01002649specific_ss.add(files('page-vary.c'))
2650
Marc-André Lureauab318052019-07-24 19:23:16 +04002651subdir('backends')
Marc-André Lureauc574e162019-07-26 12:02:31 +04002652subdir('disas')
Marc-André Lureau55166232019-07-24 19:16:22 +04002653subdir('migration')
Paolo Bonziniff219dc2020-08-04 21:14:26 +02002654subdir('monitor')
Marc-André Lureaucdaf0722019-07-22 23:47:50 +04002655subdir('net')
Marc-André Lureau17ef2af2019-07-22 23:40:45 +04002656subdir('replay')
Philippe Mathieu-Daudé8df9f0c2021-03-05 13:54:50 +00002657subdir('semihosting')
Marc-André Lureau582ea952019-08-15 15:15:32 +04002658subdir('hw')
Richard Henderson104cc2c2021-03-08 12:04:33 -08002659subdir('tcg')
Richard Hendersonc6347542021-03-08 12:15:06 -08002660subdir('fpu')
Marc-André Lureau1a828782019-08-18 16:13:08 +04002661subdir('accel')
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01002662subdir('plugins')
Richard Hendersonbbf15aa2021-11-17 16:14:00 +01002663subdir('ebpf')
2664
2665common_user_inc = []
2666
2667subdir('common-user')
Marc-André Lureaub309c322019-08-18 19:20:37 +04002668subdir('bsd-user')
Marc-André Lureau3a304462019-08-18 16:13:08 +04002669subdir('linux-user')
Andrew Melnychenko46627f42021-05-14 14:48:32 +03002670
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02002671# needed for fuzzing binaries
2672subdir('tests/qtest/libqos')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002673subdir('tests/qtest/fuzz')
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02002674
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002675# accel modules
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02002676tcg_real_module_ss = ss.source_set()
2677tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss)
2678specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss)
2679target_modules += { 'accel' : { 'qtest': qtest_module_ss,
2680 'tcg': tcg_real_module_ss }}
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002681
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002682########################
2683# Library dependencies #
2684########################
2685
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002686modinfo_collect = find_program('scripts/modinfo-collect.py')
Gerd Hoffmann5ebbfec2021-06-24 12:38:05 +02002687modinfo_generate = find_program('scripts/modinfo-generate.py')
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002688modinfo_files = []
2689
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002690block_mods = []
2691softmmu_mods = []
2692foreach d, list : modules
2693 foreach m, module_ss : list
2694 if enable_modules and targetos != 'windows'
Gerd Hoffmann3e292c52020-09-14 15:42:20 +02002695 module_ss = module_ss.apply(config_all, strict: false)
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002696 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
2697 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
2698 if d == 'block'
2699 block_mods += sl
2700 else
2701 softmmu_mods += sl
2702 endif
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002703 if module_ss.sources() != []
2704 # FIXME: Should use sl.extract_all_objects(recursive: true) as
2705 # input. Sources can be used multiple times but objects are
2706 # unique when it comes to lookup in compile_commands.json.
2707 # Depnds on a mesion version with
2708 # https://github.com/mesonbuild/meson/pull/8900
2709 modinfo_files += custom_target(d + '-' + m + '.modinfo',
2710 output: d + '-' + m + '.modinfo',
Paolo Bonziniac347112021-07-21 18:51:57 +02002711 input: module_ss.sources() + genh,
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002712 capture: true,
Paolo Bonziniac347112021-07-21 18:51:57 +02002713 command: [modinfo_collect, module_ss.sources()])
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002714 endif
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002715 else
2716 if d == 'block'
2717 block_ss.add_all(module_ss)
2718 else
2719 softmmu_ss.add_all(module_ss)
2720 endif
2721 endif
2722 endforeach
2723endforeach
2724
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002725foreach d, list : target_modules
2726 foreach m, module_ss : list
2727 if enable_modules and targetos != 'windows'
2728 foreach target : target_dirs
2729 if target.endswith('-softmmu')
2730 config_target = config_target_mak[target]
2731 config_target += config_host
2732 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
2733 c_args = ['-DNEED_CPU_H',
2734 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
2735 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
2736 target_module_ss = module_ss.apply(config_target, strict: false)
2737 if target_module_ss.sources() != []
2738 module_name = d + '-' + m + '-' + config_target['TARGET_NAME']
2739 sl = static_library(module_name,
2740 [genh, target_module_ss.sources()],
2741 dependencies: [modulecommon, target_module_ss.dependencies()],
2742 include_directories: target_inc,
2743 c_args: c_args,
2744 pic: true)
2745 softmmu_mods += sl
2746 # FIXME: Should use sl.extract_all_objects(recursive: true) too.
2747 modinfo_files += custom_target(module_name + '.modinfo',
2748 output: module_name + '.modinfo',
Gerd Hoffmann917ddc22021-07-23 14:01:56 +02002749 input: target_module_ss.sources() + genh,
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002750 capture: true,
Gerd Hoffmann917ddc22021-07-23 14:01:56 +02002751 command: [modinfo_collect, '--target', target, target_module_ss.sources()])
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002752 endif
2753 endif
2754 endforeach
2755 else
2756 specific_ss.add_all(module_ss)
2757 endif
2758 endforeach
2759endforeach
2760
Gerd Hoffmann5ebbfec2021-06-24 12:38:05 +02002761if enable_modules
2762 modinfo_src = custom_target('modinfo.c',
2763 output: 'modinfo.c',
2764 input: modinfo_files,
2765 command: [modinfo_generate, '@INPUT@'],
2766 capture: true)
2767 modinfo_lib = static_library('modinfo', modinfo_src)
2768 modinfo_dep = declare_dependency(link_whole: modinfo_lib)
2769 softmmu_ss.add(modinfo_dep)
2770endif
2771
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002772nm = find_program('nm')
Yonggang Luo604f3e42020-09-03 01:00:50 +08002773undefsym = find_program('scripts/undefsym.py')
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002774block_syms = custom_target('block.syms', output: 'block.syms',
2775 input: [libqemuutil, block_mods],
2776 capture: true,
2777 command: [undefsym, nm, '@INPUT@'])
2778qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
2779 input: [libqemuutil, softmmu_mods],
2780 capture: true,
2781 command: [undefsym, nm, '@INPUT@'])
2782
Philippe Mathieu-Daudéda33fc02020-10-06 14:56:02 +02002783qom_ss = qom_ss.apply(config_host, strict: false)
2784libqom = static_library('qom', qom_ss.sources() + genh,
2785 dependencies: [qom_ss.dependencies()],
2786 name_suffix: 'fa')
2787
2788qom = declare_dependency(link_whole: libqom)
2789
Philippe Mathieu-Daudé55567892020-10-06 14:56:01 +02002790authz_ss = authz_ss.apply(config_host, strict: false)
2791libauthz = static_library('authz', authz_ss.sources() + genh,
2792 dependencies: [authz_ss.dependencies()],
2793 name_suffix: 'fa',
2794 build_by_default: false)
2795
2796authz = declare_dependency(link_whole: libauthz,
2797 dependencies: qom)
2798
Philippe Mathieu-Daudé23893042020-10-06 14:56:00 +02002799crypto_ss = crypto_ss.apply(config_host, strict: false)
2800libcrypto = static_library('crypto', crypto_ss.sources() + genh,
2801 dependencies: [crypto_ss.dependencies()],
2802 name_suffix: 'fa',
2803 build_by_default: false)
2804
2805crypto = declare_dependency(link_whole: libcrypto,
2806 dependencies: [authz, qom])
2807
Philippe Mathieu-Daudéf78536b2020-10-06 14:55:59 +02002808io_ss = io_ss.apply(config_host, strict: false)
2809libio = static_library('io', io_ss.sources() + genh,
2810 dependencies: [io_ss.dependencies()],
2811 link_with: libqemuutil,
2812 name_suffix: 'fa',
2813 build_by_default: false)
2814
2815io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
2816
Philippe Mathieu-Daudé7e6edef2020-10-06 14:55:58 +02002817libmigration = static_library('migration', sources: migration_files + genh,
2818 name_suffix: 'fa',
2819 build_by_default: false)
2820migration = declare_dependency(link_with: libmigration,
2821 dependencies: [zlib, qom, io])
2822softmmu_ss.add(migration)
2823
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002824block_ss = block_ss.apply(config_host, strict: false)
2825libblock = static_library('block', block_ss.sources() + genh,
2826 dependencies: block_ss.dependencies(),
2827 link_depends: block_syms,
2828 name_suffix: 'fa',
2829 build_by_default: false)
2830
2831block = declare_dependency(link_whole: [libblock],
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04002832 link_args: '@block.syms',
2833 dependencies: [crypto, io])
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002834
Stefan Hajnoczi4fb90712020-09-29 13:55:14 +01002835blockdev_ss = blockdev_ss.apply(config_host, strict: false)
2836libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
2837 dependencies: blockdev_ss.dependencies(),
2838 name_suffix: 'fa',
2839 build_by_default: false)
2840
2841blockdev = declare_dependency(link_whole: [libblockdev],
2842 dependencies: [block])
2843
Paolo Bonziniff219dc2020-08-04 21:14:26 +02002844qmp_ss = qmp_ss.apply(config_host, strict: false)
2845libqmp = static_library('qmp', qmp_ss.sources() + genh,
2846 dependencies: qmp_ss.dependencies(),
2847 name_suffix: 'fa',
2848 build_by_default: false)
2849
2850qmp = declare_dependency(link_whole: [libqmp])
2851
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002852libchardev = static_library('chardev', chardev_ss.sources() + genh,
2853 name_suffix: 'fa',
Roman Bolshakov3eacf702021-01-02 15:52:13 +03002854 dependencies: [gnutls],
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002855 build_by_default: false)
2856
2857chardev = declare_dependency(link_whole: libchardev)
2858
Philippe Mathieu-Daudéf73fb062021-10-28 16:34:19 +02002859hwcore_ss = hwcore_ss.apply(config_host, strict: false)
2860libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
Philippe Mathieu-Daudée28ab092020-10-06 14:55:56 +02002861 name_suffix: 'fa',
2862 build_by_default: false)
2863hwcore = declare_dependency(link_whole: libhwcore)
2864common_ss.add(hwcore)
2865
Philippe Mathieu-Daudé064f8ee2020-10-06 14:55:54 +02002866###########
2867# Targets #
2868###########
2869
Paolo Bonzinifb721762022-01-07 13:00:44 +01002870emulator_modules = []
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002871foreach m : block_mods + softmmu_mods
Paolo Bonzinifb721762022-01-07 13:00:44 +01002872 emulator_modules += shared_module(m.name(),
2873 build_by_default: true,
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002874 name_prefix: '',
2875 link_whole: m,
2876 install: true,
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04002877 install_dir: qemu_moddir)
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002878endforeach
2879
Stefan Hajnoczi4fb90712020-09-29 13:55:14 +01002880softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp)
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002881common_ss.add(qom, qemuutil)
2882
2883common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
Paolo Bonzini2becc362020-02-03 11:42:03 +01002884common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
2885
2886common_all = common_ss.apply(config_all, strict: false)
2887common_all = static_library('common',
2888 build_by_default: false,
2889 sources: common_all.sources() + genh,
Paolo Bonzini9d24fb72021-12-21 16:09:54 +01002890 include_directories: common_user_inc,
Katsuhiro Ueno75eebe02021-04-29 11:43:07 +09002891 implicit_include_directories: false,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002892 dependencies: common_all.dependencies(),
2893 name_suffix: 'fa')
2894
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002895feature_to_c = find_program('scripts/feature_to_c.sh')
2896
Paolo Bonzinifd5eef82020-09-16 05:00:53 -04002897emulators = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01002898foreach target : target_dirs
2899 config_target = config_target_mak[target]
2900 target_name = config_target['TARGET_NAME']
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002901 target_base_arch = config_target['TARGET_BASE_ARCH']
Paolo Bonzini859aef02020-08-04 18:14:26 +02002902 arch_srcs = [config_target_h[target]]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002903 arch_deps = []
2904 c_args = ['-DNEED_CPU_H',
2905 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
2906 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -04002907 link_args = emulator_link_args
Paolo Bonzini2becc362020-02-03 11:42:03 +01002908
Paolo Bonzini859aef02020-08-04 18:14:26 +02002909 config_target += config_host
Paolo Bonzini2becc362020-02-03 11:42:03 +01002910 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
2911 if targetos == 'linux'
2912 target_inc += include_directories('linux-headers', is_system: true)
2913 endif
2914 if target.endswith('-softmmu')
2915 qemu_target_name = 'qemu-system-' + target_name
2916 target_type='system'
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002917 t = target_softmmu_arch[target_base_arch].apply(config_target, strict: false)
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002918 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002919 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002920
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002921 hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
Marc-André Lureau2c442202019-08-17 13:55:58 +04002922 hw = hw_arch[hw_dir].apply(config_target, strict: false)
2923 arch_srcs += hw.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002924 arch_deps += hw.dependencies()
Marc-André Lureau2c442202019-08-17 13:55:58 +04002925
Paolo Bonzini2becc362020-02-03 11:42:03 +01002926 arch_srcs += config_devices_h[target]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002927 link_args += ['@block.syms', '@qemu.syms']
Paolo Bonzini2becc362020-02-03 11:42:03 +01002928 else
Marc-André Lureau3a304462019-08-18 16:13:08 +04002929 abi = config_target['TARGET_ABI_DIR']
Paolo Bonzini2becc362020-02-03 11:42:03 +01002930 target_type='user'
Paolo Bonzinia3a576b2021-12-21 16:23:55 +01002931 target_inc += common_user_inc
Paolo Bonzini2becc362020-02-03 11:42:03 +01002932 qemu_target_name = 'qemu-' + target_name
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002933 if target_base_arch in target_user_arch
2934 t = target_user_arch[target_base_arch].apply(config_target, strict: false)
Philippe Mathieu-Daudé46369b52021-04-13 11:27:09 +02002935 arch_srcs += t.sources()
2936 arch_deps += t.dependencies()
2937 endif
Paolo Bonzini2becc362020-02-03 11:42:03 +01002938 if 'CONFIG_LINUX_USER' in config_target
2939 base_dir = 'linux-user'
Warner Loshe2a74722021-08-03 17:17:17 -06002940 endif
2941 if 'CONFIG_BSD_USER' in config_target
Paolo Bonzini2becc362020-02-03 11:42:03 +01002942 base_dir = 'bsd-user'
Warner Loshe2a74722021-08-03 17:17:17 -06002943 target_inc += include_directories('bsd-user/' / targetos)
2944 dir = base_dir / abi
Warner Losh19bf1292021-11-04 16:34:48 -06002945 arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c')
Paolo Bonzini2becc362020-02-03 11:42:03 +01002946 endif
2947 target_inc += include_directories(
2948 base_dir,
Marc-André Lureau3a304462019-08-18 16:13:08 +04002949 base_dir / abi,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002950 )
Marc-André Lureau3a304462019-08-18 16:13:08 +04002951 if 'CONFIG_LINUX_USER' in config_target
2952 dir = base_dir / abi
2953 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
2954 if config_target.has_key('TARGET_SYSTBL_ABI')
2955 arch_srcs += \
2956 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
2957 extra_args : config_target['TARGET_SYSTBL_ABI'])
2958 endif
2959 endif
Paolo Bonzini2becc362020-02-03 11:42:03 +01002960 endif
2961
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002962 if 'TARGET_XML_FILES' in config_target
2963 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
2964 output: target + '-gdbstub-xml.c',
2965 input: files(config_target['TARGET_XML_FILES'].split()),
2966 command: [feature_to_c, '@INPUT@'],
2967 capture: true)
2968 arch_srcs += gdbstub_xml
2969 endif
2970
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002971 t = target_arch[target_base_arch].apply(config_target, strict: false)
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002972 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002973 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002974
Paolo Bonzini2becc362020-02-03 11:42:03 +01002975 target_common = common_ss.apply(config_target, strict: false)
2976 objects = common_all.extract_objects(target_common.sources())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002977 deps = target_common.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002978
Paolo Bonzini2becc362020-02-03 11:42:03 +01002979 target_specific = specific_ss.apply(config_target, strict: false)
2980 arch_srcs += target_specific.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002981 arch_deps += target_specific.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002982
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002983 lib = static_library('qemu-' + target,
Paolo Bonzini859aef02020-08-04 18:14:26 +02002984 sources: arch_srcs + genh,
Paolo Bonzinib7612f42020-08-26 08:22:58 +02002985 dependencies: arch_deps,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002986 objects: objects,
2987 include_directories: target_inc,
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002988 c_args: c_args,
2989 build_by_default: false,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002990 name_suffix: 'fa')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002991
2992 if target.endswith('-softmmu')
2993 execs = [{
2994 'name': 'qemu-system-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002995 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002996 'sources': files('softmmu/main.c'),
2997 'dependencies': []
2998 }]
Paolo Bonzini35be72b2020-02-06 14:17:15 +01002999 if targetos == 'windows' and (sdl.found() or gtk.found())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003000 execs += [{
3001 'name': 'qemu-system-' + target_name + 'w',
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003002 'win_subsystem': 'windows',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003003 'sources': files('softmmu/main.c'),
3004 'dependencies': []
3005 }]
3006 endif
Paolo Bonzini537b7242021-10-07 15:08:12 +02003007 if get_option('fuzzing')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003008 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
3009 execs += [{
3010 'name': 'qemu-fuzz-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003011 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003012 'sources': specific_fuzz.sources(),
3013 'dependencies': specific_fuzz.dependencies(),
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003014 }]
3015 endif
3016 else
3017 execs = [{
3018 'name': 'qemu-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003019 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003020 'sources': [],
3021 'dependencies': []
3022 }]
3023 endif
3024 foreach exe: execs
Alexander Graf8a74ce62021-01-20 23:44:34 +01003025 exe_name = exe['name']
John Arbuckle3983a762021-07-05 15:53:28 -04003026 if targetos == 'darwin'
Alexander Graf8a74ce62021-01-20 23:44:34 +01003027 exe_name += '-unsigned'
3028 endif
3029
3030 emulator = executable(exe_name, exe['sources'],
Akihiko Odaki237377a2021-02-25 09:06:14 +09003031 install: true,
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003032 c_args: c_args,
3033 dependencies: arch_deps + deps + exe['dependencies'],
3034 objects: lib.extract_all_objects(recursive: true),
3035 link_language: link_language,
3036 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
3037 link_args: link_args,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003038 win_subsystem: exe['win_subsystem'])
Alexander Graf8a74ce62021-01-20 23:44:34 +01003039
John Arbuckle3983a762021-07-05 15:53:28 -04003040 if targetos == 'darwin'
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003041 icon = 'pc-bios/qemu.rsrc'
3042 build_input = [emulator, files(icon)]
3043 install_input = [
3044 get_option('bindir') / exe_name,
3045 meson.current_source_dir() / icon
3046 ]
3047 if 'CONFIG_HVF' in config_target
3048 entitlements = 'accel/hvf/entitlements.plist'
3049 build_input += files(entitlements)
3050 install_input += meson.current_source_dir() / entitlements
3051 endif
3052
Alexander Graf8a74ce62021-01-20 23:44:34 +01003053 emulators += {exe['name'] : custom_target(exe['name'],
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003054 input: build_input,
Alexander Graf8a74ce62021-01-20 23:44:34 +01003055 output: exe['name'],
3056 command: [
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003057 files('scripts/entitlement.sh'),
3058 '@OUTPUT@',
3059 '@INPUT@'
Alexander Graf8a74ce62021-01-20 23:44:34 +01003060 ])
3061 }
Akihiko Odaki237377a2021-02-25 09:06:14 +09003062
3063 meson.add_install_script('scripts/entitlement.sh', '--install',
Akihiko Odaki237377a2021-02-25 09:06:14 +09003064 get_option('bindir') / exe['name'],
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003065 install_input)
Alexander Graf8a74ce62021-01-20 23:44:34 +01003066 else
3067 emulators += {exe['name']: emulator}
3068 endif
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003069
Paolo Bonzini9c29b742021-10-07 15:08:14 +02003070 if stap.found()
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003071 foreach stp: [
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003072 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
3073 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003074 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
3075 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
3076 ]
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003077 custom_target(exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003078 input: trace_events_all,
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003079 output: exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003080 install: stp['install'],
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003081 install_dir: get_option('datadir') / 'systemtap/tapset',
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003082 command: [
3083 tracetool, '--group=all', '--format=' + stp['fmt'],
3084 '--binary=' + stp['bin'],
3085 '--target-name=' + target_name,
3086 '--target-type=' + target_type,
3087 '--probe-prefix=qemu.' + target_type + '.' + target_name,
Stefan Hajnoczic05012a2020-08-27 15:29:12 +01003088 '@INPUT@', '@OUTPUT@'
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00003089 ],
3090 depend_files: tracetool_depends)
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003091 endforeach
3092 endif
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003093 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +01003094endforeach
3095
Paolo Bonzini931049b2020-02-05 09:44:24 +01003096# Other build targets
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003097
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01003098if 'CONFIG_PLUGIN' in config_host
3099 install_headers('include/qemu/qemu-plugin.h')
3100endif
3101
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003102if 'CONFIG_GUEST_AGENT' in config_host
3103 subdir('qga')
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003104elif get_option('guest_agent_msi').enabled()
3105 error('Guest agent MSI requested, but the guest agent is not being built')
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003106endif
3107
Laurent Vivier9755c942020-08-24 17:24:30 +02003108# Don't build qemu-keymap if xkbcommon is not explicitly enabled
3109# when we don't build tools or system
Laurent Vivier4113f4c2020-08-24 17:24:29 +02003110if xkbcommon.found()
Marc-André Lureau28742462019-09-19 20:24:43 +04003111 # used for the update-keymaps target, so include rules even if !have_tools
3112 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
3113 dependencies: [qemuutil, xkbcommon], install: have_tools)
3114endif
3115
Paolo Bonzini931049b2020-02-05 09:44:24 +01003116if have_tools
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04003117 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
3118 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
3119 qemu_io = executable('qemu-io', files('qemu-io.c'),
3120 dependencies: [block, qemuutil], install: true)
Daniel P. Berrangéeb705982020-08-25 11:38:50 +01003121 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06003122 dependencies: [blockdev, qemuutil, gnutls, selinux],
3123 install: true)
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04003124
Paolo Bonzini7c58bb72020-08-04 20:18:36 +02003125 subdir('storage-daemon')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02003126 subdir('contrib/rdmacm-mux')
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +04003127 subdir('contrib/elf2dmp')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02003128
Marc-André Lureau157e7b12019-07-15 14:50:58 +04003129 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
3130 dependencies: qemuutil,
3131 install: true)
3132
Paolo Bonzini931049b2020-02-05 09:44:24 +01003133 if 'CONFIG_VHOST_USER' in config_host
Paolo Bonzini2d7ac0a2019-06-10 12:18:02 +02003134 subdir('contrib/vhost-user-blk')
Paolo Bonzinib7612f42020-08-26 08:22:58 +02003135 subdir('contrib/vhost-user-gpu')
Marc-André Lureau32fcc622019-07-12 22:11:20 +04003136 subdir('contrib/vhost-user-input')
Paolo Bonzini99650b62019-06-10 12:21:14 +02003137 subdir('contrib/vhost-user-scsi')
Paolo Bonzini931049b2020-02-05 09:44:24 +01003138 endif
Marc-André Lureau8f51e012019-07-15 14:39:25 +04003139
3140 if targetos == 'linux'
3141 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
3142 dependencies: [qemuutil, libcap_ng],
3143 install: true,
3144 install_dir: get_option('libexecdir'))
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003145
3146 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
3147 dependencies: [authz, crypto, io, qom, qemuutil,
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02003148 libcap_ng, mpathpersist],
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003149 install: true)
Marc-André Lureau8f51e012019-07-15 14:39:25 +04003150 endif
3151
Paolo Bonziniccd250a2021-06-03 12:50:17 +02003152 if have_ivshmem
Marc-André Lureau5ee24e72019-07-12 23:16:54 +04003153 subdir('contrib/ivshmem-client')
3154 subdir('contrib/ivshmem-server')
3155 endif
Paolo Bonzini931049b2020-02-05 09:44:24 +01003156endif
3157
Marc-André Lureauf5aa6322020-08-26 17:06:18 +04003158subdir('scripts')
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01003159subdir('tools')
Marc-André Lureaubdcbea72019-07-15 21:22:31 +04003160subdir('pc-bios')
Paolo Bonzinif8aa24e2020-08-05 15:49:10 +02003161subdir('docs')
Yonggang Luoe3667662020-10-16 06:06:25 +08003162subdir('tests')
Paolo Bonzini1b695472021-01-07 14:02:29 +01003163if gtk.found()
Marc-André Lureaue8f3bd72019-09-19 21:02:09 +04003164 subdir('po')
3165endif
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01003166
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003167if host_machine.system() == 'windows'
3168 nsis_cmd = [
3169 find_program('scripts/nsis.py'),
3170 '@OUTPUT@',
3171 get_option('prefix'),
3172 meson.current_source_dir(),
Stefan Weil24bdcc92020-11-25 20:18:33 +01003173 host_machine.cpu(),
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003174 '--',
3175 '-DDISPLAYVERSION=' + meson.project_version(),
3176 ]
3177 if build_docs
3178 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
3179 endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01003180 if gtk.found()
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003181 nsis_cmd += '-DCONFIG_GTK=y'
3182 endif
3183
3184 nsis = custom_target('nsis',
3185 output: 'qemu-setup-' + meson.project_version() + '.exe',
3186 input: files('qemu.nsi'),
3187 build_always_stale: true,
3188 command: nsis_cmd + ['@INPUT@'])
3189 alias_target('installer', nsis)
3190endif
3191
Paolo Bonzinia0c91622020-10-07 11:01:51 -04003192#########################
3193# Configuration summary #
3194#########################
3195
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003196# Directories
Paolo Bonzinif9332752020-02-03 13:28:38 +01003197summary_info = {}
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003198summary_info += {'Install prefix': get_option('prefix')}
3199summary_info += {'BIOS directory': qemu_datadir}
3200summary_info += {'firmware path': get_option('qemu_firmwarepath')}
3201summary_info += {'binary directory': get_option('bindir')}
3202summary_info += {'library directory': get_option('libdir')}
3203summary_info += {'module directory': qemu_moddir}
3204summary_info += {'libexec directory': get_option('libexecdir')}
3205summary_info += {'include directory': get_option('includedir')}
3206summary_info += {'config directory': get_option('sysconfdir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003207if targetos != 'windows'
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003208 summary_info += {'local state directory': get_option('localstatedir')}
Marc-André Lureaub81efab2020-08-26 15:04:18 +04003209 summary_info += {'Manual directory': get_option('mandir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003210else
3211 summary_info += {'local state directory': 'queried at runtime'}
3212endif
Marc-André Lureau491e74c2020-08-26 15:04:17 +04003213summary_info += {'Doc directory': get_option('docdir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003214summary_info += {'Build directory': meson.current_build_dir()}
3215summary_info += {'Source path': meson.current_source_dir()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003216summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003217summary(summary_info, bool_yn: true, section: 'Directories')
3218
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003219# Host binaries
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003220summary_info = {}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003221summary_info += {'git': config_host['GIT']}
3222summary_info += {'make': config_host['MAKE']}
3223summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003224summary_info += {'sphinx-build': sphinx_build}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003225if config_host.has_key('HAVE_GDB_BIN')
3226 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
3227endif
3228summary_info += {'genisoimage': config_host['GENISOIMAGE']}
3229if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003230 summary_info += {'wixl': wixl}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003231endif
Joelle van Dyneb8e0c492021-03-15 11:03:41 -07003232if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003233 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
3234endif
3235summary(summary_info, bool_yn: true, section: 'Host binaries')
3236
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003237# Configurable features
3238summary_info = {}
3239summary_info += {'Documentation': build_docs}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003240summary_info += {'system-mode emulation': have_system}
3241summary_info += {'user-mode emulation': have_user}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003242summary_info += {'block layer': have_block}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003243summary_info += {'Install blobs': get_option('install_blobs')}
3244summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
3245if config_host.has_key('CONFIG_MODULES')
3246 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
3247endif
Paolo Bonzini537b7242021-10-07 15:08:12 +02003248summary_info += {'fuzzing support': get_option('fuzzing')}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003249if have_system
Paolo Bonzini87430d52021-10-07 15:06:09 +02003250 summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003251endif
Paolo Bonzini9c29b742021-10-07 15:08:14 +02003252summary_info += {'Trace backends': ','.join(get_option('trace_backends'))}
3253if 'simple' in get_option('trace_backends')
3254 summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003255endif
Marc-André Lureau142ca622021-07-15 11:53:53 +04003256summary_info += {'D-Bus display': dbus_display}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003257summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
3258summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
3259summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
3260summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
3261summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
3262summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
3263summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
3264summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
3265summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
3266summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
3267summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
3268summary(summary_info, bool_yn: true, section: 'Configurable features')
3269
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003270# Compilation information
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003271summary_info = {}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003272summary_info += {'host CPU': cpu}
3273summary_info += {'host endianness': build_machine.endian()}
Alex Bennée63de9352021-05-27 17:03:15 +01003274summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())}
3275summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003276if link_language == 'cpp'
Alex Bennée63de9352021-05-27 17:03:15 +01003277 summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003278else
3279 summary_info += {'C++ compiler': false}
3280endif
3281if targetos == 'darwin'
Alex Bennée63de9352021-05-27 17:03:15 +01003282 summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003283endif
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003284if targetos == 'windows'
3285 if 'WIN_SDK' in config_host
3286 summary_info += {'Windows SDK': config_host['WIN_SDK']}
3287 endif
3288endif
Paolo Bonzini47b30832020-09-23 05:26:17 -04003289summary_info += {'CFLAGS': ' '.join(get_option('c_args')
3290 + ['-O' + get_option('optimization')]
3291 + (get_option('debug') ? ['-g'] : []))}
3292if link_language == 'cpp'
3293 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
3294 + ['-O' + get_option('optimization')]
3295 + (get_option('debug') ? ['-g'] : []))}
3296endif
3297link_args = get_option(link_language + '_link_args')
3298if link_args.length() > 0
3299 summary_info += {'LDFLAGS': ' '.join(link_args)}
3300endif
Paolo Bonzinif9332752020-02-03 13:28:38 +01003301summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
3302summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003303summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
Daniele Buonocdad7812020-12-04 18:06:11 -05003304summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003305summary_info += {'PIE': get_option('b_pie')}
Laurent Vivier3e8529d2020-09-17 16:07:00 +02003306summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003307summary_info += {'malloc trim support': has_malloc_trim}
3308summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003309summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
3310summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
3311summary_info += {'memory allocator': get_option('malloc')}
3312summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
3313summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
3314summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
3315summary_info += {'gcov': get_option('b_coverage')}
3316summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
3317summary_info += {'CFI support': get_option('cfi')}
3318if get_option('cfi')
3319 summary_info += {'CFI debug support': get_option('cfi_debug')}
3320endif
3321summary_info += {'strip binaries': get_option('strip')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003322summary_info += {'sparse': sparse}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003323summary_info += {'mingw32 support': targetos == 'windows'}
Alex Bennée49e85652021-02-22 10:14:50 +00003324
3325# snarf the cross-compilation information for tests
3326foreach target: target_dirs
3327 tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak'
3328 if fs.exists(tcg_mak)
3329 config_cross_tcg = keyval.load(tcg_mak)
3330 target = config_cross_tcg['TARGET_NAME']
3331 compiler = ''
3332 if 'DOCKER_CROSS_CC_GUEST' in config_cross_tcg
3333 summary_info += {target + ' tests': config_cross_tcg['DOCKER_CROSS_CC_GUEST'] +
3334 ' via ' + config_cross_tcg['DOCKER_IMAGE']}
3335 elif 'CROSS_CC_GUEST' in config_cross_tcg
3336 summary_info += {target + ' tests'
3337 : config_cross_tcg['CROSS_CC_GUEST'] }
3338 endif
3339 endif
3340endforeach
3341
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003342summary(summary_info, bool_yn: true, section: 'Compilation')
3343
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003344# Targets and accelerators
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003345summary_info = {}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003346if have_system
3347 summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
3348 summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
3349 summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
3350 summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
Reinoud Zandijk74a414a2021-04-02 22:25:32 +02003351 summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003352 summary_info += {'Xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
3353 if config_host.has_key('CONFIG_XEN_BACKEND')
3354 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
3355 endif
3356endif
3357summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
3358if config_all.has_key('CONFIG_TCG')
Philippe Mathieu-Daudé39687ac2021-01-25 15:45:29 +01003359 if get_option('tcg_interpreter')
Philippe Mathieu-Daudéf1f727a2021-11-06 12:14:57 +01003360 summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
Philippe Mathieu-Daudé39687ac2021-01-25 15:45:29 +01003361 else
3362 summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
3363 endif
Alex Bennée029aa682021-07-09 15:29:53 +01003364 summary_info += {'TCG plugins': config_host.has_key('CONFIG_PLUGIN')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003365 summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003366endif
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003367summary_info += {'target list': ' '.join(target_dirs)}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003368if have_system
3369 summary_info += {'default devices': get_option('default_devices')}
Paolo Bonzini106ad1f2021-02-17 16:24:25 +01003370 summary_info += {'out of process emulation': multiprocess_allowed}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003371endif
3372summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
3373
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003374# Block layer
3375summary_info = {}
3376summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
3377summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
3378if have_block
3379 summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
3380 summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
Kevin Wolfe5f05f82021-07-09 18:41:41 +02003381 summary_info += {'Use block whitelist in tools': config_host.has_key('CONFIG_BDRV_WHITELIST_TOOLS')}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003382 summary_info += {'VirtFS support': have_virtfs}
3383 summary_info += {'build virtiofs daemon': have_virtiofsd}
3384 summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
3385 summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
3386 summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
3387 summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
3388 summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
3389 summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
3390 summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
3391 summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
3392 summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
3393 summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003394 summary_info += {'FUSE exports': fuse}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003395endif
3396summary(summary_info, bool_yn: true, section: 'Block layer support')
3397
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003398# Crypto
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003399summary_info = {}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003400summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003401summary_info += {'GNUTLS support': gnutls}
3402if gnutls.found()
3403 summary_info += {' GNUTLS crypto': gnutls_crypto.found()}
3404endif
3405summary_info += {'libgcrypt': gcrypt}
3406summary_info += {'nettle': nettle}
Paolo Bonzini57612512021-06-03 11:15:26 +02003407if nettle.found()
3408 summary_info += {' XTS': xts != 'private'}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003409endif
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003410summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
3411summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
3412summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
3413summary(summary_info, bool_yn: true, section: 'Crypto')
3414
Philippe Mathieu-Daudé69a78cc2021-01-21 10:56:16 +01003415# Libraries
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003416summary_info = {}
3417if targetos == 'darwin'
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003418 summary_info += {'Cocoa support': cocoa}
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003419endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003420summary_info += {'SDL support': sdl}
3421summary_info += {'SDL image support': sdl_image}
3422summary_info += {'GTK support': gtk}
3423summary_info += {'pixman': pixman}
3424summary_info += {'VTE support': vte}
3425summary_info += {'slirp support': slirp_opt == 'internal' ? slirp_opt : slirp}
3426summary_info += {'libtasn1': tasn1}
3427summary_info += {'PAM': pam}
3428summary_info += {'iconv support': iconv}
3429summary_info += {'curses support': curses}
3430summary_info += {'virgl support': virgl}
3431summary_info += {'curl support': curl}
3432summary_info += {'Multipath support': mpathpersist}
3433summary_info += {'VNC support': vnc}
Paolo Bonzinia0b93232020-02-06 15:48:52 +01003434if vnc.found()
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003435 summary_info += {'VNC SASL support': sasl}
3436 summary_info += {'VNC JPEG support': jpeg}
3437 summary_info += {'VNC PNG support': png}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003438endif
Paolo Bonzini87430d52021-10-07 15:06:09 +02003439if targetos not in ['darwin', 'haiku', 'windows']
3440 summary_info += {'OSS support': oss}
3441elif targetos == 'darwin'
3442 summary_info += {'CoreAudio support': coreaudio}
3443elif targetos == 'windows'
3444 summary_info += {'DirectSound support': dsound}
3445endif
3446if targetos == 'linux'
3447 summary_info += {'ALSA support': alsa}
3448 summary_info += {'PulseAudio support': pulse}
3449endif
3450summary_info += {'JACK support': jack}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003451summary_info += {'brlapi support': brlapi}
Paolo Bonzinie1723992021-10-07 15:08:21 +02003452summary_info += {'vde support': vde}
Paolo Bonzini837b84b2021-10-07 15:08:22 +02003453summary_info += {'netmap support': have_netmap}
Thomas Hutheea94532021-10-28 20:59:08 +02003454summary_info += {'l2tpv3 support': have_l2tpv3}
Paolo Bonziniff66f3e2021-10-07 15:08:20 +02003455summary_info += {'Linux AIO support': libaio}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003456summary_info += {'Linux io_uring support': linux_io_uring}
3457summary_info += {'ATTR/XATTR support': libattr}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003458summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
3459summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
Paolo Bonzinifbb41212020-10-05 11:31:15 +02003460summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003461summary_info += {'libcap-ng support': libcap_ng}
3462summary_info += {'bpf support': libbpf}
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02003463summary_info += {'spice protocol support': spice_protocol}
3464if spice_protocol.found()
3465 summary_info += {' spice server support': spice}
3466endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003467summary_info += {'rbd support': rbd}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003468summary_info += {'smartcard support': cacard}
3469summary_info += {'U2F support': u2f}
3470summary_info += {'libusb': libusb}
3471summary_info += {'usb net redir': usbredir}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003472summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003473summary_info += {'GBM': gbm}
3474summary_info += {'libiscsi support': libiscsi}
3475summary_info += {'libnfs support': libnfs}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003476if targetos == 'windows'
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003477 if config_host.has_key('CONFIG_GUEST_AGENT')
3478 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
3479 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003480 endif
Paolo Bonzinif9332752020-02-03 13:28:38 +01003481endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003482summary_info += {'seccomp support': seccomp}
3483summary_info += {'GlusterFS support': glusterfs}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003484summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
Thomas Huthe6a52b32021-12-09 15:48:01 +01003485summary_info += {'libssh support': libssh}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003486summary_info += {'lzo support': lzo}
3487summary_info += {'snappy support': snappy}
3488summary_info += {'bzip2 support': libbzip2}
3489summary_info += {'lzfse support': liblzfse}
3490summary_info += {'zstd support': zstd}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003491summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003492summary_info += {'libxml2': libxml2}
3493summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
3494summary_info += {'libpmem support': libpmem}
3495summary_info += {'libdaxctl support': libdaxctl}
3496summary_info += {'libudev': libudev}
3497# Dummy dependency, keep .found()
Max Reitzdf4ea702020-10-27 20:05:46 +01003498summary_info += {'FUSE lseek': fuse_lseek.found()}
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06003499summary_info += {'selinux': selinux}
Philippe Mathieu-Daudé69a78cc2021-01-21 10:56:16 +01003500summary(summary_info, bool_yn: true, section: 'Dependencies')
Paolo Bonzinif9332752020-02-03 13:28:38 +01003501
3502if not supported_cpus.contains(cpu)
3503 message()
3504 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
3505 message()
3506 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
3507 message('The QEMU project intends to remove support for this host CPU in')
3508 message('a future release if nobody volunteers to maintain it and to')
3509 message('provide a build host for our continuous integration setup.')
3510 message('configure has succeeded and you can continue to build, but')
3511 message('if you care about QEMU on this platform you should contact')
3512 message('us upstream at qemu-devel@nongnu.org.')
3513endif
3514
3515if not supported_oses.contains(targetos)
3516 message()
3517 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
3518 message()
3519 message('Host OS ' + targetos + 'support is not currently maintained.')
3520 message('The QEMU project intends to remove support for this host OS in')
3521 message('a future release if nobody volunteers to maintain it and to')
3522 message('provide a build host for our continuous integration setup.')
3523 message('configure has succeeded and you can continue to build, but')
3524 message('if you care about QEMU on this platform you should contact')
3525 message('us upstream at qemu-devel@nongnu.org.')
3526endif