blob: 7b3cfb63169d3922b81f0e93d60b210ca13391cd [file] [log] [blame]
Paolo Bonzini43a363a2021-12-18 16:39:43 +01001project('qemu', ['c'], meson_version: '>=0.59.3',
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002 default_options: ['warning_level=1', 'c_std=gnu11', 'cpp_std=gnu++11', 'b_colorout=auto',
Paolo Bonzini3d2f73e2021-02-11 06:15:12 -05003 'b_staticpic=false', 'stdsplit=false'],
Paolo Bonzini654d6b02021-02-09 14:59:26 +01004 version: files('VERSION'))
Paolo Bonzinia5665052019-06-10 12:05:14 +02005
Paolo Bonzini98487b92021-10-06 11:27:47 +02006add_test_setup('quick', exclude_suites: ['block', 'slow', 'thorough'], is_default: true)
7add_test_setup('slow', exclude_suites: ['block', 'thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
8add_test_setup('thorough', exclude_suites: ['block'], env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
Paolo Bonzini3d2f73e2021-02-11 06:15:12 -05009
Paolo Bonzinia5665052019-06-10 12:05:14 +020010not_found = dependency('', required: false)
Paolo Bonzini654d6b02021-02-09 14:59:26 +010011keyval = import('keyval')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040012ss = import('sourceset')
Richard Henderson8b18cdb2020-09-13 12:19:25 -070013fs = import('fs')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040014
Paolo Bonzinice1c1e72020-01-28 16:41:44 +010015sh = find_program('sh')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -040016cc = meson.get_compiler('c')
Paolo Bonzinia5665052019-06-10 12:05:14 +020017config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
Marc-André Lureau3154fee2019-08-29 22:07:01 +040018enable_modules = 'CONFIG_MODULES' in config_host
Paolo Bonzini35be72b2020-02-06 14:17:15 +010019enable_static = 'CONFIG_STATIC' in config_host
Yonggang Luoe3667662020-10-16 06:06:25 +080020
Paolo Bonzinid7dedf42021-01-26 11:15:33 +010021# Allow both shared and static libraries unless --enable-static
22static_kwargs = enable_static ? {'static': true} : {}
23
Yonggang Luoe3667662020-10-16 06:06:25 +080024# Temporary directory used for files created while
25# configure runs. Since it is in the build directory
26# we can safely blow away any previous version of it
27# (and we need not jump through hoops to try to delete
28# it when configure exits.)
29tmpdir = meson.current_build_dir() / 'meson-private/temp'
Marc-André Lureau8fe11232020-09-11 14:42:48 +020030
31if get_option('qemu_suffix').startswith('/')
32 error('qemu_suffix cannot start with a /')
33endif
34
Paolo Bonzini16bf7a32020-10-16 03:19:14 -040035qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
Marc-André Lureauab4c0992020-08-26 15:04:16 +040036qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
Marc-André Lureau491e74c2020-08-26 15:04:17 +040037qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
Paolo Bonzini16bf7a32020-10-16 03:19:14 -040038qemu_moddir = get_option('libdir') / get_option('qemu_suffix')
39
40qemu_desktopdir = get_option('datadir') / 'applications'
41qemu_icondir = get_option('datadir') / 'icons'
42
Paolo Bonzini859aef02020-08-04 18:14:26 +020043config_host_data = configuration_data()
44genh = []
Vladimir Sementsov-Ogievskiyb83a80e2022-01-26 17:11:27 +010045qapi_trace_events = []
Paolo Bonzinia5665052019-06-10 12:05:14 +020046
Paolo Bonzini760e4322020-08-26 08:09:48 +020047target_dirs = config_host['TARGET_DIRS'].split()
Warner Loshdda2da62021-10-08 16:47:37 -060048have_linux_user = false
49have_bsd_user = false
Paolo Bonzini760e4322020-08-26 08:09:48 +020050have_system = false
51foreach target : target_dirs
Warner Loshdda2da62021-10-08 16:47:37 -060052 have_linux_user = have_linux_user or target.endswith('linux-user')
53 have_bsd_user = have_bsd_user or target.endswith('bsd-user')
Paolo Bonzini760e4322020-08-26 08:09:48 +020054 have_system = have_system or target.endswith('-softmmu')
55endforeach
Warner Loshdda2da62021-10-08 16:47:37 -060056have_user = have_linux_user or have_bsd_user
Paolo Bonzini760e4322020-08-26 08:09:48 +020057have_tools = 'CONFIG_TOOLS' in config_host
58have_block = have_system or have_tools
59
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040060python = import('python').find_installation()
61
62supported_oses = ['windows', 'freebsd', 'netbsd', 'openbsd', 'darwin', 'sunos', 'linux']
Richard Hendersonba0e7332021-09-17 11:08:09 -070063supported_cpus = ['ppc', 'ppc64', 's390x', 'riscv', 'x86', 'x86_64',
WANG Xueruidfcf9002021-12-21 13:41:04 +080064 'arm', 'aarch64', 'loongarch64', 'mips', 'mips64', 'sparc', 'sparc64']
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040065
66cpu = host_machine.cpu_family()
Richard Hendersonc94c2392021-11-16 10:50:42 +010067
68# Unify riscv* to a single family.
69if cpu in ['riscv32', 'riscv64']
70 cpu = 'riscv'
71endif
72
Paolo Bonzini201e8ed2020-09-01 07:45:54 -040073targetos = host_machine.system()
74
Paolo Bonzini823eb012021-11-08 14:18:17 +010075if cpu not in supported_cpus
76 host_arch = 'unknown'
77elif cpu == 'x86'
78 host_arch = 'i386'
Richard Henderson0e3ed772021-12-31 05:25:11 +000079elif cpu == 'mips64'
80 host_arch = 'mips'
Paolo Bonzini823eb012021-11-08 14:18:17 +010081else
82 host_arch = cpu
83endif
84
Paolo Bonzini8a199802020-09-18 05:37:01 -040085if cpu in ['x86', 'x86_64']
86 kvm_targets = ['i386-softmmu', 'x86_64-softmmu']
87elif cpu == 'aarch64'
88 kvm_targets = ['aarch64-softmmu']
89elif cpu == 's390x'
90 kvm_targets = ['s390x-softmmu']
91elif cpu in ['ppc', 'ppc64']
92 kvm_targets = ['ppc-softmmu', 'ppc64-softmmu']
Huacai Chenfbc58842020-10-07 16:39:28 +080093elif cpu in ['mips', 'mips64']
94 kvm_targets = ['mips-softmmu', 'mipsel-softmmu', 'mips64-softmmu', 'mips64el-softmmu']
Yifei Jiangfbf43c72022-01-12 16:13:29 +080095elif cpu in ['riscv']
96 kvm_targets = ['riscv32-softmmu', 'riscv64-softmmu']
Paolo Bonzini8a199802020-09-18 05:37:01 -040097else
98 kvm_targets = []
99endif
100
Igor Mammedov44d3d892021-10-27 11:10:12 -0400101kvm_targets_c = '""'
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100102if get_option('kvm').allowed() and targetos == 'linux'
Igor Mammedove741aff2021-09-02 07:35:38 -0400103 kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
104endif
105config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
106
Paolo Bonzini8a199802020-09-18 05:37:01 -0400107accelerator_targets = { 'CONFIG_KVM': kvm_targets }
Alexander Graf844a06b2021-09-16 17:54:02 +0200108
109if cpu in ['aarch64']
110 accelerator_targets += {
111 'CONFIG_HVF': ['aarch64-softmmu']
112 }
113endif
114
Alex Bennée0c3e41d2020-11-10 19:23:09 +0000115if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
Marc-André Lureau2a2d51b2021-09-14 16:30:45 +0400116 # i386 emulator provides xenpv machine type for multiple architectures
Alex Bennée0c3e41d2020-11-10 19:23:09 +0000117 accelerator_targets += {
118 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu'],
119 }
120endif
Paolo Bonzini8a199802020-09-18 05:37:01 -0400121if cpu in ['x86', 'x86_64']
122 accelerator_targets += {
123 'CONFIG_HAX': ['i386-softmmu', 'x86_64-softmmu'],
Paolo Bonzini8a199802020-09-18 05:37:01 -0400124 'CONFIG_HVF': ['x86_64-softmmu'],
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200125 'CONFIG_NVMM': ['i386-softmmu', 'x86_64-softmmu'],
Paolo Bonzini8a199802020-09-18 05:37:01 -0400126 'CONFIG_WHPX': ['i386-softmmu', 'x86_64-softmmu'],
127 }
128endif
129
Paolo Bonzinia1b176f2021-07-12 14:22:08 +0200130modular_tcg = []
131# Darwin does not support references to thread-local variables in modules
132if targetos != 'darwin'
133 modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
134endif
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +0200135
Philippe Mathieu-Daudéeae9a1d2021-01-14 18:45:08 +0100136edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
Paolo Bonzinie49c0ef2021-09-23 06:55:28 -0400137unpack_edk2_blobs = false
138foreach target : edk2_targets
139 if target in target_dirs
140 bzip2 = find_program('bzip2', required: get_option('install_blobs'))
141 unpack_edk2_blobs = bzip2.found()
142 break
143 endif
144endforeach
Philippe Mathieu-Daudé45b545d2021-01-14 18:45:09 +0100145
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200146dtrace = not_found
147stap = not_found
148if 'dtrace' in get_option('trace_backends')
149 dtrace = find_program('dtrace', required: true)
150 stap = find_program('stap', required: false)
151 if stap.found()
152 # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
153 # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
154 # instead. QEMU --enable-modules depends on this because the SystemTap
155 # semaphores are linked into the main binary and not the module's shared
156 # object.
157 add_global_arguments('-DSTAP_SDT_V2',
158 native: false, language: ['c', 'cpp', 'objc'])
159 endif
160endif
161
Paolo Bonzini201e8ed2020-09-01 07:45:54 -0400162##################
163# Compiler flags #
164##################
165
Paolo Bonzini8cc2d232021-11-08 12:36:29 +0100166qemu_cflags = config_host['QEMU_CFLAGS'].split()
167qemu_cxxflags = config_host['QEMU_CXXFLAGS'].split()
168qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
169
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +0200170if get_option('gprof')
171 qemu_cflags += ['-p']
172 qemu_cxxflags += ['-p']
173 qemu_ldflags += ['-p']
174endif
175
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400176# Specify linker-script with add_project_link_arguments so that it is not placed
177# within a linker --start-group/--end-group pair
Paolo Bonzini537b7242021-10-07 15:08:12 +0200178if get_option('fuzzing')
179 add_project_link_arguments(['-Wl,-T,',
180 (meson.current_source_dir() / 'tests/qtest/fuzz/fork_fuzz.ld')],
181 native: false, language: ['c', 'cpp', 'objc'])
182
183 # Specify a filter to only instrument code that is directly related to
184 # virtual-devices.
185 configure_file(output: 'instrumentation-filter',
186 input: 'scripts/oss-fuzz/instrumentation-filter-template',
187 copy: true)
188 add_global_arguments(
189 cc.get_supported_arguments('-fsanitize-coverage-allowlist=instrumentation-filter'),
190 native: false, language: ['c', 'cpp', 'objc'])
191
192 if get_option('fuzzing_engine') == ''
193 # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the
194 # compiled code. To build non-fuzzer binaries with --enable-fuzzing, link
195 # everything with fsanitize=fuzzer-no-link. Otherwise, the linker will be
196 # unable to bind the fuzzer-related callbacks added by instrumentation.
197 add_global_arguments('-fsanitize=fuzzer-no-link',
198 native: false, language: ['c', 'cpp', 'objc'])
199 add_global_link_arguments('-fsanitize=fuzzer-no-link',
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400200 native: false, language: ['c', 'cpp', 'objc'])
Paolo Bonzini537b7242021-10-07 15:08:12 +0200201 # For the actual fuzzer binaries, we need to link against the libfuzzer
202 # library. They need to be configurable, to support OSS-Fuzz
203 fuzz_exe_ldflags = ['-fsanitize=fuzzer']
204 else
205 # LIB_FUZZING_ENGINE was set; assume we are running on OSS-Fuzz, and
206 # the needed CFLAGS have already been provided
207 fuzz_exe_ldflags = get_option('fuzzing_engine').split()
208 endif
Alexander Bulekovff9ed622020-09-09 18:05:16 -0400209endif
210
Paolo Bonzini8cc2d232021-11-08 12:36:29 +0100211add_global_arguments(qemu_cflags, native: false, language: ['c', 'objc'])
212add_global_arguments(qemu_cxxflags, native: false, language: ['cpp'])
213add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
Paolo Bonzinia5665052019-06-10 12:05:14 +0200214
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400215if targetos == 'linux'
216 add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
217 '-isystem', 'linux-headers',
218 language: ['c', 'cpp'])
219endif
220
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100221add_project_arguments('-iquote', '.',
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400222 '-iquote', meson.current_source_dir(),
Paolo Bonzini1e6e6162020-10-14 08:45:42 -0400223 '-iquote', meson.current_source_dir() / 'include',
224 '-iquote', meson.current_source_dir() / 'disas/libvixl',
225 language: ['c', 'cpp', 'objc'])
Alexander Bulekovc46f76d2020-09-02 13:36:50 -0400226
Marc-André Lureaufc929892019-07-13 01:47:54 +0400227link_language = meson.get_external_property('link_language', 'cpp')
228if link_language == 'cpp'
229 add_languages('cpp', required: true, native: false)
Paolo Bonzini565174d2021-11-04 14:35:14 +0100230 cxx = meson.get_compiler('cpp')
231 linker = cxx
232else
233 linker = cc
Marc-André Lureaufc929892019-07-13 01:47:54 +0400234endif
Paolo Bonzinia5665052019-06-10 12:05:14 +0200235if host_machine.system() == 'darwin'
236 add_languages('objc', required: false, native: false)
237endif
238
Paolo Bonzinideb62372020-09-01 07:51:16 -0400239sparse = find_program('cgcc', required: get_option('sparse'))
240if sparse.found()
Paolo Bonzini968b4db2020-02-03 14:45:33 +0100241 run_target('sparse',
242 command: [find_program('scripts/check_sparse.py'),
Paolo Bonzinideb62372020-09-01 07:51:16 -0400243 'compile_commands.json', sparse.full_path(), '-Wbitwise',
244 '-Wno-transparent-union', '-Wno-old-initializer',
245 '-Wno-non-pointer-null'])
Paolo Bonzini968b4db2020-02-03 14:45:33 +0100246endif
247
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200248###########################################
249# Target-specific checks and dependencies #
250###########################################
251
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100252# Fuzzing
Paolo Bonzini537b7242021-10-07 15:08:12 +0200253if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
254 not cc.links('''
255 #include <stdint.h>
256 #include <sys/types.h>
257 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
258 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
259 ''',
260 args: ['-Werror', '-fsanitize=fuzzer'])
261 error('Your compiler does not support -fsanitize=fuzzer')
262endif
263
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100264# Tracing backends
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200265if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
266 error('ftrace is supported only on Linux')
267endif
268if 'syslog' in get_option('trace_backends') and not cc.compiles('''
269 #include <syslog.h>
270 int main(void) {
271 openlog("qemu", LOG_PID, LOG_DAEMON);
272 syslog(LOG_INFO, "configure");
273 return 0;
274 }''')
275 error('syslog is not supported on this system')
276endif
277
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100278# Miscellaneous Linux-only features
Paolo Bonzinia436d6d2021-12-18 16:39:43 +0100279get_option('mpath') \
280 .require(targetos == 'linux', error_message: 'Multipath is supported only on Linux')
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200281
Paolo Bonzinia436d6d2021-12-18 16:39:43 +0100282multiprocess_allowed = get_option('multiprocess') \
283 .require(targetos == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
284 .allowed()
Paolo Bonzini106ad1f2021-02-17 16:24:25 +0100285
Paolo Bonzini0d04c4c2021-12-21 12:38:27 +0100286have_tpm = get_option('tpm') \
287 .require(targetos != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
288 .allowed()
289
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100290# Target-specific libraries and flags
Paolo Bonzini7fa1c632021-06-01 10:00:48 +0200291libm = cc.find_library('m', required: false)
Paolo Bonzini6d7c7c22021-06-03 15:01:35 +0200292threads = dependency('threads')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400293util = cc.find_library('util', required: false)
Paolo Bonzini4a963372020-08-03 16:22:28 +0200294winmm = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400295socket = []
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400296version_res = []
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400297coref = []
298iokit = []
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -0400299emulator_link_args = []
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200300nvmm =not_found
Paolo Bonzini8a199802020-09-18 05:37:01 -0400301hvf = not_found
Paolo Bonzinia6305082021-10-07 15:08:15 +0200302host_dsosuf = '.so'
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400303if targetos == 'windows'
304 socket = cc.find_library('ws2_32')
Paolo Bonzini4a963372020-08-03 16:22:28 +0200305 winmm = cc.find_library('winmm')
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +0400306
307 win = import('windows')
308 version_res = win.compile_resources('version.rc',
309 depend_files: files('pc-bios/qemu-nsis.ico'),
310 include_directories: include_directories('.'))
Paolo Bonzinia6305082021-10-07 15:08:15 +0200311 host_dsosuf = '.dll'
Marc-André Lureaud92989a2019-08-20 19:48:59 +0400312elif targetos == 'darwin'
313 coref = dependency('appleframeworks', modules: 'CoreFoundation')
Joelle van Dyne14176c82021-03-15 11:03:38 -0700314 iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
Paolo Bonzinia6305082021-10-07 15:08:15 +0200315 host_dsosuf = '.dylib'
Paolo Bonzinicfad62f2020-08-09 23:47:45 +0200316elif targetos == 'sunos'
317 socket = [cc.find_library('socket'),
318 cc.find_library('nsl'),
319 cc.find_library('resolv')]
320elif targetos == 'haiku'
321 socket = [cc.find_library('posix_error_mapper'),
322 cc.find_library('network'),
323 cc.find_library('bsd')]
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -0400324elif targetos == 'openbsd'
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100325 if get_option('tcg').allowed() and target_dirs.length() > 0
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -0400326 # Disable OpenBSD W^X if available
327 emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
328 endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400329endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200330
Paolo Bonzinib7a75c82021-11-08 12:59:16 +0100331# Target-specific configuration of accelerators
Paolo Bonzini8a199802020-09-18 05:37:01 -0400332accelerators = []
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100333if get_option('kvm').allowed() and targetos == 'linux'
Paolo Bonzini8a199802020-09-18 05:37:01 -0400334 accelerators += 'CONFIG_KVM'
335endif
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100336if get_option('xen').allowed() and 'CONFIG_XEN_BACKEND' in config_host
Paolo Bonzini8a199802020-09-18 05:37:01 -0400337 accelerators += 'CONFIG_XEN'
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100338 have_xen_pci_passthrough = get_option('xen_pci_passthrough').allowed() and targetos == 'linux'
Paolo Bonzini8a199802020-09-18 05:37:01 -0400339else
340 have_xen_pci_passthrough = false
341endif
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100342if get_option('whpx').allowed() and targetos == 'windows'
Sunil Muthuswamy57e2a1f2020-10-22 00:27:55 +0000343 if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
Paolo Bonzini8a199802020-09-18 05:37:01 -0400344 error('WHPX requires 64-bit host')
345 elif cc.has_header('WinHvPlatform.h', required: get_option('whpx')) and \
346 cc.has_header('WinHvEmulation.h', required: get_option('whpx'))
347 accelerators += 'CONFIG_WHPX'
348 endif
349endif
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100350if get_option('hvf').allowed()
Paolo Bonzini8a199802020-09-18 05:37:01 -0400351 hvf = dependency('appleframeworks', modules: 'Hypervisor',
352 required: get_option('hvf'))
353 if hvf.found()
354 accelerators += 'CONFIG_HVF'
355 endif
356endif
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100357if get_option('hax').allowed()
Paolo Bonzini8a199802020-09-18 05:37:01 -0400358 if get_option('hax').enabled() or targetos in ['windows', 'darwin', 'netbsd']
359 accelerators += 'CONFIG_HAX'
360 endif
361endif
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200362if targetos == 'netbsd'
nia0cc49652021-10-13 13:54:17 +0000363 nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200364 if nvmm.found()
365 accelerators += 'CONFIG_NVMM'
366 endif
367endif
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100368
Paolo Bonzini823eb012021-11-08 14:18:17 +0100369tcg_arch = host_arch
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100370if get_option('tcg').allowed()
Paolo Bonzini823eb012021-11-08 14:18:17 +0100371 if host_arch == 'unknown'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100372 if get_option('tcg_interpreter')
Philippe Mathieu-Daudéf1f727a2021-11-06 12:14:57 +0100373 warning('Unsupported CPU @0@, will use TCG with TCI (slow)'.format(cpu))
Paolo Bonzini8a199802020-09-18 05:37:01 -0400374 else
375 error('Unsupported CPU @0@, try --enable-tcg-interpreter'.format(cpu))
376 endif
Philippe Mathieu-Daudéfa2f7b02021-01-25 15:45:30 +0100377 elif get_option('tcg_interpreter')
Philippe Mathieu-Daudé1c282da2021-05-21 12:34:23 +0200378 warning('Use of the TCG interpreter is not recommended on this host')
Philippe Mathieu-Daudéfa2f7b02021-01-25 15:45:30 +0100379 warning('architecture. There is a native TCG execution backend available')
380 warning('which provides substantially better performance and reliability.')
381 warning('It is strongly recommended to remove the --enable-tcg-interpreter')
382 warning('configuration option on this architecture to use the native')
383 warning('backend.')
Paolo Bonzini8a199802020-09-18 05:37:01 -0400384 endif
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100385 if get_option('tcg_interpreter')
386 tcg_arch = 'tci'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100387 elif host_arch == 'sparc64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100388 tcg_arch = 'sparc'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100389 elif host_arch == 'x86_64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100390 tcg_arch = 'i386'
Paolo Bonzini823eb012021-11-08 14:18:17 +0100391 elif host_arch == 'ppc64'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100392 tcg_arch = 'ppc'
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100393 endif
394 add_project_arguments('-iquote', meson.current_source_dir() / 'tcg' / tcg_arch,
Paolo Bonzini23a77b22020-12-14 12:01:45 +0100395 language: ['c', 'cpp', 'objc'])
396
Paolo Bonzini8a199802020-09-18 05:37:01 -0400397 accelerators += 'CONFIG_TCG'
398 config_host += { 'CONFIG_TCG': 'y' }
399endif
400
401if 'CONFIG_KVM' not in accelerators and get_option('kvm').enabled()
402 error('KVM not available on this platform')
403endif
404if 'CONFIG_HVF' not in accelerators and get_option('hvf').enabled()
405 error('HVF not available on this platform')
406endif
Reinoud Zandijk74a414a2021-04-02 22:25:32 +0200407if 'CONFIG_NVMM' not in accelerators and get_option('nvmm').enabled()
408 error('NVMM not available on this platform')
409endif
Paolo Bonzini8a199802020-09-18 05:37:01 -0400410if 'CONFIG_WHPX' not in accelerators and get_option('whpx').enabled()
411 error('WHPX not available on this platform')
412endif
413if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
414 if 'CONFIG_XEN' in accelerators
415 error('Xen PCI passthrough not available on this platform')
416 else
417 error('Xen PCI passthrough requested but Xen not enabled')
418 endif
419endif
Paolo Bonzinib4e312e2020-09-01 11:28:59 -0400420
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200421################
422# Dependencies #
423################
424
Paolo Bonzini215b0c22020-09-01 08:41:17 -0400425# The path to glib.h is added to all compilation commands. This was
426# grandfathered in from the QEMU Makefiles.
427add_project_arguments(config_host['GLIB_CFLAGS'].split(),
428 native: false, language: ['c', 'cpp', 'objc'])
Marc-André Lureau953d5a92020-12-15 12:03:19 +0400429glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
Marc-André Lureaud83acfd2021-10-09 17:37:40 +0400430 link_args: config_host['GLIB_LIBS'].split(),
431 version: config_host['GLIB_VERSION'])
Marc-André Lureau953d5a92020-12-15 12:03:19 +0400432# override glib dep with the configure results (for subprojects)
433meson.override_dependency('glib-2.0', glib)
434
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400435gio = not_found
436if 'CONFIG_GIO' in config_host
437 gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
Marc-André Lureaud83acfd2021-10-09 17:37:40 +0400438 link_args: config_host['GIO_LIBS'].split(),
439 version: config_host['GLIB_VERSION'])
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400440endif
441lttng = not_found
Paolo Bonzini9c29b742021-10-07 15:08:14 +0200442if 'ust' in get_option('trace_backends')
443 lttng = dependency('lttng-ust', required: true, method: 'pkg-config',
444 kwargs: static_kwargs)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -0400445endif
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200446pixman = not_found
447if have_system or have_tools
448 pixman = dependency('pixman-1', required: have_system, version:'>=0.21.8',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100449 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinib7612f42020-08-26 08:22:58 +0200450endif
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100451zlib = dependency('zlib', required: true, kwargs: static_kwargs)
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200452
Paolo Bonziniff66f3e2021-10-07 15:08:20 +0200453libaio = not_found
454if not get_option('linux_aio').auto() or have_block
455 libaio = cc.find_library('aio', has_headers: ['libaio.h'],
456 required: get_option('linux_aio'),
457 kwargs: static_kwargs)
458endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400459linux_io_uring = not_found
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200460if not get_option('linux_io_uring').auto() or have_block
Daniel P. Berrangéa41b4fd2022-01-05 13:49:38 +0000461 linux_io_uring = dependency('liburing', version: '>=0.3',
462 required: get_option('linux_io_uring'),
Paolo Bonzini53c22b62021-06-03 11:31:35 +0200463 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400464endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400465libnfs = not_found
Paolo Bonzini30045c02020-11-17 13:11:25 +0100466if not get_option('libnfs').auto() or have_block
467 libnfs = dependency('libnfs', version: '>=1.9.3',
468 required: get_option('libnfs'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100469 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400470endif
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100471
472libattr_test = '''
473 #include <stddef.h>
474 #include <sys/types.h>
475 #ifdef CONFIG_LIBATTR
476 #include <attr/xattr.h>
477 #else
478 #include <sys/xattr.h>
479 #endif
480 int main(void) { getxattr(NULL, NULL, NULL, 0); setxattr(NULL, NULL, NULL, 0, 0); return 0; }'''
481
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400482libattr = not_found
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100483have_old_libattr = false
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100484if get_option('attr').allowed()
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100485 if cc.links(libattr_test)
486 libattr = declare_dependency()
487 else
488 libattr = cc.find_library('attr', has_headers: ['attr/xattr.h'],
489 required: get_option('attr'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100490 kwargs: static_kwargs)
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100491 if libattr.found() and not \
492 cc.links(libattr_test, dependencies: libattr, args: '-DCONFIG_LIBATTR')
493 libattr = not_found
494 if get_option('attr').enabled()
495 error('could not link libattr')
496 else
497 warning('could not link libattr, disabling')
498 endif
499 else
500 have_old_libattr = libattr.found()
501 endif
502 endif
Marc-André Lureauec0d5892019-07-15 15:04:49 +0400503endif
Paolo Bonzinif7f2d652020-11-17 14:45:24 +0100504
Paolo Bonzinic1ec4942021-01-07 14:04:00 +0100505cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
506if cocoa.found() and get_option('sdl').enabled()
507 error('Cocoa and SDL cannot be enabled at the same time')
508endif
509if cocoa.found() and get_option('gtk').enabled()
510 error('Cocoa and GTK+ cannot be enabled at the same time')
511endif
512
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100513seccomp = not_found
Paolo Bonzini90835c22020-11-17 14:22:24 +0100514if not get_option('seccomp').auto() or have_system or have_tools
515 seccomp = dependency('libseccomp', version: '>=2.3.0',
516 required: get_option('seccomp'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100517 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100518endif
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100519
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100520libcap_ng = not_found
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100521if not get_option('cap_ng').auto() or have_system or have_tools
522 libcap_ng = cc.find_library('cap-ng', has_headers: ['cap-ng.h'],
523 required: get_option('cap_ng'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100524 kwargs: static_kwargs)
Paolo Bonzini3f99cf52020-02-05 09:45:39 +0100525endif
Paolo Bonzini727c8bb2020-11-17 14:46:58 +0100526if libcap_ng.found() and not cc.links('''
527 #include <cap-ng.h>
528 int main(void)
529 {
530 capng_capability_to_name(CAPNG_EFFECTIVE);
531 return 0;
532 }''', dependencies: libcap_ng)
533 libcap_ng = not_found
534 if get_option('cap_ng').enabled()
535 error('could not link libcap-ng')
536 else
537 warning('could not link libcap-ng, disabling')
538 endif
539endif
540
Paolo Bonzini1917ec62020-08-26 03:24:11 -0400541if get_option('xkbcommon').auto() and not have_system and not have_tools
542 xkbcommon = not_found
543else
544 xkbcommon = dependency('xkbcommon', required: get_option('xkbcommon'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100545 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureauade60d42019-07-15 14:48:31 +0400546endif
Paolo Bonzinie1723992021-10-07 15:08:21 +0200547
Marc-André Lureaucdaf0722019-07-22 23:47:50 +0400548vde = not_found
Paolo Bonzinie1723992021-10-07 15:08:21 +0200549if not get_option('vde').auto() or have_system or have_tools
550 vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'],
551 required: get_option('vde'),
552 kwargs: static_kwargs)
553endif
554if vde.found() and not cc.links('''
555 #include <libvdeplug.h>
556 int main(void)
557 {
558 struct vde_open_args a = {0, 0, 0};
559 char s[] = "";
560 vde_open(s, s, &a);
561 return 0;
562 }''', dependencies: vde)
563 vde = not_found
564 if get_option('cap_ng').enabled()
565 error('could not link libvdeplug')
566 else
567 warning('could not link libvdeplug, disabling')
568 endif
Marc-André Lureaucdaf0722019-07-22 23:47:50 +0400569endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200570
Paolo Bonzini478e9432020-08-17 12:47:55 +0200571pulse = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200572if not get_option('pa').auto() or (targetos == 'linux' and have_system)
573 pulse = dependency('libpulse', required: get_option('pa'),
574 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200575endif
576alsa = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200577if not get_option('alsa').auto() or (targetos == 'linux' and have_system)
578 alsa = dependency('alsa', required: get_option('alsa'),
579 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200580endif
581jack = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200582if not get_option('jack').auto() or have_system
583 jack = dependency('jack', required: get_option('jack'),
584 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini478e9432020-08-17 12:47:55 +0200585endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200586
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +0200587spice_protocol = not_found
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200588if not get_option('spice_protocol').auto() or have_system
589 spice_protocol = dependency('spice-protocol', version: '>=0.12.3',
590 required: get_option('spice_protocol'),
591 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini26347332019-07-29 15:40:07 +0200592endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200593spice = not_found
594if not get_option('spice').auto() or have_system
595 spice = dependency('spice-server', version: '>=0.12.5',
596 required: get_option('spice'),
597 method: 'pkg-config', kwargs: static_kwargs)
Gerd Hoffmann58d3f3f2021-05-19 07:39:32 +0200598endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +0200599spice_headers = spice.partial_dependency(compile_args: true, includes: true)
600
Marc-André Lureau5ee24e72019-07-12 23:16:54 +0400601rt = cc.find_library('rt', required: false)
Paolo Bonzinia399f912021-11-15 14:29:13 +0000602
Paolo Bonzini99650b62019-06-10 12:21:14 +0200603libiscsi = not_found
Paolo Bonzini9db405a2020-11-17 13:11:25 +0100604if not get_option('libiscsi').auto() or have_block
605 libiscsi = dependency('libiscsi', version: '>=1.9.0',
606 required: get_option('libiscsi'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100607 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini99650b62019-06-10 12:21:14 +0200608endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400609zstd = not_found
Paolo Bonzinib1def332020-11-17 13:37:39 +0100610if not get_option('zstd').auto() or have_block
611 zstd = dependency('libzstd', version: '>=1.4.0',
612 required: get_option('zstd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100613 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400614endif
Marc-André Lureauea458962019-07-12 22:23:46 +0400615virgl = not_found
Paolo Bonzini587d59d2021-06-03 11:31:35 +0200616if not get_option('virglrenderer').auto() or have_system
617 virgl = dependency('virglrenderer',
618 method: 'pkg-config',
619 required: get_option('virglrenderer'),
620 kwargs: static_kwargs)
Marc-André Lureauea458962019-07-12 22:23:46 +0400621endif
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +0400622curl = not_found
Paolo Bonzinif9cd86f2020-11-17 12:43:15 +0100623if not get_option('curl').auto() or have_block
624 curl = dependency('libcurl', version: '>=7.29.0',
625 method: 'pkg-config',
626 required: get_option('curl'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100627 kwargs: static_kwargs)
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +0400628endif
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200629libudev = not_found
Paolo Bonzinif01496a2020-09-16 17:54:14 +0200630if targetos == 'linux' and (have_system or have_tools)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200631 libudev = dependency('libudev',
Paolo Bonzinia0fbbb62020-11-17 12:36:15 +0100632 method: 'pkg-config',
Paolo Bonzini5c530152020-10-15 06:09:27 -0400633 required: get_option('libudev'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100634 kwargs: static_kwargs)
Paolo Bonzinif15bff22019-07-18 13:19:02 +0200635endif
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200636
Paolo Bonzini5c530152020-10-15 06:09:27 -0400637mpathlibs = [libudev]
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200638mpathpersist = not_found
639mpathpersist_new_api = false
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100640if targetos == 'linux' and have_tools and get_option('mpath').allowed()
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200641 mpath_test_source_new = '''
642 #include <libudev.h>
643 #include <mpath_persist.h>
644 unsigned mpath_mx_alloc_len = 1024;
645 int logsink;
646 static struct config *multipath_conf;
647 extern struct udev *udev;
648 extern struct config *get_multipath_config(void);
649 extern void put_multipath_config(struct config *conf);
650 struct udev *udev;
651 struct config *get_multipath_config(void) { return multipath_conf; }
652 void put_multipath_config(struct config *conf) { }
653 int main(void) {
654 udev = udev_new();
655 multipath_conf = mpath_lib_init();
656 return 0;
657 }'''
658 mpath_test_source_old = '''
659 #include <libudev.h>
660 #include <mpath_persist.h>
661 unsigned mpath_mx_alloc_len = 1024;
662 int logsink;
663 int main(void) {
664 struct udev *udev = udev_new();
665 mpath_lib_init(udev);
666 return 0;
667 }'''
Paolo Bonzini5c530152020-10-15 06:09:27 -0400668 libmpathpersist = cc.find_library('mpathpersist',
669 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100670 kwargs: static_kwargs)
Paolo Bonzini5c530152020-10-15 06:09:27 -0400671 if libmpathpersist.found()
672 mpathlibs += libmpathpersist
673 if enable_static
674 mpathlibs += cc.find_library('devmapper',
675 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100676 kwargs: static_kwargs)
Paolo Bonzini43b43a42020-09-17 12:25:09 +0200677 endif
Paolo Bonzini5c530152020-10-15 06:09:27 -0400678 mpathlibs += cc.find_library('multipath',
679 required: get_option('mpath'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100680 kwargs: static_kwargs)
Paolo Bonzini5c530152020-10-15 06:09:27 -0400681 foreach lib: mpathlibs
682 if not lib.found()
683 mpathlibs = []
684 break
685 endif
686 endforeach
687 if mpathlibs.length() == 0
688 msg = 'Dependencies missing for libmpathpersist'
689 elif cc.links(mpath_test_source_new, dependencies: mpathlibs)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200690 mpathpersist = declare_dependency(dependencies: mpathlibs)
691 mpathpersist_new_api = true
692 elif cc.links(mpath_test_source_old, dependencies: mpathlibs)
693 mpathpersist = declare_dependency(dependencies: mpathlibs)
694 else
Paolo Bonzini5c530152020-10-15 06:09:27 -0400695 msg = 'Cannot detect libmpathpersist API'
696 endif
697 if not mpathpersist.found()
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200698 if get_option('mpath').enabled()
Paolo Bonzini5c530152020-10-15 06:09:27 -0400699 error(msg)
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200700 else
Paolo Bonzini5c530152020-10-15 06:09:27 -0400701 warning(msg + ', disabling')
Paolo Bonzini6ec0e152020-09-16 18:07:29 +0200702 endif
703 endif
704 endif
705endif
706
Yonggang Luo5285e592020-10-13 07:43:48 +0800707iconv = not_found
Yonggang Luo5285e592020-10-13 07:43:48 +0800708curses = not_found
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100709if have_system and get_option('curses').allowed()
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400710 curses_test = '''
Stefan Weilfbab8cc2021-11-17 21:53:55 +0100711 #if defined(__APPLE__) || defined(__OpenBSD__)
712 #define _XOPEN_SOURCE_EXTENDED 1
713 #endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400714 #include <locale.h>
715 #include <curses.h>
716 #include <wchar.h>
717 int main(void) {
718 wchar_t wch = L'w';
719 setlocale(LC_ALL, "");
720 resize_term(0, 0);
721 addwstr(L"wide chars\n");
722 addnwstr(&wch, 1);
723 add_wch(WACS_DEGREE);
724 return 0;
725 }'''
726
Yonggang Luoca31e302020-11-17 05:31:06 +0800727 curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
728 foreach curses_dep : curses_dep_list
729 if not curses.found()
730 curses = dependency(curses_dep,
731 required: false,
732 method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100733 kwargs: static_kwargs)
Yonggang Luoca31e302020-11-17 05:31:06 +0800734 endif
735 endforeach
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400736 msg = get_option('curses').enabled() ? 'curses library not found' : ''
Stefan Weilfbab8cc2021-11-17 21:53:55 +0100737 curses_compile_args = ['-DNCURSES_WIDECHAR=1']
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400738 if curses.found()
Paolo Bonzini0dbce6e2020-11-30 08:07:48 -0500739 if cc.links(curses_test, args: curses_compile_args, dependencies: [curses])
740 curses = declare_dependency(compile_args: curses_compile_args, dependencies: [curses])
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400741 else
742 msg = 'curses package not usable'
743 curses = not_found
Yonggang Luo5285e592020-10-13 07:43:48 +0800744 endif
745 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400746 if not curses.found()
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400747 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
748 if targetos != 'windows' and not has_curses_h
749 message('Trying with /usr/include/ncursesw')
750 curses_compile_args += ['-I/usr/include/ncursesw']
751 has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
752 endif
753 if has_curses_h
754 curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
755 foreach curses_libname : curses_libname_list
Yonggang Luo5285e592020-10-13 07:43:48 +0800756 libcurses = cc.find_library(curses_libname,
757 required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100758 kwargs: static_kwargs)
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400759 if libcurses.found()
760 if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
761 curses = declare_dependency(compile_args: curses_compile_args,
762 dependencies: [libcurses])
763 break
764 else
765 msg = 'curses library not usable'
766 endif
Yonggang Luo5285e592020-10-13 07:43:48 +0800767 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400768 endforeach
769 endif
770 endif
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100771 if get_option('iconv').allowed()
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400772 foreach link_args : [ ['-liconv'], [] ]
773 # Programs will be linked with glib and this will bring in libiconv on FreeBSD.
774 # We need to use libiconv if available because mixing libiconv's headers with
775 # the system libc does not work.
776 # However, without adding glib to the dependencies -L/usr/local/lib will not be
777 # included in the command line and libiconv will not be found.
778 if cc.links('''
779 #include <iconv.h>
780 int main(void) {
781 iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
782 return conv != (iconv_t) -1;
783 }''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
784 iconv = declare_dependency(link_args: link_args, dependencies: glib)
785 break
Yonggang Luo5285e592020-10-13 07:43:48 +0800786 endif
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400787 endforeach
788 endif
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400789 if curses.found() and not iconv.found()
790 if get_option('iconv').enabled()
791 error('iconv not available')
792 endif
793 msg = 'iconv required for curses UI but not available'
794 curses = not_found
795 endif
796 if not curses.found() and msg != ''
797 if get_option('curses').enabled()
798 error(msg)
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400799 else
Paolo Bonzini925a40d2020-10-19 04:42:11 -0400800 warning(msg + ', disabling')
Paolo Bonzini30fe76b2020-10-15 13:26:50 -0400801 endif
Yonggang Luo5285e592020-10-13 07:43:48 +0800802 endif
803endif
804
Paolo Bonzini26347332019-07-29 15:40:07 +0200805brlapi = not_found
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +0100806if not get_option('brlapi').auto() or have_system
807 brlapi = cc.find_library('brlapi', has_headers: ['brlapi.h'],
808 required: get_option('brlapi'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100809 kwargs: static_kwargs)
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +0100810 if brlapi.found() and not cc.links('''
811 #include <brlapi.h>
812 #include <stddef.h>
813 int main(void) { return brlapi__openConnection (NULL, NULL, NULL); }''', dependencies: brlapi)
814 brlapi = not_found
815 if get_option('brlapi').enabled()
816 error('could not link brlapi')
817 else
818 warning('could not link brlapi, disabling')
819 endif
820 endif
Paolo Bonzini26347332019-07-29 15:40:07 +0200821endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100822
Paolo Bonzini760e4322020-08-26 08:09:48 +0200823sdl = not_found
Paolo Bonzinic1ec4942021-01-07 14:04:00 +0100824if not get_option('sdl').auto() or (have_system and not cocoa.found())
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100825 sdl = dependency('sdl2', required: get_option('sdl'), kwargs: static_kwargs)
Paolo Bonzini760e4322020-08-26 08:09:48 +0200826 sdl_image = not_found
827endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100828if sdl.found()
829 # work around 2.0.8 bug
830 sdl = declare_dependency(compile_args: '-Wno-undef',
831 dependencies: sdl)
Volker Rümelin7161a432020-08-29 12:41:58 +0200832 sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100833 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100834else
835 if get_option('sdl_image').enabled()
Sergei Trofimovicha8dc2ac2020-09-08 08:40:16 +0100836 error('sdl-image required, but SDL was @0@'.format(
837 get_option('sdl').disabled() ? 'disabled' : 'not found'))
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100838 endif
839 sdl_image = not_found
Paolo Bonzini26347332019-07-29 15:40:07 +0200840endif
Paolo Bonzini35be72b2020-02-06 14:17:15 +0100841
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400842rbd = not_found
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100843if not get_option('rbd').auto() or have_block
844 librados = cc.find_library('rados', required: get_option('rbd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100845 kwargs: static_kwargs)
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100846 librbd = cc.find_library('rbd', has_headers: ['rbd/librbd.h'],
847 required: get_option('rbd'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100848 kwargs: static_kwargs)
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100849 if librados.found() and librbd.found()
850 if cc.links('''
851 #include <stdio.h>
852 #include <rbd/librbd.h>
853 int main(void) {
854 rados_t cluster;
855 rados_create(&cluster, NULL);
Peter Lieven48672ac2021-07-02 19:23:51 +0200856 #if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 12, 0)
857 #error
858 #endif
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100859 return 0;
860 }''', dependencies: [librbd, librados])
861 rbd = declare_dependency(dependencies: [librbd, librados])
862 elif get_option('rbd').enabled()
Peter Lieven48672ac2021-07-02 19:23:51 +0200863 error('librbd >= 1.12.0 required')
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100864 else
Peter Lieven48672ac2021-07-02 19:23:51 +0200865 warning('librbd >= 1.12.0 not found, disabling')
Paolo Bonzinic518d6c2021-01-26 11:20:35 +0100866 endif
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100867 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400868endif
Paolo Bonzinifabd1e92020-11-17 13:11:25 +0100869
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400870glusterfs = not_found
Paolo Bonzini08821ca2020-11-17 13:01:26 +0100871glusterfs_ftruncate_has_stat = false
872glusterfs_iocb_has_stat = false
873if not get_option('glusterfs').auto() or have_block
874 glusterfs = dependency('glusterfs-api', version: '>=3',
875 required: get_option('glusterfs'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100876 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini08821ca2020-11-17 13:01:26 +0100877 if glusterfs.found()
878 glusterfs_ftruncate_has_stat = cc.links('''
879 #include <glusterfs/api/glfs.h>
880
881 int
882 main(void)
883 {
884 /* new glfs_ftruncate() passes two additional args */
885 return glfs_ftruncate(NULL, 0, NULL, NULL);
886 }
887 ''', dependencies: glusterfs)
888 glusterfs_iocb_has_stat = cc.links('''
889 #include <glusterfs/api/glfs.h>
890
891 /* new glfs_io_cbk() passes two additional glfs_stat structs */
892 static void
893 glusterfs_iocb(glfs_fd_t *fd, ssize_t ret, struct glfs_stat *prestat, struct glfs_stat *poststat, void *data)
894 {}
895
896 int
897 main(void)
898 {
899 glfs_io_cbk iocb = &glusterfs_iocb;
900 iocb(NULL, 0 , NULL, NULL, NULL);
901 return 0;
902 }
903 ''', dependencies: glusterfs)
904 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400905endif
Thomas Huthe6a52b32021-12-09 15:48:01 +0100906
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400907libssh = not_found
Thomas Huthe6a52b32021-12-09 15:48:01 +0100908if not get_option('libssh').auto() or have_block
909 libssh = dependency('libssh', version: '>=0.8.7',
910 method: 'pkg-config',
911 required: get_option('libssh'),
912 kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400913endif
Thomas Huthe6a52b32021-12-09 15:48:01 +0100914
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400915libbzip2 = not_found
Paolo Bonzini29ba6112020-11-17 13:07:52 +0100916if not get_option('bzip2').auto() or have_block
917 libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
918 required: get_option('bzip2'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100919 kwargs: static_kwargs)
Paolo Bonzini29ba6112020-11-17 13:07:52 +0100920 if libbzip2.found() and not cc.links('''
921 #include <bzlib.h>
922 int main(void) { BZ2_bzlibVersion(); return 0; }''', dependencies: libbzip2)
923 libbzip2 = not_found
924 if get_option('bzip2').enabled()
925 error('could not link libbzip2')
926 else
927 warning('could not link libbzip2, disabling')
928 endif
929 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400930endif
Paolo Bonziniecea3692020-11-17 13:35:28 +0100931
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400932liblzfse = not_found
Paolo Bonziniecea3692020-11-17 13:35:28 +0100933if not get_option('lzfse').auto() or have_block
934 liblzfse = cc.find_library('lzfse', has_headers: ['lzfse.h'],
935 required: get_option('lzfse'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +0100936 kwargs: static_kwargs)
Marc-André Lureau5e5733e2019-08-29 22:34:43 +0400937endif
Paolo Bonziniecea3692020-11-17 13:35:28 +0100938if liblzfse.found() and not cc.links('''
939 #include <lzfse.h>
940 int main(void) { lzfse_decode_scratch_size(); return 0; }''', dependencies: liblzfse)
941 liblzfse = not_found
942 if get_option('lzfse').enabled()
943 error('could not link liblzfse')
944 else
945 warning('could not link liblzfse, disabling')
946 endif
947endif
948
Paolo Bonzini478e9432020-08-17 12:47:55 +0200949oss = not_found
Paolo Bonzini43a363a2021-12-18 16:39:43 +0100950if get_option('oss').allowed() and have_system
Paolo Bonzini87430d52021-10-07 15:06:09 +0200951 if not cc.has_header('sys/soundcard.h')
952 # not found
953 elif targetos == 'netbsd'
954 oss = cc.find_library('ossaudio', required: get_option('oss'),
955 kwargs: static_kwargs)
956 else
957 oss = declare_dependency()
958 endif
959
960 if not oss.found()
961 if get_option('oss').enabled()
962 error('OSS not found')
Paolo Bonzini87430d52021-10-07 15:06:09 +0200963 endif
964 endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200965endif
966dsound = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200967if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
968 if cc.has_header('dsound.h')
969 dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
970 endif
971
972 if not dsound.found()
973 if get_option('dsound').enabled()
974 error('DirectSound not found')
Paolo Bonzini87430d52021-10-07 15:06:09 +0200975 endif
976 endif
Paolo Bonzini478e9432020-08-17 12:47:55 +0200977endif
Paolo Bonzini87430d52021-10-07 15:06:09 +0200978
Paolo Bonzini478e9432020-08-17 12:47:55 +0200979coreaudio = not_found
Paolo Bonzini87430d52021-10-07 15:06:09 +0200980if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
981 coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
982 required: get_option('coreaudio'))
Paolo Bonzini478e9432020-08-17 12:47:55 +0200983endif
Thomas Huth8bc51842021-07-13 13:09:02 +0200984
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400985opengl = not_found
986if 'CONFIG_OPENGL' in config_host
Paolo Bonzinide2d3002020-09-01 08:41:17 -0400987 opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
988 link_args: config_host['OPENGL_LIBS'].split())
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +0400989endif
Thomas Huth8bc51842021-07-13 13:09:02 +0200990gbm = not_found
991if (have_system or have_tools) and (virgl.found() or opengl.found())
992 gbm = dependency('gbm', method: 'pkg-config', required: false,
993 kwargs: static_kwargs)
994endif
Paolo Bonzini1b695472021-01-07 14:02:29 +0100995
Paolo Bonzini57612512021-06-03 11:15:26 +0200996gnutls = not_found
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +0100997gnutls_crypto = not_found
Alyssa Rossabc14fd2021-08-06 14:49:47 +0000998if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +0100999 # For general TLS support our min gnutls matches
1000 # that implied by our platform support matrix
1001 #
1002 # For the crypto backends, we look for a newer
1003 # gnutls:
1004 #
1005 # Version 3.6.8 is needed to get XTS
1006 # Version 3.6.13 is needed to get PBKDF
1007 # Version 3.6.14 is needed to get HW accelerated XTS
1008 #
1009 # If newer enough gnutls isn't available, we can
1010 # still use a different crypto backend to satisfy
1011 # the platform support requirements
1012 gnutls_crypto = dependency('gnutls', version: '>=3.6.14',
1013 method: 'pkg-config',
1014 required: false,
1015 kwargs: static_kwargs)
1016 if gnutls_crypto.found()
1017 gnutls = gnutls_crypto
1018 else
1019 # Our min version if all we need is TLS
1020 gnutls = dependency('gnutls', version: '>=3.5.18',
1021 method: 'pkg-config',
1022 required: get_option('gnutls'),
1023 kwargs: static_kwargs)
1024 endif
Paolo Bonzini57612512021-06-03 11:15:26 +02001025endif
1026
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001027# We prefer use of gnutls for crypto, unless the options
1028# explicitly asked for nettle or gcrypt.
1029#
1030# If gnutls isn't available for crypto, then we'll prefer
1031# gcrypt over nettle for performance reasons.
Paolo Bonzini57612512021-06-03 11:15:26 +02001032gcrypt = not_found
1033nettle = not_found
Daniel P. Berrangé68014042021-07-02 17:00:32 +01001034xts = 'none'
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001035
Paolo Bonzini57612512021-06-03 11:15:26 +02001036if get_option('nettle').enabled() and get_option('gcrypt').enabled()
1037 error('Only one of gcrypt & nettle can be enabled')
Paolo Bonzini57612512021-06-03 11:15:26 +02001038endif
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001039
1040# Explicit nettle/gcrypt request, so ignore gnutls for crypto
1041if get_option('nettle').enabled() or get_option('gcrypt').enabled()
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +01001042 gnutls_crypto = not_found
1043endif
Paolo Bonzini57612512021-06-03 11:15:26 +02001044
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001045if not gnutls_crypto.found()
1046 if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
1047 gcrypt = dependency('libgcrypt', version: '>=1.8',
1048 method: 'config-tool',
1049 required: get_option('gcrypt'),
1050 kwargs: static_kwargs)
1051 # Debian has removed -lgpg-error from libgcrypt-config
1052 # as it "spreads unnecessary dependencies" which in
1053 # turn breaks static builds...
1054 if gcrypt.found() and enable_static
1055 gcrypt = declare_dependency(dependencies: [
1056 gcrypt,
1057 cc.find_library('gpg-error', required: true, kwargs: static_kwargs)])
1058 endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001059 endif
Daniel P. Berrangé8bd09312021-07-02 17:38:33 +01001060 if (not get_option('nettle').auto() or have_system) and not gcrypt.found()
1061 nettle = dependency('nettle', version: '>=3.4',
1062 method: 'pkg-config',
1063 required: get_option('nettle'),
1064 kwargs: static_kwargs)
1065 if nettle.found() and not cc.has_header('nettle/xts.h', dependencies: nettle)
1066 xts = 'private'
1067 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001068 endif
1069endif
1070
1071gtk = not_found
Paolo Bonzini1b695472021-01-07 14:02:29 +01001072gtkx11 = not_found
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001073vte = not_found
Paolo Bonzinic1ec4942021-01-07 14:04:00 +01001074if not get_option('gtk').auto() or (have_system and not cocoa.found())
Paolo Bonzini1b695472021-01-07 14:02:29 +01001075 gtk = dependency('gtk+-3.0', version: '>=3.22.0',
1076 method: 'pkg-config',
1077 required: get_option('gtk'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001078 kwargs: static_kwargs)
Paolo Bonzini1b695472021-01-07 14:02:29 +01001079 if gtk.found()
1080 gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
1081 method: 'pkg-config',
1082 required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001083 kwargs: static_kwargs)
Paolo Bonzini1b695472021-01-07 14:02:29 +01001084 gtk = declare_dependency(dependencies: [gtk, gtkx11])
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001085
1086 if not get_option('vte').auto() or have_system
1087 vte = dependency('vte-2.91',
1088 method: 'pkg-config',
1089 required: get_option('vte'),
1090 kwargs: static_kwargs)
1091 endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001092 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001093endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001094
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001095x11 = not_found
Markus Armbruster9d49bcf2021-05-03 10:40:33 +02001096if gtkx11.found()
Paolo Bonzini1b695472021-01-07 14:02:29 +01001097 x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001098 kwargs: static_kwargs)
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001099endif
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001100vnc = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001101png = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001102jpeg = not_found
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001103sasl = not_found
Paolo Bonzini43a363a2021-12-18 16:39:43 +01001104if get_option('vnc').allowed() and have_system
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001105 vnc = declare_dependency() # dummy dependency
1106 png = dependency('libpng', required: get_option('vnc_png'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001107 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzini8e242b32020-11-23 13:34:02 -05001108 jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001109 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001110 sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'],
1111 required: get_option('vnc_sasl'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001112 kwargs: static_kwargs)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001113 if sasl.found()
1114 sasl = declare_dependency(dependencies: sasl,
1115 compile_args: '-DSTRUCT_IOVEC_DEFINED')
1116 endif
Marc-André Lureau2b1ccdf2019-07-16 23:21:02 +04001117endif
Paolo Bonzini241611e2020-11-17 13:32:34 +01001118
Paolo Bonzini05e391a2021-06-03 11:15:26 +02001119pam = not_found
1120if not get_option('auth_pam').auto() or have_system
1121 pam = cc.find_library('pam', has_headers: ['security/pam_appl.h'],
1122 required: get_option('auth_pam'),
1123 kwargs: static_kwargs)
1124endif
1125if pam.found() and not cc.links('''
1126 #include <stddef.h>
1127 #include <security/pam_appl.h>
1128 int main(void) {
1129 const char *service_name = "qemu";
1130 const char *user = "frank";
1131 const struct pam_conv pam_conv = { 0 };
1132 pam_handle_t *pamh = NULL;
1133 pam_start(service_name, user, &pam_conv, &pamh);
1134 return 0;
1135 }''', dependencies: pam)
1136 pam = not_found
1137 if get_option('auth_pam').enabled()
1138 error('could not link libpam')
1139 else
1140 warning('could not link libpam, disabling')
1141 endif
1142endif
1143
Marc-André Lureau708eab42019-09-03 16:59:33 +04001144snappy = not_found
Paolo Bonzini241611e2020-11-17 13:32:34 +01001145if not get_option('snappy').auto() or have_system
1146 snappy = cc.find_library('snappy', has_headers: ['snappy-c.h'],
1147 required: get_option('snappy'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001148 kwargs: static_kwargs)
Marc-André Lureau708eab42019-09-03 16:59:33 +04001149endif
Paolo Bonzini565174d2021-11-04 14:35:14 +01001150if snappy.found() and not linker.links('''
Paolo Bonzini241611e2020-11-17 13:32:34 +01001151 #include <snappy-c.h>
1152 int main(void) { snappy_max_compressed_length(4096); return 0; }''', dependencies: snappy)
1153 snappy = not_found
1154 if get_option('snappy').enabled()
1155 error('could not link libsnappy')
1156 else
1157 warning('could not link libsnappy, disabling')
1158 endif
Marc-André Lureau708eab42019-09-03 16:59:33 +04001159endif
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001160
Marc-André Lureau708eab42019-09-03 16:59:33 +04001161lzo = not_found
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001162if not get_option('lzo').auto() or have_system
1163 lzo = cc.find_library('lzo2', has_headers: ['lzo/lzo1x.h'],
1164 required: get_option('lzo'),
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001165 kwargs: static_kwargs)
Marc-André Lureau708eab42019-09-03 16:59:33 +04001166endif
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001167if lzo.found() and not cc.links('''
1168 #include <lzo/lzo1x.h>
1169 int main(void) { lzo_version(); return 0; }''', dependencies: lzo)
1170 lzo = not_found
1171 if get_option('lzo').enabled()
1172 error('could not link liblzo2')
1173 else
1174 warning('could not link liblzo2, disabling')
1175 endif
1176endif
1177
Paolo Bonzini488a8c72021-12-21 12:38:27 +01001178numa = not_found
1179if not get_option('numa').auto() or have_system or have_tools
1180 numa = cc.find_library('numa', has_headers: ['numa.h'],
1181 required: get_option('numa'),
1182 kwargs: static_kwargs)
1183endif
1184if numa.found() and not cc.links('''
1185 #include <numa.h>
1186 int main(void) { return numa_available(); }
1187 ''', dependencies: numa)
1188 numa = not_found
1189 if get_option('numa').enabled()
1190 error('could not link numa')
1191 else
1192 warning('could not link numa, disabling')
1193 endif
1194endif
1195
Marc-André Lureau55166232019-07-24 19:16:22 +04001196rdma = not_found
1197if 'CONFIG_RDMA' in config_host
1198 rdma = declare_dependency(link_args: config_host['RDMA_LIBS'].split())
1199endif
Marc-André Lureau582ea952019-08-15 15:15:32 +04001200xen = not_found
1201if 'CONFIG_XEN_BACKEND' in config_host
1202 xen = declare_dependency(compile_args: config_host['XEN_CFLAGS'].split(),
1203 link_args: config_host['XEN_LIBS'].split())
1204endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001205cacard = not_found
Paolo Bonzini5f364c52021-06-03 11:15:26 +02001206if not get_option('smartcard').auto() or have_system
1207 cacard = dependency('libcacard', required: get_option('smartcard'),
1208 version: '>=2.5.1', method: 'pkg-config',
1209 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001210endif
César Belley0a40bcb2020-08-26 13:42:04 +02001211u2f = not_found
1212if have_system
1213 u2f = dependency('u2f-emu', required: get_option('u2f'),
1214 method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001215 kwargs: static_kwargs)
César Belley0a40bcb2020-08-26 13:42:04 +02001216endif
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001217usbredir = not_found
Paolo Bonzini18f31e62021-06-03 11:15:26 +02001218if not get_option('usb_redir').auto() or have_system
1219 usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
1220 version: '>=0.6', method: 'pkg-config',
1221 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001222endif
1223libusb = not_found
Paolo Bonzini90540f32021-06-03 11:15:26 +02001224if not get_option('libusb').auto() or have_system
1225 libusb = dependency('libusb-1.0', required: get_option('libusb'),
1226 version: '>=1.0.13', method: 'pkg-config',
1227 kwargs: static_kwargs)
Paolo Bonzini06677ce2020-08-06 13:07:39 +02001228endif
Paolo Bonzini90540f32021-06-03 11:15:26 +02001229
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001230libpmem = not_found
Paolo Bonzinie36e8c72021-06-03 11:31:35 +02001231if not get_option('libpmem').auto() or have_system
1232 libpmem = dependency('libpmem', required: get_option('libpmem'),
1233 method: 'pkg-config', kwargs: static_kwargs)
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04001234endif
Bruce Rogersc7c91a72020-08-24 09:52:12 -06001235libdaxctl = not_found
Paolo Bonzini83ef1682021-06-03 11:31:35 +02001236if not get_option('libdaxctl').auto() or have_system
1237 libdaxctl = dependency('libdaxctl', required: get_option('libdaxctl'),
1238 version: '>=57', method: 'pkg-config',
1239 kwargs: static_kwargs)
Bruce Rogersc7c91a72020-08-24 09:52:12 -06001240endif
Marc-André Lureau8ce0a452020-08-28 15:07:20 +04001241tasn1 = not_found
Paolo Bonziniba7ed402021-06-03 11:15:26 +02001242if gnutls.found()
1243 tasn1 = dependency('libtasn1',
1244 method: 'pkg-config',
1245 kwargs: static_kwargs)
Marc-André Lureau8ce0a452020-08-28 15:07:20 +04001246endif
Marc-André Lureauaf04e892020-08-28 15:07:25 +04001247keyutils = dependency('libkeyutils', required: false,
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001248 method: 'pkg-config', kwargs: static_kwargs)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04001249
Marc-André Lureau3909def2020-08-28 15:07:33 +04001250has_gettid = cc.has_function('gettid')
1251
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06001252# libselinux
1253selinux = dependency('libselinux',
1254 required: get_option('selinux'),
1255 method: 'pkg-config', kwargs: static_kwargs)
1256
Paolo Bonziniaa087962020-09-01 11:15:30 -04001257# Malloc tests
1258
1259malloc = []
1260if get_option('malloc') == 'system'
1261 has_malloc_trim = \
Paolo Bonzini43a363a2021-12-18 16:39:43 +01001262 get_option('malloc_trim').allowed() and \
Paolo Bonziniaa087962020-09-01 11:15:30 -04001263 cc.links('''#include <malloc.h>
1264 int main(void) { malloc_trim(0); return 0; }''')
1265else
1266 has_malloc_trim = false
1267 malloc = cc.find_library(get_option('malloc'), required: true)
1268endif
1269if not has_malloc_trim and get_option('malloc_trim').enabled()
1270 if get_option('malloc') == 'system'
1271 error('malloc_trim not available on this platform.')
1272 else
1273 error('malloc_trim not available with non-libc memory allocator')
1274 endif
1275endif
1276
Max Reitz84e319a2020-11-02 17:18:55 +01001277# Check whether the glibc provides statx()
1278
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001279gnu_source_prefix = '''
Max Reitz84e319a2020-11-02 17:18:55 +01001280 #ifndef _GNU_SOURCE
1281 #define _GNU_SOURCE
1282 #endif
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001283'''
1284statx_test = gnu_source_prefix + '''
Max Reitz84e319a2020-11-02 17:18:55 +01001285 #include <sys/stat.h>
1286 int main(void) {
1287 struct statx statxbuf;
1288 statx(0, "", 0, STATX_BASIC_STATS, &statxbuf);
1289 return 0;
1290 }'''
1291
1292has_statx = cc.links(statx_test)
1293
Paolo Bonzinia436d6d2021-12-18 16:39:43 +01001294have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
1295 .require(targetos == 'linux',
1296 error_message: 'vhost_user_blk_server requires linux') \
1297 .require('CONFIG_VHOST_USER' in config_host,
1298 error_message: 'vhost_user_blk_server requires vhost-user support') \
1299 .disable_auto_if(not have_system) \
1300 .allowed()
Daniele Buono9e62ba42020-12-04 18:06:14 -05001301
Max Reitzdf4ea702020-10-27 20:05:46 +01001302if get_option('fuse').disabled() and get_option('fuse_lseek').enabled()
1303 error('Cannot enable fuse-lseek while fuse is disabled')
1304endif
1305
Max Reitza484a712020-10-27 20:05:41 +01001306fuse = dependency('fuse3', required: get_option('fuse'),
1307 version: '>=3.1', method: 'pkg-config',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01001308 kwargs: static_kwargs)
Max Reitza484a712020-10-27 20:05:41 +01001309
Max Reitzdf4ea702020-10-27 20:05:46 +01001310fuse_lseek = not_found
Paolo Bonzini43a363a2021-12-18 16:39:43 +01001311if get_option('fuse_lseek').allowed()
Max Reitzdf4ea702020-10-27 20:05:46 +01001312 if fuse.version().version_compare('>=3.8')
1313 # Dummy dependency
1314 fuse_lseek = declare_dependency()
1315 elif get_option('fuse_lseek').enabled()
1316 if fuse.found()
1317 error('fuse-lseek requires libfuse >=3.8, found ' + fuse.version())
1318 else
1319 error('fuse-lseek requires libfuse, which was not found')
1320 endif
1321 endif
1322endif
1323
Andrew Melnychenko46627f42021-05-14 14:48:32 +03001324# libbpf
1325libbpf = dependency('libbpf', required: get_option('bpf'), method: 'pkg-config')
1326if libbpf.found() and not cc.links('''
1327 #include <bpf/libbpf.h>
1328 int main(void)
1329 {
1330 bpf_object__destroy_skeleton(NULL);
1331 return 0;
1332 }''', dependencies: libbpf)
1333 libbpf = not_found
1334 if get_option('bpf').enabled()
1335 error('libbpf skeleton test failed')
1336 else
1337 warning('libbpf skeleton test failed, disabling')
1338 endif
1339endif
1340
Paolo Bonzini87430d52021-10-07 15:06:09 +02001341#################
1342# config-host.h #
1343#################
1344
1345audio_drivers_selected = []
1346if have_system
1347 audio_drivers_available = {
1348 'alsa': alsa.found(),
1349 'coreaudio': coreaudio.found(),
1350 'dsound': dsound.found(),
1351 'jack': jack.found(),
1352 'oss': oss.found(),
1353 'pa': pulse.found(),
1354 'sdl': sdl.found(),
1355 }
Paolo Bonzinie5424a22021-10-07 15:06:10 +02001356 foreach k, v: audio_drivers_available
1357 config_host_data.set('CONFIG_AUDIO_' + k.to_upper(), v)
1358 endforeach
Paolo Bonzini87430d52021-10-07 15:06:09 +02001359
1360 # Default to native drivers first, OSS second, SDL third
1361 audio_drivers_priority = \
1362 [ 'pa', 'coreaudio', 'dsound', 'oss' ] + \
1363 (targetos == 'linux' ? [] : [ 'sdl' ])
1364 audio_drivers_default = []
1365 foreach k: audio_drivers_priority
1366 if audio_drivers_available[k]
1367 audio_drivers_default += k
1368 endif
1369 endforeach
1370
1371 foreach k: get_option('audio_drv_list')
1372 if k == 'default'
1373 audio_drivers_selected += audio_drivers_default
1374 elif not audio_drivers_available[k]
1375 error('Audio driver "@0@" not available.'.format(k))
1376 else
1377 audio_drivers_selected += k
1378 endif
1379 endforeach
1380endif
Paolo Bonzini87430d52021-10-07 15:06:09 +02001381config_host_data.set('CONFIG_AUDIO_DRIVERS',
1382 '"' + '", "'.join(audio_drivers_selected) + '", ')
1383
Daniele Buono9e62ba42020-12-04 18:06:14 -05001384if get_option('cfi')
1385 cfi_flags=[]
1386 # Check for dependency on LTO
1387 if not get_option('b_lto')
1388 error('Selected Control-Flow Integrity but LTO is disabled')
1389 endif
1390 if config_host.has_key('CONFIG_MODULES')
1391 error('Selected Control-Flow Integrity is not compatible with modules')
1392 endif
1393 # Check for cfi flags. CFI requires LTO so we can't use
1394 # get_supported_arguments, but need a more complex "compiles" which allows
1395 # custom arguments
1396 if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
1397 args: ['-flto', '-fsanitize=cfi-icall'] )
1398 cfi_flags += '-fsanitize=cfi-icall'
1399 else
1400 error('-fsanitize=cfi-icall is not supported by the compiler')
1401 endif
1402 if cc.compiles('int main () { return 0; }',
1403 name: '-fsanitize-cfi-icall-generalize-pointers',
1404 args: ['-flto', '-fsanitize=cfi-icall',
1405 '-fsanitize-cfi-icall-generalize-pointers'] )
1406 cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
1407 else
1408 error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
1409 endif
1410 if get_option('cfi_debug')
1411 if cc.compiles('int main () { return 0; }',
1412 name: '-fno-sanitize-trap=cfi-icall',
1413 args: ['-flto', '-fsanitize=cfi-icall',
1414 '-fno-sanitize-trap=cfi-icall'] )
1415 cfi_flags += '-fno-sanitize-trap=cfi-icall'
1416 else
1417 error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
1418 endif
1419 endif
Marc-André Lureau5fc06172021-01-14 16:56:02 +04001420 add_global_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
1421 add_global_link_arguments(cfi_flags, native: false, language: ['c', 'cpp', 'objc'])
Daniele Buono9e62ba42020-12-04 18:06:14 -05001422endif
1423
Joelle van Dyne14176c82021-03-15 11:03:38 -07001424have_host_block_device = (targetos != 'darwin' or
1425 cc.has_header('IOKit/storage/IOMedia.h'))
1426
Paolo Bonzinia436d6d2021-12-18 16:39:43 +01001427# FIXME enable_modules shouldn't be necessary, but: https://github.com/mesonbuild/meson/issues/8333
1428dbus_display = get_option('dbus_display') \
1429 .require(gio.version().version_compare('>=2.64'),
1430 error_message: '-display dbus requires glib>=2.64') \
1431 .require(enable_modules,
1432 error_message: '-display dbus requires --enable-modules') \
1433 .require(config_host.has_key('GDBUS_CODEGEN'),
1434 error_message: '-display dbus requires gdbus-codegen') \
1435 .allowed()
Marc-André Lureau142ca622021-07-15 11:53:53 +04001436
Paolo Bonzinia436d6d2021-12-18 16:39:43 +01001437have_virtfs = get_option('virtfs') \
1438 .require(targetos == 'linux',
1439 error_message: 'virtio-9p (virtfs) requires Linux') \
1440 .require(libattr.found() and libcap_ng.found(),
1441 error_message: 'virtio-9p (virtfs) requires libcap-ng-devel and libattr-devel') \
1442 .disable_auto_if(not have_tools and not have_system) \
1443 .allowed()
Paolo Bonzini69202b42020-11-17 14:46:21 +01001444
Philippe Mathieu-Daudé3a489d32021-01-20 16:15:39 +01001445have_virtfs_proxy_helper = have_virtfs and have_tools
1446
Paolo Bonzini9c29b742021-10-07 15:08:14 +02001447foreach k : get_option('trace_backends')
1448 config_host_data.set('CONFIG_TRACE_' + k.to_upper(), true)
1449endforeach
1450config_host_data.set_quoted('CONFIG_TRACE_FILE', get_option('trace_file'))
1451
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04001452config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
1453config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
1454config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
1455config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
1456config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
1457config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
1458config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
1459config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
1460config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
1461config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
1462config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
1463config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
1464
Paolo Bonzini35acbb32021-10-13 13:43:36 +02001465have_slirp_smbd = get_option('slirp_smbd') \
1466 .require(targetos != 'windows', error_message: 'Host smbd not supported on this platform.') \
1467 .allowed()
1468if have_slirp_smbd
1469 smbd_path = get_option('smbd')
1470 if smbd_path == ''
1471 smbd_path = (targetos == 'solaris' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
1472 endif
1473 config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path)
1474endif
1475
Paolo Bonzini823eb012021-11-08 14:18:17 +01001476config_host_data.set('HOST_' + host_arch.to_upper(), 1)
1477
Paolo Bonzinif7f2d652020-11-17 14:45:24 +01001478config_host_data.set('CONFIG_ATTR', libattr.found())
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02001479config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools'))
Paolo Bonzini8c6d4ff2020-11-17 13:02:17 +01001480config_host_data.set('CONFIG_BRLAPI', brlapi.found())
Paolo Bonzinib4e312e2020-09-01 11:28:59 -04001481config_host_data.set('CONFIG_COCOA', cocoa.found())
Paolo Bonzini537b7242021-10-07 15:08:12 +02001482config_host_data.set('CONFIG_FUZZ', get_option('fuzzing'))
Paolo Bonziniaf2bb992021-10-07 15:08:17 +02001483config_host_data.set('CONFIG_GCOV', get_option('b_coverage'))
Paolo Bonzinif01496a2020-09-16 17:54:14 +02001484config_host_data.set('CONFIG_LIBUDEV', libudev.found())
Paolo Bonzini0c32a0a2020-11-17 13:11:25 +01001485config_host_data.set('CONFIG_LZO', lzo.found())
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02001486config_host_data.set('CONFIG_MPATH', mpathpersist.found())
1487config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
Paolo Bonzinif9cd86f2020-11-17 12:43:15 +01001488config_host_data.set('CONFIG_CURL', curl.found())
Yonggang Luo5285e592020-10-13 07:43:48 +08001489config_host_data.set('CONFIG_CURSES', curses.found())
Thomas Huth8bc51842021-07-13 13:09:02 +02001490config_host_data.set('CONFIG_GBM', gbm.found())
Paolo Bonzini08821ca2020-11-17 13:01:26 +01001491config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
1492if glusterfs.found()
1493 config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
1494 config_host_data.set('CONFIG_GLUSTERFS_DISCARD', glusterfs.version().version_compare('>=5'))
1495 config_host_data.set('CONFIG_GLUSTERFS_FALLOCATE', glusterfs.version().version_compare('>=6'))
1496 config_host_data.set('CONFIG_GLUSTERFS_ZEROFILL', glusterfs.version().version_compare('>=6'))
1497 config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
1498 config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
1499endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01001500config_host_data.set('CONFIG_GTK', gtk.found())
Paolo Bonzinic23d7b42021-06-03 11:31:35 +02001501config_host_data.set('CONFIG_VTE', vte.found())
Paolo Bonzinif7f2d652020-11-17 14:45:24 +01001502config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
Paolo Bonzini727c8bb2020-11-17 14:46:58 +01001503config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
Andrew Melnychenko46627f42021-05-14 14:48:32 +03001504config_host_data.set('CONFIG_EBPF', libbpf.found())
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001505config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
Paolo Bonzini9db405a2020-11-17 13:11:25 +01001506config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
Paolo Bonzini30045c02020-11-17 13:11:25 +01001507config_host_data.set('CONFIG_LIBNFS', libnfs.found())
Thomas Huthe6a52b32021-12-09 15:48:01 +01001508config_host_data.set('CONFIG_LIBSSH', libssh.found())
Paolo Bonziniff66f3e2021-10-07 15:08:20 +02001509config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001510config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
1511config_host_data.set('CONFIG_LIBPMEM', libpmem.found())
Paolo Bonzini488a8c72021-12-21 12:38:27 +01001512config_host_data.set('CONFIG_NUMA', numa.found())
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02001513config_host_data.set('CONFIG_PROFILER', get_option('profiler'))
Paolo Bonzinifabd1e92020-11-17 13:11:25 +01001514config_host_data.set('CONFIG_RBD', rbd.found())
Paolo Bonzini35be72b2020-02-06 14:17:15 +01001515config_host_data.set('CONFIG_SDL', sdl.found())
1516config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
Paolo Bonzini90835c22020-11-17 14:22:24 +01001517config_host_data.set('CONFIG_SECCOMP', seccomp.found())
Paolo Bonzini241611e2020-11-17 13:32:34 +01001518config_host_data.set('CONFIG_SNAPPY', snappy.found())
Paolo Bonzini0d04c4c2021-12-21 12:38:27 +01001519config_host_data.set('CONFIG_TPM', have_tpm)
Paolo Bonzini90540f32021-06-03 11:15:26 +02001520config_host_data.set('CONFIG_USB_LIBUSB', libusb.found())
Paolo Bonzinie1723992021-10-07 15:08:21 +02001521config_host_data.set('CONFIG_VDE', vde.found())
Stefan Hajnoczie5e856c2020-11-10 17:11:19 +00001522config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server)
Paolo Bonzinia0b93232020-02-06 15:48:52 +01001523config_host_data.set('CONFIG_VNC', vnc.found())
1524config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
1525config_host_data.set('CONFIG_VNC_PNG', png.found())
1526config_host_data.set('CONFIG_VNC_SASL', sasl.found())
Paolo Bonzini69202b42020-11-17 14:46:21 +01001527config_host_data.set('CONFIG_VIRTFS', have_virtfs)
Paolo Bonzini63a7f852021-07-08 13:50:06 +02001528config_host_data.set('CONFIG_VTE', vte.found())
Laurent Vivier4113f4c2020-08-24 17:24:29 +02001529config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
Marc-André Lureauaf04e892020-08-28 15:07:25 +04001530config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
Marc-André Lureau3909def2020-08-28 15:07:33 +04001531config_host_data.set('CONFIG_GETTID', has_gettid)
Paolo Bonzini57612512021-06-03 11:15:26 +02001532config_host_data.set('CONFIG_GNUTLS', gnutls.found())
Daniel P. Berrangécc4c7c72021-06-30 17:20:02 +01001533config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found())
Paolo Bonzini57612512021-06-03 11:15:26 +02001534config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
1535config_host_data.set('CONFIG_NETTLE', nettle.found())
1536config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts == 'private')
Paolo Bonziniaa087962020-09-01 11:15:30 -04001537config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
Max Reitz84e319a2020-11-02 17:18:55 +01001538config_host_data.set('CONFIG_STATX', has_statx)
Paolo Bonzinib1def332020-11-17 13:37:39 +01001539config_host_data.set('CONFIG_ZSTD', zstd.found())
Max Reitza484a712020-10-27 20:05:41 +01001540config_host_data.set('CONFIG_FUSE', fuse.found())
Max Reitzdf4ea702020-10-27 20:05:46 +01001541config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001542config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found())
Marc-André Lureauddece462021-10-06 14:18:09 +04001543if spice_protocol.found()
1544config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version().split('.')[0])
1545config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version().split('.')[1])
1546config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version().split('.')[2])
1547endif
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001548config_host_data.set('CONFIG_SPICE', spice.found())
Paolo Bonzini9d710372021-01-07 13:54:22 +01001549config_host_data.set('CONFIG_X11', x11.found())
Marc-André Lureau142ca622021-07-15 11:53:53 +04001550config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display)
Daniele Buono9e62ba42020-12-04 18:06:14 -05001551config_host_data.set('CONFIG_CFI', get_option('cfi'))
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06001552config_host_data.set('CONFIG_SELINUX', selinux.found())
Paolo Bonzini859aef02020-08-04 18:14:26 +02001553config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
1554config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
1555config_host_data.set('QEMU_VERSION_MINOR', meson.project_version().split('.')[1])
1556config_host_data.set('QEMU_VERSION_MICRO', meson.project_version().split('.')[2])
1557
Paolo Bonzinia6305082021-10-07 15:08:15 +02001558config_host_data.set_quoted('CONFIG_HOST_DSOSUF', host_dsosuf)
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001559config_host_data.set('HAVE_HOST_BLOCK_DEVICE', have_host_block_device)
Paolo Bonzini269506d2021-10-07 15:08:16 +02001560config_host_data.set('HOST_WORDS_BIGENDIAN', host_machine.endian() == 'big')
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001561
Paolo Bonzini728c0a22021-10-13 11:52:03 +02001562have_coroutine_pool = get_option('coroutine_pool')
1563if get_option('debug_stack_usage') and have_coroutine_pool
1564 message('Disabling coroutine pool to measure stack usage')
1565 have_coroutine_pool = false
1566endif
1567config_host_data.set10('CONFIG_COROUTINE_POOL', have_coroutine_pool)
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02001568config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex'))
Paolo Bonzini728c0a22021-10-13 11:52:03 +02001569config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage'))
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02001570config_host_data.set('CONFIG_GPROF', get_option('gprof'))
Paolo Bonzini406523f2021-10-13 11:43:54 +02001571config_host_data.set('CONFIG_LIVE_BLOCK_MIGRATION', get_option('live_block_migration').allowed())
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02001572config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug'))
Paolo Bonzini406523f2021-10-13 11:43:54 +02001573config_host_data.set('CONFIG_REPLICATION', get_option('live_block_migration').allowed())
1574
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001575# has_header
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001576config_host_data.set('CONFIG_EPOLL', cc.has_header('sys/epoll.h'))
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001577config_host_data.set('CONFIG_LINUX_MAGIC_H', cc.has_header('linux/magic.h'))
1578config_host_data.set('CONFIG_VALGRIND_H', cc.has_header('valgrind/valgrind.h'))
Thomas Huth48f670e2020-11-18 18:10:52 +01001579config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
Thomas Huth2964be52020-11-18 18:10:49 +01001580config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
Thomas Huth2802d912020-11-18 18:10:48 +01001581config_host_data.set('HAVE_PTY_H', cc.has_header('pty.h'))
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001582config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
Thomas Huthded5d782020-11-14 11:10:11 +01001583config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
Thomas Huth4a9d5f82020-11-18 18:10:51 +01001584config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
Thomas Huthded5d782020-11-14 11:10:11 +01001585
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001586# has_function
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001587config_host_data.set('CONFIG_ACCEPT4', cc.has_function('accept4'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001588config_host_data.set('CONFIG_CLOCK_ADJTIME', cc.has_function('clock_adjtime'))
1589config_host_data.set('CONFIG_DUP3', cc.has_function('dup3'))
1590config_host_data.set('CONFIG_FALLOCATE', cc.has_function('fallocate'))
1591config_host_data.set('CONFIG_POSIX_FALLOCATE', cc.has_function('posix_fallocate'))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001592config_host_data.set('CONFIG_POSIX_MEMALIGN', cc.has_function('posix_memalign'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001593config_host_data.set('CONFIG_PPOLL', cc.has_function('ppoll'))
Peter Maydell2b9f74e2021-01-26 15:58:46 +00001594config_host_data.set('CONFIG_PREADV', cc.has_function('preadv', prefix: '#include <sys/uio.h>'))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001595config_host_data.set('CONFIG_SEM_TIMEDWAIT', cc.has_function('sem_timedwait', dependencies: threads))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001596config_host_data.set('CONFIG_SENDFILE', cc.has_function('sendfile'))
1597config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_function('unshare'))
1598config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
1599config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
1600config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001601config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001602config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001603config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
Paolo Bonzini69d8de72021-06-03 11:56:11 +02001604config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
Li Zhijian911965a2021-09-10 15:02:55 +08001605if rdma.found()
1606 config_host_data.set('HAVE_IBV_ADVISE_MR',
1607 cc.has_function('ibv_advise_mr',
1608 args: config_host['RDMA_LIBS'].split(),
1609 prefix: '#include <infiniband/verbs.h>'))
1610endif
Peter Maydell2b9f74e2021-01-26 15:58:46 +00001611
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001612# has_header_symbol
1613config_host_data.set('CONFIG_BYTESWAP_H',
1614 cc.has_header_symbol('byteswap.h', 'bswap_32'))
1615config_host_data.set('CONFIG_EPOLL_CREATE1',
1616 cc.has_header_symbol('sys/epoll.h', 'epoll_create1'))
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001617config_host_data.set('CONFIG_HAS_ENVIRON',
1618 cc.has_header_symbol('unistd.h', 'environ', prefix: gnu_source_prefix))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001619config_host_data.set('CONFIG_FALLOCATE_PUNCH_HOLE',
1620 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_PUNCH_HOLE') and
1621 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_KEEP_SIZE'))
1622config_host_data.set('CONFIG_FALLOCATE_ZERO_RANGE',
1623 cc.has_header_symbol('linux/falloc.h', 'FALLOC_FL_ZERO_RANGE'))
1624config_host_data.set('CONFIG_FIEMAP',
1625 cc.has_header('linux/fiemap.h') and
1626 cc.has_header_symbol('linux/fs.h', 'FS_IOC_FIEMAP'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001627config_host_data.set('CONFIG_GETRANDOM',
1628 cc.has_function('getrandom') and
1629 cc.has_header_symbol('sys/random.h', 'GRND_NONBLOCK'))
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001630config_host_data.set('CONFIG_INOTIFY',
1631 cc.has_header_symbol('sys/inotify.h', 'inotify_init'))
1632config_host_data.set('CONFIG_INOTIFY1',
1633 cc.has_header_symbol('sys/inotify.h', 'inotify_init1'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001634config_host_data.set('CONFIG_MACHINE_BSWAP_H',
1635 cc.has_header_symbol('machine/bswap.h', 'bswap32',
1636 prefix: '''#include <sys/endian.h>
1637 #include <sys/types.h>'''))
1638config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK',
1639 cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK'))
Paolo Bonzinibe7e89f2021-06-03 12:02:00 +02001640config_host_data.set('CONFIG_RTNETLINK',
1641 cc.has_header_symbol('linux/rtnetlink.h', 'IFLA_PROTO_DOWN'))
1642config_host_data.set('CONFIG_SYSMACROS',
1643 cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001644config_host_data.set('HAVE_OPTRESET',
1645 cc.has_header_symbol('getopt.h', 'optreset'))
Marc-André Lureau653163f2021-09-07 16:19:13 +04001646config_host_data.set('HAVE_IPPROTO_MPTCP',
1647 cc.has_header_symbol('netinet/in.h', 'IPPROTO_MPTCP'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001648
1649# has_member
1650config_host_data.set('HAVE_SIGEV_NOTIFY_THREAD_ID',
1651 cc.has_member('struct sigevent', 'sigev_notify_thread_id',
1652 prefix: '#include <signal.h>'))
Paolo Bonzinied3b3f12021-06-03 12:14:48 +02001653config_host_data.set('HAVE_STRUCT_STAT_ST_ATIM',
1654 cc.has_member('struct stat', 'st_atim',
1655 prefix: '#include <sys/stat.h>'))
Paolo Bonzinie66420a2021-06-03 12:10:05 +02001656
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001657# has_type
1658config_host_data.set('CONFIG_IOVEC',
1659 cc.has_type('struct iovec',
1660 prefix: '#include <sys/uio.h>'))
1661config_host_data.set('HAVE_UTMPX',
1662 cc.has_type('struct utmpx',
1663 prefix: '#include <utmpx.h>'))
1664
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001665config_host_data.set('CONFIG_EVENTFD', cc.links('''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001666 #include <sys/eventfd.h>
1667 int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001668config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001669 #include <unistd.h>
1670 int main(void) {
1671 #if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
1672 return fdatasync(0);
1673 #else
1674 #error Not supported
1675 #endif
1676 }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001677config_host_data.set('CONFIG_MADVISE', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001678 #include <sys/types.h>
1679 #include <sys/mman.h>
1680 #include <stddef.h>
1681 int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001682config_host_data.set('CONFIG_MEMFD', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001683 #include <sys/mman.h>
1684 int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001685config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
Paolo Bonzinid47a8b32021-06-03 12:02:00 +02001686 #include <fcntl.h>
1687 #if !defined(AT_EMPTY_PATH)
1688 # error missing definition
1689 #else
1690 int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
1691 #endif'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001692config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + '''
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001693 #include <unistd.h>
1694 #include <fcntl.h>
1695
1696 int main(void)
1697 {
1698 int pipefd[2];
1699 return pipe2(pipefd, O_CLOEXEC);
1700 }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001701config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001702 #include <sys/mman.h>
1703 #include <stddef.h>
1704 int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }'''))
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001705
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001706config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_prefix + '''
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001707 #include <pthread.h>
1708
1709 static void *f(void *p) { return NULL; }
1710 int main(void)
1711 {
1712 pthread_t thread;
1713 pthread_create(&thread, 0, f, 0);
1714 pthread_setname_np(thread, "QEMU");
1715 return 0;
1716 }''', dependencies: threads))
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001717config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_prefix + '''
Paolo Bonzini10f6b232021-10-07 15:08:19 +02001718 #include <pthread.h>
1719
1720 static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
1721 int main(void)
1722 {
1723 pthread_t thread;
1724 pthread_create(&thread, 0, f, 0);
1725 return 0;
1726 }''', dependencies: threads))
1727
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001728config_host_data.set('CONFIG_SIGNALFD', cc.links(gnu_source_prefix + '''
Kacper Słomiński6bd17dc2021-09-05 03:16:22 +02001729 #include <sys/signalfd.h>
1730 #include <stddef.h>
1731 int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }'''))
Paolo Bonzini904ad5e2021-07-07 16:35:26 +02001732config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + '''
Paolo Bonzinia620fbe2021-06-03 13:04:47 +02001733 #include <unistd.h>
1734 #include <fcntl.h>
1735 #include <limits.h>
1736
1737 int main(void)
1738 {
1739 int len, fd = 0;
1740 len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK);
1741 splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE);
1742 return 0;
1743 }'''))
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001744
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001745config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + '''
1746 #include <sys/mman.h>
1747 int main(int argc, char *argv[]) {
1748 return mlockall(MCL_FUTURE);
1749 }'''))
1750
Thomas Hutheea94532021-10-28 20:59:08 +02001751have_l2tpv3 = false
Paolo Bonzini43a363a2021-12-18 16:39:43 +01001752if get_option('l2tpv3').allowed() and have_system
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001753 have_l2tpv3 = cc.has_type('struct mmsghdr',
1754 prefix: gnu_source_prefix + '''
1755 #include <sys/socket.h>
1756 #include <linux/ip.h>''')
Thomas Hutheea94532021-10-28 20:59:08 +02001757endif
1758config_host_data.set('CONFIG_L2TPV3', have_l2tpv3)
1759
Paolo Bonzini837b84b2021-10-07 15:08:22 +02001760have_netmap = false
Paolo Bonzini43a363a2021-12-18 16:39:43 +01001761if get_option('netmap').allowed() and have_system
Paolo Bonzini837b84b2021-10-07 15:08:22 +02001762 have_netmap = cc.compiles('''
1763 #include <inttypes.h>
1764 #include <net/if.h>
1765 #include <net/netmap.h>
1766 #include <net/netmap_user.h>
1767 #if (NETMAP_API < 11) || (NETMAP_API > 15)
1768 #error
1769 #endif
1770 int main(void) { return 0; }''')
1771 if not have_netmap and get_option('netmap').enabled()
1772 error('Netmap headers not available')
1773 endif
1774endif
1775config_host_data.set('CONFIG_NETMAP', have_netmap)
1776
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001777# Work around a system header bug with some kernel/XFS header
1778# versions where they both try to define 'struct fsxattr':
1779# xfs headers will not try to redefine structs from linux headers
1780# if this macro is set.
1781config_host_data.set('HAVE_FSXATTR', cc.links('''
Paolo Bonzini6a23f812021-11-16 08:28:29 +01001782 #include <linux/fs.h>
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001783 struct fsxattr foo;
1784 int main(void) {
1785 return 0;
1786 }'''))
1787
Paolo Bonzinie46bd552021-06-03 11:57:04 +02001788# Some versions of Mac OS X incorrectly define SIZE_MAX
1789config_host_data.set('HAVE_BROKEN_SIZE_MAX', not cc.compiles('''
1790 #include <stdint.h>
1791 #include <stdio.h>
1792 int main(int argc, char *argv[]) {
1793 return printf("%zu", SIZE_MAX);
1794 }''', args: ['-Werror']))
1795
Paolo Bonzinibd87a362021-10-07 15:08:25 +02001796# See if 64-bit atomic operations are supported.
1797# Note that without __atomic builtins, we can only
1798# assume atomic loads/stores max at pointer size.
1799config_host_data.set('CONFIG_ATOMIC64', cc.links('''
1800 #include <stdint.h>
1801 int main(void)
1802 {
1803 uint64_t x = 0, y = 0;
1804 y = __atomic_load_n(&x, __ATOMIC_RELAXED);
1805 __atomic_store_n(&x, y, __ATOMIC_RELAXED);
1806 __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
1807 __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
1808 __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
1809 return 0;
1810 }'''))
1811
1812config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
1813 #include <sys/auxv.h>
1814 int main(void) {
1815 return getauxval(AT_HWCAP) == 0;
1816 }'''))
1817
Paolo Bonzini622753d2021-11-08 13:38:58 +01001818have_cpuid_h = cc.links('''
1819 #include <cpuid.h>
1820 int main(void) {
1821 unsigned a, b, c, d;
1822 unsigned max = __get_cpuid_max(0, 0);
1823
1824 if (max >= 1) {
1825 __cpuid(1, a, b, c, d);
1826 }
1827
1828 if (max >= 7) {
1829 __cpuid_count(7, 0, a, b, c, d);
1830 }
1831
1832 return 0;
1833 }''')
1834config_host_data.set('CONFIG_CPUID_H', have_cpuid_h)
1835
1836config_host_data.set('CONFIG_AVX2_OPT', get_option('avx2') \
1837 .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX2') \
1838 .require(cc.links('''
1839 #pragma GCC push_options
1840 #pragma GCC target("avx2")
1841 #include <cpuid.h>
1842 #include <immintrin.h>
1843 static int bar(void *a) {
1844 __m256i x = *(__m256i *)a;
1845 return _mm256_testz_si256(x, x);
1846 }
1847 int main(int argc, char *argv[]) { return bar(argv[0]); }
1848 '''), error_message: 'AVX2 not available').allowed())
1849
1850config_host_data.set('CONFIG_AVX512F_OPT', get_option('avx512f') \
1851 .require(have_cpuid_h, error_message: 'cpuid.h not available, cannot enable AVX512F') \
1852 .require(cc.links('''
1853 #pragma GCC push_options
1854 #pragma GCC target("avx512f")
1855 #include <cpuid.h>
1856 #include <immintrin.h>
1857 static int bar(void *a) {
1858 __m512i x = *(__m512i *)a;
1859 return _mm512_test_epi64_mask(x, x);
1860 }
1861 int main(int argc, char *argv[]) { return bar(argv[0]); }
1862 '''), error_message: 'AVX512F not available').allowed())
1863
Paolo Bonzinib87df902021-11-08 13:52:11 +01001864if get_option('membarrier').disabled()
1865 have_membarrier = false
1866elif targetos == 'windows'
1867 have_membarrier = true
1868elif targetos == 'linux'
1869 have_membarrier = cc.compiles('''
1870 #include <linux/membarrier.h>
1871 #include <sys/syscall.h>
1872 #include <unistd.h>
1873 #include <stdlib.h>
1874 int main(void) {
1875 syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, 0);
1876 syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0);
1877 exit(0);
1878 }''')
1879endif
1880config_host_data.set('CONFIG_MEMBARRIER', get_option('membarrier') \
1881 .require(have_membarrier, error_message: 'membarrier system call not available') \
1882 .allowed())
1883
Paolo Bonzini34b52612021-11-08 14:02:42 +01001884have_afalg = get_option('crypto_afalg') \
1885 .require(cc.compiles(gnu_source_prefix + '''
1886 #include <errno.h>
1887 #include <sys/types.h>
1888 #include <sys/socket.h>
1889 #include <linux/if_alg.h>
1890 int main(void) {
1891 int sock;
1892 sock = socket(AF_ALG, SOCK_SEQPACKET, 0);
1893 return sock;
1894 }
1895 '''), error_message: 'AF_ALG requested but could not be detected').allowed()
1896config_host_data.set('CONFIG_AF_ALG', have_afalg)
1897
Paolo Bonzinibd87a362021-10-07 15:08:25 +02001898config_host_data.set('CONFIG_AF_VSOCK', cc.compiles(gnu_source_prefix + '''
1899 #include <errno.h>
1900 #include <sys/types.h>
1901 #include <sys/socket.h>
1902 #if !defined(AF_VSOCK)
1903 # error missing AF_VSOCK flag
1904 #endif
1905 #include <linux/vm_sockets.h>
1906 int main(void) {
1907 int sock, ret;
1908 struct sockaddr_vm svm;
1909 socklen_t len = sizeof(svm);
1910 sock = socket(AF_VSOCK, SOCK_STREAM, 0);
1911 ret = getpeername(sock, (struct sockaddr *)&svm, &len);
1912 if ((ret == -1) && (errno == ENOTCONN)) {
1913 return 0;
1914 }
1915 return -1;
1916 }'''))
1917
Paolo Bonzinia76a1f62021-10-13 10:04:24 +02001918ignored = ['CONFIG_QEMU_INTERP_PREFIX', # actually per-target
1919 'HAVE_GDB_BIN']
Paolo Bonzini87430d52021-10-07 15:06:09 +02001920arrays = ['CONFIG_BDRV_RW_WHITELIST', 'CONFIG_BDRV_RO_WHITELIST']
Paolo Bonzinia6305082021-10-07 15:08:15 +02001921strings = ['CONFIG_IASL']
Paolo Bonzini859aef02020-08-04 18:14:26 +02001922foreach k, v: config_host
Paolo Bonzini765686d2020-09-18 06:37:21 -04001923 if ignored.contains(k)
1924 # do nothing
1925 elif arrays.contains(k)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001926 if v != ''
1927 v = '"' + '", "'.join(v.split()) + '", '
1928 endif
1929 config_host_data.set(k, v)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001930 elif strings.contains(k)
Paolo Bonzini859aef02020-08-04 18:14:26 +02001931 config_host_data.set_quoted(k, v)
Paolo Bonzini96a63ae2021-10-07 15:08:18 +02001932 elif k.startswith('CONFIG_')
Paolo Bonzini859aef02020-08-04 18:14:26 +02001933 config_host_data.set(k, v == 'y' ? 1 : v)
1934 endif
1935endforeach
Paolo Bonzini859aef02020-08-04 18:14:26 +02001936
Paolo Bonzinia0c91622020-10-07 11:01:51 -04001937########################
1938# Target configuration #
1939########################
1940
Paolo Bonzini2becc362020-02-03 11:42:03 +01001941minikconf = find_program('scripts/minikconf.py')
Paolo Bonzini05512f52020-09-16 15:31:11 -04001942config_all = {}
Paolo Bonzinia98006b2020-09-01 05:32:23 -04001943config_all_devices = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001944config_all_disas = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001945config_devices_mak_list = []
1946config_devices_h = {}
Paolo Bonzini859aef02020-08-04 18:14:26 +02001947config_target_h = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01001948config_target_mak = {}
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001949
1950disassemblers = {
1951 'alpha' : ['CONFIG_ALPHA_DIS'],
1952 'arm' : ['CONFIG_ARM_DIS'],
1953 'avr' : ['CONFIG_AVR_DIS'],
1954 'cris' : ['CONFIG_CRIS_DIS'],
Taylor Simpson3e7a84e2021-02-07 23:46:24 -06001955 'hexagon' : ['CONFIG_HEXAGON_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001956 'hppa' : ['CONFIG_HPPA_DIS'],
1957 'i386' : ['CONFIG_I386_DIS'],
1958 'x86_64' : ['CONFIG_I386_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001959 'm68k' : ['CONFIG_M68K_DIS'],
1960 'microblaze' : ['CONFIG_MICROBLAZE_DIS'],
1961 'mips' : ['CONFIG_MIPS_DIS'],
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001962 'nios2' : ['CONFIG_NIOS2_DIS'],
1963 'or1k' : ['CONFIG_OPENRISC_DIS'],
1964 'ppc' : ['CONFIG_PPC_DIS'],
1965 'riscv' : ['CONFIG_RISCV_DIS'],
1966 'rx' : ['CONFIG_RX_DIS'],
1967 's390' : ['CONFIG_S390_DIS'],
1968 'sh4' : ['CONFIG_SH4_DIS'],
1969 'sparc' : ['CONFIG_SPARC_DIS'],
1970 'xtensa' : ['CONFIG_XTENSA_DIS'],
1971}
1972if link_language == 'cpp'
1973 disassemblers += {
1974 'aarch64' : [ 'CONFIG_ARM_A64_DIS'],
1975 'arm' : [ 'CONFIG_ARM_DIS', 'CONFIG_ARM_A64_DIS'],
1976 'mips' : [ 'CONFIG_MIPS_DIS', 'CONFIG_NANOMIPS_DIS'],
1977 }
1978endif
1979
Paolo Bonzinie1fbd2c2021-06-03 12:02:00 +02001980have_ivshmem = config_host_data.get('CONFIG_EVENTFD')
Paolo Bonzini0a189112020-11-17 14:58:32 +01001981host_kconfig = \
Paolo Bonzini537b7242021-10-07 15:08:12 +02001982 (get_option('fuzzing') ? ['CONFIG_FUZZ=y'] : []) + \
Paolo Bonzini0d04c4c2021-12-21 12:38:27 +01001983 (have_tpm ? ['CONFIG_TPM=y'] : []) + \
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02001984 (spice.found() ? ['CONFIG_SPICE=y'] : []) + \
Paolo Bonziniccd250a2021-06-03 12:50:17 +02001985 (have_ivshmem ? ['CONFIG_IVSHMEM=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001986 ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
Paolo Bonzini9d710372021-01-07 13:54:22 +01001987 (x11.found() ? ['CONFIG_X11=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001988 ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
1989 ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
1990 ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
Paolo Bonzini69202b42020-11-17 14:46:21 +01001991 (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
Paolo Bonzini0a189112020-11-17 14:58:32 +01001992 ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \
Jagannathan Raman3090de62021-01-29 11:46:05 -05001993 ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \
Paolo Bonzini106ad1f2021-02-17 16:24:25 +01001994 (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : [])
Paolo Bonzini0a189112020-11-17 14:58:32 +01001995
Paolo Bonzinia9a74902020-09-21 05:11:01 -04001996ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ]
Paolo Bonzinica0fc782020-09-01 06:04:28 -04001997
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04001998default_targets = 'CONFIG_DEFAULT_TARGETS' in config_host
1999actual_target_dirs = []
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002000fdt_required = []
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002001foreach target : target_dirs
Paolo Bonzini765686d2020-09-18 06:37:21 -04002002 config_target = { 'TARGET_NAME': target.split('-')[0] }
2003 if target.endswith('linux-user')
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002004 if targetos != 'linux'
2005 if default_targets
2006 continue
2007 endif
2008 error('Target @0@ is only available on a Linux host'.format(target))
2009 endif
Paolo Bonzini765686d2020-09-18 06:37:21 -04002010 config_target += { 'CONFIG_LINUX_USER': 'y' }
2011 elif target.endswith('bsd-user')
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002012 if 'CONFIG_BSD' not in config_host
2013 if default_targets
2014 continue
2015 endif
2016 error('Target @0@ is only available on a BSD host'.format(target))
2017 endif
Paolo Bonzini765686d2020-09-18 06:37:21 -04002018 config_target += { 'CONFIG_BSD_USER': 'y' }
2019 elif target.endswith('softmmu')
2020 config_target += { 'CONFIG_SOFTMMU': 'y' }
2021 endif
2022 if target.endswith('-user')
2023 config_target += {
2024 'CONFIG_USER_ONLY': 'y',
2025 'CONFIG_QEMU_INTERP_PREFIX':
2026 config_host['CONFIG_QEMU_INTERP_PREFIX'].format(config_target['TARGET_NAME'])
2027 }
2028 endif
Paolo Bonzini859aef02020-08-04 18:14:26 +02002029
Paolo Bonzini0a189112020-11-17 14:58:32 +01002030 accel_kconfig = []
Paolo Bonzini8a199802020-09-18 05:37:01 -04002031 foreach sym: accelerators
2032 if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
2033 config_target += { sym: 'y' }
2034 config_all += { sym: 'y' }
Paolo Bonzini23a77b22020-12-14 12:01:45 +01002035 if sym == 'CONFIG_TCG' and tcg_arch == 'tci'
2036 config_target += { 'CONFIG_TCG_INTERPRETER': 'y' }
2037 elif sym == 'CONFIG_XEN' and have_xen_pci_passthrough
Paolo Bonzini8a199802020-09-18 05:37:01 -04002038 config_target += { 'CONFIG_XEN_PCI_PASSTHROUGH': 'y' }
2039 endif
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02002040 if target in modular_tcg
2041 config_target += { 'CONFIG_TCG_MODULAR': 'y' }
2042 else
2043 config_target += { 'CONFIG_TCG_BUILTIN': 'y' }
2044 endif
Paolo Bonzini0a189112020-11-17 14:58:32 +01002045 accel_kconfig += [ sym + '=y' ]
Paolo Bonzini8a199802020-09-18 05:37:01 -04002046 endif
2047 endforeach
Paolo Bonzini0a189112020-11-17 14:58:32 +01002048 if accel_kconfig.length() == 0
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002049 if default_targets
2050 continue
2051 endif
2052 error('No accelerator available for target @0@'.format(target))
2053 endif
Paolo Bonzini8a199802020-09-18 05:37:01 -04002054
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002055 actual_target_dirs += target
Alex Bennée812b31d2021-07-07 14:17:43 +01002056 config_target += keyval.load('configs/targets' / target + '.mak')
Paolo Bonzinia9a74902020-09-21 05:11:01 -04002057 config_target += { 'TARGET_' + config_target['TARGET_ARCH'].to_upper(): 'y' }
Paolo Bonzini765686d2020-09-18 06:37:21 -04002058
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002059 if 'TARGET_NEED_FDT' in config_target
2060 fdt_required += target
2061 endif
2062
Paolo Bonzinifa731682020-09-21 05:19:07 -04002063 # Add default keys
2064 if 'TARGET_BASE_ARCH' not in config_target
2065 config_target += {'TARGET_BASE_ARCH': config_target['TARGET_ARCH']}
2066 endif
2067 if 'TARGET_ABI_DIR' not in config_target
2068 config_target += {'TARGET_ABI_DIR': config_target['TARGET_ARCH']}
2069 endif
Paolo Bonzini859aef02020-08-04 18:14:26 +02002070
Paolo Bonzinica0fc782020-09-01 06:04:28 -04002071 foreach k, v: disassemblers
Paolo Bonzini823eb012021-11-08 14:18:17 +01002072 if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
Paolo Bonzinica0fc782020-09-01 06:04:28 -04002073 foreach sym: v
2074 config_target += { sym: 'y' }
2075 config_all_disas += { sym: 'y' }
2076 endforeach
2077 endif
2078 endforeach
2079
Paolo Bonzini859aef02020-08-04 18:14:26 +02002080 config_target_data = configuration_data()
2081 foreach k, v: config_target
2082 if not k.startswith('TARGET_') and not k.startswith('CONFIG_')
2083 # do nothing
2084 elif ignored.contains(k)
2085 # do nothing
2086 elif k == 'TARGET_BASE_ARCH'
Paolo Bonzinia9a74902020-09-21 05:11:01 -04002087 # Note that TARGET_BASE_ARCH ends up in config-target.h but it is
2088 # not used to select files from sourcesets.
Paolo Bonzini859aef02020-08-04 18:14:26 +02002089 config_target_data.set('TARGET_' + v.to_upper(), 1)
Paolo Bonzini765686d2020-09-18 06:37:21 -04002090 elif k == 'TARGET_NAME' or k == 'CONFIG_QEMU_INTERP_PREFIX'
Paolo Bonzini859aef02020-08-04 18:14:26 +02002091 config_target_data.set_quoted(k, v)
2092 elif v == 'y'
2093 config_target_data.set(k, 1)
2094 else
2095 config_target_data.set(k, v)
2096 endif
2097 endforeach
Peter Maydellcb2c5532021-07-30 11:59:43 +01002098 config_target_data.set('QEMU_ARCH',
2099 'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
Paolo Bonzini859aef02020-08-04 18:14:26 +02002100 config_target_h += {target: configure_file(output: target + '-config-target.h',
2101 configuration: config_target_data)}
Paolo Bonzini2becc362020-02-03 11:42:03 +01002102
2103 if target.endswith('-softmmu')
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01002104 config_input = meson.get_external_property(target, 'default')
Paolo Bonzini2becc362020-02-03 11:42:03 +01002105 config_devices_mak = target + '-config-devices.mak'
2106 config_devices_mak = configure_file(
Alex Bennéed1d5e9e2021-07-07 14:17:44 +01002107 input: ['configs/devices' / target / config_input + '.mak', 'Kconfig'],
Paolo Bonzini2becc362020-02-03 11:42:03 +01002108 output: config_devices_mak,
2109 depfile: config_devices_mak + '.d',
2110 capture: true,
Paolo Bonzini7bc3ca72020-11-20 08:38:22 +01002111 command: [minikconf,
2112 get_option('default_devices') ? '--defconfig' : '--allnoconfig',
Paolo Bonzini2becc362020-02-03 11:42:03 +01002113 config_devices_mak, '@DEPFILE@', '@INPUT@',
Philippe Mathieu-Daudéf4063f92021-07-07 14:17:40 +01002114 host_kconfig, accel_kconfig,
2115 'CONFIG_' + config_target['TARGET_ARCH'].to_upper() + '=y'])
Paolo Bonzini859aef02020-08-04 18:14:26 +02002116
2117 config_devices_data = configuration_data()
2118 config_devices = keyval.load(config_devices_mak)
2119 foreach k, v: config_devices
2120 config_devices_data.set(k, 1)
2121 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +01002122 config_devices_mak_list += config_devices_mak
Paolo Bonzini859aef02020-08-04 18:14:26 +02002123 config_devices_h += {target: configure_file(output: target + '-config-devices.h',
2124 configuration: config_devices_data)}
2125 config_target += config_devices
Paolo Bonzinia98006b2020-09-01 05:32:23 -04002126 config_all_devices += config_devices
Paolo Bonzini2becc362020-02-03 11:42:03 +01002127 endif
2128 config_target_mak += {target: config_target}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002129endforeach
Paolo Bonzinifdb75ae2020-09-21 04:37:49 -04002130target_dirs = actual_target_dirs
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002131
Paolo Bonzini2becc362020-02-03 11:42:03 +01002132# This configuration is used to build files that are shared by
2133# multiple binaries, and then extracted out of the "common"
2134# static_library target.
2135#
2136# We do not use all_sources()/all_dependencies(), because it would
2137# build literally all source files, including devices only used by
2138# targets that are not built for this compilation. The CONFIG_ALL
2139# pseudo symbol replaces it.
2140
Paolo Bonzini05512f52020-09-16 15:31:11 -04002141config_all += config_all_devices
Paolo Bonzini2becc362020-02-03 11:42:03 +01002142config_all += config_host
2143config_all += config_all_disas
2144config_all += {
2145 'CONFIG_XEN': config_host.has_key('CONFIG_XEN_BACKEND'),
2146 'CONFIG_SOFTMMU': have_system,
2147 'CONFIG_USER_ONLY': have_user,
2148 'CONFIG_ALL': true,
2149}
2150
Paolo Bonzinieed56e92021-11-10 11:01:26 +01002151target_configs_h = []
2152foreach target: target_dirs
2153 target_configs_h += config_target_h[target]
2154 target_configs_h += config_devices_h.get(target, [])
2155endforeach
2156genh += custom_target('config-poison.h',
2157 input: [target_configs_h],
2158 output: 'config-poison.h',
2159 capture: true,
2160 command: [find_program('scripts/make-config-poison.sh'),
2161 target_configs_h])
2162
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002163##############
2164# Submodules #
2165##############
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002166
2167capstone = not_found
2168capstone_opt = get_option('capstone')
2169if capstone_opt in ['enabled', 'auto', 'system']
2170 have_internal = fs.exists(meson.current_source_dir() / 'capstone/Makefile')
Richard Hendersonbcf36862020-09-21 09:46:16 -07002171 capstone = dependency('capstone', version: '>=4.0',
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002172 kwargs: static_kwargs, method: 'pkg-config',
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002173 required: capstone_opt == 'system' or
2174 capstone_opt == 'enabled' and not have_internal)
Daniel P. Berrangé8f4aea72021-07-09 15:29:31 +01002175
2176 # Some versions of capstone have broken pkg-config file
2177 # that reports a wrong -I path, causing the #include to
2178 # fail later. If the system has such a broken version
2179 # do not use it.
2180 if capstone.found() and not cc.compiles('#include <capstone.h>',
2181 dependencies: [capstone])
2182 capstone = not_found
2183 if capstone_opt == 'system'
2184 error('system capstone requested, it does not appear to work')
2185 endif
2186 endif
2187
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002188 if capstone.found()
2189 capstone_opt = 'system'
2190 elif have_internal
2191 capstone_opt = 'internal'
2192 else
2193 capstone_opt = 'disabled'
2194 endif
2195endif
2196if capstone_opt == 'internal'
2197 capstone_data = configuration_data()
2198 capstone_data.set('CAPSTONE_USE_SYS_DYN_MEM', '1')
2199
2200 capstone_files = files(
2201 'capstone/cs.c',
2202 'capstone/MCInst.c',
2203 'capstone/MCInstrDesc.c',
2204 'capstone/MCRegisterInfo.c',
2205 'capstone/SStream.c',
2206 'capstone/utils.c'
2207 )
2208
2209 if 'CONFIG_ARM_DIS' in config_all_disas
2210 capstone_data.set('CAPSTONE_HAS_ARM', '1')
2211 capstone_files += files(
2212 'capstone/arch/ARM/ARMDisassembler.c',
2213 'capstone/arch/ARM/ARMInstPrinter.c',
2214 'capstone/arch/ARM/ARMMapping.c',
2215 'capstone/arch/ARM/ARMModule.c'
2216 )
2217 endif
2218
2219 # FIXME: This config entry currently depends on a c++ compiler.
2220 # Which is needed for building libvixl, but not for capstone.
2221 if 'CONFIG_ARM_A64_DIS' in config_all_disas
2222 capstone_data.set('CAPSTONE_HAS_ARM64', '1')
2223 capstone_files += files(
2224 'capstone/arch/AArch64/AArch64BaseInfo.c',
2225 'capstone/arch/AArch64/AArch64Disassembler.c',
2226 'capstone/arch/AArch64/AArch64InstPrinter.c',
2227 'capstone/arch/AArch64/AArch64Mapping.c',
2228 'capstone/arch/AArch64/AArch64Module.c'
2229 )
2230 endif
2231
2232 if 'CONFIG_PPC_DIS' in config_all_disas
2233 capstone_data.set('CAPSTONE_HAS_POWERPC', '1')
2234 capstone_files += files(
2235 'capstone/arch/PowerPC/PPCDisassembler.c',
2236 'capstone/arch/PowerPC/PPCInstPrinter.c',
2237 'capstone/arch/PowerPC/PPCMapping.c',
2238 'capstone/arch/PowerPC/PPCModule.c'
2239 )
2240 endif
2241
Richard Henderson3d562842020-01-04 07:24:59 +10002242 if 'CONFIG_S390_DIS' in config_all_disas
2243 capstone_data.set('CAPSTONE_HAS_SYSZ', '1')
2244 capstone_files += files(
2245 'capstone/arch/SystemZ/SystemZDisassembler.c',
2246 'capstone/arch/SystemZ/SystemZInstPrinter.c',
2247 'capstone/arch/SystemZ/SystemZMapping.c',
2248 'capstone/arch/SystemZ/SystemZModule.c',
2249 'capstone/arch/SystemZ/SystemZMCTargetDesc.c'
2250 )
2251 endif
2252
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002253 if 'CONFIG_I386_DIS' in config_all_disas
2254 capstone_data.set('CAPSTONE_HAS_X86', 1)
2255 capstone_files += files(
2256 'capstone/arch/X86/X86Disassembler.c',
2257 'capstone/arch/X86/X86DisassemblerDecoder.c',
2258 'capstone/arch/X86/X86ATTInstPrinter.c',
2259 'capstone/arch/X86/X86IntelInstPrinter.c',
Richard Hendersoneef20e42020-09-14 16:02:02 -07002260 'capstone/arch/X86/X86InstPrinterCommon.c',
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002261 'capstone/arch/X86/X86Mapping.c',
2262 'capstone/arch/X86/X86Module.c'
2263 )
2264 endif
2265
2266 configure_file(output: 'capstone-defs.h', configuration: capstone_data)
2267
2268 capstone_cargs = [
2269 # FIXME: There does not seem to be a way to completely replace the c_args
2270 # that come from add_project_arguments() -- we can only add to them.
2271 # So: disable all warnings with a big hammer.
2272 '-Wno-error', '-w',
2273
2274 # Include all configuration defines via a header file, which will wind up
2275 # as a dependency on the object file, and thus changes here will result
2276 # in a rebuild.
2277 '-include', 'capstone-defs.h'
2278 ]
2279
2280 libcapstone = static_library('capstone',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002281 build_by_default: false,
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002282 sources: capstone_files,
2283 c_args: capstone_cargs,
2284 include_directories: 'capstone/include')
2285 capstone = declare_dependency(link_with: libcapstone,
Richard Hendersoneef20e42020-09-14 16:02:02 -07002286 include_directories: 'capstone/include/capstone')
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002287endif
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002288
2289slirp = not_found
2290slirp_opt = 'disabled'
2291if have_system
2292 slirp_opt = get_option('slirp')
2293 if slirp_opt in ['enabled', 'auto', 'system']
2294 have_internal = fs.exists(meson.current_source_dir() / 'slirp/meson.build')
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002295 slirp = dependency('slirp', kwargs: static_kwargs,
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002296 method: 'pkg-config',
2297 required: slirp_opt == 'system' or
2298 slirp_opt == 'enabled' and not have_internal)
2299 if slirp.found()
2300 slirp_opt = 'system'
2301 elif have_internal
2302 slirp_opt = 'internal'
2303 else
2304 slirp_opt = 'disabled'
2305 endif
2306 endif
2307 if slirp_opt == 'internal'
2308 slirp_deps = []
2309 if targetos == 'windows'
2310 slirp_deps = cc.find_library('iphlpapi')
Marc-André Lureau43f547b2021-05-18 19:51:11 +04002311 elif targetos == 'darwin'
2312 slirp_deps = cc.find_library('resolv')
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002313 endif
2314 slirp_conf = configuration_data()
2315 slirp_conf.set('SLIRP_MAJOR_VERSION', meson.project_version().split('.')[0])
2316 slirp_conf.set('SLIRP_MINOR_VERSION', meson.project_version().split('.')[1])
2317 slirp_conf.set('SLIRP_MICRO_VERSION', meson.project_version().split('.')[2])
2318 slirp_conf.set_quoted('SLIRP_VERSION_STRING', meson.project_version())
2319 slirp_cargs = ['-DG_LOG_DOMAIN="Slirp"']
2320 slirp_files = [
2321 'slirp/src/arp_table.c',
2322 'slirp/src/bootp.c',
2323 'slirp/src/cksum.c',
2324 'slirp/src/dhcpv6.c',
2325 'slirp/src/dnssearch.c',
2326 'slirp/src/if.c',
2327 'slirp/src/ip6_icmp.c',
2328 'slirp/src/ip6_input.c',
2329 'slirp/src/ip6_output.c',
2330 'slirp/src/ip_icmp.c',
2331 'slirp/src/ip_input.c',
2332 'slirp/src/ip_output.c',
2333 'slirp/src/mbuf.c',
2334 'slirp/src/misc.c',
2335 'slirp/src/ncsi.c',
2336 'slirp/src/ndp_table.c',
2337 'slirp/src/sbuf.c',
2338 'slirp/src/slirp.c',
2339 'slirp/src/socket.c',
2340 'slirp/src/state.c',
2341 'slirp/src/stream.c',
2342 'slirp/src/tcp_input.c',
2343 'slirp/src/tcp_output.c',
2344 'slirp/src/tcp_subr.c',
2345 'slirp/src/tcp_timer.c',
2346 'slirp/src/tftp.c',
2347 'slirp/src/udp.c',
2348 'slirp/src/udp6.c',
2349 'slirp/src/util.c',
2350 'slirp/src/version.c',
2351 'slirp/src/vmstate.c',
2352 ]
2353
2354 configure_file(
2355 input : 'slirp/src/libslirp-version.h.in',
2356 output : 'libslirp-version.h',
2357 configuration: slirp_conf)
2358
2359 slirp_inc = include_directories('slirp', 'slirp/src')
2360 libslirp = static_library('slirp',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002361 build_by_default: false,
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002362 sources: slirp_files,
2363 c_args: slirp_cargs,
2364 include_directories: slirp_inc)
2365 slirp = declare_dependency(link_with: libslirp,
2366 dependencies: slirp_deps,
2367 include_directories: slirp_inc)
2368 endif
2369endif
2370
Daniele Buonoc7153432021-03-03 21:59:38 -05002371# For CFI, we need to compile slirp as a static library together with qemu.
2372# This is because we register slirp functions as callbacks for QEMU Timers.
2373# When using a system-wide shared libslirp, the type information for the
2374# callback is missing and the timer call produces a false positive with CFI.
2375#
2376# Now that slirp_opt has been defined, check if the selected slirp is compatible
2377# with control-flow integrity.
2378if get_option('cfi') and slirp_opt == 'system'
2379 error('Control-Flow Integrity is not compatible with system-wide slirp.' \
2380 + ' Please configure with --enable-slirp=git')
2381endif
2382
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002383fdt = not_found
2384fdt_opt = get_option('fdt')
2385if have_system
2386 if fdt_opt in ['enabled', 'auto', 'system']
2387 have_internal = fs.exists(meson.current_source_dir() / 'dtc/libfdt/Makefile.libfdt')
Paolo Bonzinid7dedf42021-01-26 11:15:33 +01002388 fdt = cc.find_library('fdt', kwargs: static_kwargs,
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002389 required: fdt_opt == 'system' or
2390 fdt_opt == 'enabled' and not have_internal)
2391 if fdt.found() and cc.links('''
2392 #include <libfdt.h>
2393 #include <libfdt_env.h>
Thomas Huthde47b0f2022-01-18 18:05:48 +01002394 int main(void) { fdt_find_max_phandle(NULL, NULL); return 0; }''',
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002395 dependencies: fdt)
2396 fdt_opt = 'system'
Thomas Huth6c228532021-08-27 14:09:00 +02002397 elif fdt_opt == 'system'
2398 error('system libfdt requested, but it is too old (1.5.1 or newer required)')
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002399 elif have_internal
2400 fdt_opt = 'internal'
2401 else
2402 fdt_opt = 'disabled'
Thomas Huth87daf892021-08-27 14:08:59 +02002403 fdt = not_found
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002404 endif
2405 endif
2406 if fdt_opt == 'internal'
2407 fdt_files = files(
2408 'dtc/libfdt/fdt.c',
2409 'dtc/libfdt/fdt_ro.c',
2410 'dtc/libfdt/fdt_wip.c',
2411 'dtc/libfdt/fdt_sw.c',
2412 'dtc/libfdt/fdt_rw.c',
2413 'dtc/libfdt/fdt_strerror.c',
2414 'dtc/libfdt/fdt_empty_tree.c',
2415 'dtc/libfdt/fdt_addresses.c',
2416 'dtc/libfdt/fdt_overlay.c',
2417 'dtc/libfdt/fdt_check.c',
2418 )
2419
2420 fdt_inc = include_directories('dtc/libfdt')
2421 libfdt = static_library('fdt',
Philippe Mathieu-Daudé610e7e02021-01-22 21:44:33 +01002422 build_by_default: false,
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002423 sources: fdt_files,
2424 include_directories: fdt_inc)
2425 fdt = declare_dependency(link_with: libfdt,
2426 include_directories: fdt_inc)
2427 endif
2428endif
2429if not fdt.found() and fdt_required.length() > 0
2430 error('fdt not available but required by targets ' + ', '.join(fdt_required))
2431endif
2432
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002433config_host_data.set('CONFIG_CAPSTONE', capstone.found())
Paolo Bonzinifbb41212020-10-05 11:31:15 +02002434config_host_data.set('CONFIG_FDT', fdt.found())
Paolo Bonzini4d34a862020-10-05 11:31:15 +02002435config_host_data.set('CONFIG_SLIRP', slirp.found())
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002436
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002437#####################
2438# Generated sources #
2439#####################
Richard Henderson8b18cdb2020-09-13 12:19:25 -07002440
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002441genh += configure_file(output: 'config-host.h', configuration: config_host_data)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002442
Marc-André Lureau3f885652019-07-15 18:06:04 +04002443hxtool = find_program('scripts/hxtool')
Marc-André Lureau650b5d52019-07-15 17:36:47 +04002444shaderinclude = find_program('scripts/shaderinclude.pl')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002445qapi_gen = find_program('scripts/qapi-gen.py')
Paolo Bonzini654d6b02021-02-09 14:59:26 +01002446qapi_gen_depends = [ meson.current_source_dir() / 'scripts/qapi/__init__.py',
2447 meson.current_source_dir() / 'scripts/qapi/commands.py',
2448 meson.current_source_dir() / 'scripts/qapi/common.py',
2449 meson.current_source_dir() / 'scripts/qapi/error.py',
2450 meson.current_source_dir() / 'scripts/qapi/events.py',
2451 meson.current_source_dir() / 'scripts/qapi/expr.py',
2452 meson.current_source_dir() / 'scripts/qapi/gen.py',
2453 meson.current_source_dir() / 'scripts/qapi/introspect.py',
2454 meson.current_source_dir() / 'scripts/qapi/parser.py',
2455 meson.current_source_dir() / 'scripts/qapi/schema.py',
2456 meson.current_source_dir() / 'scripts/qapi/source.py',
2457 meson.current_source_dir() / 'scripts/qapi/types.py',
2458 meson.current_source_dir() / 'scripts/qapi/visit.py',
2459 meson.current_source_dir() / 'scripts/qapi/common.py',
2460 meson.current_source_dir() / 'scripts/qapi-gen.py'
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002461]
2462
2463tracetool = [
2464 python, files('scripts/tracetool.py'),
Paolo Bonzini9c29b742021-10-07 15:08:14 +02002465 '--backend=' + ','.join(get_option('trace_backends'))
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002466]
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00002467tracetool_depends = files(
2468 'scripts/tracetool/backend/log.py',
2469 'scripts/tracetool/backend/__init__.py',
2470 'scripts/tracetool/backend/dtrace.py',
2471 'scripts/tracetool/backend/ftrace.py',
2472 'scripts/tracetool/backend/simple.py',
2473 'scripts/tracetool/backend/syslog.py',
2474 'scripts/tracetool/backend/ust.py',
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00002475 'scripts/tracetool/format/ust_events_c.py',
2476 'scripts/tracetool/format/ust_events_h.py',
2477 'scripts/tracetool/format/__init__.py',
2478 'scripts/tracetool/format/d.py',
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00002479 'scripts/tracetool/format/simpletrace_stap.py',
2480 'scripts/tracetool/format/c.py',
2481 'scripts/tracetool/format/h.py',
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00002482 'scripts/tracetool/format/log_stap.py',
2483 'scripts/tracetool/format/stap.py',
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00002484 'scripts/tracetool/__init__.py',
2485 'scripts/tracetool/transform.py',
2486 'scripts/tracetool/vcpu.py'
2487)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002488
Marc-André Lureau2c273f32019-07-15 17:10:19 +04002489qemu_version_cmd = [find_program('scripts/qemu-version.sh'),
2490 meson.current_source_dir(),
Paolo Bonzini859aef02020-08-04 18:14:26 +02002491 config_host['PKGVERSION'], meson.project_version()]
Marc-André Lureau2c273f32019-07-15 17:10:19 +04002492qemu_version = custom_target('qemu-version.h',
2493 output: 'qemu-version.h',
2494 command: qemu_version_cmd,
2495 capture: true,
2496 build_by_default: true,
2497 build_always_stale: true)
2498genh += qemu_version
2499
Marc-André Lureau3f885652019-07-15 18:06:04 +04002500hxdep = []
2501hx_headers = [
2502 ['qemu-options.hx', 'qemu-options.def'],
2503 ['qemu-img-cmds.hx', 'qemu-img-cmds.h'],
2504]
2505if have_system
2506 hx_headers += [
2507 ['hmp-commands.hx', 'hmp-commands.h'],
2508 ['hmp-commands-info.hx', 'hmp-commands-info.h'],
2509 ]
2510endif
2511foreach d : hx_headers
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04002512 hxdep += custom_target(d[1],
Marc-André Lureau3f885652019-07-15 18:06:04 +04002513 input: files(d[0]),
2514 output: d[1],
2515 capture: true,
2516 build_by_default: true, # to be removed when added to a target
2517 command: [hxtool, '-h', '@INPUT0@'])
2518endforeach
2519genh += hxdep
2520
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002521###################
2522# Collect sources #
2523###################
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002524
Philippe Mathieu-Daudé55567892020-10-06 14:56:01 +02002525authz_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002526blockdev_ss = ss.source_set()
2527block_ss = ss.source_set()
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002528chardev_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002529common_ss = ss.source_set()
Philippe Mathieu-Daudé23893042020-10-06 14:56:00 +02002530crypto_ss = ss.source_set()
Philippe Mathieu-Daudéf73fb062021-10-28 16:34:19 +02002531hwcore_ss = ss.source_set()
Philippe Mathieu-Daudéf78536b2020-10-06 14:55:59 +02002532io_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002533qmp_ss = ss.source_set()
Philippe Mathieu-Daudéda33fc02020-10-06 14:56:02 +02002534qom_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002535softmmu_ss = ss.source_set()
2536specific_fuzz_ss = ss.source_set()
2537specific_ss = ss.source_set()
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002538stub_ss = ss.source_set()
2539trace_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002540user_ss = ss.source_set()
Philippe Mathieu-Daudé7e2b8882020-10-06 14:55:55 +02002541util_ss = ss.source_set()
Paolo Bonzini2becc362020-02-03 11:42:03 +01002542
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002543# accel modules
2544qtest_module_ss = ss.source_set()
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02002545tcg_module_ss = ss.source_set()
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002546
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002547modules = {}
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002548target_modules = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01002549hw_arch = {}
2550target_arch = {}
2551target_softmmu_arch = {}
Philippe Mathieu-Daudé46369b52021-04-13 11:27:09 +02002552target_user_arch = {}
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002553
2554###############
2555# Trace files #
2556###############
2557
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002558# TODO: add each directory to the subdirs from its own meson.build, once
2559# we have those
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002560trace_events_subdirs = [
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002561 'crypto',
Philippe Mathieu-Daudé69ff4d02021-01-22 21:44:35 +01002562 'qapi',
2563 'qom',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002564 'monitor',
Philippe Mathieu-Daudé69ff4d02021-01-22 21:44:35 +01002565 'util',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002566]
Warner Losh6ddc1ab2022-01-08 17:37:23 -07002567if have_linux_user
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002568 trace_events_subdirs += [ 'linux-user' ]
2569endif
Warner Losh6ddc1ab2022-01-08 17:37:23 -07002570if have_bsd_user
2571 trace_events_subdirs += [ 'bsd-user' ]
2572endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002573if have_block
2574 trace_events_subdirs += [
2575 'authz',
2576 'block',
2577 'io',
2578 'nbd',
2579 'scsi',
2580 ]
2581endif
2582if have_system
2583 trace_events_subdirs += [
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002584 'accel/kvm',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002585 'audio',
2586 'backends',
2587 'backends/tpm',
2588 'chardev',
Andrew Melnychenko46627f42021-05-14 14:48:32 +03002589 'ebpf',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002590 'hw/9pfs',
2591 'hw/acpi',
Hao Wu77c05b02021-01-08 11:09:42 -08002592 'hw/adc',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002593 'hw/alpha',
2594 'hw/arm',
2595 'hw/audio',
2596 'hw/block',
2597 'hw/block/dataplane',
2598 'hw/char',
2599 'hw/display',
2600 'hw/dma',
2601 'hw/hppa',
2602 'hw/hyperv',
2603 'hw/i2c',
2604 'hw/i386',
2605 'hw/i386/xen',
2606 'hw/ide',
2607 'hw/input',
2608 'hw/intc',
2609 'hw/isa',
2610 'hw/mem',
2611 'hw/mips',
2612 'hw/misc',
2613 'hw/misc/macio',
2614 'hw/net',
Vikram Garhwal98e5d7a2020-11-18 11:48:43 -08002615 'hw/net/can',
Mark Cave-Aylandce0e6a22021-09-24 08:37:55 +01002616 'hw/nubus',
Klaus Jensen88eea452021-04-14 22:14:30 +02002617 'hw/nvme',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002618 'hw/nvram',
2619 'hw/pci',
2620 'hw/pci-host',
2621 'hw/ppc',
2622 'hw/rdma',
2623 'hw/rdma/vmw',
2624 'hw/rtc',
2625 'hw/s390x',
2626 'hw/scsi',
2627 'hw/sd',
BALATON Zoltanad52cfc2021-10-29 23:02:09 +02002628 'hw/sh4',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002629 'hw/sparc',
2630 'hw/sparc64',
2631 'hw/ssi',
2632 'hw/timer',
2633 'hw/tpm',
2634 'hw/usb',
2635 'hw/vfio',
2636 'hw/virtio',
2637 'hw/watchdog',
2638 'hw/xen',
2639 'hw/gpio',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002640 'migration',
2641 'net',
Philippe Mathieu-Daudé8b7a5502020-08-05 15:02:20 +02002642 'softmmu',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002643 'ui',
Elena Ufimtsevaad22c302021-01-29 11:46:10 -05002644 'hw/remote',
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002645 ]
2646endif
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002647if have_system or have_user
2648 trace_events_subdirs += [
2649 'accel/tcg',
2650 'hw/core',
2651 'target/arm',
Alexander Grafa1477da2021-09-16 17:53:58 +02002652 'target/arm/hvf',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002653 'target/hppa',
2654 'target/i386',
2655 'target/i386/kvm',
Philippe Mathieu-Daudé34b8ff22021-05-30 09:02:16 +02002656 'target/mips/tcg',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002657 'target/ppc',
2658 'target/riscv',
2659 'target/s390x',
Cho, Yu-Chen67043602021-07-07 18:53:23 +08002660 'target/s390x/kvm',
Philippe Mathieu-Daudé8985db22021-01-22 21:44:36 +01002661 'target/sparc',
2662 ]
2663endif
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002664
Marc-André Lureau0df750e2020-11-25 14:06:37 +04002665vhost_user = not_found
2666if 'CONFIG_VHOST_USER' in config_host
2667 libvhost_user = subproject('libvhost-user')
2668 vhost_user = libvhost_user.get_variable('vhost_user_dep')
2669endif
2670
Vladimir Sementsov-Ogievskiyb83a80e2022-01-26 17:11:27 +01002671# NOTE: the trace/ subdirectory needs the qapi_trace_events variable
2672# that is filled in by qapi/.
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002673subdir('qapi')
2674subdir('qobject')
2675subdir('stubs')
2676subdir('trace')
2677subdir('util')
Marc-André Lureau5582c582019-07-16 19:28:54 +04002678subdir('qom')
2679subdir('authz')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002680subdir('crypto')
Marc-André Lureau2d78b562019-07-15 16:00:36 +04002681subdir('ui')
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002682
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002683
2684if enable_modules
2685 libmodulecommon = static_library('module-common', files('module-common.c') + genh, pic: true, c_args: '-DBUILD_DSO')
2686 modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
2687endif
2688
Paolo Bonzini2becc362020-02-03 11:42:03 +01002689stub_ss = stub_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002690
2691util_ss.add_all(trace_ss)
Paolo Bonzini2becc362020-02-03 11:42:03 +01002692util_ss = util_ss.apply(config_all, strict: false)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002693libqemuutil = static_library('qemuutil',
2694 sources: util_ss.sources() + stub_ss.sources() + genh,
Paolo Bonzini6d7c7c22021-06-03 15:01:35 +02002695 dependencies: [util_ss.dependencies(), libm, threads, glib, socket, malloc, pixman])
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002696qemuutil = declare_dependency(link_with: libqemuutil,
Marc-André Lureau04c6f1e2019-07-18 00:31:05 +04002697 sources: genh + version_res)
Paolo Bonzinia81df1b2020-08-19 08:44:56 -04002698
Philippe Mathieu-Daudé957b31f2021-01-22 21:44:37 +01002699if have_system or have_user
2700 decodetree = generator(find_program('scripts/decodetree.py'),
2701 output: 'decode-@BASENAME@.c.inc',
2702 arguments: ['@INPUT@', '@EXTRA_ARGS@', '-o', '@OUTPUT@'])
2703 subdir('libdecnumber')
2704 subdir('target')
2705endif
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02002706
Paolo Bonzini478e9432020-08-17 12:47:55 +02002707subdir('audio')
Marc-André Lureau7fcfd452019-07-16 19:33:55 +04002708subdir('io')
Marc-André Lureau848e8ff2019-07-15 23:18:07 +04002709subdir('chardev')
Marc-André Lureauec0d5892019-07-15 15:04:49 +04002710subdir('fsdev')
Marc-André Lureau708eab42019-09-03 16:59:33 +04002711subdir('dump')
Marc-André Lureauec0d5892019-07-15 15:04:49 +04002712
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002713if have_block
2714 block_ss.add(files(
2715 'block.c',
2716 'blockjob.c',
2717 'job.c',
2718 'qemu-io-cmds.c',
2719 ))
Paolo Bonzini406523f2021-10-13 11:43:54 +02002720 if config_host_data.get('CONFIG_REPLICATION')
2721 block_ss.add(files('replication.c'))
2722 endif
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002723
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002724 subdir('nbd')
2725 subdir('scsi')
2726 subdir('block')
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002727
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002728 blockdev_ss.add(files(
2729 'blockdev.c',
2730 'blockdev-nbd.c',
2731 'iothread.c',
2732 'job-qmp.c',
2733 ), gnutls)
Paolo Bonzini4a963372020-08-03 16:22:28 +02002734
Philippe Mathieu-Daudéf285bd32021-01-22 21:44:34 +01002735 # os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
2736 # os-win32.c does not
2737 blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
2738 softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
2739endif
Paolo Bonzini4a963372020-08-03 16:22:28 +02002740
2741common_ss.add(files('cpus-common.c'))
2742
Paolo Bonzini5d3ea0e2020-08-06 13:40:26 +02002743subdir('softmmu')
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002744
Richard Hendersonf3433462020-09-12 10:47:33 -07002745common_ss.add(capstone)
Paolo Bonzinid9f24bf2020-10-06 09:05:29 +02002746specific_ss.add(files('cpu.c', 'disas.c', 'gdbstub.c'), capstone)
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04002747
Richard Henderson44b99a62021-03-22 12:24:26 +01002748# Work around a gcc bug/misfeature wherein constant propagation looks
2749# through an alias:
2750# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99696
2751# to guess that a const variable is always zero. Without lto, this is
2752# impossible, as the alias is restricted to page-vary-common.c. Indeed,
2753# without lto, not even the alias is required -- we simply use different
2754# declarations in different compilation units.
2755pagevary = files('page-vary-common.c')
2756if get_option('b_lto')
2757 pagevary_flags = ['-fno-lto']
2758 if get_option('cfi')
2759 pagevary_flags += '-fno-sanitize=cfi-icall'
2760 endif
2761 pagevary = static_library('page-vary-common', sources: pagevary,
2762 c_args: pagevary_flags)
2763 pagevary = declare_dependency(link_with: pagevary)
2764endif
2765common_ss.add(pagevary)
Richard Henderson6670d4d2021-03-22 12:24:24 +01002766specific_ss.add(files('page-vary.c'))
2767
Marc-André Lureauab318052019-07-24 19:23:16 +04002768subdir('backends')
Marc-André Lureauc574e162019-07-26 12:02:31 +04002769subdir('disas')
Marc-André Lureau55166232019-07-24 19:16:22 +04002770subdir('migration')
Paolo Bonziniff219dc2020-08-04 21:14:26 +02002771subdir('monitor')
Marc-André Lureaucdaf0722019-07-22 23:47:50 +04002772subdir('net')
Marc-André Lureau17ef2af2019-07-22 23:40:45 +04002773subdir('replay')
Philippe Mathieu-Daudé8df9f0c2021-03-05 13:54:50 +00002774subdir('semihosting')
Marc-André Lureau582ea952019-08-15 15:15:32 +04002775subdir('hw')
Richard Henderson104cc2c2021-03-08 12:04:33 -08002776subdir('tcg')
Richard Hendersonc6347542021-03-08 12:15:06 -08002777subdir('fpu')
Marc-André Lureau1a828782019-08-18 16:13:08 +04002778subdir('accel')
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01002779subdir('plugins')
Richard Hendersonbbf15aa2021-11-17 16:14:00 +01002780subdir('ebpf')
2781
2782common_user_inc = []
2783
2784subdir('common-user')
Marc-André Lureaub309c322019-08-18 19:20:37 +04002785subdir('bsd-user')
Marc-André Lureau3a304462019-08-18 16:13:08 +04002786subdir('linux-user')
Andrew Melnychenko46627f42021-05-14 14:48:32 +03002787
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02002788# needed for fuzzing binaries
2789subdir('tests/qtest/libqos')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002790subdir('tests/qtest/fuzz')
Paolo Bonzinia2ce7db2020-08-04 20:00:40 +02002791
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002792# accel modules
Gerd Hoffmanndae0ec12021-06-24 12:38:31 +02002793tcg_real_module_ss = ss.source_set()
2794tcg_real_module_ss.add_all(when: 'CONFIG_TCG_MODULAR', if_true: tcg_module_ss)
2795specific_ss.add_all(when: 'CONFIG_TCG_BUILTIN', if_true: tcg_module_ss)
2796target_modules += { 'accel' : { 'qtest': qtest_module_ss,
2797 'tcg': tcg_real_module_ss }}
Gerd Hoffmannc94a7b82021-06-24 12:38:29 +02002798
Paolo Bonzinia0c91622020-10-07 11:01:51 -04002799########################
2800# Library dependencies #
2801########################
2802
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002803modinfo_collect = find_program('scripts/modinfo-collect.py')
Gerd Hoffmann5ebbfec2021-06-24 12:38:05 +02002804modinfo_generate = find_program('scripts/modinfo-generate.py')
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002805modinfo_files = []
2806
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002807block_mods = []
2808softmmu_mods = []
2809foreach d, list : modules
2810 foreach m, module_ss : list
2811 if enable_modules and targetos != 'windows'
Gerd Hoffmann3e292c52020-09-14 15:42:20 +02002812 module_ss = module_ss.apply(config_all, strict: false)
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002813 sl = static_library(d + '-' + m, [genh, module_ss.sources()],
2814 dependencies: [modulecommon, module_ss.dependencies()], pic: true)
2815 if d == 'block'
2816 block_mods += sl
2817 else
2818 softmmu_mods += sl
2819 endif
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002820 if module_ss.sources() != []
2821 # FIXME: Should use sl.extract_all_objects(recursive: true) as
2822 # input. Sources can be used multiple times but objects are
2823 # unique when it comes to lookup in compile_commands.json.
2824 # Depnds on a mesion version with
2825 # https://github.com/mesonbuild/meson/pull/8900
2826 modinfo_files += custom_target(d + '-' + m + '.modinfo',
2827 output: d + '-' + m + '.modinfo',
Paolo Bonziniac347112021-07-21 18:51:57 +02002828 input: module_ss.sources() + genh,
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002829 capture: true,
Paolo Bonziniac347112021-07-21 18:51:57 +02002830 command: [modinfo_collect, module_ss.sources()])
Gerd Hoffmannf5723ab2021-06-24 12:38:04 +02002831 endif
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002832 else
2833 if d == 'block'
2834 block_ss.add_all(module_ss)
2835 else
2836 softmmu_ss.add_all(module_ss)
2837 endif
2838 endif
2839 endforeach
2840endforeach
2841
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002842foreach d, list : target_modules
2843 foreach m, module_ss : list
2844 if enable_modules and targetos != 'windows'
2845 foreach target : target_dirs
2846 if target.endswith('-softmmu')
2847 config_target = config_target_mak[target]
2848 config_target += config_host
2849 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
2850 c_args = ['-DNEED_CPU_H',
2851 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
2852 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
2853 target_module_ss = module_ss.apply(config_target, strict: false)
2854 if target_module_ss.sources() != []
2855 module_name = d + '-' + m + '-' + config_target['TARGET_NAME']
2856 sl = static_library(module_name,
2857 [genh, target_module_ss.sources()],
2858 dependencies: [modulecommon, target_module_ss.dependencies()],
2859 include_directories: target_inc,
2860 c_args: c_args,
2861 pic: true)
2862 softmmu_mods += sl
2863 # FIXME: Should use sl.extract_all_objects(recursive: true) too.
2864 modinfo_files += custom_target(module_name + '.modinfo',
2865 output: module_name + '.modinfo',
Gerd Hoffmann917ddc22021-07-23 14:01:56 +02002866 input: target_module_ss.sources() + genh,
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002867 capture: true,
Gerd Hoffmann917ddc22021-07-23 14:01:56 +02002868 command: [modinfo_collect, '--target', target, target_module_ss.sources()])
Gerd Hoffmanndb2e89d2021-06-24 12:38:22 +02002869 endif
2870 endif
2871 endforeach
2872 else
2873 specific_ss.add_all(module_ss)
2874 endif
2875 endforeach
2876endforeach
2877
Gerd Hoffmann5ebbfec2021-06-24 12:38:05 +02002878if enable_modules
2879 modinfo_src = custom_target('modinfo.c',
2880 output: 'modinfo.c',
2881 input: modinfo_files,
2882 command: [modinfo_generate, '@INPUT@'],
2883 capture: true)
2884 modinfo_lib = static_library('modinfo', modinfo_src)
2885 modinfo_dep = declare_dependency(link_whole: modinfo_lib)
2886 softmmu_ss.add(modinfo_dep)
2887endif
2888
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002889nm = find_program('nm')
Yonggang Luo604f3e42020-09-03 01:00:50 +08002890undefsym = find_program('scripts/undefsym.py')
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002891block_syms = custom_target('block.syms', output: 'block.syms',
2892 input: [libqemuutil, block_mods],
2893 capture: true,
2894 command: [undefsym, nm, '@INPUT@'])
2895qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
2896 input: [libqemuutil, softmmu_mods],
2897 capture: true,
2898 command: [undefsym, nm, '@INPUT@'])
2899
Philippe Mathieu-Daudéda33fc02020-10-06 14:56:02 +02002900qom_ss = qom_ss.apply(config_host, strict: false)
2901libqom = static_library('qom', qom_ss.sources() + genh,
2902 dependencies: [qom_ss.dependencies()],
2903 name_suffix: 'fa')
2904
2905qom = declare_dependency(link_whole: libqom)
2906
Philippe Mathieu-Daudé55567892020-10-06 14:56:01 +02002907authz_ss = authz_ss.apply(config_host, strict: false)
2908libauthz = static_library('authz', authz_ss.sources() + genh,
2909 dependencies: [authz_ss.dependencies()],
2910 name_suffix: 'fa',
2911 build_by_default: false)
2912
2913authz = declare_dependency(link_whole: libauthz,
2914 dependencies: qom)
2915
Philippe Mathieu-Daudé23893042020-10-06 14:56:00 +02002916crypto_ss = crypto_ss.apply(config_host, strict: false)
2917libcrypto = static_library('crypto', crypto_ss.sources() + genh,
2918 dependencies: [crypto_ss.dependencies()],
2919 name_suffix: 'fa',
2920 build_by_default: false)
2921
2922crypto = declare_dependency(link_whole: libcrypto,
2923 dependencies: [authz, qom])
2924
Philippe Mathieu-Daudéf78536b2020-10-06 14:55:59 +02002925io_ss = io_ss.apply(config_host, strict: false)
2926libio = static_library('io', io_ss.sources() + genh,
2927 dependencies: [io_ss.dependencies()],
2928 link_with: libqemuutil,
2929 name_suffix: 'fa',
2930 build_by_default: false)
2931
2932io = declare_dependency(link_whole: libio, dependencies: [crypto, qom])
2933
Philippe Mathieu-Daudé7e6edef2020-10-06 14:55:58 +02002934libmigration = static_library('migration', sources: migration_files + genh,
2935 name_suffix: 'fa',
2936 build_by_default: false)
2937migration = declare_dependency(link_with: libmigration,
2938 dependencies: [zlib, qom, io])
2939softmmu_ss.add(migration)
2940
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002941block_ss = block_ss.apply(config_host, strict: false)
2942libblock = static_library('block', block_ss.sources() + genh,
2943 dependencies: block_ss.dependencies(),
2944 link_depends: block_syms,
2945 name_suffix: 'fa',
2946 build_by_default: false)
2947
2948block = declare_dependency(link_whole: [libblock],
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04002949 link_args: '@block.syms',
2950 dependencies: [crypto, io])
Marc-André Lureau5e5733e2019-08-29 22:34:43 +04002951
Stefan Hajnoczi4fb90712020-09-29 13:55:14 +01002952blockdev_ss = blockdev_ss.apply(config_host, strict: false)
2953libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
2954 dependencies: blockdev_ss.dependencies(),
2955 name_suffix: 'fa',
2956 build_by_default: false)
2957
2958blockdev = declare_dependency(link_whole: [libblockdev],
2959 dependencies: [block])
2960
Paolo Bonziniff219dc2020-08-04 21:14:26 +02002961qmp_ss = qmp_ss.apply(config_host, strict: false)
2962libqmp = static_library('qmp', qmp_ss.sources() + genh,
2963 dependencies: qmp_ss.dependencies(),
2964 name_suffix: 'fa',
2965 build_by_default: false)
2966
2967qmp = declare_dependency(link_whole: [libqmp])
2968
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002969libchardev = static_library('chardev', chardev_ss.sources() + genh,
2970 name_suffix: 'fa',
Roman Bolshakov3eacf702021-01-02 15:52:13 +03002971 dependencies: [gnutls],
Philippe Mathieu-Daudéc2306d72020-10-06 14:55:57 +02002972 build_by_default: false)
2973
2974chardev = declare_dependency(link_whole: libchardev)
2975
Philippe Mathieu-Daudéf73fb062021-10-28 16:34:19 +02002976hwcore_ss = hwcore_ss.apply(config_host, strict: false)
2977libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
Philippe Mathieu-Daudée28ab092020-10-06 14:55:56 +02002978 name_suffix: 'fa',
2979 build_by_default: false)
2980hwcore = declare_dependency(link_whole: libhwcore)
2981common_ss.add(hwcore)
2982
Philippe Mathieu-Daudé064f8ee2020-10-06 14:55:54 +02002983###########
2984# Targets #
2985###########
2986
Paolo Bonzinifb721762022-01-07 13:00:44 +01002987emulator_modules = []
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002988foreach m : block_mods + softmmu_mods
Paolo Bonzinifb721762022-01-07 13:00:44 +01002989 emulator_modules += shared_module(m.name(),
2990 build_by_default: true,
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002991 name_prefix: '',
2992 link_whole: m,
2993 install: true,
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04002994 install_dir: qemu_moddir)
Marc-André Lureau3154fee2019-08-29 22:07:01 +04002995endforeach
2996
Stefan Hajnoczi4fb90712020-09-29 13:55:14 +01002997softmmu_ss.add(authz, blockdev, chardev, crypto, io, qmp)
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02002998common_ss.add(qom, qemuutil)
2999
3000common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: [softmmu_ss])
Paolo Bonzini2becc362020-02-03 11:42:03 +01003001common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
3002
3003common_all = common_ss.apply(config_all, strict: false)
3004common_all = static_library('common',
3005 build_by_default: false,
3006 sources: common_all.sources() + genh,
Paolo Bonzini9d24fb72021-12-21 16:09:54 +01003007 include_directories: common_user_inc,
Katsuhiro Ueno75eebe02021-04-29 11:43:07 +09003008 implicit_include_directories: false,
Paolo Bonzini2becc362020-02-03 11:42:03 +01003009 dependencies: common_all.dependencies(),
3010 name_suffix: 'fa')
3011
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04003012feature_to_c = find_program('scripts/feature_to_c.sh')
3013
Paolo Bonzinifd5eef82020-09-16 05:00:53 -04003014emulators = {}
Paolo Bonzini2becc362020-02-03 11:42:03 +01003015foreach target : target_dirs
3016 config_target = config_target_mak[target]
3017 target_name = config_target['TARGET_NAME']
Paolo Bonziniffb91f62021-11-08 15:44:39 +01003018 target_base_arch = config_target['TARGET_BASE_ARCH']
Paolo Bonzini859aef02020-08-04 18:14:26 +02003019 arch_srcs = [config_target_h[target]]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003020 arch_deps = []
3021 c_args = ['-DNEED_CPU_H',
3022 '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
3023 '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
Paolo Bonzinib6c7cfd2020-09-21 04:49:50 -04003024 link_args = emulator_link_args
Paolo Bonzini2becc362020-02-03 11:42:03 +01003025
Paolo Bonzini859aef02020-08-04 18:14:26 +02003026 config_target += config_host
Paolo Bonzini2becc362020-02-03 11:42:03 +01003027 target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
3028 if targetos == 'linux'
3029 target_inc += include_directories('linux-headers', is_system: true)
3030 endif
3031 if target.endswith('-softmmu')
3032 qemu_target_name = 'qemu-system-' + target_name
3033 target_type='system'
Paolo Bonziniffb91f62021-11-08 15:44:39 +01003034 t = target_softmmu_arch[target_base_arch].apply(config_target, strict: false)
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02003035 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003036 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02003037
Paolo Bonziniffb91f62021-11-08 15:44:39 +01003038 hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
Marc-André Lureau2c442202019-08-17 13:55:58 +04003039 hw = hw_arch[hw_dir].apply(config_target, strict: false)
3040 arch_srcs += hw.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003041 arch_deps += hw.dependencies()
Marc-André Lureau2c442202019-08-17 13:55:58 +04003042
Paolo Bonzini2becc362020-02-03 11:42:03 +01003043 arch_srcs += config_devices_h[target]
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003044 link_args += ['@block.syms', '@qemu.syms']
Paolo Bonzini2becc362020-02-03 11:42:03 +01003045 else
Marc-André Lureau3a304462019-08-18 16:13:08 +04003046 abi = config_target['TARGET_ABI_DIR']
Paolo Bonzini2becc362020-02-03 11:42:03 +01003047 target_type='user'
Paolo Bonzinia3a576b2021-12-21 16:23:55 +01003048 target_inc += common_user_inc
Paolo Bonzini2becc362020-02-03 11:42:03 +01003049 qemu_target_name = 'qemu-' + target_name
Paolo Bonziniffb91f62021-11-08 15:44:39 +01003050 if target_base_arch in target_user_arch
3051 t = target_user_arch[target_base_arch].apply(config_target, strict: false)
Philippe Mathieu-Daudé46369b52021-04-13 11:27:09 +02003052 arch_srcs += t.sources()
3053 arch_deps += t.dependencies()
3054 endif
Paolo Bonzini2becc362020-02-03 11:42:03 +01003055 if 'CONFIG_LINUX_USER' in config_target
3056 base_dir = 'linux-user'
Warner Loshe2a74722021-08-03 17:17:17 -06003057 endif
3058 if 'CONFIG_BSD_USER' in config_target
Paolo Bonzini2becc362020-02-03 11:42:03 +01003059 base_dir = 'bsd-user'
Warner Loshe2a74722021-08-03 17:17:17 -06003060 target_inc += include_directories('bsd-user/' / targetos)
Warner Losh85fc1b52022-01-08 17:27:34 -07003061 target_inc += include_directories('bsd-user/host/' / host_arch)
Warner Loshe2a74722021-08-03 17:17:17 -06003062 dir = base_dir / abi
Warner Losh19bf1292021-11-04 16:34:48 -06003063 arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c')
Paolo Bonzini2becc362020-02-03 11:42:03 +01003064 endif
3065 target_inc += include_directories(
3066 base_dir,
Marc-André Lureau3a304462019-08-18 16:13:08 +04003067 base_dir / abi,
Paolo Bonzini2becc362020-02-03 11:42:03 +01003068 )
Marc-André Lureau3a304462019-08-18 16:13:08 +04003069 if 'CONFIG_LINUX_USER' in config_target
3070 dir = base_dir / abi
3071 arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
3072 if config_target.has_key('TARGET_SYSTBL_ABI')
3073 arch_srcs += \
3074 syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
3075 extra_args : config_target['TARGET_SYSTBL_ABI'])
3076 endif
3077 endif
Paolo Bonzini2becc362020-02-03 11:42:03 +01003078 endif
3079
Marc-André Lureauc9322ab2019-08-18 19:51:17 +04003080 if 'TARGET_XML_FILES' in config_target
3081 gdbstub_xml = custom_target(target + '-gdbstub-xml.c',
3082 output: target + '-gdbstub-xml.c',
3083 input: files(config_target['TARGET_XML_FILES'].split()),
3084 command: [feature_to_c, '@INPUT@'],
3085 capture: true)
3086 arch_srcs += gdbstub_xml
3087 endif
3088
Paolo Bonziniffb91f62021-11-08 15:44:39 +01003089 t = target_arch[target_base_arch].apply(config_target, strict: false)
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02003090 arch_srcs += t.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003091 arch_deps += t.dependencies()
Paolo Bonziniabff1ab2020-08-07 12:10:23 +02003092
Paolo Bonzini2becc362020-02-03 11:42:03 +01003093 target_common = common_ss.apply(config_target, strict: false)
3094 objects = common_all.extract_objects(target_common.sources())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003095 deps = target_common.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01003096
Paolo Bonzini2becc362020-02-03 11:42:03 +01003097 target_specific = specific_ss.apply(config_target, strict: false)
3098 arch_srcs += target_specific.sources()
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003099 arch_deps += target_specific.dependencies()
Paolo Bonzini2becc362020-02-03 11:42:03 +01003100
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003101 lib = static_library('qemu-' + target,
Paolo Bonzini859aef02020-08-04 18:14:26 +02003102 sources: arch_srcs + genh,
Paolo Bonzinib7612f42020-08-26 08:22:58 +02003103 dependencies: arch_deps,
Paolo Bonzini2becc362020-02-03 11:42:03 +01003104 objects: objects,
3105 include_directories: target_inc,
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003106 c_args: c_args,
3107 build_by_default: false,
Paolo Bonzini2becc362020-02-03 11:42:03 +01003108 name_suffix: 'fa')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003109
3110 if target.endswith('-softmmu')
3111 execs = [{
3112 'name': 'qemu-system-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003113 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003114 'sources': files('softmmu/main.c'),
3115 'dependencies': []
3116 }]
Paolo Bonzini35be72b2020-02-06 14:17:15 +01003117 if targetos == 'windows' and (sdl.found() or gtk.found())
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003118 execs += [{
3119 'name': 'qemu-system-' + target_name + 'w',
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003120 'win_subsystem': 'windows',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003121 'sources': files('softmmu/main.c'),
3122 'dependencies': []
3123 }]
3124 endif
Paolo Bonzini537b7242021-10-07 15:08:12 +02003125 if get_option('fuzzing')
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003126 specific_fuzz = specific_fuzz_ss.apply(config_target, strict: false)
3127 execs += [{
3128 'name': 'qemu-fuzz-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003129 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003130 'sources': specific_fuzz.sources(),
3131 'dependencies': specific_fuzz.dependencies(),
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003132 }]
3133 endif
3134 else
3135 execs = [{
3136 'name': 'qemu-' + target_name,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003137 'win_subsystem': 'console',
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003138 'sources': [],
3139 'dependencies': []
3140 }]
3141 endif
3142 foreach exe: execs
Alexander Graf8a74ce62021-01-20 23:44:34 +01003143 exe_name = exe['name']
John Arbuckle3983a762021-07-05 15:53:28 -04003144 if targetos == 'darwin'
Alexander Graf8a74ce62021-01-20 23:44:34 +01003145 exe_name += '-unsigned'
3146 endif
3147
3148 emulator = executable(exe_name, exe['sources'],
Akihiko Odaki237377a2021-02-25 09:06:14 +09003149 install: true,
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003150 c_args: c_args,
3151 dependencies: arch_deps + deps + exe['dependencies'],
3152 objects: lib.extract_all_objects(recursive: true),
3153 link_language: link_language,
3154 link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
3155 link_args: link_args,
Paolo Bonzini654d6b02021-02-09 14:59:26 +01003156 win_subsystem: exe['win_subsystem'])
Alexander Graf8a74ce62021-01-20 23:44:34 +01003157
John Arbuckle3983a762021-07-05 15:53:28 -04003158 if targetos == 'darwin'
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003159 icon = 'pc-bios/qemu.rsrc'
3160 build_input = [emulator, files(icon)]
3161 install_input = [
3162 get_option('bindir') / exe_name,
3163 meson.current_source_dir() / icon
3164 ]
3165 if 'CONFIG_HVF' in config_target
3166 entitlements = 'accel/hvf/entitlements.plist'
3167 build_input += files(entitlements)
3168 install_input += meson.current_source_dir() / entitlements
3169 endif
3170
Philippe Mathieu-Daudé235b5232022-01-22 01:20:52 +01003171 entitlement = find_program('scripts/entitlement.sh')
Alexander Graf8a74ce62021-01-20 23:44:34 +01003172 emulators += {exe['name'] : custom_target(exe['name'],
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003173 input: build_input,
Alexander Graf8a74ce62021-01-20 23:44:34 +01003174 output: exe['name'],
Philippe Mathieu-Daudé235b5232022-01-22 01:20:52 +01003175 command: [entitlement, '@OUTPUT@', '@INPUT@'])
Alexander Graf8a74ce62021-01-20 23:44:34 +01003176 }
Akihiko Odaki237377a2021-02-25 09:06:14 +09003177
Philippe Mathieu-Daudé235b5232022-01-22 01:20:52 +01003178 meson.add_install_script(entitlement, '--install',
Akihiko Odaki237377a2021-02-25 09:06:14 +09003179 get_option('bindir') / exe['name'],
Akihiko Odaki411ad8d2021-07-09 10:25:33 +09003180 install_input)
Alexander Graf8a74ce62021-01-20 23:44:34 +01003181 else
3182 emulators += {exe['name']: emulator}
3183 endif
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003184
Paolo Bonzini9c29b742021-10-07 15:08:14 +02003185 if stap.found()
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003186 foreach stp: [
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003187 {'ext': '.stp-build', 'fmt': 'stap', 'bin': meson.current_build_dir() / exe['name'], 'install': false},
3188 {'ext': '.stp', 'fmt': 'stap', 'bin': get_option('prefix') / get_option('bindir') / exe['name'], 'install': true},
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003189 {'ext': '-simpletrace.stp', 'fmt': 'simpletrace-stap', 'bin': '', 'install': true},
3190 {'ext': '-log.stp', 'fmt': 'log-stap', 'bin': '', 'install': true},
3191 ]
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003192 custom_target(exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003193 input: trace_events_all,
Stefan Hajnoczibd5f9732020-08-25 08:49:53 +02003194 output: exe['name'] + stp['ext'],
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003195 install: stp['install'],
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003196 install_dir: get_option('datadir') / 'systemtap/tapset',
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003197 command: [
3198 tracetool, '--group=all', '--format=' + stp['fmt'],
3199 '--binary=' + stp['bin'],
3200 '--target-name=' + target_name,
3201 '--target-type=' + target_type,
3202 '--probe-prefix=qemu.' + target_type + '.' + target_name,
Stefan Hajnoczic05012a2020-08-27 15:29:12 +01003203 '@INPUT@', '@OUTPUT@'
Stefan Hajnoczi0572d6c2021-01-25 11:09:58 +00003204 ],
3205 depend_files: tracetool_depends)
Marc-André Lureau10e1d262019-08-20 12:29:52 +04003206 endforeach
3207 endif
Paolo Bonzini64ed6f92020-08-03 17:04:25 +02003208 endforeach
Paolo Bonzini2becc362020-02-03 11:42:03 +01003209endforeach
3210
Paolo Bonzini931049b2020-02-05 09:44:24 +01003211# Other build targets
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003212
Paolo Bonzinif556b4a2020-01-24 13:08:01 +01003213if 'CONFIG_PLUGIN' in config_host
3214 install_headers('include/qemu/qemu-plugin.h')
3215endif
3216
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003217if 'CONFIG_GUEST_AGENT' in config_host
3218 subdir('qga')
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003219elif get_option('guest_agent_msi').enabled()
3220 error('Guest agent MSI requested, but the guest agent is not being built')
Paolo Bonzinif15bff22019-07-18 13:19:02 +02003221endif
3222
Laurent Vivier9755c942020-08-24 17:24:30 +02003223# Don't build qemu-keymap if xkbcommon is not explicitly enabled
3224# when we don't build tools or system
Laurent Vivier4113f4c2020-08-24 17:24:29 +02003225if xkbcommon.found()
Marc-André Lureau28742462019-09-19 20:24:43 +04003226 # used for the update-keymaps target, so include rules even if !have_tools
3227 qemu_keymap = executable('qemu-keymap', files('qemu-keymap.c', 'ui/input-keymap.c') + genh,
3228 dependencies: [qemuutil, xkbcommon], install: have_tools)
3229endif
3230
Paolo Bonzini931049b2020-02-05 09:44:24 +01003231if have_tools
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04003232 qemu_img = executable('qemu-img', [files('qemu-img.c'), hxdep],
3233 dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
3234 qemu_io = executable('qemu-io', files('qemu-io.c'),
3235 dependencies: [block, qemuutil], install: true)
Daniel P. Berrangéeb705982020-08-25 11:38:50 +01003236 qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06003237 dependencies: [blockdev, qemuutil, gnutls, selinux],
3238 install: true)
Marc-André Lureaub7c70bf2019-07-16 21:37:25 +04003239
Paolo Bonzini7c58bb72020-08-04 20:18:36 +02003240 subdir('storage-daemon')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02003241 subdir('contrib/rdmacm-mux')
Marc-André Lureau1d7bb6a2019-07-12 23:47:06 +04003242 subdir('contrib/elf2dmp')
Paolo Bonzinia9c97272019-06-10 12:27:52 +02003243
Marc-André Lureau157e7b12019-07-15 14:50:58 +04003244 executable('qemu-edid', files('qemu-edid.c', 'hw/display/edid-generate.c'),
3245 dependencies: qemuutil,
3246 install: true)
3247
Paolo Bonzini931049b2020-02-05 09:44:24 +01003248 if 'CONFIG_VHOST_USER' in config_host
Paolo Bonzini2d7ac0a2019-06-10 12:18:02 +02003249 subdir('contrib/vhost-user-blk')
Paolo Bonzinib7612f42020-08-26 08:22:58 +02003250 subdir('contrib/vhost-user-gpu')
Marc-André Lureau32fcc622019-07-12 22:11:20 +04003251 subdir('contrib/vhost-user-input')
Paolo Bonzini99650b62019-06-10 12:21:14 +02003252 subdir('contrib/vhost-user-scsi')
Paolo Bonzini931049b2020-02-05 09:44:24 +01003253 endif
Marc-André Lureau8f51e012019-07-15 14:39:25 +04003254
3255 if targetos == 'linux'
3256 executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
3257 dependencies: [qemuutil, libcap_ng],
3258 install: true,
3259 install_dir: get_option('libexecdir'))
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003260
3261 executable('qemu-pr-helper', files('scsi/qemu-pr-helper.c', 'scsi/utils.c'),
3262 dependencies: [authz, crypto, io, qom, qemuutil,
Paolo Bonzini6ec0e152020-09-16 18:07:29 +02003263 libcap_ng, mpathpersist],
Marc-André Lureau897b5af2019-07-16 21:54:15 +04003264 install: true)
Marc-André Lureau8f51e012019-07-15 14:39:25 +04003265 endif
3266
Paolo Bonziniccd250a2021-06-03 12:50:17 +02003267 if have_ivshmem
Marc-André Lureau5ee24e72019-07-12 23:16:54 +04003268 subdir('contrib/ivshmem-client')
3269 subdir('contrib/ivshmem-server')
3270 endif
Paolo Bonzini931049b2020-02-05 09:44:24 +01003271endif
3272
Marc-André Lureauf5aa6322020-08-26 17:06:18 +04003273subdir('scripts')
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01003274subdir('tools')
Marc-André Lureaubdcbea72019-07-15 21:22:31 +04003275subdir('pc-bios')
Paolo Bonzinif8aa24e2020-08-05 15:49:10 +02003276subdir('docs')
Yonggang Luoe3667662020-10-16 06:06:25 +08003277subdir('tests')
Paolo Bonzini1b695472021-01-07 14:02:29 +01003278if gtk.found()
Marc-André Lureaue8f3bd72019-09-19 21:02:09 +04003279 subdir('po')
3280endif
Paolo Bonzini3f99cf52020-02-05 09:45:39 +01003281
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003282if host_machine.system() == 'windows'
3283 nsis_cmd = [
3284 find_program('scripts/nsis.py'),
3285 '@OUTPUT@',
3286 get_option('prefix'),
3287 meson.current_source_dir(),
Stefan Weil24bdcc92020-11-25 20:18:33 +01003288 host_machine.cpu(),
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003289 '--',
3290 '-DDISPLAYVERSION=' + meson.project_version(),
3291 ]
3292 if build_docs
3293 nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
3294 endif
Paolo Bonzini1b695472021-01-07 14:02:29 +01003295 if gtk.found()
Marc-André Lureau8adfeba2020-08-26 15:04:19 +04003296 nsis_cmd += '-DCONFIG_GTK=y'
3297 endif
3298
3299 nsis = custom_target('nsis',
3300 output: 'qemu-setup-' + meson.project_version() + '.exe',
3301 input: files('qemu.nsi'),
3302 build_always_stale: true,
3303 command: nsis_cmd + ['@INPUT@'])
3304 alias_target('installer', nsis)
3305endif
3306
Paolo Bonzinia0c91622020-10-07 11:01:51 -04003307#########################
3308# Configuration summary #
3309#########################
3310
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003311# Directories
Paolo Bonzinif9332752020-02-03 13:28:38 +01003312summary_info = {}
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003313summary_info += {'Install prefix': get_option('prefix')}
3314summary_info += {'BIOS directory': qemu_datadir}
3315summary_info += {'firmware path': get_option('qemu_firmwarepath')}
3316summary_info += {'binary directory': get_option('bindir')}
3317summary_info += {'library directory': get_option('libdir')}
3318summary_info += {'module directory': qemu_moddir}
3319summary_info += {'libexec directory': get_option('libexecdir')}
3320summary_info += {'include directory': get_option('includedir')}
3321summary_info += {'config directory': get_option('sysconfdir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003322if targetos != 'windows'
Paolo Bonzini16bf7a32020-10-16 03:19:14 -04003323 summary_info += {'local state directory': get_option('localstatedir')}
Marc-André Lureaub81efab2020-08-26 15:04:18 +04003324 summary_info += {'Manual directory': get_option('mandir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003325else
3326 summary_info += {'local state directory': 'queried at runtime'}
3327endif
Marc-André Lureau491e74c2020-08-26 15:04:17 +04003328summary_info += {'Doc directory': get_option('docdir')}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003329summary_info += {'Build directory': meson.current_build_dir()}
3330summary_info += {'Source path': meson.current_source_dir()}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003331summary_info += {'GIT submodules': config_host['GIT_SUBMODULES']}
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003332summary(summary_info, bool_yn: true, section: 'Directories')
3333
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003334# Host binaries
Philippe Mathieu-Daudé983d0a72021-01-21 10:56:09 +01003335summary_info = {}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003336summary_info += {'git': config_host['GIT']}
3337summary_info += {'make': config_host['MAKE']}
3338summary_info += {'python': '@0@ (version: @1@)'.format(python.full_path(), python.language_version())}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003339summary_info += {'sphinx-build': sphinx_build}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003340if config_host.has_key('HAVE_GDB_BIN')
3341 summary_info += {'gdb': config_host['HAVE_GDB_BIN']}
3342endif
3343summary_info += {'genisoimage': config_host['GENISOIMAGE']}
3344if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003345 summary_info += {'wixl': wixl}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003346endif
Paolo Bonzini35acbb32021-10-13 13:43:36 +02003347if slirp_opt != 'disabled' and have_system
3348 summary_info += {'smbd': have_slirp_smbd ? smbd_path : false}
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003349endif
3350summary(summary_info, bool_yn: true, section: 'Host binaries')
3351
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003352# Configurable features
3353summary_info = {}
3354summary_info += {'Documentation': build_docs}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003355summary_info += {'system-mode emulation': have_system}
3356summary_info += {'user-mode emulation': have_user}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003357summary_info += {'block layer': have_block}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003358summary_info += {'Install blobs': get_option('install_blobs')}
3359summary_info += {'module support': config_host.has_key('CONFIG_MODULES')}
3360if config_host.has_key('CONFIG_MODULES')
3361 summary_info += {'alternative module path': config_host.has_key('CONFIG_MODULE_UPGRADES')}
3362endif
Paolo Bonzini537b7242021-10-07 15:08:12 +02003363summary_info += {'fuzzing support': get_option('fuzzing')}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003364if have_system
Paolo Bonzini87430d52021-10-07 15:06:09 +02003365 summary_info += {'Audio drivers': ' '.join(audio_drivers_selected)}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003366endif
Paolo Bonzini9c29b742021-10-07 15:08:14 +02003367summary_info += {'Trace backends': ','.join(get_option('trace_backends'))}
3368if 'simple' in get_option('trace_backends')
3369 summary_info += {'Trace output file': get_option('trace_file') + '-<pid>'}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003370endif
Marc-André Lureau142ca622021-07-15 11:53:53 +04003371summary_info += {'D-Bus display': dbus_display}
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02003372summary_info += {'QOM debugging': get_option('qom_cast_debug')}
Philippe Mathieu-Daudé1d718862021-01-21 10:56:11 +01003373summary_info += {'vhost-kernel support': config_host.has_key('CONFIG_VHOST_KERNEL')}
3374summary_info += {'vhost-net support': config_host.has_key('CONFIG_VHOST_NET')}
3375summary_info += {'vhost-crypto support': config_host.has_key('CONFIG_VHOST_CRYPTO')}
3376summary_info += {'vhost-scsi support': config_host.has_key('CONFIG_VHOST_SCSI')}
3377summary_info += {'vhost-vsock support': config_host.has_key('CONFIG_VHOST_VSOCK')}
3378summary_info += {'vhost-user support': config_host.has_key('CONFIG_VHOST_USER')}
3379summary_info += {'vhost-user-blk server support': have_vhost_user_blk_server}
3380summary_info += {'vhost-user-fs support': config_host.has_key('CONFIG_VHOST_USER_FS')}
3381summary_info += {'vhost-vdpa support': config_host.has_key('CONFIG_VHOST_VDPA')}
3382summary_info += {'build guest agent': config_host.has_key('CONFIG_GUEST_AGENT')}
3383summary(summary_info, bool_yn: true, section: 'Configurable features')
3384
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003385# Compilation information
Philippe Mathieu-Daudée11a0e12021-01-21 10:56:10 +01003386summary_info = {}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003387summary_info += {'host CPU': cpu}
3388summary_info += {'host endianness': build_machine.endian()}
Alex Bennée63de9352021-05-27 17:03:15 +01003389summary_info += {'C compiler': ' '.join(meson.get_compiler('c').cmd_array())}
3390summary_info += {'Host C compiler': ' '.join(meson.get_compiler('c', native: true).cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003391if link_language == 'cpp'
Alex Bennée63de9352021-05-27 17:03:15 +01003392 summary_info += {'C++ compiler': ' '.join(meson.get_compiler('cpp').cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003393else
3394 summary_info += {'C++ compiler': false}
3395endif
3396if targetos == 'darwin'
Alex Bennée63de9352021-05-27 17:03:15 +01003397 summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003398endif
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003399if targetos == 'windows'
3400 if 'WIN_SDK' in config_host
3401 summary_info += {'Windows SDK': config_host['WIN_SDK']}
3402 endif
3403endif
Paolo Bonzini47b30832020-09-23 05:26:17 -04003404summary_info += {'CFLAGS': ' '.join(get_option('c_args')
3405 + ['-O' + get_option('optimization')]
3406 + (get_option('debug') ? ['-g'] : []))}
3407if link_language == 'cpp'
3408 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
3409 + ['-O' + get_option('optimization')]
3410 + (get_option('debug') ? ['-g'] : []))}
3411endif
3412link_args = get_option(link_language + '_link_args')
3413if link_args.length() > 0
3414 summary_info += {'LDFLAGS': ' '.join(link_args)}
3415endif
Paolo Bonzinif9332752020-02-03 13:28:38 +01003416summary_info += {'QEMU_CFLAGS': config_host['QEMU_CFLAGS']}
3417summary_info += {'QEMU_LDFLAGS': config_host['QEMU_LDFLAGS']}
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02003418summary_info += {'profiler': get_option('profiler')}
Daniele Buonocdad7812020-12-04 18:06:11 -05003419summary_info += {'link-time optimization (LTO)': get_option('b_lto')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003420summary_info += {'PIE': get_option('b_pie')}
Laurent Vivier3e8529d2020-09-17 16:07:00 +02003421summary_info += {'static build': config_host.has_key('CONFIG_STATIC')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003422summary_info += {'malloc trim support': has_malloc_trim}
Paolo Bonzinib87df902021-11-08 13:52:11 +01003423summary_info += {'membarrier': have_membarrier}
Paolo Bonzini728c0a22021-10-13 11:52:03 +02003424summary_info += {'debug stack usage': get_option('debug_stack_usage')}
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02003425summary_info += {'mutex debugging': get_option('debug_mutex')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003426summary_info += {'memory allocator': get_option('malloc')}
Paolo Bonzini622753d2021-11-08 13:38:58 +01003427summary_info += {'avx2 optimization': config_host_data.get('CONFIG_AVX2_OPT')}
3428summary_info += {'avx512f optimization': config_host_data.get('CONFIG_AVX512F_OPT')}
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02003429summary_info += {'gprof enabled': get_option('gprof')}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003430summary_info += {'gcov': get_option('b_coverage')}
3431summary_info += {'thread sanitizer': config_host.has_key('CONFIG_TSAN')}
3432summary_info += {'CFI support': get_option('cfi')}
3433if get_option('cfi')
3434 summary_info += {'CFI debug support': get_option('cfi_debug')}
3435endif
3436summary_info += {'strip binaries': get_option('strip')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003437summary_info += {'sparse': sparse}
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003438summary_info += {'mingw32 support': targetos == 'windows'}
Alex Bennée49e85652021-02-22 10:14:50 +00003439
3440# snarf the cross-compilation information for tests
3441foreach target: target_dirs
3442 tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak'
3443 if fs.exists(tcg_mak)
3444 config_cross_tcg = keyval.load(tcg_mak)
3445 target = config_cross_tcg['TARGET_NAME']
3446 compiler = ''
3447 if 'DOCKER_CROSS_CC_GUEST' in config_cross_tcg
3448 summary_info += {target + ' tests': config_cross_tcg['DOCKER_CROSS_CC_GUEST'] +
3449 ' via ' + config_cross_tcg['DOCKER_IMAGE']}
3450 elif 'CROSS_CC_GUEST' in config_cross_tcg
3451 summary_info += {target + ' tests'
3452 : config_cross_tcg['CROSS_CC_GUEST'] }
3453 endif
3454 endif
3455endforeach
3456
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003457summary(summary_info, bool_yn: true, section: 'Compilation')
3458
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003459# Targets and accelerators
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003460summary_info = {}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003461if have_system
3462 summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
3463 summary_info += {'HAX support': config_all.has_key('CONFIG_HAX')}
3464 summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
3465 summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
Reinoud Zandijk74a414a2021-04-02 22:25:32 +02003466 summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003467 summary_info += {'Xen support': config_host.has_key('CONFIG_XEN_BACKEND')}
3468 if config_host.has_key('CONFIG_XEN_BACKEND')
3469 summary_info += {'xen ctrl version': config_host['CONFIG_XEN_CTRL_INTERFACE_VERSION']}
3470 endif
3471endif
3472summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
3473if config_all.has_key('CONFIG_TCG')
Philippe Mathieu-Daudé39687ac2021-01-25 15:45:29 +01003474 if get_option('tcg_interpreter')
Philippe Mathieu-Daudéf1f727a2021-11-06 12:14:57 +01003475 summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
Philippe Mathieu-Daudé39687ac2021-01-25 15:45:29 +01003476 else
3477 summary_info += {'TCG backend': 'native (@0@)'.format(cpu)}
3478 endif
Alex Bennée029aa682021-07-09 15:29:53 +01003479 summary_info += {'TCG plugins': config_host.has_key('CONFIG_PLUGIN')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003480 summary_info += {'TCG debug enabled': config_host.has_key('CONFIG_DEBUG_TCG')}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003481endif
Philippe Mathieu-Daudé2e864b82021-01-21 10:56:12 +01003482summary_info += {'target list': ' '.join(target_dirs)}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003483if have_system
3484 summary_info += {'default devices': get_option('default_devices')}
Paolo Bonzini106ad1f2021-02-17 16:24:25 +01003485 summary_info += {'out of process emulation': multiprocess_allowed}
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003486endif
3487summary(summary_info, bool_yn: true, section: 'Targets and accelerators')
3488
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003489# Block layer
3490summary_info = {}
3491summary_info += {'coroutine backend': config_host['CONFIG_COROUTINE_BACKEND']}
Paolo Bonzini728c0a22021-10-13 11:52:03 +02003492summary_info += {'coroutine pool': have_coroutine_pool}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003493if have_block
3494 summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
3495 summary_info += {'Block whitelist (ro)': config_host['CONFIG_BDRV_RO_WHITELIST']}
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02003496 summary_info += {'Use block whitelist in tools': get_option('block_drv_whitelist_in_tools')}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003497 summary_info += {'VirtFS support': have_virtfs}
3498 summary_info += {'build virtiofs daemon': have_virtiofsd}
Paolo Bonzini406523f2021-10-13 11:43:54 +02003499 summary_info += {'Live block migration': config_host_data.get('CONFIG_LIVE_BLOCK_MIGRATION')}
3500 summary_info += {'replication support': config_host_data.get('CONFIG_REPLICATION')}
Paolo Bonzinied793c22021-10-13 11:42:25 +02003501 summary_info += {'bochs support': get_option('bochs').allowed()}
3502 summary_info += {'cloop support': get_option('cloop').allowed()}
3503 summary_info += {'dmg support': get_option('dmg').allowed()}
3504 summary_info += {'qcow v1 support': get_option('qcow1').allowed()}
3505 summary_info += {'vdi support': get_option('vdi').allowed()}
3506 summary_info += {'vvfat support': get_option('vvfat').allowed()}
3507 summary_info += {'qed support': get_option('qed').allowed()}
3508 summary_info += {'parallels support': get_option('parallels').allowed()}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003509 summary_info += {'FUSE exports': fuse}
Philippe Mathieu-Daudé813803a2021-01-21 10:56:14 +01003510endif
3511summary(summary_info, bool_yn: true, section: 'Block layer support')
3512
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003513# Crypto
Philippe Mathieu-Daudéaa3ca632021-01-21 10:56:13 +01003514summary_info = {}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003515summary_info += {'TLS priority': config_host['CONFIG_TLS_PRIORITY']}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003516summary_info += {'GNUTLS support': gnutls}
3517if gnutls.found()
3518 summary_info += {' GNUTLS crypto': gnutls_crypto.found()}
3519endif
3520summary_info += {'libgcrypt': gcrypt}
3521summary_info += {'nettle': nettle}
Paolo Bonzini57612512021-06-03 11:15:26 +02003522if nettle.found()
3523 summary_info += {' XTS': xts != 'private'}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003524endif
Paolo Bonzini34b52612021-11-08 14:02:42 +01003525summary_info += {'AF_ALG support': have_afalg}
Paolo Bonzinic55cf6a2021-10-13 11:46:09 +02003526summary_info += {'rng-none': get_option('rng_none')}
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003527summary_info += {'Linux keyring': config_host.has_key('CONFIG_SECRET_KEYRING')}
3528summary(summary_info, bool_yn: true, section: 'Crypto')
3529
Philippe Mathieu-Daudé69a78cc2021-01-21 10:56:16 +01003530# Libraries
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003531summary_info = {}
3532if targetos == 'darwin'
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003533 summary_info += {'Cocoa support': cocoa}
Philippe Mathieu-Daudéaa580282021-01-21 10:56:15 +01003534endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003535summary_info += {'SDL support': sdl}
3536summary_info += {'SDL image support': sdl_image}
3537summary_info += {'GTK support': gtk}
3538summary_info += {'pixman': pixman}
3539summary_info += {'VTE support': vte}
3540summary_info += {'slirp support': slirp_opt == 'internal' ? slirp_opt : slirp}
3541summary_info += {'libtasn1': tasn1}
3542summary_info += {'PAM': pam}
3543summary_info += {'iconv support': iconv}
3544summary_info += {'curses support': curses}
3545summary_info += {'virgl support': virgl}
3546summary_info += {'curl support': curl}
3547summary_info += {'Multipath support': mpathpersist}
3548summary_info += {'VNC support': vnc}
Paolo Bonzinia0b93232020-02-06 15:48:52 +01003549if vnc.found()
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003550 summary_info += {'VNC SASL support': sasl}
3551 summary_info += {'VNC JPEG support': jpeg}
3552 summary_info += {'VNC PNG support': png}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003553endif
Paolo Bonzini87430d52021-10-07 15:06:09 +02003554if targetos not in ['darwin', 'haiku', 'windows']
3555 summary_info += {'OSS support': oss}
3556elif targetos == 'darwin'
3557 summary_info += {'CoreAudio support': coreaudio}
3558elif targetos == 'windows'
3559 summary_info += {'DirectSound support': dsound}
3560endif
3561if targetos == 'linux'
3562 summary_info += {'ALSA support': alsa}
3563 summary_info += {'PulseAudio support': pulse}
3564endif
3565summary_info += {'JACK support': jack}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003566summary_info += {'brlapi support': brlapi}
Paolo Bonzinie1723992021-10-07 15:08:21 +02003567summary_info += {'vde support': vde}
Paolo Bonzini837b84b2021-10-07 15:08:22 +02003568summary_info += {'netmap support': have_netmap}
Thomas Hutheea94532021-10-28 20:59:08 +02003569summary_info += {'l2tpv3 support': have_l2tpv3}
Paolo Bonziniff66f3e2021-10-07 15:08:20 +02003570summary_info += {'Linux AIO support': libaio}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003571summary_info += {'Linux io_uring support': linux_io_uring}
3572summary_info += {'ATTR/XATTR support': libattr}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003573summary_info += {'RDMA support': config_host.has_key('CONFIG_RDMA')}
3574summary_info += {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA')}
Paolo Bonzinifbb41212020-10-05 11:31:15 +02003575summary_info += {'fdt support': fdt_opt == 'disabled' ? false : fdt_opt}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003576summary_info += {'libcap-ng support': libcap_ng}
3577summary_info += {'bpf support': libbpf}
Marc-André Lureau3f0a5d52021-10-07 15:08:23 +02003578summary_info += {'spice protocol support': spice_protocol}
3579if spice_protocol.found()
3580 summary_info += {' spice server support': spice}
3581endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003582summary_info += {'rbd support': rbd}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003583summary_info += {'smartcard support': cacard}
3584summary_info += {'U2F support': u2f}
3585summary_info += {'libusb': libusb}
3586summary_info += {'usb net redir': usbredir}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003587summary_info += {'OpenGL support': config_host.has_key('CONFIG_OPENGL')}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003588summary_info += {'GBM': gbm}
3589summary_info += {'libiscsi support': libiscsi}
3590summary_info += {'libnfs support': libnfs}
Paolo Bonzinif9332752020-02-03 13:28:38 +01003591if targetos == 'windows'
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003592 if config_host.has_key('CONFIG_GUEST_AGENT')
3593 summary_info += {'QGA VSS support': config_host.has_key('CONFIG_QGA_VSS')}
3594 summary_info += {'QGA w32 disk info': config_host.has_key('CONFIG_QGA_NTDDSCSI')}
Paolo Bonzinib846ab72021-01-21 11:49:04 +01003595 endif
Paolo Bonzinif9332752020-02-03 13:28:38 +01003596endif
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003597summary_info += {'seccomp support': seccomp}
3598summary_info += {'GlusterFS support': glusterfs}
Paolo Bonzini0d04c4c2021-12-21 12:38:27 +01003599summary_info += {'TPM support': have_tpm}
Thomas Huthe6a52b32021-12-09 15:48:01 +01003600summary_info += {'libssh support': libssh}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003601summary_info += {'lzo support': lzo}
3602summary_info += {'snappy support': snappy}
3603summary_info += {'bzip2 support': libbzip2}
3604summary_info += {'lzfse support': liblzfse}
3605summary_info += {'zstd support': zstd}
Paolo Bonzini488a8c72021-12-21 12:38:27 +01003606summary_info += {'NUMA host support': numa}
Paolo Bonzinibb647c42021-06-03 11:24:56 +02003607summary_info += {'capstone': capstone_opt == 'internal' ? capstone_opt : capstone}
3608summary_info += {'libpmem support': libpmem}
3609summary_info += {'libdaxctl support': libdaxctl}
3610summary_info += {'libudev': libudev}
3611# Dummy dependency, keep .found()
Max Reitzdf4ea702020-10-27 20:05:46 +01003612summary_info += {'FUSE lseek': fuse_lseek.found()}
Richard W.M. Jones3d212b42021-11-15 14:29:43 -06003613summary_info += {'selinux': selinux}
Philippe Mathieu-Daudé69a78cc2021-01-21 10:56:16 +01003614summary(summary_info, bool_yn: true, section: 'Dependencies')
Paolo Bonzinif9332752020-02-03 13:28:38 +01003615
3616if not supported_cpus.contains(cpu)
3617 message()
3618 warning('SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!')
3619 message()
3620 message('CPU host architecture ' + cpu + ' support is not currently maintained.')
3621 message('The QEMU project intends to remove support for this host CPU in')
3622 message('a future release if nobody volunteers to maintain it and to')
3623 message('provide a build host for our continuous integration setup.')
3624 message('configure has succeeded and you can continue to build, but')
3625 message('if you care about QEMU on this platform you should contact')
3626 message('us upstream at qemu-devel@nongnu.org.')
3627endif
3628
3629if not supported_oses.contains(targetos)
3630 message()
3631 warning('WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!')
3632 message()
3633 message('Host OS ' + targetos + 'support is not currently maintained.')
3634 message('The QEMU project intends to remove support for this host OS in')
3635 message('a future release if nobody volunteers to maintain it and to')
3636 message('provide a build host for our continuous integration setup.')
3637 message('configure has succeeded and you can continue to build, but')
3638 message('if you care about QEMU on this platform you should contact')
3639 message('us upstream at qemu-devel@nongnu.org.')
3640endif