blob: 1c70839bbf17f06fe3e534a55bae61d5460e13b6 [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',
3 'b_staticpic=false'],
4 version: files('VERSION'))
Paolo Bonzinia5665052019-06-10 12:05:14 +02005
6not_found = dependency('', required: false)
Paolo Bonzini654d6b02021-02-09 14:59:26 +01007keyval = import('keyval')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04008ss = import('sourceset')
Richard Henderson8b18cdb2020-09-13 12:19:25 -07009fs = import('fs')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040010
Paolo Bonzinice1c1e72020-01-28 16:41:44 +010011sh = find_program('sh')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040012cc = meson.get_compiler('c')
Paolo Bonzinia5665052019-06-10 12:05:14 +020013config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
Marc-André Lureau3154fee2019-08-29 22:07:01 +040014enable_modules = 'CONFIG_MODULES' in config_host
Paolo Bonzini35be72b2020-02-06 14:17:15 +010015enable_static = 'CONFIG_STATIC' in config_host
Yonggang Luoe3667662020-10-16 06:06:25 +080016
Paolo Bonzinid7dedf42021-01-26 11:15:33 +010017# Allow both shared and static libraries unless --enable-static
18static_kwargs = enable_static ? {'static': true} : {}
19
Yonggang Luoe3667662020-10-16 06:06:25 +080020# Temporary directory used for files created while
21# configure runs. Since it is in the build directory
22# we can safely blow away any previous version of it
23# (and we need not jump through hoops to try to delete
24# it when configure exits.)
25tmpdir = meson.current_build_dir() / 'meson-private/temp'
Marc-André Lureau8fe11232020-09-11 14:42:48 +020026
27if get_option('qemu_suffix').startswith('/')
28 error('qemu_suffix cannot start with a /')
29endif
30
Paolo Bonzini16bf7a32020-10-16 03:19:14 -040031qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
Marc-André Lureauab4c0992020-08-26 15:04:16 +040032qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
Marc-André Lureau491e74c2020-08-26 15:04:17 +040033qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
Paolo Bonzini16bf7a32020-10-16 03:19:14 -040034qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
35
36qemu_desktopdir = get_option('datadir') / 'applications'
37qemu_icondir = get_option('datadir') / 'icons'
38
Paolo Bonzini859aef02020-08-04 18:14:26 +020039config_host_data = configuration_data()
40genh = []
Paolo Bonzinia5665052019-06-10 12:05:14 +020041
Paolo Bonzini760e4322020-08-26 08:09:48 +020042target_dirs = config_host['TARGET_DIRS'].split()
Warner Loshdda2da62021-10-08 16:47:37 -060043have_linux_user = false
44have_bsd_user = false
Paolo Bonzini760e4322020-08-26 08:09:48 +020045have_system = false
46foreach target : target_dirs
Warner Loshdda2da62021-10-08 16:47:37 -060047 have_linux_user = have_linux_user or target.endswith('linux-user')
48 have_bsd_user = have_bsd_user or target.endswith('bsd-user')
Paolo Bonzini760e4322020-08-26 08:09:48 +020049 have_system = have_system or target.endswith('-softmmu')
50endforeach
Warner Loshdda2da62021-10-08 16:47:37 -060051have_user = have_linux_user or have_bsd_user
Paolo Bonzini760e4322020-08-26 08:09:48 +020052have_tools = 'CONFIG_TOOLS' in config_host
53have_block = have_system or have_tools
54
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040055python = import('python').find_installation()
56
57supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
Richard Hendersonba0e7332021-09-17 11:08:09 -070058supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64',
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040059 'arm', 'aarch64', 'mips', 'mips64', 'sparc', 'sparc64']
60
61cpu = host_machine.cpu_family()
Richard Hendersonc94c2392021-11-16 10:50:42 +010062
63# Unify riscv* to a single family.
64if cpu in ['riscv32', 'riscv64']
65 cpu = 'riscv'
66endif
67
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040068targetos = host_machine.system()
69
Paolo Bonzini823eb012021-11-08 14:18:17 +010070if cpu not in supported_cpus
71 host_arch = 'unknown'
72elif cpu == 'x86'
73 host_arch = 'i386'
74else
75 host_arch = cpu
76endif
77
Paolo Bonzini8a199802020-09-18 05:37:01 -040078if cpu in ['x86', 'x86_64']
79 kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
80elif cpu == 'aarch64'
81 kvm_targets = ['aarch64-softmmu']
82elif cpu == 's390x'
83 kvm_targets = ['s390x-softmmu']
84elif cpu in ['ppc', 'ppc64']
85 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
Huacai Chenfbc58842020-10-07 16:39:28 +080086elif cpu in ['mips', 'mips64']
87 kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
Paolo Bonzini8a199802020-09-18 05:37:01 -040088else
89 kvm_targets = []
90endif
91
Igor Mammedov44d3d892021-10-27 11:10:12 -040092kvm_targets_c = '""'
Igor Mammedove741aff2021-09-02 07:35:38 -040093if not get_option('kvm').disabled() and targetos == 'linux'
94 kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
95endif
96config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
97
Paolo Bonzini8a199802020-09-18 05:37:01 -040098accelerator_targets = { 'CONFIG_KVM': kvm_targets }
Alexander Graf844a06b2021-09-16 17:54:02 +020099
100if cpu in ['aarch64']
101 accelerator_targets += {
102 'CONFIG_HVF': ['aarch64-softmmu']
103 }
104endif
105
Alex Bennée0c3e41d2020-11-10 19:23:09 +0000106if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
Marc-André Lureau2a2d51b2021-09-14 16:30:45 +0400107 # i386 emulator provides xenpv machine type for multiple architectures
Alex Bennée0c3e41d2020-11-10 19:23:09 +0000108 accelerator_targets += {
109 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
110 }
111endif
Paolo Bonzini8a199802020-09-18 05:37:01 -0400112if cpu in ['x86', 'x86_64']
113 accelerator_targets += {
114 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
Paolo Bonzini8a199802020-09-18 05:37:01 -0400115 'CONFIG_HVF': ['x86_64-softmmu'],
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200116 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
Paolo Bonzini8a199802020-09-18 05:37:01 -0400117 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
118 }
119endif
120
Paolo Bonzinia1b176f2021-07-12 14:22:08 +0200121modular_tcg = []
122# Darwin does not support references to thread-local variables in modules
123if targetos != 'darwin'
124 modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
125endif
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +0200126
Philippe Mathieu-Daudéeae9a1d2021-01-14 18:45:08 +0100127edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
Paolo Bonzinie49c0ef2021-09-23 06:55:28 -0400128unpack_edk2_blobs = false
129foreach target : edk2_targets
130 if target in target_dirs
131 bzip2 = find_program('bzip2', required: get_option('install_blobs'))
132 unpack_edk2_blobs = bzip2.found()
133 break
134 endif
135endforeach
Philippe Mathieu-Daudé45b545d2021-01-14 18:45:09 +0100136
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200137dtrace = not_found
138stap = not_found
139if 'dtrace' in get_option('trace_backends')
140 dtrace = find_program('dtrace', required: true)
141 stap = find_program('stap', required: false)
142 if stap.found()
143 # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
144 # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
145 # instead. QEMU --enable-modules depends on this because the SystemTap
146 # semaphores are linked into the main binary and not the module's shared
147 # object.
148 add_global_arguments('-DSTAP_SDT_V2',
149 native: false, language: ['c', 'cpp', 'objc'])
150 endif
151endif
152
Paolo Bonzini201e8ed2020-09-01 07:45:54 -0400153##################
154# Compiler flags #
155##################
156
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400157# Specify linker-script with add_project_link_arguments so that it is not placed
158# within a linker --start-group/--end-group pair
Paolo Bonzini537b7242021-10-07 15:08:12 +0200159if get_option('fuzzing')
160 add_project_link_arguments(['-Wl,-T,',
161 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
162 native: false, language: ['c', 'cpp', 'objc'])
163
164 # Specify a filter to only instrument code that is directly related to
165 # virtual-devices.
166 configure_file(output: 'instrumentation-filter',
167 input: 'scripts/oss-fuzz/instrumentation-filter-template',
168 copy: true)
169 add_global_arguments(
170 cc.get_supported_arguments('-fsanitize-coverage-allowlist=instrumentation-filter'),
171 native: false, language: ['c', 'cpp', 'objc'])
172
173 if get_option('fuzzing_engine') == ''
174 # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
175 # compiled code. To build non-fuzzer binaries with --enable-fuzzing, link
176 # everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be
177 # unable to bind the fuzzer-related callbacks added by instrumentation.
178 add_global_arguments('-fsanitize=fuzzer-no-link',
179 native: false, language: ['c', 'cpp', 'objc'])
180 add_global_link_arguments('-fsanitize=fuzzer-no-link',
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400181 native: false, language: ['c', 'cpp', 'objc'])
Paolo Bonzini537b7242021-10-07 15:08:12 +0200182 # For the actual fuzzer binaries, we need to link against the libfuzzer
183 # library. They need to be configurable, to support OSS-Fuzz
184 fuzz_exe_ldflags = ['-fsanitize=fuzzer']
185 else
186 # LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and
187 # the needed CFLAGS have already been provided
188 fuzz_exe_ldflags = get_option('fuzzing_engine').split()
189 endif
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400190endif
191
Marc-André Lureau5fc06172021-01-14 16:56:02 +0400192add_global_arguments(config_host['QEMU_CFLAGS'].split(),
193 native: false, language: ['c', 'objc'])
194add_global_arguments(config_host['QEMU_CXXFLAGS'].split(),
195 native: false, language: 'cpp')
196add_global_link_arguments(config_host['QEMU_LDFLAGS'].split(),
197 native: false, language: ['c', 'cpp', 'objc'])
Paolo Bonzinia5665052019-06-10 12:05:14 +0200198
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400199if targetos == 'linux'
200 add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
201 '-isystem', 'linux-headers',
202 language: ['c', 'cpp'])
203endif
204
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100205add_project_arguments('-iquote', '.',
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400206 '-iquote', meson.current_source_dir(),
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400207 '-iquote', meson.current_source_dir() / 'include',
208 '-iquote', meson.current_source_dir() / 'disas/libvixl',
209 language: ['c', 'cpp', 'objc'])
Alexander Bulekovc46f76d2020-09-02 13:36:50 -0400210
Marc-André Lureaufc929892019-07-13 01:47:54 +0400211link_language = meson.get_external_property('link_language', 'cpp')
212if link_language == 'cpp'
213 add_languages('cpp', required: true, native: false)
Paolo Bonzini565174d2021-11-04 14:35:14 +0100214 cxx = meson.get_compiler('cpp')
215 linker = cxx
216else
217 linker = cc
Marc-André Lureaufc929892019-07-13 01:47:54 +0400218endif
Paolo Bonzinia5665052019-06-10 12:05:14 +0200219if host_machine.system() == 'darwin'
220 add_languages('objc', required: false, native: false)
221endif
222
Paolo Bonzinideb62372020-09-01 07:51:16 -0400223sparse = find_program('cgcc', required: get_option('sparse'))
224if sparse.found()
Paolo Bonzini968b4db2020-02-03 14:45:33 +0100225 run_target('sparse',
226 command: [find_program('scripts/check_sparse.py'),
Paolo Bonzinideb62372020-09-01 07:51:16 -0400227 'compile_commands.json', sparse.full_path(), '-Wbitwise',
228 '-Wno-transparent-union', '-Wno-old-initializer',
229 '-Wno-non-pointer-null'])
Paolo Bonzini968b4db2020-02-03 14:45:33 +0100230endif
231
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200232###########################################
233# Target-specific checks and dependencies #
234###########################################
235
Paolo Bonzini537b7242021-10-07 15:08:12 +0200236if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
237 not cc.links('''
238 #include <stdint.h>
239 #include <sys/types.h>
240 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
241 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
242 ''',
243 args: ['-Werror', '-fsanitize=fuzzer'])
244 error('Your compiler does not support -fsanitize=fuzzer')
245endif
246
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200247if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
248 error('ftrace is supported only on Linux')
249endif
250if 'syslog' in get_option('trace_backends') and not cc.compiles('''
251 #include <syslog.h>
252 int main(void) {
253 openlog("qemu", LOG_PID, LOG_DAEMON);
254 syslog(LOG_INFO, "configure");
255 return 0;
256 }''')
257 error('syslog is not supported on this system')
258endif
259
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200260if targetos != 'linux' and get_option('mpath').enabled()
261 error('Multipath is supported only on Linux')
262endif
263
Paolo Bonzini106ad1f2021-02-17 16:24:25 +0100264if targetos != 'linux' and get_option('multiprocess').enabled()
265 error('Multiprocess QEMU is supported only on Linux')
266endif
267multiprocess_allowed = targetos == 'linux' and not get_option('multiprocess').disabled()
268
Paolo Bonzini7fa1c632021-06-01 10:00:48 +0200269libm = cc.find_library('m', required: false)
Paolo Bonzini6d7c7c22021-06-03 15:01:35 +0200270threads = dependency('threads')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400271util = cc.find_library('util', required: false)
Paolo Bonzini4a963372020-08-03 16:22:28 +0200272winmm = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400273socket = []
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400274version_res = []
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400275coref = []
276iokit = []
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -0400277emulator_link_args = []
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200278nvmm =not_found
Paolo Bonzini8a199802020-09-18 05:37:01 -0400279hvf = not_found
Paolo Bonzinia6305082021-10-07 15:08:15 +0200280host_dsosuf = '.so'
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400281if targetos == 'windows'
282 socket = cc.find_library('ws2_32')
Paolo Bonzini4a963372020-08-03 16:22:28 +0200283 winmm = cc.find_library('winmm')
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400284
285 win = import('windows')
286 version_res = win.compile_resources('version.rc',
287 depend_files: files('pc-bios/qemu-nsis.ico'),
288 include_directories: include_directories('.'))
Paolo Bonzinia6305082021-10-07 15:08:15 +0200289 host_dsosuf = '.dll'
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400290elif targetos == 'darwin'
291 coref = dependency('appleframeworks', modules: 'CoreFoundation')
Joelle van Dyne14176c82021-03-15 11:03:38 -0700292 iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
Paolo Bonzinia6305082021-10-07 15:08:15 +0200293 host_dsosuf = '.dylib'
Paolo Bonzinicfad62f2020-08-09 23:47:45 +0200294elif targetos == 'sunos'
295 socket = [cc.find_library('socket'),
296 cc.find_library('nsl'),
297 cc.find_library('resolv')]
298elif targetos == 'haiku'
299 socket = [cc.find_library('posix_error_mapper'),
300 cc.find_library('network'),
301 cc.find_library('bsd')]
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -0400302elif targetos == 'openbsd'
303 if not get_option('tcg').disabled() and target_dirs.length() > 0
304 # Disable OpenBSD W^X if available
305 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
306 endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400307endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200308
Paolo Bonzini8a199802020-09-18 05:37:01 -0400309accelerators = []
310if not get_option('kvm').disabled() and targetos == 'linux'
311 accelerators += 'CONFIG_KVM'
312endif
313if not get_option('xen').disabled() and 'CONFIG_XEN_BACKEND' in config_host
314 accelerators += 'CONFIG_XEN'
315 have_xen_pci_passthrough = not get_option('xen_pci_passthrough').disabled() and targetos == 'linux'
316else
317 have_xen_pci_passthrough = false
318endif
319if not get_option('whpx').disabled() and targetos == 'windows'
Sunil Muthuswamy57e2a1f2020-10-22 00:27:55 +0000320 if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
Paolo Bonzini8a199802020-09-18 05:37:01 -0400321 error('WHPX requires 64-bit host')
322 elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
323 cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
324 accelerators += 'CONFIG_WHPX'
325 endif
326endif
327if not get_option('hvf').disabled()
328 hvf = dependency('appleframeworks', modules: 'Hypervisor',
329 required: get_option('hvf'))
330 if hvf.found()
331 accelerators += 'CONFIG_HVF'
332 endif
333endif
334if not get_option('hax').disabled()
335 if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
336 accelerators += 'CONFIG_HAX'
337 endif
338endif
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200339if targetos == 'netbsd'
nia0cc49652021-10-13 13:54:17 +0000340 nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200341 if nvmm.found()
342 accelerators += 'CONFIG_NVMM'
343 endif
344endif
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100345
Paolo Bonzini823eb012021-11-08 14:18:17 +0100346tcg_arch = host_arch
Paolo Bonzini8a199802020-09-18 05:37:01 -0400347if not get_option('tcg').disabled()
Paolo Bonzini823eb012021-11-08 14:18:17 +0100348 if host_arch == 'unknown'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100349 if get_option('tcg_interpreter')
Philippe Mathieu-Daudéf1f727a2021-11-06 12:14:57 +0100350 warning('Unsupported CPU @0@, will use TCG with TCI (slow)'.format(cpu))
Paolo Bonzini8a199802020-09-18 05:37:01 -0400351 else
352 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
353 endif
Philippe Mathieu-Daudéfa2f7b02021-01-25 15:45:30 +0100354 elif get_option('tcg_interpreter')
Philippe Mathieu-Daudé1c282da2021-05-21 12:34:23 +0200355 warning('Use of the TCG interpreter is not recommended on this host')
Philippe Mathieu-Daudéfa2f7b02021-01-25 15:45:30 +0100356 warning('architecture. There is a native TCG execution backend available')
357 warning('which provides substantially better performance and reliability.')
358 warning('It is strongly recommended to remove the --enable-tcg-interpreter')
359 warning('configuration option on this architecture to use the native')
360 warning('backend.')
Paolo Bonzini8a199802020-09-18 05:37:01 -0400361 endif
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100362 if get_option('tcg_interpreter')
363 tcg_arch = 'tci'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100364 elif host_arch == 'sparc64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100365 tcg_arch = 'sparc'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100366 elif host_arch == 'x86_64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100367 tcg_arch = 'i386'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100368 elif host_arch == 'ppc64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100369 tcg_arch = 'ppc'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100370 endif
371 add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100372 language: ['c', 'cpp', 'objc'])
373
Paolo Bonzini8a199802020-09-18 05:37:01 -0400374 accelerators += 'CONFIG_TCG'
375 config_host += { 'CONFIG_TCG': 'y' }
376endif
377
378if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
379 error('KVM not available on this platform')
380endif
381if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
382 error('HVF not available on this platform')
383endif
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200384if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
385 error('NVMM not available on this platform')
386endif
Paolo Bonzini8a199802020-09-18 05:37:01 -0400387if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
388 error('WHPX not available on this platform')
389endif
390if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
391 if 'CONFIG_XEN' in accelerators
392 error('Xen PCI passthrough not available on this platform')
393 else
394 error('Xen PCI passthrough requested but Xen not enabled')
395 endif
396endif
Paolo Bonzinib4e312e2020-09-01 11:28:59 -0400397
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200398################
399# Dependencies #
400################
401
Paolo Bonzini215b0c22020-09-01 08:41:17 -0400402# The path to glib.h is added to all compilation commands. This was
403# grandfathered in from the QEMU Makefiles.
404add_project_arguments(config_host['GLIB_CFLAGS'].split(),
405 native: false, language: ['c', 'cpp', 'objc'])
Marc-André Lureau953d5a92020-12-15 12:03:19 +0400406glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
407 link_args: config_host['GLIB_LIBS'].split())
408# override glib dep with the configure results (for subprojects)
409meson.override_dependency('glib-2.0', glib)
410
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400411gio = not_found
412if 'CONFIG_GIO' in config_host
413 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
414 link_args: config_host['GIO_LIBS'].split())
415endif
416lttng = not_found
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200417if 'ust' in get_option('trace_backends')
418 lttng = dependency('lttng-ust', required: true, method: 'pkg-config',
419 kwargs: static_kwargs)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400420endif
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200421pixman = not_found
422if have_system or have_tools
423 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100424 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200425endif
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100426zlib = dependency('zlib', required: true, kwargs: static_kwargs)
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200427
Paolo Bonziniff66f3e2021-10-07 15:08:20 +0200428libaio = not_found
429if not get_option('linux_aio').auto() or have_block
430 libaio = cc.find_library('aio', has_headers: ['libaio.h'],
431 required: get_option('linux_aio'),
432 kwargs: static_kwargs)
433endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400434linux_io_uring = not_found
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200435if not get_option('linux_io_uring').auto() or have_block
436 linux_io_uring = dependency('liburing', required: get_option('linux_io_uring'),
437 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400438endif
439libxml2 = not_found
Paolo Bonzinic5b36c22021-06-03 11:31:35 +0200440if not get_option('libxml2').auto() or have_block
441 libxml2 = dependency('libxml-2.0', required: get_option('libxml2'),
442 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400443endif
444libnfs = not_found
Paolo Bonzini30045c02020-11-17 13:11:25 +0100445if not get_option('libnfs').auto() or have_block
446 libnfs = dependency('libnfs', version: '>=1.9.3',
447 required: get_option('libnfs'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100448 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400449endif
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100450
451libattr_test = '''
452 #include <stddef.h>
453 #include <sys/types.h>
454 #ifdef CONFIG_LIBATTR
455 #include <attr/xattr.h>
456 #else
457 #include <sys/xattr.h>
458 #endif
459 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
460
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400461libattr = not_found
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100462have_old_libattr = false
463if not get_option('attr').disabled()
464 if cc.links(libattr_test)
465 libattr = declare_dependency()
466 else
467 libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
468 required: get_option('attr'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100469 kwargs: static_kwargs)
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100470 if libattr.found() and not \
471 cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
472 libattr = not_found
473 if get_option('attr').enabled()
474 error('could not link libattr')
475 else
476 warning('could not link libattr, disabling')
477 endif
478 else
479 have_old_libattr = libattr.found()
480 endif
481 endif
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400482endif
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100483
Paolo Bonzinic1ec4942021-01-07 14:04:00 +0100484cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
485if cocoa.found() and get_option('sdl').enabled()
486 error('Cocoa and SDL cannot be enabled at the same time')
487endif
488if cocoa.found() and get_option('gtk').enabled()
489 error('Cocoa and GTK+ cannot be enabled at the same time')
490endif
491
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100492seccomp = not_found
Paolo Bonzini90835c22020-11-17 14:22:24 +0100493if not get_option('seccomp').auto() or have_system or have_tools
494 seccomp = dependency('libseccomp', version: '>=2.3.0',
495 required: get_option('seccomp'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100496 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100497endif
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100498
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100499libcap_ng = not_found
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100500if not get_option('cap_ng').auto() or have_system or have_tools
501 libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
502 required: get_option('cap_ng'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100503 kwargs: static_kwargs)
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100504endif
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100505if libcap_ng.found() and not cc.links('''
506 #include <cap-ng.h>
507 int main(void)
508 {
509 capng_capability_to_name(CAPNG_EFFECTIVE);
510 return 0;
511 }''', dependencies: libcap_ng)
512 libcap_ng = not_found
513 if get_option('cap_ng').enabled()
514 error('could not link libcap-ng')
515 else
516 warning('could not link libcap-ng, disabling')
517 endif
518endif
519
Paolo Bonzini1917ec62020-08-26 03:24:11 -0400520if get_option('xkbcommon').auto() and not have_system and not have_tools
521 xkbcommon = not_found
522else
523 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100524 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureauade60d42019-07-15 14:48:31 +0400525endif
Paolo Bonzinie1723992021-10-07 15:08:21 +0200526
Marc-André Lureaucdaf0722019-07-22 23:47:50 +0400527vde = not_found
Paolo Bonzinie1723992021-10-07 15:08:21 +0200528if not get_option('vde').auto() or have_system or have_tools
529 vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'],
530 required: get_option('vde'),
531 kwargs: static_kwargs)
532endif
533if vde.found() and not cc.links('''
534 #include <libvdeplug.h>
535 int main(void)
536 {
537 struct vde_open_args a = {0, 0, 0};
538 char s[] = "";
539 vde_open(s, s, &a);
540 return 0;
541 }''', dependencies: vde)
542 vde = not_found
543 if get_option('cap_ng').enabled()
544 error('could not link libvdeplug')
545 else
546 warning('could not link libvdeplug, disabling')
547 endif
Marc-André Lureaucdaf0722019-07-22 23:47:50 +0400548endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200549
Paolo Bonzini478e9432020-08-17 12:47:55 +0200550pulse = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200551if not get_option('pa').auto() or (targetos == 'linux' and have_system)
552 pulse = dependency('libpulse', required: get_option('pa'),
553 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200554endif
555alsa = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200556if not get_option('alsa').auto() or (targetos == 'linux' and have_system)
557 alsa = dependency('alsa', required: get_option('alsa'),
558 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200559endif
560jack = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200561if not get_option('jack').auto() or have_system
562 jack = dependency('jack', required: get_option('jack'),
563 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200564endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200565
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +0200566spice_protocol = not_found
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200567if not get_option('spice_protocol').auto() or have_system
568 spice_protocol = dependency('spice-protocol', version: '>=0.12.3',
569 required: get_option('spice_protocol'),
570 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini26347332019-07-29 15:40:07 +0200571endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200572spice = not_found
573if not get_option('spice').auto() or have_system
574 spice = dependency('spice-server', version: '>=0.12.5',
575 required: get_option('spice'),
576 method: 'pkg-config', kwargs: static_kwargs)
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +0200577endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200578spice_headers = spice.partial_dependency(compile_args: true, includes: true)
579
Marc-André Lureau5ee24e72019-07-12 23:16:54 +0400580rt = cc.find_library('rt', required: false)
Paolo Bonzinia399f912021-11-15 14:29:13 +0000581
Paolo Bonzini99650b62019-06-10 12:21:14 +0200582libiscsi = not_found
Paolo Bonzini9db405a2020-11-17 13:11:25 +0100583if not get_option('libiscsi').auto() or have_block
584 libiscsi = dependency('libiscsi', version: '>=1.9.0',
585 required: get_option('libiscsi'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100586 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini99650b62019-06-10 12:21:14 +0200587endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400588zstd = not_found
Paolo Bonzinib1def332020-11-17 13:37:39 +0100589if not get_option('zstd').auto() or have_block
590 zstd = dependency('libzstd', version: '>=1.4.0',
591 required: get_option('zstd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100592 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400593endif
Marc-André Lureauea458962019-07-12 22:23:46 +0400594virgl = not_found
Paolo Bonzini587d59d2021-06-03 11:31:35 +0200595if not get_option('virglrenderer').auto() or have_system
596 virgl = dependency('virglrenderer',
597 method: 'pkg-config',
598 required: get_option('virglrenderer'),
599 kwargs: static_kwargs)
Marc-André Lureauea458962019-07-12 22:23:46 +0400600endif
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +0400601curl = not_found
Paolo Bonzinif9cd86f2020-11-17 12:43:15 +0100602if not get_option('curl').auto() or have_block
603 curl = dependency('libcurl', version: '>=7.29.0',
604 method: 'pkg-config',
605 required: get_option('curl'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100606 kwargs: static_kwargs)
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +0400607endif
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200608libudev = not_found
Paolo Bonzinif01496a2020-09-16 17:54:14 +0200609if targetos == 'linux' and (have_system or have_tools)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200610 libudev = dependency('libudev',
Paolo Bonzinia0fbbb62020-11-17 12:36:15 +0100611 method: 'pkg-config',
Paolo Bonzini5c530152020-10-15 06:09:27 -0400612 required: get_option('libudev'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100613 kwargs: static_kwargs)
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200614endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200615
Paolo Bonzini5c530152020-10-15 06:09:27 -0400616mpathlibs = [libudev]
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200617mpathpersist = not_found
618mpathpersist_new_api = false
619if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
620 mpath_test_source_new = '''
621 #include <libudev.h>
622 #include <mpath_persist.h>
623 unsigned mpath_mx_alloc_len = 1024;
624 int logsink;
625 static struct config *multipath_conf;
626 extern struct udev *udev;
627 extern struct config *get_multipath_config(void);
628 extern void put_multipath_config(struct config *conf);
629 struct udev *udev;
630 struct config *get_multipath_config(void) { return multipath_conf; }
631 void put_multipath_config(struct config *conf) { }
632 int main(void) {
633 udev = udev_new();
634 multipath_conf = mpath_lib_init();
635 return 0;
636 }'''
637 mpath_test_source_old = '''
638 #include <libudev.h>
639 #include <mpath_persist.h>
640 unsigned mpath_mx_alloc_len = 1024;
641 int logsink;
642 int main(void) {
643 struct udev *udev = udev_new();
644 mpath_lib_init(udev);
645 return 0;
646 }'''
Paolo Bonzini5c530152020-10-15 06:09:27 -0400647 libmpathpersist = cc.find_library('mpathpersist',
648 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100649 kwargs: static_kwargs)
Paolo Bonzini5c530152020-10-15 06:09:27 -0400650 if libmpathpersist.found()
651 mpathlibs += libmpathpersist
652 if enable_static
653 mpathlibs += cc.find_library('devmapper',
654 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100655 kwargs: static_kwargs)
Paolo Bonzini43b43a42020-09-17 12:25:09 +0200656 endif
Paolo Bonzini5c530152020-10-15 06:09:27 -0400657 mpathlibs += cc.find_library('multipath',
658 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100659 kwargs: static_kwargs)
Paolo Bonzini5c530152020-10-15 06:09:27 -0400660 foreach lib: mpathlibs
661 if not lib.found()
662 mpathlibs = []
663 break
664 endif
665 endforeach
666 if mpathlibs.length() == 0
667 msg = 'Dependencies missing for libmpathpersist'
668 elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200669 mpathpersist = declare_dependency(dependencies: mpathlibs)
670 mpathpersist_new_api = true
671 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
672 mpathpersist = declare_dependency(dependencies: mpathlibs)
673 else
Paolo Bonzini5c530152020-10-15 06:09:27 -0400674 msg = 'Cannot detect libmpathpersist API'
675 endif
676 if not mpathpersist.found()
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200677 if get_option('mpath').enabled()
Paolo Bonzini5c530152020-10-15 06:09:27 -0400678 error(msg)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200679 else
Paolo Bonzini5c530152020-10-15 06:09:27 -0400680 warning(msg + ', disabling')
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200681 endif
682 endif
683 endif
684endif
685
Yonggang Luo5285e592020-10-13 07:43:48 +0800686iconv = not_found
Yonggang Luo5285e592020-10-13 07:43:48 +0800687curses = not_found
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400688if have_system and not get_option('curses').disabled()
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400689 curses_test = '''
Stefan Weilfbab8cc2021-11-17 21:53:55 +0100690 #if defined(__APPLE__) || defined(__OpenBSD__)
691 #define _XOPEN_SOURCE_EXTENDED 1
692 #endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400693 #include <locale.h>
694 #include <curses.h>
695 #include <wchar.h>
696 int main(void) {
697 wchar_t wch = L'w';
698 setlocale(LC_ALL, "");
699 resize_term(0, 0);
700 addwstr(L"wide chars\n");
701 addnwstr(&wch, 1);
702 add_wch(WACS_DEGREE);
703 return 0;
704 }'''
705
Yonggang Luoca31e302020-11-17 05:31:06 +0800706 curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
707 foreach curses_dep : curses_dep_list
708 if not curses.found()
709 curses = dependency(curses_dep,
710 required: false,
711 method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100712 kwargs: static_kwargs)
Yonggang Luoca31e302020-11-17 05:31:06 +0800713 endif
714 endforeach
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400715 msg = get_option('curses').enabled() ? 'curses library not found' : ''
Stefan Weilfbab8cc2021-11-17 21:53:55 +0100716 curses_compile_args = ['-DNCURSES_WIDECHAR=1']
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400717 if curses.found()
Paolo Bonzini0dbce6e2020-11-30 08:07:48 -0500718 if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
719 curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses])
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400720 else
721 msg = 'curses package not usable'
722 curses = not_found
Yonggang Luo5285e592020-10-13 07:43:48 +0800723 endif
724 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400725 if not curses.found()
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400726 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
727 if targetos != 'windows' and not has_curses_h
728 message('Trying with /usr/include/ncursesw')
729 curses_compile_args += ['-I/usr/include/ncursesw']
730 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
731 endif
732 if has_curses_h
733 curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
734 foreach curses_libname : curses_libname_list
Yonggang Luo5285e592020-10-13 07:43:48 +0800735 libcurses = cc.find_library(curses_libname,
736 required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100737 kwargs: static_kwargs)
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400738 if libcurses.found()
739 if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
740 curses = declare_dependency(compile_args: curses_compile_args,
741 dependencies: [libcurses])
742 break
743 else
744 msg = 'curses library not usable'
745 endif
Yonggang Luo5285e592020-10-13 07:43:48 +0800746 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400747 endforeach
748 endif
749 endif
750 if not get_option('iconv').disabled()
751 foreach link_args : [ ['-liconv'], [] ]
752 # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
753 # We need to use libiconv if available because mixing libiconv's headers with
754 # the system libc does not work.
755 # However, without adding glib to the dependencies -L/usr/local/lib will not be
756 # included in the command line and libiconv will not be found.
757 if cc.links('''
758 #include <iconv.h>
759 int main(void) {
760 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
761 return conv != (iconv_t) -1;
762 }''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
763 iconv = declare_dependency(link_args: link_args, dependencies: glib)
764 break
Yonggang Luo5285e592020-10-13 07:43:48 +0800765 endif
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400766 endforeach
767 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400768 if curses.found() and not iconv.found()
769 if get_option('iconv').enabled()
770 error('iconv not available')
771 endif
772 msg = 'iconv required for curses UI but not available'
773 curses = not_found
774 endif
775 if not curses.found() and msg != ''
776 if get_option('curses').enabled()
777 error(msg)
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400778 else
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400779 warning(msg + ', disabling')
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400780 endif
Yonggang Luo5285e592020-10-13 07:43:48 +0800781 endif
782endif
783
Paolo Bonzini26347332019-07-29 15:40:07 +0200784brlapi = not_found
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +0100785if not get_option('brlapi').auto() or have_system
786 brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
787 required: get_option('brlapi'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100788 kwargs: static_kwargs)
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +0100789 if brlapi.found() and not cc.links('''
790 #include <brlapi.h>
791 #include <stddef.h>
792 int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
793 brlapi = not_found
794 if get_option('brlapi').enabled()
795 error('could not link brlapi')
796 else
797 warning('could not link brlapi, disabling')
798 endif
799 endif
Paolo Bonzini26347332019-07-29 15:40:07 +0200800endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100801
Paolo Bonzini760e4322020-08-26 08:09:48 +0200802sdl = not_found
Paolo Bonzinic1ec4942021-01-07 14:04:00 +0100803if not get_option('sdl').auto() or (have_system and not cocoa.found())
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100804 sdl = dependency('sdl2', required: get_option('sdl'), kwargs: static_kwargs)
Paolo Bonzini760e4322020-08-26 08:09:48 +0200805 sdl_image = not_found
806endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100807if sdl.found()
808 # work around 2.0.8 bug
809 sdl = declare_dependency(compile_args: '-Wno-undef',
810 dependencies: sdl)
Volker Rümelin7161a432020-08-29 12:41:58 +0200811 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100812 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100813else
814 if get_option('sdl_image').enabled()
Sergei Trofimovicha8dc2ac2020-09-08 08:40:16 +0100815 error('sdl-image required, but SDL was @0@'.format(
816 get_option('sdl').disabled() ? 'disabled' : 'not found'))
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100817 endif
818 sdl_image = not_found
Paolo Bonzini26347332019-07-29 15:40:07 +0200819endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100820
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400821rbd = not_found
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100822if not get_option('rbd').auto() or have_block
823 librados = cc.find_library('rados', required: get_option('rbd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100824 kwargs: static_kwargs)
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100825 librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
826 required: get_option('rbd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100827 kwargs: static_kwargs)
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100828 if librados.found() and librbd.found()
829 if cc.links('''
830 #include <stdio.h>
831 #include <rbd/librbd.h>
832 int main(void) {
833 rados_t cluster;
834 rados_create(&cluster, NULL);
Peter Lieven48672ac2021-07-02 19:23:51 +0200835 #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0)
836 #error
837 #endif
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100838 return 0;
839 }''', dependencies: [librbd, librados])
840 rbd = declare_dependency(dependencies: [librbd, librados])
841 elif get_option('rbd').enabled()
Peter Lieven48672ac2021-07-02 19:23:51 +0200842 error('librbd >= 1.12.0 required')
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100843 else
Peter Lieven48672ac2021-07-02 19:23:51 +0200844 warning('librbd >= 1.12.0 not found, disabling')
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100845 endif
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100846 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400847endif
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100848
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400849glusterfs = not_found
Paolo Bonzini08821ca2020-11-17 13:01:26 +0100850glusterfs_ftruncate_has_stat = false
851glusterfs_iocb_has_stat = false
852if not get_option('glusterfs').auto() or have_block
853 glusterfs = dependency('glusterfs-api', version: '>=3',
854 required: get_option('glusterfs'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100855 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini08821ca2020-11-17 13:01:26 +0100856 if glusterfs.found()
857 glusterfs_ftruncate_has_stat = cc.links('''
858 #include <glusterfs/api/glfs.h>
859
860 int
861 main(void)
862 {
863 /* new glfs_ftruncate() passes two additional args */
864 return glfs_ftruncate(NULL, 0, NULL, NULL);
865 }
866 ''', dependencies: glusterfs)
867 glusterfs_iocb_has_stat = cc.links('''
868 #include <glusterfs/api/glfs.h>
869
870 /* new glfs_io_cbk() passes two additional glfs_stat structs */
871 static void
872 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
873 {}
874
875 int
876 main(void)
877 {
878 glfs_io_cbk iocb = &glusterfs_iocb;
879 iocb(NULL, 0 , NULL, NULL, NULL);
880 return 0;
881 }
882 ''', dependencies: glusterfs)
883 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400884endif
Thomas Huthe6a52b32021-12-09 15:48:01 +0100885
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400886libssh = not_found
Thomas Huthe6a52b32021-12-09 15:48:01 +0100887if not get_option('libssh').auto() or have_block
888 libssh = dependency('libssh', version: '>=0.8.7',
889 method: 'pkg-config',
890 required: get_option('libssh'),
891 kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400892endif
Thomas Huthe6a52b32021-12-09 15:48:01 +0100893
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400894libbzip2 = not_found
Paolo Bonzini29ba6112020-11-17 13:07:52 +0100895if not get_option('bzip2').auto() or have_block
896 libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
897 required: get_option('bzip2'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100898 kwargs: static_kwargs)
Paolo Bonzini29ba6112020-11-17 13:07:52 +0100899 if libbzip2.found() and not cc.links('''
900 #include <bzlib.h>
901 int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
902 libbzip2 = not_found
903 if get_option('bzip2').enabled()
904 error('could not link libbzip2')
905 else
906 warning('could not link libbzip2, disabling')
907 endif
908 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400909endif
Paolo Bonziniecea3692020-11-17 13:35:28 +0100910
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400911liblzfse = not_found
Paolo Bonziniecea3692020-11-17 13:35:28 +0100912if not get_option('lzfse').auto() or have_block
913 liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
914 required: get_option('lzfse'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100915 kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400916endif
Paolo Bonziniecea3692020-11-17 13:35:28 +0100917if liblzfse.found() and not cc.links('''
918 #include <lzfse.h>
919 int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
920 liblzfse = not_found
921 if get_option('lzfse').enabled()
922 error('could not link liblzfse')
923 else
924 warning('could not link liblzfse, disabling')
925 endif
926endif
927
Paolo Bonzini478e9432020-08-17 12:47:55 +0200928oss = not_found
Thomas Huthab486f12021-11-02 11:58:22 +0100929if have_system and not get_option('oss').disabled()
Paolo Bonzini87430d52021-10-07 15:06:09 +0200930 if not cc.has_header('sys/soundcard.h')
931 # not found
932 elif targetos == 'netbsd'
933 oss = cc.find_library('ossaudio', required: get_option('oss'),
934 kwargs: static_kwargs)
935 else
936 oss = declare_dependency()
937 endif
938
939 if not oss.found()
940 if get_option('oss').enabled()
941 error('OSS not found')
Paolo Bonzini87430d52021-10-07 15:06:09 +0200942 endif
943 endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200944endif
945dsound = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200946if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
947 if cc.has_header('dsound.h')
948 dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
949 endif
950
951 if not dsound.found()
952 if get_option('dsound').enabled()
953 error('DirectSound not found')
Paolo Bonzini87430d52021-10-07 15:06:09 +0200954 endif
955 endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200956endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200957
Paolo Bonzini478e9432020-08-17 12:47:55 +0200958coreaudio = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200959if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
960 coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
961 required: get_option('coreaudio'))
Paolo Bonzini478e9432020-08-17 12:47:55 +0200962endif
Thomas Huth8bc51842021-07-13 13:09:02 +0200963
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400964opengl = not_found
965if 'CONFIG_OPENGL' in config_host
Paolo Bonzinide2d3002020-09-01 08:41:17 -0400966 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
967 link_args: config_host['OPENGL_LIBS'].split())
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400968endif
Thomas Huth8bc51842021-07-13 13:09:02 +0200969gbm = not_found
970if (have_system or have_tools) and (virgl.found() or opengl.found())
971 gbm = dependency('gbm', method: 'pkg-config', required: false,
972 kwargs: static_kwargs)
973endif
Paolo Bonzini1b695472021-01-07 14:02:29 +0100974
Paolo Bonzini57612512021-06-03 11:15:26 +0200975gnutls = not_found
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +0100976gnutls_crypto = not_found
Alyssa Rossabc14fd2021-08-06 14:49:47 +0000977if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +0100978 # For general TLS support our min gnutls matches
979 # that implied by our platform support matrix
980 #
981 # For the crypto backends, we look for a newer
982 # gnutls:
983 #
984 # Version 3.6.8 is needed to get XTS
985 # Version 3.6.13 is needed to get PBKDF
986 # Version 3.6.14 is needed to get HW accelerated XTS
987 #
988 # If newer enough gnutls isn't available, we can
989 # still use a different crypto backend to satisfy
990 # the platform support requirements
991 gnutls_crypto = dependency('gnutls', version: '>=3.6.14',
992 method: 'pkg-config',
993 required: false,
994 kwargs: static_kwargs)
995 if gnutls_crypto.found()
996 gnutls = gnutls_crypto
997 else
998 # Our min version if all we need is TLS
999 gnutls = dependency('gnutls', version: '>=3.5.18',
1000 method: 'pkg-config',
1001 required: get_option('gnutls'),
1002 kwargs: static_kwargs)
1003 endif
Paolo Bonzini57612512021-06-03 11:15:26 +02001004endif
1005
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001006# We prefer use of gnutls for crypto, unless the options
1007# explicitly asked for nettle or gcrypt.
1008#
1009# If gnutls isn't available for crypto, then we'll prefer
1010# gcrypt over nettle for performance reasons.
Paolo Bonzini57612512021-06-03 11:15:26 +02001011gcrypt = not_found
1012nettle = not_found
Daniel P. Berrangé68014042021-07-02 17:00:32 +01001013xts = 'none'
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001014
Paolo Bonzini57612512021-06-03 11:15:26 +02001015if get_option('nettle').enabled() and get_option('gcrypt').enabled()
1016 error('Only one of gcrypt & nettle can be enabled')
Paolo Bonzini57612512021-06-03 11:15:26 +02001017endif
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001018
1019# Explicit nettle/gcrypt request, so ignore gnutls for crypto
1020if get_option('nettle').enabled() or get_option('gcrypt').enabled()
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +01001021 gnutls_crypto = not_found
1022endif
Paolo Bonzini57612512021-06-03 11:15:26 +02001023
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001024if not gnutls_crypto.found()
1025 if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
1026 gcrypt = dependency('libgcrypt', version: '>=1.8',
1027 method: 'config-tool',
1028 required: get_option('gcrypt'),
1029 kwargs: static_kwargs)
1030 # Debian has removed -lgpg-error from libgcrypt-config
1031 # as it "spreads unnecessary dependencies" which in
1032 # turn breaks static builds...
1033 if gcrypt.found() and enable_static
1034 gcrypt = declare_dependency(dependencies: [
1035 gcrypt,
1036 cc.find_library('gpg-error', required: true, kwargs: static_kwargs)])
1037 endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001038 endif
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001039 if (not get_option('nettle').auto() or have_system) and not gcrypt.found()
1040 nettle = dependency('nettle', version: '>=3.4',
1041 method: 'pkg-config',
1042 required: get_option('nettle'),
1043 kwargs: static_kwargs)
1044 if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle)
1045 xts = 'private'
1046 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001047 endif
1048endif
1049
1050gtk = not_found
Paolo Bonzini1b695472021-01-07 14:02:29 +01001051gtkx11 = not_found
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001052vte = not_found
Paolo Bonzinic1ec4942021-01-07 14:04:00 +01001053if not get_option('gtk').auto() or (have_system and not cocoa.found())
Paolo Bonzini1b695472021-01-07 14:02:29 +01001054 gtk = dependency('gtk+-3.0', version: '>=3.22.0',
1055 method: 'pkg-config',
1056 required: get_option('gtk'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001057 kwargs: static_kwargs)
Paolo Bonzini1b695472021-01-07 14:02:29 +01001058 if gtk.found()
1059 gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
1060 method: 'pkg-config',
1061 required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001062 kwargs: static_kwargs)
Paolo Bonzini1b695472021-01-07 14:02:29 +01001063 gtk = declare_dependency(dependencies: [gtk, gtkx11])
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001064
1065 if not get_option('vte').auto() or have_system
1066 vte = dependency('vte-2.91',
1067 method: 'pkg-config',
1068 required: get_option('vte'),
1069 kwargs: static_kwargs)
1070 endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001071 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001072endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001073
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001074x11 = not_found
Markus Armbruster9d49bcf2021-05-03 10:40:33 +02001075if gtkx11.found()
Paolo Bonzini1b695472021-01-07 14:02:29 +01001076 x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001077 kwargs: static_kwargs)
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001078endif
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001079vnc = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001080png = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001081jpeg = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001082sasl = not_found
Thomas Huth95e22892021-09-06 17:39:39 +02001083if have_system and not get_option('vnc').disabled()
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001084 vnc = declare_dependency() # dummy dependency
1085 png = dependency('libpng', required: get_option('vnc_png'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001086 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini8e242b32020-11-23 13:34:02 -05001087 jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001088 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001089 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
1090 required: get_option('vnc_sasl'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001091 kwargs: static_kwargs)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001092 if sasl.found()
1093 sasl = declare_dependency(dependencies: sasl,
1094 compile_args: '-DSTRUCT_IOVEC_DEFINED')
1095 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001096endif
Paolo Bonzini241611e2020-11-17 13:32:34 +01001097
Paolo Bonzini05e391a2021-06-03 11:15:26 +02001098pam = not_found
1099if not get_option('auth_pam').auto() or have_system
1100 pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
1101 required: get_option('auth_pam'),
1102 kwargs: static_kwargs)
1103endif
1104if pam.found() and not cc.links('''
1105 #include <stddef.h>
1106 #include <security/pam_appl.h>
1107 int main(void) {
1108 const char *service_name = "qemu";
1109 const char *user = "frank";
1110 const struct pam_conv pam_conv = { 0 };
1111 pam_handle_t *pamh = NULL;
1112 pam_start(service_name, user, &pam_conv, &pamh);
1113 return 0;
1114 }''', dependencies: pam)
1115 pam = not_found
1116 if get_option('auth_pam').enabled()
1117 error('could not link libpam')
1118 else
1119 warning('could not link libpam, disabling')
1120 endif
1121endif
1122
Marc-André Lureau708eab42019-09-03 16:59:33 +04001123snappy = not_found
Paolo Bonzini241611e2020-11-17 13:32:34 +01001124if not get_option('snappy').auto() or have_system
1125 snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
1126 required: get_option('snappy'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001127 kwargs: static_kwargs)
Marc-André Lureau708eab42019-09-03 16:59:33 +04001128endif
Paolo Bonzini565174d2021-11-04 14:35:14 +01001129if snappy.found() and not linker.links('''
Paolo Bonzini241611e2020-11-17 13:32:34 +01001130 #include <snappy-c.h>
1131 int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
1132 snappy = not_found
1133 if get_option('snappy').enabled()
1134 error('could not link libsnappy')
1135 else
1136 warning('could not link libsnappy, disabling')
1137 endif
Marc-André Lureau708eab42019-09-03 16:59:33 +04001138endif
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001139
Marc-André Lureau708eab42019-09-03 16:59:33 +04001140lzo = not_found
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001141if not get_option('lzo').auto() or have_system
1142 lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
1143 required: get_option('lzo'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001144 kwargs: static_kwargs)
Marc-André Lureau708eab42019-09-03 16:59:33 +04001145endif
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001146if lzo.found() and not cc.links('''
1147 #include <lzo/lzo1x.h>
1148 int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
1149 lzo = not_found
1150 if get_option('lzo').enabled()
1151 error('could not link liblzo2')
1152 else
1153 warning('could not link liblzo2, disabling')
1154 endif
1155endif
1156
Marc-André Lureau55166232019-07-24 19:16:22 +04001157rdma = not_found
1158if 'CONFIG_RDMA' in config_host
1159 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
1160endif
Marc-André Lureauab318052019-07-24 19:23:16 +04001161numa = not_found
1162if 'CONFIG_NUMA' in config_host
1163 numa = declare_dependency(link_args: config_host['NUMA_LIBS'].split())
1164endif
Marc-André Lureau582ea952019-08-15 15:15:32 +04001165xen = not_found
1166if 'CONFIG_XEN_BACKEND' in config_host
1167 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
1168 link_args: config_host['XEN_LIBS'].split())
1169endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001170cacard = not_found
Paolo Bonzini5f364c52021-06-03 11:15:26 +02001171if not get_option('smartcard').auto() or have_system
1172 cacard = dependency('libcacard', required: get_option('smartcard'),
1173 version: '>=2.5.1', method: 'pkg-config',
1174 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001175endif
César Belley0a40bcb2020-08-26 13:42:04 +02001176u2f = not_found
1177if have_system
1178 u2f = dependency('u2f-emu', required: get_option('u2f'),
1179 method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001180 kwargs: static_kwargs)
César Belley0a40bcb2020-08-26 13:42:04 +02001181endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001182usbredir = not_found
Paolo Bonzini18f31e62021-06-03 11:15:26 +02001183if not get_option('usb_redir').auto() or have_system
1184 usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
1185 version: '>=0.6', method: 'pkg-config',
1186 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001187endif
1188libusb = not_found
Paolo Bonzini90540f32021-06-03 11:15:26 +02001189if not get_option('libusb').auto() or have_system
1190 libusb = dependency('libusb-1.0', required: get_option('libusb'),
1191 version: '>=1.0.13', method: 'pkg-config',
1192 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001193endif
Paolo Bonzini90540f32021-06-03 11:15:26 +02001194
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001195libpmem = not_found
Paolo Bonzinie36e8c72021-06-03 11:31:35 +02001196if not get_option('libpmem').auto() or have_system
1197 libpmem = dependency('libpmem', required: get_option('libpmem'),
1198 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001199endif
Bruce Rogersc7c91a72020-08-24 09:52:12 -06001200libdaxctl = not_found
Paolo Bonzini83ef1682021-06-03 11:31:35 +02001201if not get_option('libdaxctl').auto() or have_system
1202 libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'),
1203 version: '>=57', method: 'pkg-config',
1204 kwargs: static_kwargs)
Bruce Rogersc7c91a72020-08-24 09:52:12 -06001205endif
Marc-André Lureau8ce0a452020-08-28 15:07:20 +04001206tasn1 = not_found
Paolo Bonziniba7ed402021-06-03 11:15:26 +02001207if gnutls.found()
1208 tasn1 = dependency('libtasn1',
1209 method: 'pkg-config',
1210 kwargs: static_kwargs)
Marc-André Lureau8ce0a452020-08-28 15:07:20 +04001211endif
Marc-André Lureauaf04e892020-08-28 15:07:25 +04001212keyutils = dependency('libkeyutils', required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001213 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001214
Marc-André Lureau3909def2020-08-28 15:07:33 +04001215has_gettid = cc.has_function('gettid')
1216
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06001217# libselinux
1218selinux = dependency('libselinux',
1219 required: get_option('selinux'),
1220 method: 'pkg-config', kwargs: static_kwargs)
1221
Paolo Bonziniaa087962020-09-01 11:15:30 -04001222# Malloc tests
1223
1224malloc = []
1225if get_option('malloc') == 'system'
1226 has_malloc_trim = \
1227 not get_option('malloc_trim').disabled() and \
1228 cc.links('''#include <malloc.h>
1229 int main(void) { malloc_trim(0); return 0; }''')
1230else
1231 has_malloc_trim = false
1232 malloc = cc.find_library(get_option('malloc'), required: true)
1233endif
1234if not has_malloc_trim and get_option('malloc_trim').enabled()
1235 if get_option('malloc') == 'system'
1236 error('malloc_trim not available on this platform.')
1237 else
1238 error('malloc_trim not available with non-libc memory allocator')
1239 endif
1240endif
1241
Max Reitz84e319a2020-11-02 17:18:55 +01001242# Check whether the glibc provides statx()
1243
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001244gnu_source_prefix = '''
Max Reitz84e319a2020-11-02 17:18:55 +01001245 #ifndef _GNU_SOURCE
1246 #define _GNU_SOURCE
1247 #endif
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001248'''
1249statx_test = gnu_source_prefix + '''
Max Reitz84e319a2020-11-02 17:18:55 +01001250 #include <sys/stat.h>
1251 int main(void) {
1252 struct statx statxbuf;
1253 statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
1254 return 0;
1255 }'''
1256
1257has_statx = cc.links(statx_test)
1258
Stefan Hajnoczieb6a3882020-11-10 17:11:20 +00001259have_vhost_user_blk_server = (targetos == 'linux' and
1260 'CONFIG_VHOST_USER' in config_host)
Stefan Hajnoczie5e856c2020-11-10 17:11:19 +00001261
1262if get_option('vhost_user_blk_server').enabled()
1263 if targetos != 'linux'
1264 error('vhost_user_blk_server requires linux')
Stefan Hajnoczieb6a3882020-11-10 17:11:20 +00001265 elif 'CONFIG_VHOST_USER' not in config_host
1266 error('vhost_user_blk_server requires vhost-user support')
Stefan Hajnoczie5e856c2020-11-10 17:11:19 +00001267 endif
1268elif get_option('vhost_user_blk_server').disabled() or not have_system
1269 have_vhost_user_blk_server = false
1270endif
1271
Daniele Buono9e62ba42020-12-04 18:06:14 -05001272
Max Reitzdf4ea702020-10-27 20:05:46 +01001273if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
1274 error('Cannot enable fuse-lseek while fuse is disabled')
1275endif
1276
Max Reitza484a712020-10-27 20:05:41 +01001277fuse = dependency('fuse3', required: get_option('fuse'),
1278 version: '>=3.1', method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001279 kwargs: static_kwargs)
Max Reitza484a712020-10-27 20:05:41 +01001280
Max Reitzdf4ea702020-10-27 20:05:46 +01001281fuse_lseek = not_found
1282if not get_option('fuse_lseek').disabled()
1283 if fuse.version().version_compare('>=3.8')
1284 # Dummy dependency
1285 fuse_lseek = declare_dependency()
1286 elif get_option('fuse_lseek').enabled()
1287 if fuse.found()
1288 error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
1289 else
1290 error('fuse-lseek requires libfuse, which was not found')
1291 endif
1292 endif
1293endif
1294
Andrew Melnychenko46627f42021-05-14 14:48:32 +03001295# libbpf
1296libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config')
1297if libbpf.found() and not cc.links('''
1298 #include <bpf/libbpf.h>
1299 int main(void)
1300 {
1301 bpf_object__destroy_skeleton(NULL);
1302 return 0;
1303 }''', dependencies: libbpf)
1304 libbpf = not_found
1305 if get_option('bpf').enabled()
1306 error('libbpf skeleton test failed')
1307 else
1308 warning('libbpf skeleton test failed, disabling')
1309 endif
1310endif
1311
Paolo Bonzini87430d52021-10-07 15:06:09 +02001312#################
1313# config-host.h #
1314#################
1315
1316audio_drivers_selected = []
1317if have_system
1318 audio_drivers_available = {
1319 'alsa': alsa.found(),
1320 'coreaudio': coreaudio.found(),
1321 'dsound': dsound.found(),
1322 'jack': jack.found(),
1323 'oss': oss.found(),
1324 'pa': pulse.found(),
1325 'sdl': sdl.found(),
1326 }
Paolo Bonzinie5424a22021-10-07 15:06:10 +02001327 foreach k, v: audio_drivers_available
1328 config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
1329 endforeach
Paolo Bonzini87430d52021-10-07 15:06:09 +02001330
1331 # Default to native drivers first, OSS second, SDL third
1332 audio_drivers_priority = \
1333 [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \
1334 (targetos == 'linux' ? [] : [ 'sdl' ])
1335 audio_drivers_default = []
1336 foreach k: audio_drivers_priority
1337 if audio_drivers_available[k]
1338 audio_drivers_default += k
1339 endif
1340 endforeach
1341
1342 foreach k: get_option('audio_drv_list')
1343 if k == 'default'
1344 audio_drivers_selected += audio_drivers_default
1345 elif not audio_drivers_available[k]
1346 error('Audio driver "@0@" not available.'.format(k))
1347 else
1348 audio_drivers_selected += k
1349 endif
1350 endforeach
1351endif
Paolo Bonzini87430d52021-10-07 15:06:09 +02001352config_host_data.set('CONFIG_AUDIO_DRIVERS',
1353 '"' + '", "'.join(audio_drivers_selected) + '", ')
1354
Daniele Buono9e62ba42020-12-04 18:06:14 -05001355if get_option('cfi')
1356 cfi_flags=[]
1357 # Check for dependency on LTO
1358 if not get_option('b_lto')
1359 error('Selected Control-Flow Integrity but LTO is disabled')
1360 endif
1361 if config_host.has_key('CONFIG_MODULES')
1362 error('Selected Control-Flow Integrity is not compatible with modules')
1363 endif
1364 # Check for cfi flags. CFI requires LTO so we can't use
1365 # get_supported_arguments, but need a more complex "compiles" which allows
1366 # custom arguments
1367 if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
1368 args: ['-flto', '-fsanitize=cfi-icall'] )
1369 cfi_flags += '-fsanitize=cfi-icall'
1370 else
1371 error('-fsanitize=cfi-icall is not supported by the compiler')
1372 endif
1373 if cc.compiles('int main () { return 0; }',
1374 name: '-fsanitize-cfi-icall-generalize-pointers',
1375 args: ['-flto', '-fsanitize=cfi-icall',
1376 '-fsanitize-cfi-icall-generalize-pointers'] )
1377 cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
1378 else
1379 error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
1380 endif
1381 if get_option('cfi_debug')
1382 if cc.compiles('int main () { return 0; }',
1383 name: '-fno-sanitize-trap=cfi-icall',
1384 args: ['-flto', '-fsanitize=cfi-icall',
1385 '-fno-sanitize-trap=cfi-icall'] )
1386 cfi_flags += '-fno-sanitize-trap=cfi-icall'
1387 else
1388 error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
1389 endif
1390 endif
Marc-André Lureau5fc06172021-01-14 16:56:02 +04001391 add_global_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
1392 add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
Daniele Buono9e62ba42020-12-04 18:06:14 -05001393endif
1394
Joelle van Dyne14176c82021-03-15 11:03:38 -07001395have_host_block_device = (targetos != 'darwin' or
1396 cc.has_header('IOKit/storage/IOMedia.h'))
1397
Paolo Bonzini69202b42020-11-17 14:46:21 +01001398have_virtfs = (targetos == 'linux' and
1399 have_system and
1400 libattr.found() and
1401 libcap_ng.found())
1402
Philippe Mathieu-Daudé3a489d32021-01-20 16:15:39 +01001403have_virtfs_proxy_helper = have_virtfs and have_tools
1404
Paolo Bonzini69202b42020-11-17 14:46:21 +01001405if get_option('virtfs').enabled()
1406 if not have_virtfs
1407 if targetos != 'linux'
1408 error('virtio-9p (virtfs) requires Linux')
1409 elif not libcap_ng.found() or not libattr.found()
1410 error('virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel')
1411 elif not have_system
1412 error('virtio-9p (virtfs) needs system emulation support')
1413 endif
1414 endif
1415elif get_option('virtfs').disabled()
1416 have_virtfs = false
1417endif
1418
Paolo Bonzini9c29b742021-10-07 15:08:14 +02001419foreach k : get_option('trace_backends')
1420 config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
1421endforeach
1422config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'))
1423
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04001424config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
1425config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
1426config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
1427config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
1428config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
1429config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
1430config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
1431config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
1432config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
1433config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
1434config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
1435config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
1436
Paolo Bonzini823eb012021-11-08 14:18:17 +01001437config_host_data.set('HOST_' + host_arch.to_upper(), 1)
1438
Paolo Bonzinif7f2d652020-11-17 14:45:24 +01001439config_host_data.set('CONFIG_ATTR', libattr.found())
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +01001440config_host_data.set('CONFIG_BRLAPI', brlapi.found())
Paolo Bonzinib4e312e2020-09-01 11:28:59 -04001441config_host_data.set('CONFIG_COCOA', cocoa.found())
Paolo Bonzini537b7242021-10-07 15:08:12 +02001442config_host_data.set('CONFIG_FUZZ', get_option('fuzzing'))
Paolo Bonziniaf2bb992021-10-07 15:08:17 +02001443config_host_data.set('CONFIG_GCOV', get_option('b_coverage'))
Paolo Bonzinif01496a2020-09-16 17:54:14 +02001444config_host_data.set('CONFIG_LIBUDEV', libudev.found())
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001445config_host_data.set('CONFIG_LZO', lzo.found())
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02001446config_host_data.set('CONFIG_MPATH', mpathpersist.found())
1447config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
Paolo Bonzinif9cd86f2020-11-17 12:43:15 +01001448config_host_data.set('CONFIG_CURL', curl.found())
Yonggang Luo5285e592020-10-13 07:43:48 +08001449config_host_data.set('CONFIG_CURSES', curses.found())
Thomas Huth8bc51842021-07-13 13:09:02 +02001450config_host_data.set('CONFIG_GBM', gbm.found())
Paolo Bonzini08821ca2020-11-17 13:01:26 +01001451config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
1452if glusterfs.found()
1453 config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
1454 config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5'))
1455 config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6'))
1456 config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
1457 config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
1458 config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
1459endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001460config_host_data.set('CONFIG_GTK', gtk.found())
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001461config_host_data.set('CONFIG_VTE', vte.found())
Paolo Bonzinif7f2d652020-11-17 14:45:24 +01001462config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
Paolo Bonzini727c8bb2020-11-17 14:46:58 +01001463config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
Andrew Melnychenko46627f42021-05-14 14:48:32 +03001464config_host_data.set('CONFIG_EBPF', libbpf.found())
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001465config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
Paolo Bonzini9db405a2020-11-17 13:11:25 +01001466config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
Paolo Bonzini30045c02020-11-17 13:11:25 +01001467config_host_data.set('CONFIG_LIBNFS', libnfs.found())
Thomas Huthe6a52b32021-12-09 15:48:01 +01001468config_host_data.set('CONFIG_LIBSSH', libssh.found())
Paolo Bonziniff66f3e2021-10-07 15:08:20 +02001469config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001470config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
1471config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
Paolo Bonzinifabd1e92020-11-17 13:11:25 +01001472config_host_data.set('CONFIG_RBD', rbd.found())
Paolo Bonzini35be72b2020-02-06 14:17:15 +01001473config_host_data.set('CONFIG_SDL', sdl.found())
1474config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
Paolo Bonzini90835c22020-11-17 14:22:24 +01001475config_host_data.set('CONFIG_SECCOMP', seccomp.found())
Paolo Bonzini241611e2020-11-17 13:32:34 +01001476config_host_data.set('CONFIG_SNAPPY', snappy.found())
Paolo Bonzini90540f32021-06-03 11:15:26 +02001477config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
Paolo Bonzinie1723992021-10-07 15:08:21 +02001478config_host_data.set('CONFIG_VDE', vde.found())
Stefan Hajnoczie5e856c2020-11-10 17:11:19 +00001479config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001480config_host_data.set('CONFIG_VNC', vnc.found())
1481config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
1482config_host_data.set('CONFIG_VNC_PNG', png.found())
1483config_host_data.set('CONFIG_VNC_SASL', sasl.found())
Paolo Bonzini69202b42020-11-17 14:46:21 +01001484config_host_data.set('CONFIG_VIRTFS', have_virtfs)
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001485config_host_data.set('CONFIG_VTE', vte.found())
Laurent Vivier4113f4c2020-08-24 17:24:29 +02001486config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
Marc-André Lureauaf04e892020-08-28 15:07:25 +04001487config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
Marc-André Lureau3909def2020-08-28 15:07:33 +04001488config_host_data.set('CONFIG_GETTID', has_gettid)
Paolo Bonzini57612512021-06-03 11:15:26 +02001489config_host_data.set('CONFIG_GNUTLS', gnutls.found())
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +01001490config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found())
Paolo Bonzini57612512021-06-03 11:15:26 +02001491config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
1492config_host_data.set('CONFIG_NETTLE', nettle.found())
1493config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private')
Paolo Bonziniaa087962020-09-01 11:15:30 -04001494config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
Max Reitz84e319a2020-11-02 17:18:55 +01001495config_host_data.set('CONFIG_STATX', has_statx)
Paolo Bonzinib1def332020-11-17 13:37:39 +01001496config_host_data.set('CONFIG_ZSTD', zstd.found())
Max Reitza484a712020-10-27 20:05:41 +01001497config_host_data.set('CONFIG_FUSE', fuse.found())
Max Reitzdf4ea702020-10-27 20:05:46 +01001498config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001499config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found())
Marc-André Lureauddece462021-10-06 14:18:09 +04001500if spice_protocol.found()
1501config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version().split('.')[0])
1502config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version().split('.')[1])
1503config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version().split('.')[2])
1504endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001505config_host_data.set('CONFIG_SPICE', spice.found())
Paolo Bonzini9d710372021-01-07 13:54:22 +01001506config_host_data.set('CONFIG_X11', x11.found())
Daniele Buono9e62ba42020-12-04 18:06:14 -05001507config_host_data.set('CONFIG_CFI', get_option('cfi'))
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06001508config_host_data.set('CONFIG_SELINUX', selinux.found())
Paolo Bonzini859aef02020-08-04 18:14:26 +02001509config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
1510config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
1511config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
1512config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
1513
Paolo Bonzinia6305082021-10-07 15:08:15 +02001514config_host_data.set_quoted('CONFIG_HOST_DSOSUF', host_dsosuf)
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001515config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
Paolo Bonzini269506d2021-10-07 15:08:16 +02001516config_host_data.set('HOST_WORDS_BIGENDIAN', host_machine.endian() == 'big')
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001517
1518# has_header
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001519config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h'))
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001520config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h'))
1521config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h'))
Thomas Huth48f670e2020-11-18 18:10:52 +01001522config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
Thomas Huth2964be52020-11-18 18:10:49 +01001523config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
Thomas Huth2802d912020-11-18 18:10:48 +01001524config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001525config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
Thomas Huthded5d782020-11-14 11:10:11 +01001526config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
Thomas Huth4a9d5f82020-11-18 18:10:51 +01001527config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
Thomas Huthded5d782020-11-14 11:10:11 +01001528
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001529# has_function
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001530config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001531config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
1532config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
1533config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate'))
1534config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001535config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001536config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
Peter Maydell2b9f74e2021-01-26 15:58:46 +00001537config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001538config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001539config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile'))
1540config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare'))
1541config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
1542config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
1543config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001544config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001545config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001546config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001547config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
Li Zhijian911965a2021-09-10 15:02:55 +08001548if rdma.found()
1549 config_host_data.set('HAVE_IBV_ADVISE_MR',
1550 cc.has_function('ibv_advise_mr',
1551 args: config_host['RDMA_LIBS'].split(),
1552 prefix: '#include <infiniband/verbs.h>'))
1553endif
Peter Maydell2b9f74e2021-01-26 15:58:46 +00001554
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001555# has_header_symbol
1556config_host_data.set('CONFIG_BYTESWAP_H',
1557 cc.has_header_symbol('byteswap.h', 'bswap_32'))
1558config_host_data.set('CONFIG_EPOLL_CREATE1',
1559 cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001560config_host_data.set('CONFIG_HAS_ENVIRON',
1561 cc.has_header_symbol('unistd.h', 'environ', prefix: gnu_source_prefix))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001562config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
1563 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and
1564 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE'))
1565config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE',
1566 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE'))
1567config_host_data.set('CONFIG_FIEMAP',
1568 cc.has_header('linux/fiemap.h') and
1569 cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001570config_host_data.set('CONFIG_GETRANDOM',
1571 cc.has_function('getrandom') and
1572 cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK'))
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001573config_host_data.set('CONFIG_INOTIFY',
1574 cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
1575config_host_data.set('CONFIG_INOTIFY1',
1576 cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001577config_host_data.set('CONFIG_MACHINE_BSWAP_H',
1578 cc.has_header_symbol('machine/bswap.h', 'bswap32',
1579 prefix: '''#include <sys/endian.h>
1580 #include <sys/types.h>'''))
1581config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
1582 cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001583config_host_data.set('CONFIG_RTNETLINK',
1584 cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN'))
1585config_host_data.set('CONFIG_SYSMACROS',
1586 cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001587config_host_data.set('HAVE_OPTRESET',
1588 cc.has_header_symbol('getopt.h', 'optreset'))
Marc-André Lureau653163f2021-09-07 16:19:13 +04001589config_host_data.set('HAVE_IPPROTO_MPTCP',
1590 cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001591
1592# has_member
1593config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
1594 cc.has_member('struct sigevent', 'sigev_notify_thread_id',
1595 prefix: '#include <signal.h>'))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001596config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM',
1597 cc.has_member('struct stat', 'st_atim',
1598 prefix: '#include <sys/stat.h>'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001599
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001600# has_type
1601config_host_data.set('CONFIG_IOVEC',
1602 cc.has_type('struct iovec',
1603 prefix: '#include <sys/uio.h>'))
1604config_host_data.set('HAVE_UTMPX',
1605 cc.has_type('struct utmpx',
1606 prefix: '#include <utmpx.h>'))
1607
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001608config_host_data.set('CONFIG_EVENTFD', cc.links('''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001609 #include <sys/eventfd.h>
1610 int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001611config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001612 #include <unistd.h>
1613 int main(void) {
1614 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
1615 return fdatasync(0);
1616 #else
1617 #error Not supported
1618 #endif
1619 }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001620config_host_data.set('CONFIG_MADVISE', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001621 #include <sys/types.h>
1622 #include <sys/mman.h>
1623 #include <stddef.h>
1624 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001625config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001626 #include <sys/mman.h>
1627 int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001628config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001629 #include <fcntl.h>
1630 #if !defined(AT_EMPTY_PATH)
1631 # error missing definition
1632 #else
1633 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
1634 #endif'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001635config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + '''
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001636 #include <unistd.h>
1637 #include <fcntl.h>
1638
1639 int main(void)
1640 {
1641 int pipefd[2];
1642 return pipe2(pipefd, O_CLOEXEC);
1643 }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001644config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001645 #include <sys/mman.h>
1646 #include <stddef.h>
1647 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }'''))
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001648
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001649config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + '''
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001650 #include <pthread.h>
1651
1652 static void *f(void *p) { return NULL; }
1653 int main(void)
1654 {
1655 pthread_t thread;
1656 pthread_create(&thread, 0, f, 0);
1657 pthread_setname_np(thread, "QEMU");
1658 return 0;
1659 }''', dependencies: threads))
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001660config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + '''
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001661 #include <pthread.h>
1662
1663 static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
1664 int main(void)
1665 {
1666 pthread_t thread;
1667 pthread_create(&thread, 0, f, 0);
1668 return 0;
1669 }''', dependencies: threads))
1670
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001671config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
Kacper Słomiński6bd17dc2021-09-05 03:16:22 +02001672 #include <sys/signalfd.h>
1673 #include <stddef.h>
1674 int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001675config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + '''
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001676 #include <unistd.h>
1677 #include <fcntl.h>
1678 #include <limits.h>
1679
1680 int main(void)
1681 {
1682 int len, fd = 0;
1683 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1684 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1685 return 0;
1686 }'''))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001687
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001688config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + '''
1689 #include <sys/mman.h>
1690 int main(int argc, char *argv[]) {
1691 return mlockall(MCL_FUTURE);
1692 }'''))
1693
Thomas Hutheea94532021-10-28 20:59:08 +02001694have_l2tpv3 = false
1695if not get_option('l2tpv3').disabled() and have_system
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001696 have_l2tpv3 = cc.has_type('struct mmsghdr',
1697 prefix: gnu_source_prefix + '''
1698 #include <sys/socket.h>
1699 #include <linux/ip.h>''')
Thomas Hutheea94532021-10-28 20:59:08 +02001700endif
1701config_host_data.set('CONFIG_L2TPV3', have_l2tpv3)
1702
Paolo Bonzini837b84b2021-10-07 15:08:22 +02001703have_netmap = false
1704if not get_option('netmap').disabled() and have_system
1705 have_netmap = cc.compiles('''
1706 #include <inttypes.h>
1707 #include <net/if.h>
1708 #include <net/netmap.h>
1709 #include <net/netmap_user.h>
1710 #if (NETMAP_API < 11) || (NETMAP_API > 15)
1711 #error
1712 #endif
1713 int main(void) { return 0; }''')
1714 if not have_netmap and get_option('netmap').enabled()
1715 error('Netmap headers not available')
1716 endif
1717endif
1718config_host_data.set('CONFIG_NETMAP', have_netmap)
1719
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001720# Work around a system header bug with some kernel/XFS header
1721# versions where they both try to define 'struct fsxattr':
1722# xfs headers will not try to redefine structs from linux headers
1723# if this macro is set.
1724config_host_data.set('HAVE_FSXATTR', cc.links('''
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001725 #include <linux/fs.h>
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001726 struct fsxattr foo;
1727 int main(void) {
1728 return 0;
1729 }'''))
1730
Paolo Bonzinie46bd552021-06-03 11:57:04 +02001731# Some versions of Mac OS X incorrectly define SIZE_MAX
1732config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
1733 #include <stdint.h>
1734 #include <stdio.h>
1735 int main(int argc, char *argv[]) {
1736 return printf("%zu", SIZE_MAX);
1737 }''', args: ['-Werror']))
1738
Paolo Bonzinibd87a362021-10-07 15:08:25 +02001739# See if 64-bit atomic operations are supported.
1740# Note that without __atomic builtins, we can only
1741# assume atomic loads/stores max at pointer size.
1742config_host_data.set('CONFIG_ATOMIC64', cc.links('''
1743 #include <stdint.h>
1744 int main(void)
1745 {
1746 uint64_t x = 0, y = 0;
1747 y = __atomic_load_n(&x, __ATOMIC_RELAXED);
1748 __atomic_store_n(&x, y, __ATOMIC_RELAXED);
1749 __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
1750 __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
1751 __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
1752 return 0;
1753 }'''))
1754
1755config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
1756 #include <sys/auxv.h>
1757 int main(void) {
1758 return getauxval(AT_HWCAP) == 0;
1759 }'''))
1760
1761config_host_data.set('CONFIG_AF_VSOCK', cc.compiles(gnu_source_prefix + '''
1762 #include <errno.h>
1763 #include <sys/types.h>
1764 #include <sys/socket.h>
1765 #if !defined(AF_VSOCK)
1766 # error missing AF_VSOCK flag
1767 #endif
1768 #include <linux/vm_sockets.h>
1769 int main(void) {
1770 int sock, ret;
1771 struct sockaddr_vm svm;
1772 socklen_t len = sizeof(svm);
1773 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
1774 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
1775 if ((ret == -1) && (errno == ENOTCONN)) {
1776 return 0;
1777 }
1778 return -1;
1779 }'''))
1780
Paolo Bonzinia76a1f62021-10-13 10:04:24 +02001781ignored = ['CONFIG_QEMU_INTERP_PREFIX', # actually per-target
1782 'HAVE_GDB_BIN']
Paolo Bonzini87430d52021-10-07 15:06:09 +02001783arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
Paolo Bonzinia6305082021-10-07 15:08:15 +02001784strings = ['CONFIG_IASL']
Paolo Bonzini859aef02020-08-04 18:14:26 +02001785foreach k, v: config_host
Paolo Bonzini765686d2020-09-18 06:37:21 -04001786 if ignored.contains(k)
1787 # do nothing
1788 elif arrays.contains(k)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001789 if v != ''
1790 v = '"' + '", "'.join(v.split()) + '", '
1791 endif
1792 config_host_data.set(k, v)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001793 elif strings.contains(k)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001794 config_host_data.set_quoted(k, v)
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001795 elif k.startswith('CONFIG_')
Paolo Bonzini859aef02020-08-04 18:14:26 +02001796 config_host_data.set(k, v == 'y' ? 1 : v)
1797 endif
1798endforeach
Paolo Bonzini859aef02020-08-04 18:14:26 +02001799
Paolo Bonzinia0c91622020-10-07 11:01:51 -04001800########################
1801# Target configuration #
1802########################
1803
Paolo Bonzini2becc362020-02-03 11:42:03 +01001804minikconf = find_program('scripts/minikconf.py')
Paolo Bonzini05512f52020-09-16 15:31:11 -04001805config_all = {}
Paolo Bonzinia98006b2020-09-01 05:32:23 -04001806config_all_devices = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001807config_all_disas = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001808config_devices_mak_list = []
1809config_devices_h = {}
Paolo Bonzini859aef02020-08-04 18:14:26 +02001810config_target_h = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001811config_target_mak = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001812
1813disassemblers = {
1814 'alpha' : ['CONFIG_ALPHA_DIS'],
1815 'arm' : ['CONFIG_ARM_DIS'],
1816 'avr' : ['CONFIG_AVR_DIS'],
1817 'cris' : ['CONFIG_CRIS_DIS'],
Taylor Simpson3e7a84e2021-02-07 23:46:24 -06001818 'hexagon' : ['CONFIG_HEXAGON_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001819 'hppa' : ['CONFIG_HPPA_DIS'],
1820 'i386' : ['CONFIG_I386_DIS'],
1821 'x86_64' : ['CONFIG_I386_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001822 'm68k' : ['CONFIG_M68K_DIS'],
1823 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
1824 'mips' : ['CONFIG_MIPS_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001825 'nios2' : ['CONFIG_NIOS2_DIS'],
1826 'or1k' : ['CONFIG_OPENRISC_DIS'],
1827 'ppc' : ['CONFIG_PPC_DIS'],
1828 'riscv' : ['CONFIG_RISCV_DIS'],
1829 'rx' : ['CONFIG_RX_DIS'],
1830 's390' : ['CONFIG_S390_DIS'],
1831 'sh4' : ['CONFIG_SH4_DIS'],
1832 'sparc' : ['CONFIG_SPARC_DIS'],
1833 'xtensa' : ['CONFIG_XTENSA_DIS'],
1834}
1835if link_language == 'cpp'
1836 disassemblers += {
1837 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
1838 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
1839 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
1840 }
1841endif
1842
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001843have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
Paolo Bonzini0a189112020-11-17 14:58:32 +01001844host_kconfig = \
Paolo Bonzini537b7242021-10-07 15:08:12 +02001845 (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001846 ('CONFIG_TPM' in config_host ? ['CONFIG_TPM=y'] : []) + \
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001847 (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
Paolo Bonziniccd250a2021-06-03 12:50:17 +02001848 (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001849 ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
Paolo Bonzini9d710372021-01-07 13:54:22 +01001850 (x11.found() ? ['CONFIG_X11=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001851 ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
1852 ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
1853 ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
Paolo Bonzini69202b42020-11-17 14:46:21 +01001854 (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001855 ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
Jagannathan Raman3090de62021-01-29 11:46:05 -05001856 ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
Paolo Bonzini106ad1f2021-02-17 16:24:25 +01001857 (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : [])
Paolo Bonzini0a189112020-11-17 14:58:32 +01001858
Paolo Bonzinia9a74902020-09-21 05:11:01 -04001859ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001860
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001861default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
1862actual_target_dirs = []
Paolo Bonzinifbb41212020-10-05 11:31:15 +02001863fdt_required = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001864foreach target : target_dirs
Paolo Bonzini765686d2020-09-18 06:37:21 -04001865 config_target = { 'TARGET_NAME': target.split('-')[0] }
1866 if target.endswith('linux-user')
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001867 if targetos != 'linux'
1868 if default_targets
1869 continue
1870 endif
1871 error('Target @0@ is only available on a Linux host'.format(target))
1872 endif
Paolo Bonzini765686d2020-09-18 06:37:21 -04001873 config_target += { 'CONFIG_LINUX_USER': 'y' }
1874 elif target.endswith('bsd-user')
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001875 if 'CONFIG_BSD' not in config_host
1876 if default_targets
1877 continue
1878 endif
1879 error('Target @0@ is only available on a BSD host'.format(target))
1880 endif
Paolo Bonzini765686d2020-09-18 06:37:21 -04001881 config_target += { 'CONFIG_BSD_USER': 'y' }
1882 elif target.endswith('softmmu')
1883 config_target += { 'CONFIG_SOFTMMU': 'y' }
1884 endif
1885 if target.endswith('-user')
1886 config_target += {
1887 'CONFIG_USER_ONLY': 'y',
1888 'CONFIG_QEMU_INTERP_PREFIX':
1889 config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
1890 }
1891 endif
Paolo Bonzini859aef02020-08-04 18:14:26 +02001892
Paolo Bonzini0a189112020-11-17 14:58:32 +01001893 accel_kconfig = []
Paolo Bonzini8a199802020-09-18 05:37:01 -04001894 foreach sym: accelerators
1895 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
1896 config_target += { sym: 'y' }
1897 config_all += { sym: 'y' }
Paolo Bonzini23a77b22020-12-14 12:01:45 +01001898 if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
1899 config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
1900 elif sym == 'CONFIG_XEN' and have_xen_pci_passthrough
Paolo Bonzini8a199802020-09-18 05:37:01 -04001901 config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
1902 endif
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02001903 if target in modular_tcg
1904 config_target += { 'CONFIG_TCG_MODULAR': 'y' }
1905 else
1906 config_target += { 'CONFIG_TCG_BUILTIN': 'y' }
1907 endif
Paolo Bonzini0a189112020-11-17 14:58:32 +01001908 accel_kconfig += [ sym + '=y' ]
Paolo Bonzini8a199802020-09-18 05:37:01 -04001909 endif
1910 endforeach
Paolo Bonzini0a189112020-11-17 14:58:32 +01001911 if accel_kconfig.length() == 0
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001912 if default_targets
1913 continue
1914 endif
1915 error('No accelerator available for target @0@'.format(target))
1916 endif
Paolo Bonzini8a199802020-09-18 05:37:01 -04001917
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001918 actual_target_dirs += target
Alex Bennée812b31d2021-07-07 14:17:43 +01001919 config_target += keyval.load('configs/targets' / target + '.mak')
Paolo Bonzinia9a74902020-09-21 05:11:01 -04001920 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
Paolo Bonzini765686d2020-09-18 06:37:21 -04001921
Paolo Bonzinifbb41212020-10-05 11:31:15 +02001922 if 'TARGET_NEED_FDT' in config_target
1923 fdt_required += target
1924 endif
1925
Paolo Bonzinifa731682020-09-21 05:19:07 -04001926 # Add default keys
1927 if 'TARGET_BASE_ARCH' not in config_target
1928 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
1929 endif
1930 if 'TARGET_ABI_DIR' not in config_target
1931 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
1932 endif
Paolo Bonzini859aef02020-08-04 18:14:26 +02001933
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001934 foreach k, v: disassemblers
Paolo Bonzini823eb012021-11-08 14:18:17 +01001935 if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001936 foreach sym: v
1937 config_target += { sym: 'y' }
1938 config_all_disas += { sym: 'y' }
1939 endforeach
1940 endif
1941 endforeach
1942
Paolo Bonzini859aef02020-08-04 18:14:26 +02001943 config_target_data = configuration_data()
1944 foreach k, v: config_target
1945 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
1946 # do nothing
1947 elif ignored.contains(k)
1948 # do nothing
1949 elif k == 'TARGET_BASE_ARCH'
Paolo Bonzinia9a74902020-09-21 05:11:01 -04001950 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
1951 # not used to select files from sourcesets.
Paolo Bonzini859aef02020-08-04 18:14:26 +02001952 config_target_data.set('TARGET_' + v.to_upper(), 1)
Paolo Bonzini765686d2020-09-18 06:37:21 -04001953 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
Paolo Bonzini859aef02020-08-04 18:14:26 +02001954 config_target_data.set_quoted(k, v)
1955 elif v == 'y'
1956 config_target_data.set(k, 1)
1957 else
1958 config_target_data.set(k, v)
1959 endif
1960 endforeach
Peter Maydellcb2c5532021-07-30 11:59:43 +01001961 config_target_data.set('QEMU_ARCH',
1962 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
Paolo Bonzini859aef02020-08-04 18:14:26 +02001963 config_target_h += {target: configure_file(output: target + '-config-target.h',
1964 configuration: config_target_data)}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001965
1966 if target.endswith('-softmmu')
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01001967 config_input = meson.get_external_property(target, 'default')
Paolo Bonzini2becc362020-02-03 11:42:03 +01001968 config_devices_mak = target + '-config-devices.mak'
1969 config_devices_mak = configure_file(
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01001970 input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'],
Paolo Bonzini2becc362020-02-03 11:42:03 +01001971 output: config_devices_mak,
1972 depfile: config_devices_mak + '.d',
1973 capture: true,
Paolo Bonzini7bc3ca72020-11-20 08:38:22 +01001974 command: [minikconf,
1975 get_option('default_devices') ? '--defconfig' : '--allnoconfig',
Paolo Bonzini2becc362020-02-03 11:42:03 +01001976 config_devices_mak, '@DEPFILE@', '@INPUT@',
Philippe Mathieu-Daudéf4063f92021-07-07 14:17:40 +01001977 host_kconfig, accel_kconfig,
1978 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
Paolo Bonzini859aef02020-08-04 18:14:26 +02001979
1980 config_devices_data = configuration_data()
1981 config_devices = keyval.load(config_devices_mak)
1982 foreach k, v: config_devices
1983 config_devices_data.set(k, 1)
1984 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +01001985 config_devices_mak_list += config_devices_mak
Paolo Bonzini859aef02020-08-04 18:14:26 +02001986 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
1987 configuration: config_devices_data)}
1988 config_target += config_devices
Paolo Bonzinia98006b2020-09-01 05:32:23 -04001989 config_all_devices += config_devices
Paolo Bonzini2becc362020-02-03 11:42:03 +01001990 endif
1991 config_target_mak += {target: config_target}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001992endforeach
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001993target_dirs = actual_target_dirs
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001994
Paolo Bonzini2becc362020-02-03 11:42:03 +01001995# This configuration is used to build files that are shared by
1996# multiple binaries, and then extracted out of the "common"
1997# static_library target.
1998#
1999# We do not use all_sources()/all_dependencies(), because it would
2000# build literally all source files, including devices only used by
2001# targets that are not built for this compilation. The CONFIG_ALL
2002# pseudo symbol replaces it.
2003
Paolo Bonzini05512f52020-09-16 15:31:11 -04002004config_all += config_all_devices
Paolo Bonzini2becc362020-02-03 11:42:03 +01002005config_all += config_host
2006config_all += config_all_disas
2007config_all += {
2008 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
2009 'CONFIG_SOFTMMU': have_system,
2010 'CONFIG_USER_ONLY': have_user,
2011 'CONFIG_ALL': true,
2012}
2013
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002014##############
2015# Submodules #
2016##############
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002017
2018capstone = not_found
2019capstone_opt = get_option('capstone')
2020if capstone_opt in ['enabled', 'auto', 'system']
2021 have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
Richard Hendersonbcf36862020-09-21 09:46:16 -07002022 capstone = dependency('capstone', version: '>=4.0',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002023 kwargs: static_kwargs, method: 'pkg-config',
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002024 required: capstone_opt == 'system' or
2025 capstone_opt == 'enabled' and not have_internal)
Daniel P. Berrangé8f4aea72021-07-09 15:29:31 +01002026
2027 # Some versions of capstone have broken pkg-config file
2028 # that reports a wrong -I path, causing the #include to
2029 # fail later. If the system has such a broken version
2030 # do not use it.
2031 if capstone.found() and not cc.compiles('#include <capstone.h>',
2032 dependencies: [capstone])
2033 capstone = not_found
2034 if capstone_opt == 'system'
2035 error('system capstone requested, it does not appear to work')
2036 endif
2037 endif
2038
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002039 if capstone.found()
2040 capstone_opt = 'system'
2041 elif have_internal
2042 capstone_opt = 'internal'
2043 else
2044 capstone_opt = 'disabled'
2045 endif
2046endif
2047if capstone_opt == 'internal'
2048 capstone_data = configuration_data()
2049 capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
2050
2051 capstone_files = files(
2052 'capstone/cs.c',
2053 'capstone/MCInst.c',
2054 'capstone/MCInstrDesc.c',
2055 'capstone/MCRegisterInfo.c',
2056 'capstone/SStream.c',
2057 'capstone/utils.c'
2058 )
2059
2060 if 'CONFIG_ARM_DIS' in config_all_disas
2061 capstone_data.set('CAPSTONE_HAS_ARM', '1')
2062 capstone_files += files(
2063 'capstone/arch/ARM/ARMDisassembler.c',
2064 'capstone/arch/ARM/ARMInstPrinter.c',
2065 'capstone/arch/ARM/ARMMapping.c',
2066 'capstone/arch/ARM/ARMModule.c'
2067 )
2068 endif
2069
2070 # FIXME: This config entry currently depends on a c++ compiler.
2071 # Which is needed for building libvixl, but not for capstone.
2072 if 'CONFIG_ARM_A64_DIS' in config_all_disas
2073 capstone_data.set('CAPSTONE_HAS_ARM64', '1')
2074 capstone_files += files(
2075 'capstone/arch/AArch64/AArch64BaseInfo.c',
2076 'capstone/arch/AArch64/AArch64Disassembler.c',
2077 'capstone/arch/AArch64/AArch64InstPrinter.c',
2078 'capstone/arch/AArch64/AArch64Mapping.c',
2079 'capstone/arch/AArch64/AArch64Module.c'
2080 )
2081 endif
2082
2083 if 'CONFIG_PPC_DIS' in config_all_disas
2084 capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
2085 capstone_files += files(
2086 'capstone/arch/PowerPC/PPCDisassembler.c',
2087 'capstone/arch/PowerPC/PPCInstPrinter.c',
2088 'capstone/arch/PowerPC/PPCMapping.c',
2089 'capstone/arch/PowerPC/PPCModule.c'
2090 )
2091 endif
2092
Richard Henderson3d562842020-01-04 07:24:59 +10002093 if 'CONFIG_S390_DIS' in config_all_disas
2094 capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
2095 capstone_files += files(
2096 'capstone/arch/SystemZ/SystemZDisassembler.c',
2097 'capstone/arch/SystemZ/SystemZInstPrinter.c',
2098 'capstone/arch/SystemZ/SystemZMapping.c',
2099 'capstone/arch/SystemZ/SystemZModule.c',
2100 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
2101 )
2102 endif
2103
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002104 if 'CONFIG_I386_DIS' in config_all_disas
2105 capstone_data.set('CAPSTONE_HAS_X86', 1)
2106 capstone_files += files(
2107 'capstone/arch/X86/X86Disassembler.c',
2108 'capstone/arch/X86/X86DisassemblerDecoder.c',
2109 'capstone/arch/X86/X86ATTInstPrinter.c',
2110 'capstone/arch/X86/X86IntelInstPrinter.c',
Richard Hendersoneef20e42020-09-14 16:02:02 -07002111 'capstone/arch/X86/X86InstPrinterCommon.c',
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002112 'capstone/arch/X86/X86Mapping.c',
2113 'capstone/arch/X86/X86Module.c'
2114 )
2115 endif
2116
2117 configure_file(output: 'capstone-defs.h', configuration: capstone_data)
2118
2119 capstone_cargs = [
2120 # FIXME: There does not seem to be a way to completely replace the c_args
2121 # that come from add_project_arguments() -- we can only add to them.
2122 # So: disable all warnings with a big hammer.
2123 '-Wno-error', '-w',
2124
2125 # Include all configuration defines via a header file, which will wind up
2126 # as a dependency on the object file, and thus changes here will result
2127 # in a rebuild.
2128 '-include', 'capstone-defs.h'
2129 ]
2130
2131 libcapstone = static_library('capstone',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002132 build_by_default: false,
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002133 sources: capstone_files,
2134 c_args: capstone_cargs,
2135 include_directories: 'capstone/include')
2136 capstone = declare_dependency(link_with: libcapstone,
Richard Hendersoneef20e42020-09-14 16:02:02 -07002137 include_directories: 'capstone/include/capstone')
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002138endif
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002139
2140slirp = not_found
2141slirp_opt = 'disabled'
2142if have_system
2143 slirp_opt = get_option('slirp')
2144 if slirp_opt in ['enabled', 'auto', 'system']
2145 have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002146 slirp = dependency('slirp', kwargs: static_kwargs,
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002147 method: 'pkg-config',
2148 required: slirp_opt == 'system' or
2149 slirp_opt == 'enabled' and not have_internal)
2150 if slirp.found()
2151 slirp_opt = 'system'
2152 elif have_internal
2153 slirp_opt = 'internal'
2154 else
2155 slirp_opt = 'disabled'
2156 endif
2157 endif
2158 if slirp_opt == 'internal'
2159 slirp_deps = []
2160 if targetos == 'windows'
2161 slirp_deps = cc.find_library('iphlpapi')
Marc-André Lureau43f547b2021-05-18 19:51:11 +04002162 elif targetos == 'darwin'
2163 slirp_deps = cc.find_library('resolv')
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002164 endif
2165 slirp_conf = configuration_data()
2166 slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
2167 slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
2168 slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
2169 slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
2170 slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
2171 slirp_files = [
2172 'slirp/src/arp_table.c',
2173 'slirp/src/bootp.c',
2174 'slirp/src/cksum.c',
2175 'slirp/src/dhcpv6.c',
2176 'slirp/src/dnssearch.c',
2177 'slirp/src/if.c',
2178 'slirp/src/ip6_icmp.c',
2179 'slirp/src/ip6_input.c',
2180 'slirp/src/ip6_output.c',
2181 'slirp/src/ip_icmp.c',
2182 'slirp/src/ip_input.c',
2183 'slirp/src/ip_output.c',
2184 'slirp/src/mbuf.c',
2185 'slirp/src/misc.c',
2186 'slirp/src/ncsi.c',
2187 'slirp/src/ndp_table.c',
2188 'slirp/src/sbuf.c',
2189 'slirp/src/slirp.c',
2190 'slirp/src/socket.c',
2191 'slirp/src/state.c',
2192 'slirp/src/stream.c',
2193 'slirp/src/tcp_input.c',
2194 'slirp/src/tcp_output.c',
2195 'slirp/src/tcp_subr.c',
2196 'slirp/src/tcp_timer.c',
2197 'slirp/src/tftp.c',
2198 'slirp/src/udp.c',
2199 'slirp/src/udp6.c',
2200 'slirp/src/util.c',
2201 'slirp/src/version.c',
2202 'slirp/src/vmstate.c',
2203 ]
2204
2205 configure_file(
2206 input : 'slirp/src/libslirp-version.h.in',
2207 output : 'libslirp-version.h',
2208 configuration: slirp_conf)
2209
2210 slirp_inc = include_directories('slirp', 'slirp/src')
2211 libslirp = static_library('slirp',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002212 build_by_default: false,
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002213 sources: slirp_files,
2214 c_args: slirp_cargs,
2215 include_directories: slirp_inc)
2216 slirp = declare_dependency(link_with: libslirp,
2217 dependencies: slirp_deps,
2218 include_directories: slirp_inc)
2219 endif
2220endif
2221
Daniele Buonoc7153432021-03-03 21:59:38 -05002222# For CFI, we need to compile slirp as a static library together with qemu.
2223# This is because we register slirp functions as callbacks for QEMU Timers.
2224# When using a system-wide shared libslirp, the type information for the
2225# callback is missing and the timer call produces a false positive with CFI.
2226#
2227# Now that slirp_opt has been defined, check if the selected slirp is compatible
2228# with control-flow integrity.
2229if get_option('cfi') and slirp_opt == 'system'
2230 error('Control-Flow Integrity is not compatible with system-wide slirp.' \
2231 + ' Please configure with --enable-slirp=git')
2232endif
2233
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002234fdt = not_found
2235fdt_opt = get_option('fdt')
2236if have_system
2237 if fdt_opt in ['enabled', 'auto', 'system']
2238 have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002239 fdt = cc.find_library('fdt', kwargs: static_kwargs,
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002240 required: fdt_opt == 'system' or
2241 fdt_opt == 'enabled' and not have_internal)
2242 if fdt.found() and cc.links('''
2243 #include <libfdt.h>
2244 #include <libfdt_env.h>
2245 int main(void) { fdt_check_full(NULL, 0); return 0; }''',
2246 dependencies: fdt)
2247 fdt_opt = 'system'
Thomas Huth6c228532021-08-27 14:09:00 +02002248 elif fdt_opt == 'system'
2249 error('system libfdt requested, but it is too old (1.5.1 or newer required)')
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002250 elif have_internal
2251 fdt_opt = 'internal'
2252 else
2253 fdt_opt = 'disabled'
Thomas Huth87daf892021-08-27 14:08:59 +02002254 fdt = not_found
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002255 endif
2256 endif
2257 if fdt_opt == 'internal'
2258 fdt_files = files(
2259 'dtc/libfdt/fdt.c',
2260 'dtc/libfdt/fdt_ro.c',
2261 'dtc/libfdt/fdt_wip.c',
2262 'dtc/libfdt/fdt_sw.c',
2263 'dtc/libfdt/fdt_rw.c',
2264 'dtc/libfdt/fdt_strerror.c',
2265 'dtc/libfdt/fdt_empty_tree.c',
2266 'dtc/libfdt/fdt_addresses.c',
2267 'dtc/libfdt/fdt_overlay.c',
2268 'dtc/libfdt/fdt_check.c',
2269 )
2270
2271 fdt_inc = include_directories('dtc/libfdt')
2272 libfdt = static_library('fdt',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002273 build_by_default: false,
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002274 sources: fdt_files,
2275 include_directories: fdt_inc)
2276 fdt = declare_dependency(link_with: libfdt,
2277 include_directories: fdt_inc)
2278 endif
2279endif
2280if not fdt.found() and fdt_required.length() > 0
2281 error('fdt not available but required by targets ' + ', '.join(fdt_required))
2282endif
2283
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002284config_host_data.set('CONFIG_CAPSTONE', capstone.found())
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002285config_host_data.set('CONFIG_FDT', fdt.found())
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002286config_host_data.set('CONFIG_SLIRP', slirp.found())
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002287
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002288#####################
2289# Generated sources #
2290#####################
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002291
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002292genh += configure_file(output: 'config-host.h', configuration: config_host_data)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002293
Marc-André Lureau3f885652019-07-15 18:06:04 +04002294hxtool = find_program('scripts/hxtool')
Marc-André Lureau650b5d52019-07-15 17:36:47 +04002295shaderinclude = find_program('scripts/shaderinclude.pl')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002296qapi_gen = find_program('scripts/qapi-gen.py')
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002297qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
2298 meson.current_source_dir() / 'scripts/qapi/commands.py',
2299 meson.current_source_dir() / 'scripts/qapi/common.py',
2300 meson.current_source_dir() / 'scripts/qapi/error.py',
2301 meson.current_source_dir() / 'scripts/qapi/events.py',
2302 meson.current_source_dir() / 'scripts/qapi/expr.py',
2303 meson.current_source_dir() / 'scripts/qapi/gen.py',
2304 meson.current_source_dir() / 'scripts/qapi/introspect.py',
2305 meson.current_source_dir() / 'scripts/qapi/parser.py',
2306 meson.current_source_dir() / 'scripts/qapi/schema.py',
2307 meson.current_source_dir() / 'scripts/qapi/source.py',
2308 meson.current_source_dir() / 'scripts/qapi/types.py',
2309 meson.current_source_dir() / 'scripts/qapi/visit.py',
2310 meson.current_source_dir() / 'scripts/qapi/common.py',
2311 meson.current_source_dir() / 'scripts/qapi-gen.py'
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002312]
2313
2314tracetool = [
2315 python, files('scripts/tracetool.py'),
Paolo Bonzini9c29b742021-10-07 15:08:14 +02002316 '--backend=' + ','.join(get_option('trace_backends'))
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002317]
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00002318tracetool_depends = files(
2319 'scripts/tracetool/backend/log.py',
2320 'scripts/tracetool/backend/__init__.py',
2321 'scripts/tracetool/backend/dtrace.py',
2322 'scripts/tracetool/backend/ftrace.py',
2323 'scripts/tracetool/backend/simple.py',
2324 'scripts/tracetool/backend/syslog.py',
2325 'scripts/tracetool/backend/ust.py',
2326 'scripts/tracetool/format/tcg_h.py',
2327 'scripts/tracetool/format/ust_events_c.py',
2328 'scripts/tracetool/format/ust_events_h.py',
2329 'scripts/tracetool/format/__init__.py',
2330 'scripts/tracetool/format/d.py',
2331 'scripts/tracetool/format/tcg_helper_c.py',
2332 'scripts/tracetool/format/simpletrace_stap.py',
2333 'scripts/tracetool/format/c.py',
2334 'scripts/tracetool/format/h.py',
2335 'scripts/tracetool/format/tcg_helper_h.py',
2336 'scripts/tracetool/format/log_stap.py',
2337 'scripts/tracetool/format/stap.py',
2338 'scripts/tracetool/format/tcg_helper_wrapper_h.py',
2339 'scripts/tracetool/__init__.py',
2340 'scripts/tracetool/transform.py',
2341 'scripts/tracetool/vcpu.py'
2342)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002343
Marc-André Lureau2c273f32019-07-15 17:10:19 +04002344qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
2345 meson.current_source_dir(),
Paolo Bonzini859aef02020-08-04 18:14:26 +02002346 config_host['PKGVERSION'], meson.project_version()]
Marc-André Lureau2c273f32019-07-15 17:10:19 +04002347qemu_version = custom_target('qemu-version.h',
2348 output: 'qemu-version.h',
2349 command: qemu_version_cmd,
2350 capture: true,
2351 build_by_default: true,
2352 build_always_stale: true)
2353genh += qemu_version
2354
Marc-André Lureau3f885652019-07-15 18:06:04 +04002355hxdep = []
2356hx_headers = [
2357 ['qemu-options.hx', 'qemu-options.def'],
2358 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
2359]
2360if have_system
2361 hx_headers += [
2362 ['hmp-commands.hx', 'hmp-commands.h'],
2363 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
2364 ]
2365endif
2366foreach d : hx_headers
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04002367 hxdep += custom_target(d[1],
Marc-André Lureau3f885652019-07-15 18:06:04 +04002368 input: files(d[0]),
2369 output: d[1],
2370 capture: true,
2371 build_by_default: true, # to be removed when added to a target
2372 command: [hxtool, '-h', '@INPUT0@'])
2373endforeach
2374genh += hxdep
2375
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002376###################
2377# Collect sources #
2378###################
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002379
Philippe Mathieu-Daudé55567892020-10-06 14:56:01 +02002380authz_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002381blockdev_ss = ss.source_set()
2382block_ss = ss.source_set()
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002383chardev_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002384common_ss = ss.source_set()
Richard Hendersonbbf15aa2021-11-17 16:14:00 +01002385common_user_ss = ss.source_set()
Philippe Mathieu-Daudé23893042020-10-06 14:56:00 +02002386crypto_ss = ss.source_set()
Philippe Mathieu-Daudéf73fb062021-10-28 16:34:19 +02002387hwcore_ss = ss.source_set()
Philippe Mathieu-Daudéf78536b2020-10-06 14:55:59 +02002388io_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002389qmp_ss = ss.source_set()
Philippe Mathieu-Daudéda33fc02020-10-06 14:56:02 +02002390qom_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002391softmmu_ss = ss.source_set()
2392specific_fuzz_ss = ss.source_set()
2393specific_ss = ss.source_set()
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002394stub_ss = ss.source_set()
2395trace_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002396user_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002397util_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002398
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002399# accel modules
2400qtest_module_ss = ss.source_set()
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02002401tcg_module_ss = ss.source_set()
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002402
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002403modules = {}
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002404target_modules = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01002405hw_arch = {}
2406target_arch = {}
2407target_softmmu_arch = {}
Philippe Mathieu-Daudé46369b52021-04-13 11:27:09 +02002408target_user_arch = {}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002409
2410###############
2411# Trace files #
2412###############
2413
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002414# TODO: add each directory to the subdirs from its own meson.build, once
2415# we have those
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002416trace_events_subdirs = [
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002417 'crypto',
Philippe Mathieu-Daudé69ff4d02021-01-22 21:44:35 +01002418 'qapi',
2419 'qom',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002420 'monitor',
Philippe Mathieu-Daudé69ff4d02021-01-22 21:44:35 +01002421 'util',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002422]
2423if have_user
2424 trace_events_subdirs += [ 'linux-user' ]
2425endif
2426if have_block
2427 trace_events_subdirs += [
2428 'authz',
2429 'block',
2430 'io',
2431 'nbd',
2432 'scsi',
2433 ]
2434endif
2435if have_system
2436 trace_events_subdirs += [
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002437 'accel/kvm',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002438 'audio',
2439 'backends',
2440 'backends/tpm',
2441 'chardev',
Andrew Melnychenko46627f42021-05-14 14:48:32 +03002442 'ebpf',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002443 'hw/9pfs',
2444 'hw/acpi',
Hao Wu77c05b02021-01-08 11:09:42 -08002445 'hw/adc',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002446 'hw/alpha',
2447 'hw/arm',
2448 'hw/audio',
2449 'hw/block',
2450 'hw/block/dataplane',
2451 'hw/char',
2452 'hw/display',
2453 'hw/dma',
2454 'hw/hppa',
2455 'hw/hyperv',
2456 'hw/i2c',
2457 'hw/i386',
2458 'hw/i386/xen',
2459 'hw/ide',
2460 'hw/input',
2461 'hw/intc',
2462 'hw/isa',
2463 'hw/mem',
2464 'hw/mips',
2465 'hw/misc',
2466 'hw/misc/macio',
2467 'hw/net',
Vikram Garhwal98e5d7a2020-11-18 11:48:43 -08002468 'hw/net/can',
Mark Cave-Aylandce0e6a22021-09-24 08:37:55 +01002469 'hw/nubus',
Klaus Jensen88eea452021-04-14 22:14:30 +02002470 'hw/nvme',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002471 'hw/nvram',
2472 'hw/pci',
2473 'hw/pci-host',
2474 'hw/ppc',
2475 'hw/rdma',
2476 'hw/rdma/vmw',
2477 'hw/rtc',
2478 'hw/s390x',
2479 'hw/scsi',
2480 'hw/sd',
BALATON Zoltanad52cfc2021-10-29 23:02:09 +02002481 'hw/sh4',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002482 'hw/sparc',
2483 'hw/sparc64',
2484 'hw/ssi',
2485 'hw/timer',
2486 'hw/tpm',
2487 'hw/usb',
2488 'hw/vfio',
2489 'hw/virtio',
2490 'hw/watchdog',
2491 'hw/xen',
2492 'hw/gpio',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002493 'migration',
2494 'net',
Philippe Mathieu-Daudé8b7a5502020-08-05 15:02:20 +02002495 'softmmu',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002496 'ui',
Elena Ufimtsevaad22c302021-01-29 11:46:10 -05002497 'hw/remote',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002498 ]
2499endif
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002500if have_system or have_user
2501 trace_events_subdirs += [
2502 'accel/tcg',
2503 'hw/core',
2504 'target/arm',
Alexander Grafa1477da2021-09-16 17:53:58 +02002505 'target/arm/hvf',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002506 'target/hppa',
2507 'target/i386',
2508 'target/i386/kvm',
Philippe Mathieu-Daudé34b8ff22021-05-30 09:02:16 +02002509 'target/mips/tcg',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002510 'target/ppc',
2511 'target/riscv',
2512 'target/s390x',
Cho, Yu-Chen67043602021-07-07 18:53:23 +08002513 'target/s390x/kvm',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002514 'target/sparc',
2515 ]
2516endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002517
Marc-André Lureau0df750e2020-11-25 14:06:37 +04002518vhost_user = not_found
2519if 'CONFIG_VHOST_USER' in config_host
2520 libvhost_user = subproject('libvhost-user')
2521 vhost_user = libvhost_user.get_variable('vhost_user_dep')
2522endif
2523
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002524subdir('qapi')
2525subdir('qobject')
2526subdir('stubs')
2527subdir('trace')
2528subdir('util')
Marc-André Lureau5582c582019-07-16 19:28:54 +04002529subdir('qom')
2530subdir('authz')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002531subdir('crypto')
Marc-André Lureau2d78b562019-07-15 16:00:36 +04002532subdir('ui')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002533
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002534
2535if enable_modules
2536 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
2537 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
2538endif
2539
Paolo Bonzini2becc362020-02-03 11:42:03 +01002540stub_ss = stub_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002541
2542util_ss.add_all(trace_ss)
Paolo Bonzini2becc362020-02-03 11:42:03 +01002543util_ss = util_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002544libqemuutil = static_library('qemuutil',
2545 sources: util_ss.sources() + stub_ss.sources() + genh,
Paolo Bonzini6d7c7c22021-06-03 15:01:35 +02002546 dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman])
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002547qemuutil = declare_dependency(link_with: libqemuutil,
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +04002548 sources: genh + version_res)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002549
Philippe Mathieu-Daudé957b31f2021-01-22 21:44:37 +01002550if have_system or have_user
2551 decodetree = generator(find_program('scripts/decodetree.py'),
2552 output: 'decode-@BASENAME@.c.inc',
2553 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
2554 subdir('libdecnumber')
2555 subdir('target')
2556endif
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002557
Paolo Bonzini478e9432020-08-17 12:47:55 +02002558subdir('audio')
Marc-André Lureau7fcfd452019-07-16 19:33:55 +04002559subdir('io')
Marc-André Lureau848e8ff2019-07-15 23:18:07 +04002560subdir('chardev')
Marc-André Lureauec0d5892019-07-15 15:04:49 +04002561subdir('fsdev')
Marc-André Lureau708eab42019-09-03 16:59:33 +04002562subdir('dump')
Marc-André Lureauec0d5892019-07-15 15:04:49 +04002563
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002564if have_block
2565 block_ss.add(files(
2566 'block.c',
2567 'blockjob.c',
2568 'job.c',
2569 'qemu-io-cmds.c',
2570 ))
2571 block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002572
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002573 subdir('nbd')
2574 subdir('scsi')
2575 subdir('block')
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002576
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002577 blockdev_ss.add(files(
2578 'blockdev.c',
2579 'blockdev-nbd.c',
2580 'iothread.c',
2581 'job-qmp.c',
2582 ), gnutls)
Paolo Bonzini4a963372020-08-03 16:22:28 +02002583
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002584 # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
2585 # os-win32.c does not
2586 blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
2587 softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
2588endif
Paolo Bonzini4a963372020-08-03 16:22:28 +02002589
2590common_ss.add(files('cpus-common.c'))
2591
Paolo Bonzini5d3ea0e2020-08-06 13:40:26 +02002592subdir('softmmu')
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002593
Richard Hendersonf3433462020-09-12 10:47:33 -07002594common_ss.add(capstone)
Paolo Bonzinid9f24bf2020-10-06 09:05:29 +02002595specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002596
Richard Henderson44b99a62021-03-22 12:24:26 +01002597# Work around a gcc bug/misfeature wherein constant propagation looks
2598# through an alias:
2599# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696
2600# to guess that a const variable is always zero. Without lto, this is
2601# impossible, as the alias is restricted to page-vary-common.c. Indeed,
2602# without lto, not even the alias is required -- we simply use different
2603# declarations in different compilation units.
2604pagevary = files('page-vary-common.c')
2605if get_option('b_lto')
2606 pagevary_flags = ['-fno-lto']
2607 if get_option('cfi')
2608 pagevary_flags += '-fno-sanitize=cfi-icall'
2609 endif
2610 pagevary = static_library('page-vary-common', sources: pagevary,
2611 c_args: pagevary_flags)
2612 pagevary = declare_dependency(link_with: pagevary)
2613endif
2614common_ss.add(pagevary)
Richard Henderson6670d4d2021-03-22 12:24:24 +01002615specific_ss.add(files('page-vary.c'))
2616
Marc-André Lureauab318052019-07-24 19:23:16 +04002617subdir('backends')
Marc-André Lureauc574e162019-07-26 12:02:31 +04002618subdir('disas')
Marc-André Lureau55166232019-07-24 19:16:22 +04002619subdir('migration')
Paolo Bonziniff219dc2020-08-04 21:14:26 +02002620subdir('monitor')
Marc-André Lureaucdaf0722019-07-22 23:47:50 +04002621subdir('net')
Marc-André Lureau17ef2af2019-07-22 23:40:45 +04002622subdir('replay')
Philippe Mathieu-Daudé8df9f0c2021-03-05 13:54:50 +00002623subdir('semihosting')
Marc-André Lureau582ea952019-08-15 15:15:32 +04002624subdir('hw')
Richard Henderson104cc2c2021-03-08 12:04:33 -08002625subdir('tcg')
Richard Hendersonc6347542021-03-08 12:15:06 -08002626subdir('fpu')
Marc-André Lureau1a828782019-08-18 16:13:08 +04002627subdir('accel')
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01002628subdir('plugins')
Richard Hendersonbbf15aa2021-11-17 16:14:00 +01002629subdir('ebpf')
2630
2631common_user_inc = []
2632
2633subdir('common-user')
Marc-André Lureaub309c322019-08-18 19:20:37 +04002634subdir('bsd-user')
Marc-André Lureau3a304462019-08-18 16:13:08 +04002635subdir('linux-user')
Andrew Melnychenko46627f42021-05-14 14:48:32 +03002636
Richard Hendersonbbf15aa2021-11-17 16:14:00 +01002637common_user_ss = common_user_ss.apply(config_all, strict: false)
2638common_user = static_library('common-user',
2639 sources: common_user_ss.sources(),
2640 dependencies: common_user_ss.dependencies(),
2641 include_directories: common_user_inc,
2642 name_suffix: 'fa',
2643 build_by_default: false)
2644common_user = declare_dependency(link_with: common_user)
2645
2646user_ss.add(common_user)
2647
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02002648# needed for fuzzing binaries
2649subdir('tests/qtest/libqos')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002650subdir('tests/qtest/fuzz')
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02002651
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002652# accel modules
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02002653tcg_real_module_ss = ss.source_set()
2654tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss)
2655specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss)
2656target_modules += { 'accel' : { 'qtest': qtest_module_ss,
2657 'tcg': tcg_real_module_ss }}
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002658
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002659########################
2660# Library dependencies #
2661########################
2662
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002663modinfo_collect = find_program('scripts/modinfo-collect.py')
Gerd Hoffmann5ebbfec2021-06-24 12:38:05 +02002664modinfo_generate = find_program('scripts/modinfo-generate.py')
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002665modinfo_files = []
2666
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002667block_mods = []
2668softmmu_mods = []
2669foreach d, list : modules
2670 foreach m, module_ss : list
2671 if enable_modules and targetos != 'windows'
Gerd Hoffmann3e292c52020-09-14 15:42:20 +02002672 module_ss = module_ss.apply(config_all, strict: false)
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002673 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
2674 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
2675 if d == 'block'
2676 block_mods += sl
2677 else
2678 softmmu_mods += sl
2679 endif
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002680 if module_ss.sources() != []
2681 # FIXME: Should use sl.extract_all_objects(recursive: true) as
2682 # input. Sources can be used multiple times but objects are
2683 # unique when it comes to lookup in compile_commands.json.
2684 # Depnds on a mesion version with
2685 # https://github.com/mesonbuild/meson/pull/8900
2686 modinfo_files += custom_target(d + '-' + m + '.modinfo',
2687 output: d + '-' + m + '.modinfo',
Paolo Bonziniac347112021-07-21 18:51:57 +02002688 input: module_ss.sources() + genh,
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002689 capture: true,
Paolo Bonziniac347112021-07-21 18:51:57 +02002690 command: [modinfo_collect, module_ss.sources()])
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002691 endif
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002692 else
2693 if d == 'block'
2694 block_ss.add_all(module_ss)
2695 else
2696 softmmu_ss.add_all(module_ss)
2697 endif
2698 endif
2699 endforeach
2700endforeach
2701
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002702foreach d, list : target_modules
2703 foreach m, module_ss : list
2704 if enable_modules and targetos != 'windows'
2705 foreach target : target_dirs
2706 if target.endswith('-softmmu')
2707 config_target = config_target_mak[target]
2708 config_target += config_host
2709 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
2710 c_args = ['-DNEED_CPU_H',
2711 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
2712 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
2713 target_module_ss = module_ss.apply(config_target, strict: false)
2714 if target_module_ss.sources() != []
2715 module_name = d + '-' + m + '-' + config_target['TARGET_NAME']
2716 sl = static_library(module_name,
2717 [genh, target_module_ss.sources()],
2718 dependencies: [modulecommon, target_module_ss.dependencies()],
2719 include_directories: target_inc,
2720 c_args: c_args,
2721 pic: true)
2722 softmmu_mods += sl
2723 # FIXME: Should use sl.extract_all_objects(recursive: true) too.
2724 modinfo_files += custom_target(module_name + '.modinfo',
2725 output: module_name + '.modinfo',
Gerd Hoffmann917ddc22021-07-23 14:01:56 +02002726 input: target_module_ss.sources() + genh,
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002727 capture: true,
Gerd Hoffmann917ddc22021-07-23 14:01:56 +02002728 command: [modinfo_collect, '--target', target, target_module_ss.sources()])
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002729 endif
2730 endif
2731 endforeach
2732 else
2733 specific_ss.add_all(module_ss)
2734 endif
2735 endforeach
2736endforeach
2737
Gerd Hoffmann5ebbfec2021-06-24 12:38:05 +02002738if enable_modules
2739 modinfo_src = custom_target('modinfo.c',
2740 output: 'modinfo.c',
2741 input: modinfo_files,
2742 command: [modinfo_generate, '@INPUT@'],
2743 capture: true)
2744 modinfo_lib = static_library('modinfo', modinfo_src)
2745 modinfo_dep = declare_dependency(link_whole: modinfo_lib)
2746 softmmu_ss.add(modinfo_dep)
2747endif
2748
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002749nm = find_program('nm')
Yonggang Luo604f3e42020-09-03 01:00:50 +08002750undefsym = find_program('scripts/undefsym.py')
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002751block_syms = custom_target('block.syms', output: 'block.syms',
2752 input: [libqemuutil, block_mods],
2753 capture: true,
2754 command: [undefsym, nm, '@INPUT@'])
2755qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
2756 input: [libqemuutil, softmmu_mods],
2757 capture: true,
2758 command: [undefsym, nm, '@INPUT@'])
2759
Philippe Mathieu-Daudéda33fc02020-10-06 14:56:02 +02002760qom_ss = qom_ss.apply(config_host, strict: false)
2761libqom = static_library('qom', qom_ss.sources() + genh,
2762 dependencies: [qom_ss.dependencies()],
2763 name_suffix: 'fa')
2764
2765qom = declare_dependency(link_whole: libqom)
2766
Philippe Mathieu-Daudé55567892020-10-06 14:56:01 +02002767authz_ss = authz_ss.apply(config_host, strict: false)
2768libauthz = static_library('authz', authz_ss.sources() + genh,
2769 dependencies: [authz_ss.dependencies()],
2770 name_suffix: 'fa',
2771 build_by_default: false)
2772
2773authz = declare_dependency(link_whole: libauthz,
2774 dependencies: qom)
2775
Philippe Mathieu-Daudé23893042020-10-06 14:56:00 +02002776crypto_ss = crypto_ss.apply(config_host, strict: false)
2777libcrypto = static_library('crypto', crypto_ss.sources() + genh,
2778 dependencies: [crypto_ss.dependencies()],
2779 name_suffix: 'fa',
2780 build_by_default: false)
2781
2782crypto = declare_dependency(link_whole: libcrypto,
2783 dependencies: [authz, qom])
2784
Philippe Mathieu-Daudéf78536b2020-10-06 14:55:59 +02002785io_ss = io_ss.apply(config_host, strict: false)
2786libio = static_library('io', io_ss.sources() + genh,
2787 dependencies: [io_ss.dependencies()],
2788 link_with: libqemuutil,
2789 name_suffix: 'fa',
2790 build_by_default: false)
2791
2792io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
2793
Philippe Mathieu-Daudé7e6edef2020-10-06 14:55:58 +02002794libmigration = static_library('migration', sources: migration_files + genh,
2795 name_suffix: 'fa',
2796 build_by_default: false)
2797migration = declare_dependency(link_with: libmigration,
2798 dependencies: [zlib, qom, io])
2799softmmu_ss.add(migration)
2800
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002801block_ss = block_ss.apply(config_host, strict: false)
2802libblock = static_library('block', block_ss.sources() + genh,
2803 dependencies: block_ss.dependencies(),
2804 link_depends: block_syms,
2805 name_suffix: 'fa',
2806 build_by_default: false)
2807
2808block = declare_dependency(link_whole: [libblock],
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04002809 link_args: '@block.syms',
2810 dependencies: [crypto, io])
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002811
Stefan Hajnoczi4fb90712020-09-29 13:55:14 +01002812blockdev_ss = blockdev_ss.apply(config_host, strict: false)
2813libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
2814 dependencies: blockdev_ss.dependencies(),
2815 name_suffix: 'fa',
2816 build_by_default: false)
2817
2818blockdev = declare_dependency(link_whole: [libblockdev],
2819 dependencies: [block])
2820
Paolo Bonziniff219dc2020-08-04 21:14:26 +02002821qmp_ss = qmp_ss.apply(config_host, strict: false)
2822libqmp = static_library('qmp', qmp_ss.sources() + genh,
2823 dependencies: qmp_ss.dependencies(),
2824 name_suffix: 'fa',
2825 build_by_default: false)
2826
2827qmp = declare_dependency(link_whole: [libqmp])
2828
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002829libchardev = static_library('chardev', chardev_ss.sources() + genh,
2830 name_suffix: 'fa',
Roman Bolshakov3eacf702021-01-02 15:52:13 +03002831 dependencies: [gnutls],
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002832 build_by_default: false)
2833
2834chardev = declare_dependency(link_whole: libchardev)
2835
Philippe Mathieu-Daudéf73fb062021-10-28 16:34:19 +02002836hwcore_ss = hwcore_ss.apply(config_host, strict: false)
2837libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
Philippe Mathieu-Daudée28ab092020-10-06 14:55:56 +02002838 name_suffix: 'fa',
2839 build_by_default: false)
2840hwcore = declare_dependency(link_whole: libhwcore)
2841common_ss.add(hwcore)
2842
Philippe Mathieu-Daudé064f8ee2020-10-06 14:55:54 +02002843###########
2844# Targets #
2845###########
2846
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002847foreach m : block_mods + softmmu_mods
2848 shared_module(m.name(),
2849 name_prefix: '',
2850 link_whole: m,
2851 install: true,
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04002852 install_dir: qemu_moddir)
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002853endforeach
2854
Stefan Hajnoczi4fb90712020-09-29 13:55:14 +01002855softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp)
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002856common_ss.add(qom, qemuutil)
2857
2858common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
Paolo Bonzini2becc362020-02-03 11:42:03 +01002859common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
2860
2861common_all = common_ss.apply(config_all, strict: false)
2862common_all = static_library('common',
2863 build_by_default: false,
2864 sources: common_all.sources() + genh,
Katsuhiro Ueno75eebe02021-04-29 11:43:07 +09002865 implicit_include_directories: false,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002866 dependencies: common_all.dependencies(),
2867 name_suffix: 'fa')
2868
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002869feature_to_c = find_program('scripts/feature_to_c.sh')
2870
Paolo Bonzinifd5eef82020-09-16 05:00:53 -04002871emulators = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01002872foreach target : target_dirs
2873 config_target = config_target_mak[target]
2874 target_name = config_target['TARGET_NAME']
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002875 target_base_arch = config_target['TARGET_BASE_ARCH']
Paolo Bonzini859aef02020-08-04 18:14:26 +02002876 arch_srcs = [config_target_h[target]]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002877 arch_deps = []
2878 c_args = ['-DNEED_CPU_H',
2879 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
2880 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -04002881 link_args = emulator_link_args
Paolo Bonzini2becc362020-02-03 11:42:03 +01002882
Paolo Bonzini859aef02020-08-04 18:14:26 +02002883 config_target += config_host
Paolo Bonzini2becc362020-02-03 11:42:03 +01002884 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
2885 if targetos == 'linux'
2886 target_inc += include_directories('linux-headers', is_system: true)
2887 endif
2888 if target.endswith('-softmmu')
2889 qemu_target_name = 'qemu-system-' + target_name
2890 target_type='system'
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002891 t = target_softmmu_arch[target_base_arch].apply(config_target, strict: false)
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002892 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002893 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002894
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002895 hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
Marc-André Lureau2c442202019-08-17 13:55:58 +04002896 hw = hw_arch[hw_dir].apply(config_target, strict: false)
2897 arch_srcs += hw.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002898 arch_deps += hw.dependencies()
Marc-André Lureau2c442202019-08-17 13:55:58 +04002899
Paolo Bonzini2becc362020-02-03 11:42:03 +01002900 arch_srcs += config_devices_h[target]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002901 link_args += ['@block.syms', '@qemu.syms']
Paolo Bonzini2becc362020-02-03 11:42:03 +01002902 else
Marc-André Lureau3a304462019-08-18 16:13:08 +04002903 abi = config_target['TARGET_ABI_DIR']
Paolo Bonzini2becc362020-02-03 11:42:03 +01002904 target_type='user'
2905 qemu_target_name = 'qemu-' + target_name
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002906 if target_base_arch in target_user_arch
2907 t = target_user_arch[target_base_arch].apply(config_target, strict: false)
Philippe Mathieu-Daudé46369b52021-04-13 11:27:09 +02002908 arch_srcs += t.sources()
2909 arch_deps += t.dependencies()
2910 endif
Paolo Bonzini2becc362020-02-03 11:42:03 +01002911 if 'CONFIG_LINUX_USER' in config_target
2912 base_dir = 'linux-user'
Paolo Bonzini823eb012021-11-08 14:18:17 +01002913 target_inc += include_directories('linux-user/host/' / host_arch)
Warner Loshe2a74722021-08-03 17:17:17 -06002914 endif
2915 if 'CONFIG_BSD_USER' in config_target
Paolo Bonzini2becc362020-02-03 11:42:03 +01002916 base_dir = 'bsd-user'
Warner Loshe2a74722021-08-03 17:17:17 -06002917 target_inc += include_directories('bsd-user/' / targetos)
2918 dir = base_dir / abi
2919 arch_srcs += files(dir / 'target_arch_cpu.c')
Paolo Bonzini2becc362020-02-03 11:42:03 +01002920 endif
2921 target_inc += include_directories(
2922 base_dir,
Marc-André Lureau3a304462019-08-18 16:13:08 +04002923 base_dir / abi,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002924 )
Marc-André Lureau3a304462019-08-18 16:13:08 +04002925 if 'CONFIG_LINUX_USER' in config_target
2926 dir = base_dir / abi
2927 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
2928 if config_target.has_key('TARGET_SYSTBL_ABI')
2929 arch_srcs += \
2930 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
2931 extra_args : config_target['TARGET_SYSTBL_ABI'])
2932 endif
2933 endif
Paolo Bonzini2becc362020-02-03 11:42:03 +01002934 endif
2935
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002936 if 'TARGET_XML_FILES' in config_target
2937 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
2938 output: target + '-gdbstub-xml.c',
2939 input: files(config_target['TARGET_XML_FILES'].split()),
2940 command: [feature_to_c, '@INPUT@'],
2941 capture: true)
2942 arch_srcs += gdbstub_xml
2943 endif
2944
Paolo Bonziniffb91f62021-11-08 15:44:39 +01002945 t = target_arch[target_base_arch].apply(config_target, strict: false)
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002946 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002947 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002948
Paolo Bonzini2becc362020-02-03 11:42:03 +01002949 target_common = common_ss.apply(config_target, strict: false)
2950 objects = common_all.extract_objects(target_common.sources())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002951 deps = target_common.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002952
Paolo Bonzini2becc362020-02-03 11:42:03 +01002953 target_specific = specific_ss.apply(config_target, strict: false)
2954 arch_srcs += target_specific.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002955 arch_deps += target_specific.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002956
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002957 lib = static_library('qemu-' + target,
Paolo Bonzini859aef02020-08-04 18:14:26 +02002958 sources: arch_srcs + genh,
Paolo Bonzinib7612f42020-08-26 08:22:58 +02002959 dependencies: arch_deps,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002960 objects: objects,
2961 include_directories: target_inc,
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002962 c_args: c_args,
2963 build_by_default: false,
Paolo Bonzini2becc362020-02-03 11:42:03 +01002964 name_suffix: 'fa')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002965
2966 if target.endswith('-softmmu')
2967 execs = [{
2968 'name': 'qemu-system-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002969 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002970 'sources': files('softmmu/main.c'),
2971 'dependencies': []
2972 }]
Paolo Bonzini35be72b2020-02-06 14:17:15 +01002973 if targetos == 'windows' and (sdl.found() or gtk.found())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002974 execs += [{
2975 'name': 'qemu-system-' + target_name + 'w',
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002976 'win_subsystem': 'windows',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002977 'sources': files('softmmu/main.c'),
2978 'dependencies': []
2979 }]
2980 endif
Paolo Bonzini537b7242021-10-07 15:08:12 +02002981 if get_option('fuzzing')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002982 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
2983 execs += [{
2984 'name': 'qemu-fuzz-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002985 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002986 'sources': specific_fuzz.sources(),
2987 'dependencies': specific_fuzz.dependencies(),
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002988 }]
2989 endif
2990 else
2991 execs = [{
2992 'name': 'qemu-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002993 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002994 'sources': [],
2995 'dependencies': []
2996 }]
2997 endif
2998 foreach exe: execs
Alexander Graf8a74ce62021-01-20 23:44:34 +01002999 exe_name = exe['name']
John Arbuckle3983a762021-07-05 15:53:28 -04003000 if targetos == 'darwin'
Alexander Graf8a74ce62021-01-20 23:44:34 +01003001 exe_name += '-unsigned'
3002 endif
3003
3004 emulator = executable(exe_name, exe['sources'],
Akihiko Odaki237377a2021-02-25 09:06:14 +09003005 install: true,
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003006 c_args: c_args,
3007 dependencies: arch_deps + deps + exe['dependencies'],
3008 objects: lib.extract_all_objects(recursive: true),
3009 link_language: link_language,
3010 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
3011 link_args: link_args,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003012 win_subsystem: exe['win_subsystem'])
Alexander Graf8a74ce62021-01-20 23:44:34 +01003013
John Arbuckle3983a762021-07-05 15:53:28 -04003014 if targetos == 'darwin'
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003015 icon = 'pc-bios/qemu.rsrc'
3016 build_input = [emulator, files(icon)]
3017 install_input = [
3018 get_option('bindir') / exe_name,
3019 meson.current_source_dir() / icon
3020 ]
3021 if 'CONFIG_HVF' in config_target
3022 entitlements = 'accel/hvf/entitlements.plist'
3023 build_input += files(entitlements)
3024 install_input += meson.current_source_dir() / entitlements
3025 endif
3026
Alexander Graf8a74ce62021-01-20 23:44:34 +01003027 emulators += {exe['name'] : custom_target(exe['name'],
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003028 input: build_input,
Alexander Graf8a74ce62021-01-20 23:44:34 +01003029 output: exe['name'],
3030 command: [
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003031 files('scripts/entitlement.sh'),
3032 '@OUTPUT@',
3033 '@INPUT@'
Alexander Graf8a74ce62021-01-20 23:44:34 +01003034 ])
3035 }
Akihiko Odaki237377a2021-02-25 09:06:14 +09003036
3037 meson.add_install_script('scripts/entitlement.sh', '--install',
Akihiko Odaki237377a2021-02-25 09:06:14 +09003038 get_option('bindir') / exe['name'],
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003039 install_input)
Alexander Graf8a74ce62021-01-20 23:44:34 +01003040 else
3041 emulators += {exe['name']: emulator}
3042 endif
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003043
Paolo Bonzini9c29b742021-10-07 15:08:14 +02003044 if stap.found()
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003045 foreach stp: [
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003046 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
3047 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003048 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
3049 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
3050 ]
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003051 custom_target(exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003052 input: trace_events_all,
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003053 output: exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003054 install: stp['install'],
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003055 install_dir: get_option('datadir') / 'systemtap/tapset',
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003056 command: [
3057 tracetool, '--group=all', '--format=' + stp['fmt'],
3058 '--binary=' + stp['bin'],
3059 '--target-name=' + target_name,
3060 '--target-type=' + target_type,
3061 '--probe-prefix=qemu.' + target_type + '.' + target_name,
Stefan Hajnoczic05012a2020-08-27 15:29:12 +01003062 '@INPUT@', '@OUTPUT@'
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00003063 ],
3064 depend_files: tracetool_depends)
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003065 endforeach
3066 endif
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003067 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +01003068endforeach
3069
Paolo Bonzini931049b2020-02-05 09:44:24 +01003070# Other build targets
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003071
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01003072if 'CONFIG_PLUGIN' in config_host
3073 install_headers('include/qemu/qemu-plugin.h')
3074endif
3075
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003076if 'CONFIG_GUEST_AGENT' in config_host
3077 subdir('qga')
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003078elif get_option('guest_agent_msi').enabled()
3079 error('Guest agent MSI requested, but the guest agent is not being built')
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003080endif
3081
Laurent Vivier9755c942020-08-24 17:24:30 +02003082# Don't build qemu-keymap if xkbcommon is not explicitly enabled
3083# when we don't build tools or system
Laurent Vivier4113f4c2020-08-24 17:24:29 +02003084if xkbcommon.found()
Marc-André Lureau28742462019-09-19 20:24:43 +04003085 # used for the update-keymaps target, so include rules even if !have_tools
3086 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
3087 dependencies: [qemuutil, xkbcommon], install: have_tools)
3088endif
3089
Paolo Bonzini931049b2020-02-05 09:44:24 +01003090if have_tools
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04003091 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
3092 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
3093 qemu_io = executable('qemu-io', files('qemu-io.c'),
3094 dependencies: [block, qemuutil], install: true)
Daniel P. Berrangéeb705982020-08-25 11:38:50 +01003095 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06003096 dependencies: [blockdev, qemuutil, gnutls, selinux],
3097 install: true)
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04003098
Paolo Bonzini7c58bb72020-08-04 20:18:36 +02003099 subdir('storage-daemon')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02003100 subdir('contrib/rdmacm-mux')
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +04003101 subdir('contrib/elf2dmp')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02003102
Marc-André Lureau157e7b12019-07-15 14:50:58 +04003103 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
3104 dependencies: qemuutil,
3105 install: true)
3106
Paolo Bonzini931049b2020-02-05 09:44:24 +01003107 if 'CONFIG_VHOST_USER' in config_host
Paolo Bonzini2d7ac0a2019-06-10 12:18:02 +02003108 subdir('contrib/vhost-user-blk')
Paolo Bonzinib7612f42020-08-26 08:22:58 +02003109 subdir('contrib/vhost-user-gpu')
Marc-André Lureau32fcc622019-07-12 22:11:20 +04003110 subdir('contrib/vhost-user-input')
Paolo Bonzini99650b62019-06-10 12:21:14 +02003111 subdir('contrib/vhost-user-scsi')
Paolo Bonzini931049b2020-02-05 09:44:24 +01003112 endif
Marc-André Lureau8f51e012019-07-15 14:39:25 +04003113
3114 if targetos == 'linux'
3115 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
3116 dependencies: [qemuutil, libcap_ng],
3117 install: true,
3118 install_dir: get_option('libexecdir'))
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003119
3120 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
3121 dependencies: [authz, crypto, io, qom, qemuutil,
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02003122 libcap_ng, mpathpersist],
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003123 install: true)
Marc-André Lureau8f51e012019-07-15 14:39:25 +04003124 endif
3125
Paolo Bonziniccd250a2021-06-03 12:50:17 +02003126 if have_ivshmem
Marc-André Lureau5ee24e72019-07-12 23:16:54 +04003127 subdir('contrib/ivshmem-client')
3128 subdir('contrib/ivshmem-server')
3129 endif
Paolo Bonzini931049b2020-02-05 09:44:24 +01003130endif
3131
Marc-André Lureauf5aa6322020-08-26 17:06:18 +04003132subdir('scripts')
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01003133subdir('tools')
Marc-André Lureaubdcbea72019-07-15 21:22:31 +04003134subdir('pc-bios')
Paolo Bonzinif8aa24e2020-08-05 15:49:10 +02003135subdir('docs')
Yonggang Luoe3667662020-10-16 06:06:25 +08003136subdir('tests')
Paolo Bonzini1b695472021-01-07 14:02:29 +01003137if gtk.found()
Marc-André Lureaue8f3bd72019-09-19 21:02:09 +04003138 subdir('po')
3139endif
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01003140
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003141if host_machine.system() == 'windows'
3142 nsis_cmd = [
3143 find_program('scripts/nsis.py'),
3144 '@OUTPUT@',
3145 get_option('prefix'),
3146 meson.current_source_dir(),
Stefan Weil24bdcc92020-11-25 20:18:33 +01003147 host_machine.cpu(),
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003148 '--',
3149 '-DDISPLAYVERSION=' + meson.project_version(),
3150 ]
3151 if build_docs
3152 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
3153 endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01003154 if gtk.found()
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003155 nsis_cmd += '-DCONFIG_GTK=y'
3156 endif
3157
3158 nsis = custom_target('nsis',
3159 output: 'qemu-setup-' + meson.project_version() + '.exe',
3160 input: files('qemu.nsi'),
3161 build_always_stale: true,
3162 command: nsis_cmd + ['@INPUT@'])
3163 alias_target('installer', nsis)
3164endif
3165
Paolo Bonzinia0c91622020-10-07 11:01:51 -04003166#########################
3167# Configuration summary #
3168#########################
3169
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003170# Directories
Paolo Bonzinif9332752020-02-03 13:28:38 +01003171summary_info = {}
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003172summary_info += {'Install prefix': get_option('prefix')}
3173summary_info += {'BIOS directory': qemu_datadir}
3174summary_info += {'firmware path': get_option('qemu_firmwarepath')}
3175summary_info += {'binary directory': get_option('bindir')}
3176summary_info += {'library directory': get_option('libdir')}
3177summary_info += {'module directory': qemu_moddir}
3178summary_info += {'libexec directory': get_option('libexecdir')}
3179summary_info += {'include directory': get_option('includedir')}
3180summary_info += {'config directory': get_option('sysconfdir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003181if targetos != 'windows'
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003182 summary_info += {'local state directory': get_option('localstatedir')}
Marc-André Lureaub81efab2020-08-26 15:04:18 +04003183 summary_info += {'Manual directory': get_option('mandir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003184else
3185 summary_info += {'local state directory': 'queried at runtime'}
3186endif
Marc-André Lureau491e74c2020-08-26 15:04:17 +04003187summary_info += {'Doc directory': get_option('docdir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003188summary_info += {'Build directory': meson.current_build_dir()}
3189summary_info += {'Source path': meson.current_source_dir()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003190summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003191summary(summary_info, bool_yn: true, section: 'Directories')
3192
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003193# Host binaries
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003194summary_info = {}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003195summary_info += {'git': config_host['GIT']}
3196summary_info += {'make': config_host['MAKE']}
3197summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003198summary_info += {'sphinx-build': sphinx_build}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003199if config_host.has_key('HAVE_GDB_BIN')
3200 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
3201endif
3202summary_info += {'genisoimage': config_host['GENISOIMAGE']}
3203if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003204 summary_info += {'wixl': wixl}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003205endif
Joelle van Dyneb8e0c492021-03-15 11:03:41 -07003206if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003207 summary_info += {'smbd': config_host['CONFIG_SMBD_COMMAND']}
3208endif
3209summary(summary_info, bool_yn: true, section: 'Host binaries')
3210
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003211# Configurable features
3212summary_info = {}
3213summary_info += {'Documentation': build_docs}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003214summary_info += {'system-mode emulation': have_system}
3215summary_info += {'user-mode emulation': have_user}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003216summary_info += {'block layer': have_block}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003217summary_info += {'Install blobs': get_option('install_blobs')}
3218summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
3219if config_host.has_key('CONFIG_MODULES')
3220 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
3221endif
Paolo Bonzini537b7242021-10-07 15:08:12 +02003222summary_info += {'fuzzing support': get_option('fuzzing')}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003223if have_system
Paolo Bonzini87430d52021-10-07 15:06:09 +02003224 summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003225endif
Paolo Bonzini9c29b742021-10-07 15:08:14 +02003226summary_info += {'Trace backends': ','.join(get_option('trace_backends'))}
3227if 'simple' in get_option('trace_backends')
3228 summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003229endif
3230summary_info += {'QOM debugging': config_host.has_key('CONFIG_QOM_CAST_DEBUG')}
3231summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
3232summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
3233summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
3234summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
3235summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
3236summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
3237summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
3238summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
3239summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
3240summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
3241summary(summary_info, bool_yn: true, section: 'Configurable features')
3242
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003243# Compilation information
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003244summary_info = {}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003245summary_info += {'host CPU': cpu}
3246summary_info += {'host endianness': build_machine.endian()}
Alex Bennée63de9352021-05-27 17:03:15 +01003247summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())}
3248summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003249if link_language == 'cpp'
Alex Bennée63de9352021-05-27 17:03:15 +01003250 summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003251else
3252 summary_info += {'C++ compiler': false}
3253endif
3254if targetos == 'darwin'
Alex Bennée63de9352021-05-27 17:03:15 +01003255 summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003256endif
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003257if targetos == 'windows'
3258 if 'WIN_SDK' in config_host
3259 summary_info += {'Windows SDK': config_host['WIN_SDK']}
3260 endif
3261endif
Paolo Bonzini47b30832020-09-23 05:26:17 -04003262summary_info += {'CFLAGS': ' '.join(get_option('c_args')
3263 + ['-O' + get_option('optimization')]
3264 + (get_option('debug') ? ['-g'] : []))}
3265if link_language == 'cpp'
3266 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
3267 + ['-O' + get_option('optimization')]
3268 + (get_option('debug') ? ['-g'] : []))}
3269endif
3270link_args = get_option(link_language + '_link_args')
3271if link_args.length() > 0
3272 summary_info += {'LDFLAGS': ' '.join(link_args)}
3273endif
Paolo Bonzinif9332752020-02-03 13:28:38 +01003274summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
3275summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003276summary_info += {'profiler': config_host.has_key('CONFIG_PROFILER')}
Daniele Buonocdad7812020-12-04 18:06:11 -05003277summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003278summary_info += {'PIE': get_option('b_pie')}
Laurent Vivier3e8529d2020-09-17 16:07:00 +02003279summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003280summary_info += {'malloc trim support': has_malloc_trim}
3281summary_info += {'membarrier': config_host.has_key('CONFIG_MEMBARRIER')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003282summary_info += {'debug stack usage': config_host.has_key('CONFIG_DEBUG_STACK_USAGE')}
3283summary_info += {'mutex debugging': config_host.has_key('CONFIG_DEBUG_MUTEX')}
3284summary_info += {'memory allocator': get_option('malloc')}
3285summary_info += {'avx2 optimization': config_host.has_key('CONFIG_AVX2_OPT')}
3286summary_info += {'avx512f optimization': config_host.has_key('CONFIG_AVX512F_OPT')}
3287summary_info += {'gprof enabled': config_host.has_key('CONFIG_GPROF')}
3288summary_info += {'gcov': get_option('b_coverage')}
3289summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
3290summary_info += {'CFI support': get_option('cfi')}
3291if get_option('cfi')
3292 summary_info += {'CFI debug support': get_option('cfi_debug')}
3293endif
3294summary_info += {'strip binaries': get_option('strip')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003295summary_info += {'sparse': sparse}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003296summary_info += {'mingw32 support': targetos == 'windows'}
Alex Bennée49e85652021-02-22 10:14:50 +00003297
3298# snarf the cross-compilation information for tests
3299foreach target: target_dirs
3300 tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak'
3301 if fs.exists(tcg_mak)
3302 config_cross_tcg = keyval.load(tcg_mak)
3303 target = config_cross_tcg['TARGET_NAME']
3304 compiler = ''
3305 if 'DOCKER_CROSS_CC_GUEST' in config_cross_tcg
3306 summary_info += {target + ' tests': config_cross_tcg['DOCKER_CROSS_CC_GUEST'] +
3307 ' via ' + config_cross_tcg['DOCKER_IMAGE']}
3308 elif 'CROSS_CC_GUEST' in config_cross_tcg
3309 summary_info += {target + ' tests'
3310 : config_cross_tcg['CROSS_CC_GUEST'] }
3311 endif
3312 endif
3313endforeach
3314
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003315summary(summary_info, bool_yn: true, section: 'Compilation')
3316
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003317# Targets and accelerators
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003318summary_info = {}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003319if have_system
3320 summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
3321 summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
3322 summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
3323 summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
Reinoud Zandijk74a414a2021-04-02 22:25:32 +02003324 summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003325 summary_info += {'Xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
3326 if config_host.has_key('CONFIG_XEN_BACKEND')
3327 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
3328 endif
3329endif
3330summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
3331if config_all.has_key('CONFIG_TCG')
Philippe Mathieu-Daudé39687ac2021-01-25 15:45:29 +01003332 if get_option('tcg_interpreter')
Philippe Mathieu-Daudéf1f727a2021-11-06 12:14:57 +01003333 summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
Philippe Mathieu-Daudé39687ac2021-01-25 15:45:29 +01003334 else
3335 summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
3336 endif
Alex Bennée029aa682021-07-09 15:29:53 +01003337 summary_info += {'TCG plugins': config_host.has_key('CONFIG_PLUGIN')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003338 summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003339endif
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003340summary_info += {'target list': ' '.join(target_dirs)}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003341if have_system
3342 summary_info += {'default devices': get_option('default_devices')}
Paolo Bonzini106ad1f2021-02-17 16:24:25 +01003343 summary_info += {'out of process emulation': multiprocess_allowed}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003344endif
3345summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
3346
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003347# Block layer
3348summary_info = {}
3349summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
3350summary_info += {'coroutine pool': config_host['CONFIG_COROUTINE_POOL'] == '1'}
3351if have_block
3352 summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
3353 summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
Kevin Wolfe5f05f82021-07-09 18:41:41 +02003354 summary_info += {'Use block whitelist in tools': config_host.has_key('CONFIG_BDRV_WHITELIST_TOOLS')}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003355 summary_info += {'VirtFS support': have_virtfs}
3356 summary_info += {'build virtiofs daemon': have_virtiofsd}
3357 summary_info += {'Live block migration': config_host.has_key('CONFIG_LIVE_BLOCK_MIGRATION')}
3358 summary_info += {'replication support': config_host.has_key('CONFIG_REPLICATION')}
3359 summary_info += {'bochs support': config_host.has_key('CONFIG_BOCHS')}
3360 summary_info += {'cloop support': config_host.has_key('CONFIG_CLOOP')}
3361 summary_info += {'dmg support': config_host.has_key('CONFIG_DMG')}
3362 summary_info += {'qcow v1 support': config_host.has_key('CONFIG_QCOW1')}
3363 summary_info += {'vdi support': config_host.has_key('CONFIG_VDI')}
3364 summary_info += {'vvfat support': config_host.has_key('CONFIG_VVFAT')}
3365 summary_info += {'qed support': config_host.has_key('CONFIG_QED')}
3366 summary_info += {'parallels support': config_host.has_key('CONFIG_PARALLELS')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003367 summary_info += {'FUSE exports': fuse}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003368endif
3369summary(summary_info, bool_yn: true, section: 'Block layer support')
3370
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003371# Crypto
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003372summary_info = {}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003373summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003374summary_info += {'GNUTLS support': gnutls}
3375if gnutls.found()
3376 summary_info += {' GNUTLS crypto': gnutls_crypto.found()}
3377endif
3378summary_info += {'libgcrypt': gcrypt}
3379summary_info += {'nettle': nettle}
Paolo Bonzini57612512021-06-03 11:15:26 +02003380if nettle.found()
3381 summary_info += {' XTS': xts != 'private'}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003382endif
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003383summary_info += {'crypto afalg': config_host.has_key('CONFIG_AF_ALG')}
3384summary_info += {'rng-none': config_host.has_key('CONFIG_RNG_NONE')}
3385summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
3386summary(summary_info, bool_yn: true, section: 'Crypto')
3387
Philippe Mathieu-Daudé69a78cc2021-01-21 10:56:16 +01003388# Libraries
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003389summary_info = {}
3390if targetos == 'darwin'
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003391 summary_info += {'Cocoa support': cocoa}
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003392endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003393summary_info += {'SDL support': sdl}
3394summary_info += {'SDL image support': sdl_image}
3395summary_info += {'GTK support': gtk}
3396summary_info += {'pixman': pixman}
3397summary_info += {'VTE support': vte}
3398summary_info += {'slirp support': slirp_opt == 'internal' ? slirp_opt : slirp}
3399summary_info += {'libtasn1': tasn1}
3400summary_info += {'PAM': pam}
3401summary_info += {'iconv support': iconv}
3402summary_info += {'curses support': curses}
3403summary_info += {'virgl support': virgl}
3404summary_info += {'curl support': curl}
3405summary_info += {'Multipath support': mpathpersist}
3406summary_info += {'VNC support': vnc}
Paolo Bonzinia0b93232020-02-06 15:48:52 +01003407if vnc.found()
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003408 summary_info += {'VNC SASL support': sasl}
3409 summary_info += {'VNC JPEG support': jpeg}
3410 summary_info += {'VNC PNG support': png}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003411endif
Paolo Bonzini87430d52021-10-07 15:06:09 +02003412if targetos not in ['darwin', 'haiku', 'windows']
3413 summary_info += {'OSS support': oss}
3414elif targetos == 'darwin'
3415 summary_info += {'CoreAudio support': coreaudio}
3416elif targetos == 'windows'
3417 summary_info += {'DirectSound support': dsound}
3418endif
3419if targetos == 'linux'
3420 summary_info += {'ALSA support': alsa}
3421 summary_info += {'PulseAudio support': pulse}
3422endif
3423summary_info += {'JACK support': jack}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003424summary_info += {'brlapi support': brlapi}
Paolo Bonzinie1723992021-10-07 15:08:21 +02003425summary_info += {'vde support': vde}
Paolo Bonzini837b84b2021-10-07 15:08:22 +02003426summary_info += {'netmap support': have_netmap}
Thomas Hutheea94532021-10-28 20:59:08 +02003427summary_info += {'l2tpv3 support': have_l2tpv3}
Paolo Bonziniff66f3e2021-10-07 15:08:20 +02003428summary_info += {'Linux AIO support': libaio}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003429summary_info += {'Linux io_uring support': linux_io_uring}
3430summary_info += {'ATTR/XATTR support': libattr}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003431summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
3432summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
Paolo Bonzinifbb41212020-10-05 11:31:15 +02003433summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003434summary_info += {'libcap-ng support': libcap_ng}
3435summary_info += {'bpf support': libbpf}
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02003436summary_info += {'spice protocol support': spice_protocol}
3437if spice_protocol.found()
3438 summary_info += {' spice server support': spice}
3439endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003440summary_info += {'rbd support': rbd}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003441summary_info += {'xfsctl support': config_host.has_key('CONFIG_XFS')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003442summary_info += {'smartcard support': cacard}
3443summary_info += {'U2F support': u2f}
3444summary_info += {'libusb': libusb}
3445summary_info += {'usb net redir': usbredir}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003446summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003447summary_info += {'GBM': gbm}
3448summary_info += {'libiscsi support': libiscsi}
3449summary_info += {'libnfs support': libnfs}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003450if targetos == 'windows'
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003451 if config_host.has_key('CONFIG_GUEST_AGENT')
3452 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
3453 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003454 endif
Paolo Bonzinif9332752020-02-03 13:28:38 +01003455endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003456summary_info += {'seccomp support': seccomp}
3457summary_info += {'GlusterFS support': glusterfs}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003458summary_info += {'TPM support': config_host.has_key('CONFIG_TPM')}
Thomas Huthe6a52b32021-12-09 15:48:01 +01003459summary_info += {'libssh support': libssh}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003460summary_info += {'lzo support': lzo}
3461summary_info += {'snappy support': snappy}
3462summary_info += {'bzip2 support': libbzip2}
3463summary_info += {'lzfse support': liblzfse}
3464summary_info += {'zstd support': zstd}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003465summary_info += {'NUMA host support': config_host.has_key('CONFIG_NUMA')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003466summary_info += {'libxml2': libxml2}
3467summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
3468summary_info += {'libpmem support': libpmem}
3469summary_info += {'libdaxctl support': libdaxctl}
3470summary_info += {'libudev': libudev}
3471# Dummy dependency, keep .found()
Max Reitzdf4ea702020-10-27 20:05:46 +01003472summary_info += {'FUSE lseek': fuse_lseek.found()}
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06003473summary_info += {'selinux': selinux}
Philippe Mathieu-Daudé69a78cc2021-01-21 10:56:16 +01003474summary(summary_info, bool_yn: true, section: 'Dependencies')
Paolo Bonzinif9332752020-02-03 13:28:38 +01003475
3476if not supported_cpus.contains(cpu)
3477 message()
3478 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
3479 message()
3480 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
3481 message('The QEMU project intends to remove support for this host CPU in')
3482 message('a future release if nobody volunteers to maintain it and to')
3483 message('provide a build host for our continuous integration setup.')
3484 message('configure has succeeded and you can continue to build, but')
3485 message('if you care about QEMU on this platform you should contact')
3486 message('us upstream at qemu-devel@nongnu.org.')
3487endif
3488
3489if not supported_oses.contains(targetos)
3490 message()
3491 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
3492 message()
3493 message('Host OS ' + targetos + 'support is not currently maintained.')
3494 message('The QEMU project intends to remove support for this host OS in')
3495 message('a future release if nobody volunteers to maintain it and to')
3496 message('provide a build host for our continuous integration setup.')
3497 message('configure has succeeded and you can continue to build, but')
3498 message('if you care about QEMU on this platform you should contact')
3499 message('us upstream at qemu-devel@nongnu.org.')
3500endif