meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
+####################
+# Global variables #
+####################
+
not_found = dependency('', required: false)
keyval = import('keyval')
ss = import('sourceset')
fs = import('fs')
-targetos = host_machine.system()
-sh = find_program('sh')
+host_os = host_machine.system()
config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
-cc = meson.get_compiler('c')
-all_languages = ['c']
-if targetos == 'windows' and add_languages('cpp', required: false, native: false)
- all_languages += ['cpp']
- cxx = meson.get_compiler('cpp')
-endif
-if targetos == 'darwin' and \
- add_languages('objc', required: get_option('cocoa'), native: false)
- all_languages += ['objc']
- objc = meson.get_compiler('objc')
-endif
-
# Temporary directory used for files created while
# configure runs. Since it is in the build directory
# we can safely blow away any previous version of it
qemu_desktopdir = get_option('datadir') / 'applications'
qemu_icondir = get_option('datadir') / 'icons'
-config_host_data = configuration_data()
genh = []
qapi_trace_events = []
cpu = host_machine.cpu_family()
target_dirs = config_host['TARGET_DIRS'].split()
+
+############
+# Programs #
+############
+
+sh = find_program('sh')
+python = import('python').find_installation()
+
+cc = meson.get_compiler('c')
+all_languages = ['c']
+if host_os == 'windows' and add_languages('cpp', required: false, native: false)
+ all_languages += ['cpp']
+ cxx = meson.get_compiler('cpp')
+endif
+if host_os == 'darwin' and \
+ add_languages('objc', required: get_option('cocoa'), native: false)
+ all_languages += ['objc']
+ objc = meson.get_compiler('objc')
+endif
+
+dtrace = not_found
+stap = not_found
+if 'dtrace' in get_option('trace_backends')
+ dtrace = find_program('dtrace', required: true)
+ stap = find_program('stap', required: false)
+ if stap.found()
+ # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
+ # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
+ # instead. QEMU --enable-modules depends on this because the SystemTap
+ # semaphores are linked into the main binary and not the module's shared
+ # object.
+ add_global_arguments('-DSTAP_SDT_V2',
+ native: false, language: all_languages)
+ endif
+endif
+
+if get_option('iasl') == ''
+ iasl = find_program('iasl', required: false)
+else
+ iasl = find_program(get_option('iasl'), required: true)
+endif
+
+edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
+unpack_edk2_blobs = false
+foreach target : edk2_targets
+ if target in target_dirs
+ bzip2 = find_program('bzip2', required: get_option('install_blobs'))
+ unpack_edk2_blobs = bzip2.found()
+ break
+ endif
+endforeach
+
+#####################
+# Option validation #
+#####################
+
+# Fuzzing
+if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
+ not cc.links('''
+ #include <stdint.h>
+ #include <sys/types.h>
+ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
+ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
+ ''',
+ args: ['-Werror', '-fsanitize=fuzzer'])
+ error('Your compiler does not support -fsanitize=fuzzer')
+endif
+
+# Tracing backends
+if 'ftrace' in get_option('trace_backends') and host_os != 'linux'
+ error('ftrace is supported only on Linux')
+endif
+if 'syslog' in get_option('trace_backends') and not cc.compiles('''
+ #include <syslog.h>
+ int main(void) {
+ openlog("qemu", LOG_PID, LOG_DAEMON);
+ syslog(LOG_INFO, "configure");
+ return 0;
+ }''')
+ error('syslog is not supported on this system')
+endif
+
+# Miscellaneous Linux-only features
+get_option('mpath') \
+ .require(host_os == 'linux', error_message: 'Multipath is supported only on Linux')
+
+multiprocess_allowed = get_option('multiprocess') \
+ .require(host_os == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
+ .allowed()
+
+vfio_user_server_allowed = get_option('vfio_user_server') \
+ .require(host_os == 'linux', error_message: 'vfio-user server is supported only on Linux') \
+ .allowed()
+
+have_tpm = get_option('tpm') \
+ .require(host_os != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
+ .allowed()
+
+# vhost
+have_vhost_user = get_option('vhost_user') \
+ .disable_auto_if(host_os != 'linux') \
+ .require(host_os != 'windows',
+ error_message: 'vhost-user is not available on Windows').allowed()
+have_vhost_vdpa = get_option('vhost_vdpa') \
+ .require(host_os == 'linux',
+ error_message: 'vhost-vdpa is only available on Linux').allowed()
+have_vhost_kernel = get_option('vhost_kernel') \
+ .require(host_os == 'linux',
+ error_message: 'vhost-kernel is only available on Linux').allowed()
+have_vhost_user_crypto = get_option('vhost_crypto') \
+ .require(have_vhost_user,
+ error_message: 'vhost-crypto requires vhost-user to be enabled').allowed()
+
+have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel
+
+have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed()
+have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed()
+have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed()
+have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa
+
+# type of binaries to build
have_linux_user = false
have_bsd_user = false
have_system = false
have_system = have_system or target.endswith('-softmmu')
endforeach
have_user = have_linux_user or have_bsd_user
+
have_tools = get_option('tools') \
.disable_auto_if(not have_system) \
.allowed()
have_ga = get_option('guest_agent') \
.disable_auto_if(not have_system and not have_tools) \
- .require(targetos in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'],
+ .require(host_os in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'],
error_message: 'unsupported OS for QEMU guest agent') \
.allowed()
+have_block = have_system or have_tools
+
enable_modules = get_option('modules') \
- .require(targetos != 'windows',
+ .require(host_os != 'windows',
error_message: 'Modules are not available for Windows') \
.require(not get_option('prefer_static'),
error_message: 'Modules are incompatible with static linking') \
.allowed()
-have_block = have_system or have_tools
-python = import('python').find_installation()
+#######################################
+# Variables for host and accelerators #
+#######################################
if cpu not in supported_cpus
host_arch = 'unknown'
kvm_targets = ['riscv32-softmmu']
elif cpu in ['riscv64']
kvm_targets = ['riscv64-softmmu']
+elif cpu in ['loongarch64']
+ kvm_targets = ['loongarch64-softmmu']
else
kvm_targets = []
endif
+accelerator_targets = { 'CONFIG_KVM': kvm_targets }
-kvm_targets_c = '""'
-if get_option('kvm').allowed() and targetos == 'linux'
- kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
+if cpu in ['x86', 'x86_64']
+ xen_targets = ['i386-softmmu', 'x86_64-softmmu']
+elif cpu in ['arm', 'aarch64']
+ # i386 emulator provides xenpv machine type for multiple architectures
+ xen_targets = ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu']
+else
+ xen_targets = []
endif
-config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
-
-accelerator_targets = { 'CONFIG_KVM': kvm_targets }
+accelerator_targets += { 'CONFIG_XEN': xen_targets }
if cpu in ['aarch64']
accelerator_targets += {
}
endif
-if cpu in ['x86', 'x86_64', 'arm', 'aarch64']
- # i386 emulator provides xenpv machine type for multiple architectures
- accelerator_targets += {
- 'CONFIG_XEN': ['i386-softmmu', 'x86_64-softmmu', 'aarch64-softmmu'],
- }
-endif
if cpu in ['x86', 'x86_64']
accelerator_targets += {
'CONFIG_HVF': ['x86_64-softmmu'],
modular_tcg = []
# Darwin does not support references to thread-local variables in modules
-if targetos != 'darwin'
+if host_os != 'darwin'
modular_tcg = ['i386-softmmu', 'x86_64-softmmu']
endif
-edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ]
-unpack_edk2_blobs = false
-foreach target : edk2_targets
- if target in target_dirs
- bzip2 = find_program('bzip2', required: get_option('install_blobs'))
- unpack_edk2_blobs = bzip2.found()
- break
- endif
-endforeach
-
-dtrace = not_found
-stap = not_found
-if 'dtrace' in get_option('trace_backends')
- dtrace = find_program('dtrace', required: true)
- stap = find_program('stap', required: false)
- if stap.found()
- # Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
- # visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
- # instead. QEMU --enable-modules depends on this because the SystemTap
- # semaphores are linked into the main binary and not the module's shared
- # object.
- add_global_arguments('-DSTAP_SDT_V2',
- native: false, language: all_languages)
- endif
-endif
-
-if get_option('iasl') == ''
- iasl = find_program('iasl', required: false)
-else
- iasl = find_program(get_option('iasl'), required: true)
-endif
-
##################
# Compiler flags #
##################
qemu_cflags = []
qemu_ldflags = []
-if targetos == 'darwin'
+if host_os == 'darwin'
# Disable attempts to use ObjectiveC features in os/object.h since they
# won't work when we're compiling with gcc as a C compiler.
if compiler.get_id() == 'gcc'
qemu_common_flags += '-DOS_OBJECT_USE_OBJC=0'
endif
-elif targetos == 'sunos'
+elif host_os == 'sunos'
# needed for CMSG_ macros in sys/socket.h
qemu_common_flags += '-D_XOPEN_SOURCE=600'
# needed for TIOCWIN* defines in termios.h
qemu_common_flags += '-D__EXTENSIONS__'
-elif targetos == 'haiku'
+elif host_os == 'haiku'
qemu_common_flags += ['-DB_USE_POSITIVE_POSIX_ERRORS', '-D_BSD_SOURCE', '-fPIC']
endif
# For POSIX prefer ucontext, but it's not always possible. The fallback
# is sigcontext.
supported_backends = []
-if targetos == 'windows'
+if host_os == 'windows'
supported_backends += ['windows']
else
- if targetos != 'darwin' and cc.links(ucontext_probe)
+ if host_os != 'darwin' and cc.links(ucontext_probe)
supported_backends += ['ucontext']
endif
supported_backends += ['sigaltstack']
# The combination is known as "full relro", because .got.plt is read-only too.
qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now')
-if targetos == 'windows'
+if host_os == 'windows'
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--no-seh', '-Wl,--nxcompat')
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--dynamicbase', '-Wl,--high-entropy-va')
endif
# Exclude --warn-common with TSan to suppress warnings from the TSan libraries.
-if targetos != 'sunos' and not get_option('tsan')
+if host_os != 'sunos' and not get_option('tsan')
qemu_ldflags += cc.get_supported_link_arguments('-Wl,--warn-common')
endif
endif
endif
+if get_option('cfi')
+ cfi_flags=[]
+ # Check for dependency on LTO
+ if not get_option('b_lto')
+ error('Selected Control-Flow Integrity but LTO is disabled')
+ endif
+ if enable_modules
+ error('Selected Control-Flow Integrity is not compatible with modules')
+ endif
+ # Check for cfi flags. CFI requires LTO so we can't use
+ # get_supported_arguments, but need a more complex "compiles" which allows
+ # custom arguments
+ if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
+ args: ['-flto', '-fsanitize=cfi-icall'] )
+ cfi_flags += '-fsanitize=cfi-icall'
+ else
+ error('-fsanitize=cfi-icall is not supported by the compiler')
+ endif
+ if cc.compiles('int main () { return 0; }',
+ name: '-fsanitize-cfi-icall-generalize-pointers',
+ args: ['-flto', '-fsanitize=cfi-icall',
+ '-fsanitize-cfi-icall-generalize-pointers'] )
+ cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
+ else
+ error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
+ endif
+ if get_option('cfi_debug')
+ if cc.compiles('int main () { return 0; }',
+ name: '-fno-sanitize-trap=cfi-icall',
+ args: ['-flto', '-fsanitize=cfi-icall',
+ '-fno-sanitize-trap=cfi-icall'] )
+ cfi_flags += '-fno-sanitize-trap=cfi-icall'
+ else
+ error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
+ endif
+ endif
+ add_global_arguments(cfi_flags, native: false, language: all_languages)
+ add_global_link_arguments(cfi_flags, native: false, language: all_languages)
+endif
+
+# Check further flags that make QEMU more robust against malicious parties
+
+hardening_flags = [
+ # Zero out registers used during a function call
+ # upon its return. This makes it harder to assemble
+ # ROP gadgets into something usable
+ '-fzero-call-used-regs=used-gpr',
+
+ # Initialize all stack variables to zero. This makes
+ # it harder to take advantage of uninitialized stack
+ # data to drive exploits
+ '-ftrivial-auto-var-init=zero',
+]
+
+qemu_common_flags += cc.get_supported_arguments(hardening_flags)
+
add_global_arguments(qemu_common_flags, native: false, language: all_languages)
add_global_link_arguments(qemu_ldflags, native: false, language: all_languages)
'-Wshadow=local',
]
-if targetos != 'darwin'
+if host_os != 'darwin'
warn_flags += ['-Wthread-safety']
endif
# Note sanitizer flags are not applied to Objective-C sources!
add_project_arguments(objc.get_supported_arguments(warn_flags), native: false, language: 'objc')
endif
-if targetos == 'linux'
+if host_os == 'linux'
add_project_arguments('-isystem', meson.current_source_dir() / 'linux-headers',
'-isystem', 'linux-headers',
language: all_languages)
'-Wno-non-pointer-null'])
endif
-###########################################
-# Target-specific checks and dependencies #
-###########################################
-
-# Fuzzing
-if get_option('fuzzing') and get_option('fuzzing_engine') == '' and \
- not cc.links('''
- #include <stdint.h>
- #include <sys/types.h>
- int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
- int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; }
- ''',
- args: ['-Werror', '-fsanitize=fuzzer'])
- error('Your compiler does not support -fsanitize=fuzzer')
-endif
-
-# Tracing backends
-if 'ftrace' in get_option('trace_backends') and targetos != 'linux'
- error('ftrace is supported only on Linux')
-endif
-if 'syslog' in get_option('trace_backends') and not cc.compiles('''
- #include <syslog.h>
- int main(void) {
- openlog("qemu", LOG_PID, LOG_DAEMON);
- syslog(LOG_INFO, "configure");
- return 0;
- }''')
- error('syslog is not supported on this system')
-endif
-
-# Miscellaneous Linux-only features
-get_option('mpath') \
- .require(targetos == 'linux', error_message: 'Multipath is supported only on Linux')
-
-multiprocess_allowed = get_option('multiprocess') \
- .require(targetos == 'linux', error_message: 'Multiprocess QEMU is supported only on Linux') \
- .allowed()
-
-vfio_user_server_allowed = get_option('vfio_user_server') \
- .require(targetos == 'linux', error_message: 'vfio-user server is supported only on Linux') \
- .allowed()
-
-have_tpm = get_option('tpm') \
- .require(targetos != 'windows', error_message: 'TPM emulation only available on POSIX systems') \
- .allowed()
-
-# vhost
-have_vhost_user = get_option('vhost_user') \
- .disable_auto_if(targetos != 'linux') \
- .require(targetos != 'windows',
- error_message: 'vhost-user is not available on Windows').allowed()
-have_vhost_vdpa = get_option('vhost_vdpa') \
- .require(targetos == 'linux',
- error_message: 'vhost-vdpa is only available on Linux').allowed()
-have_vhost_kernel = get_option('vhost_kernel') \
- .require(targetos == 'linux',
- error_message: 'vhost-kernel is only available on Linux').allowed()
-have_vhost_user_crypto = get_option('vhost_crypto') \
- .require(have_vhost_user,
- error_message: 'vhost-crypto requires vhost-user to be enabled').allowed()
-
-have_vhost = have_vhost_user or have_vhost_vdpa or have_vhost_kernel
+#####################################
+# Host-specific libraries and flags #
+#####################################
-have_vhost_net_user = have_vhost_user and get_option('vhost_net').allowed()
-have_vhost_net_vdpa = have_vhost_vdpa and get_option('vhost_net').allowed()
-have_vhost_net_kernel = have_vhost_kernel and get_option('vhost_net').allowed()
-have_vhost_net = have_vhost_net_kernel or have_vhost_net_user or have_vhost_net_vdpa
-
-# Target-specific libraries and flags
libm = cc.find_library('m', required: false)
threads = dependency('threads')
util = cc.find_library('util', required: false)
coref = []
iokit = []
emulator_link_args = []
-nvmm =not_found
-hvf = not_found
midl = not_found
widl = not_found
pathcch = not_found
host_dsosuf = '.so'
-if targetos == 'windows'
+if host_os == 'windows'
midl = find_program('midl', required: false)
widl = find_program('widl', required: false)
pathcch = cc.find_library('pathcch')
depend_files: files('pc-bios/qemu-nsis.ico'),
include_directories: include_directories('.'))
host_dsosuf = '.dll'
-elif targetos == 'darwin'
+elif host_os == 'darwin'
coref = dependency('appleframeworks', modules: 'CoreFoundation')
iokit = dependency('appleframeworks', modules: 'IOKit', required: false)
host_dsosuf = '.dylib'
-elif targetos == 'sunos'
+elif host_os == 'sunos'
socket = [cc.find_library('socket'),
cc.find_library('nsl'),
cc.find_library('resolv')]
-elif targetos == 'haiku'
+elif host_os == 'haiku'
socket = [cc.find_library('posix_error_mapper'),
cc.find_library('network'),
cc.find_library('bsd')]
-elif targetos == 'openbsd'
+elif host_os == 'openbsd'
if get_option('tcg').allowed() and target_dirs.length() > 0
# Disable OpenBSD W^X if available
emulator_link_args = cc.get_supported_link_arguments('-Wl,-z,wxneeded')
endif
endif
-# Target-specific configuration of accelerators
+###############################################
+# Host-specific configuration of accelerators #
+###############################################
+
accelerators = []
-if get_option('kvm').allowed() and targetos == 'linux'
+if get_option('kvm').allowed() and host_os == 'linux'
accelerators += 'CONFIG_KVM'
endif
-if get_option('whpx').allowed() and targetos == 'windows'
+if get_option('whpx').allowed() and host_os == 'windows'
if get_option('whpx').enabled() and host_machine.cpu() != 'x86_64'
error('WHPX requires 64-bit host')
elif cc.has_header('winhvplatform.h', required: get_option('whpx')) and \
accelerators += 'CONFIG_WHPX'
endif
endif
+
+hvf = not_found
if get_option('hvf').allowed()
hvf = dependency('appleframeworks', modules: 'Hypervisor',
required: get_option('hvf'))
accelerators += 'CONFIG_HVF'
endif
endif
-if targetos == 'netbsd'
+
+nvmm = not_found
+if host_os == 'netbsd'
nvmm = cc.find_library('nvmm', required: get_option('nvmm'))
if nvmm.found()
accelerators += 'CONFIG_NVMM'
error('WHPX not available on this platform')
endif
+xen = not_found
+if get_option('xen').enabled() or (get_option('xen').auto() and have_system)
+ xencontrol = dependency('xencontrol', required: false,
+ method: 'pkg-config')
+ if xencontrol.found()
+ xen_pc = declare_dependency(version: xencontrol.version(),
+ dependencies: [
+ xencontrol,
+ # disabler: true makes xen_pc.found() return false if any is not found
+ dependency('xenstore', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xenforeignmemory', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xengnttab', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xenevtchn', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ dependency('xendevicemodel', required: false,
+ method: 'pkg-config',
+ disabler: true),
+ # optional, no "disabler: true"
+ dependency('xentoolcore', required: false,
+ method: 'pkg-config')])
+ if xen_pc.found()
+ xen = xen_pc
+ endif
+ endif
+ if not xen.found()
+ xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ]
+ xen_libs = {
+ '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
+ '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
+ '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
+ '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
+ '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
+ }
+ xen_deps = {}
+ foreach ver: xen_tests
+ # cache the various library tests to avoid polluting the logs
+ xen_test_deps = []
+ foreach l: xen_libs[ver]
+ if l not in xen_deps
+ xen_deps += { l: cc.find_library(l, required: false) }
+ endif
+ xen_test_deps += xen_deps[l]
+ endforeach
+
+ # Use -D to pick just one of the test programs in scripts/xen-detect.c
+ xen_version = ver.split('.')
+ xen_ctrl_version = xen_version[0] + \
+ ('0' + xen_version[1]).substring(-2) + \
+ ('0' + xen_version[2]).substring(-2)
+ if cc.links(files('scripts/xen-detect.c'),
+ args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version,
+ dependencies: xen_test_deps)
+ xen = declare_dependency(version: ver, dependencies: xen_test_deps)
+ break
+ endif
+ endforeach
+ endif
+ if xen.found()
+ accelerators += 'CONFIG_XEN'
+ elif get_option('xen').enabled()
+ error('could not compile and link Xen test program')
+ endif
+endif
+have_xen_pci_passthrough = get_option('xen_pci_passthrough') \
+ .require(xen.found(),
+ error_message: 'Xen PCI passthrough requested but Xen not enabled') \
+ .require(host_os == 'linux',
+ error_message: 'Xen PCI passthrough not available on this platform') \
+ .require(cpu == 'x86' or cpu == 'x86_64',
+ error_message: 'Xen PCI passthrough not available on this platform') \
+ .allowed()
+
################
# Dependencies #
################
# This workaround is required due to a bug in pkg-config file for glib as it
# doesn't define GLIB_STATIC_COMPILATION for pkg-config --static
-if targetos == 'windows' and get_option('prefer_static')
+if host_os == 'windows' and get_option('prefer_static')
glib_cflags += ['-DGLIB_STATIC_COMPILATION']
endif
endif
pulse = not_found
-if not get_option('pa').auto() or (targetos == 'linux' and have_system)
+if not get_option('pa').auto() or (host_os == 'linux' and have_system)
pulse = dependency('libpulse', required: get_option('pa'),
method: 'pkg-config')
endif
alsa = not_found
-if not get_option('alsa').auto() or (targetos == 'linux' and have_system)
+if not get_option('alsa').auto() or (host_os == 'linux' and have_system)
alsa = dependency('alsa', required: get_option('alsa'),
method: 'pkg-config')
endif
method: 'pkg-config')
endif
pipewire = not_found
-if not get_option('pipewire').auto() or (targetos == 'linux' and have_system)
+if not get_option('pipewire').auto() or (host_os == 'linux' and have_system)
pipewire = dependency('libpipewire-0.3', version: '>=0.3.60',
required: get_option('pipewire'),
method: 'pkg-config')
endif
virgl = not_found
-have_vhost_user_gpu = have_tools and targetos == 'linux' and pixman.found()
+have_vhost_user_gpu = have_tools and host_os == 'linux' and pixman.found()
if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu
virgl = dependency('virglrenderer',
method: 'pkg-config',
required: get_option('virglrenderer'))
- if virgl.found()
- config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT',
- cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d',
- prefix: '#include <virglrenderer.h>',
- dependencies: virgl))
- endif
endif
rutabaga = not_found
if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu
required: get_option('curl'))
endif
libudev = not_found
-if targetos == 'linux' and (have_system or have_tools)
+if host_os == 'linux' and (have_system or have_tools)
libudev = dependency('libudev',
method: 'pkg-config',
required: get_option('libudev'))
mpathlibs = [libudev]
mpathpersist = not_found
-if targetos == 'linux' and have_tools and get_option('mpath').allowed()
+if host_os == 'linux' and have_tools and get_option('mpath').allowed()
mpath_test_source = '''
#include <libudev.h>
#include <mpath_persist.h>
return 0;
}'''
- curses_dep_list = targetos == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
+ curses_dep_list = host_os == 'windows' ? ['ncurses', 'ncursesw'] : ['ncursesw']
curses = dependency(curses_dep_list,
required: false,
method: 'pkg-config')
endif
if not curses.found()
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
- if targetos != 'windows' and not has_curses_h
+ if host_os != 'windows' and not has_curses_h
message('Trying with /usr/include/ncursesw')
curses_compile_args += ['-I/usr/include/ncursesw']
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
endif
if has_curses_h
- curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
+ curses_libname_list = (host_os == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
foreach curses_libname : curses_libname_list
libcurses = cc.find_library(curses_libname,
required: false)
if get_option('oss').allowed() and have_system
if not cc.has_header('sys/soundcard.h')
# not found
- elif targetos == 'netbsd'
+ elif host_os == 'netbsd'
oss = cc.find_library('ossaudio', required: get_option('oss'))
else
oss = declare_dependency()
endif
endif
dsound = not_found
-if not get_option('dsound').auto() or (targetos == 'windows' and have_system)
+if not get_option('dsound').auto() or (host_os == 'windows' and have_system)
if cc.has_header('dsound.h')
dsound = declare_dependency(link_args: ['-lole32', '-ldxguid'])
endif
endif
coreaudio = not_found
-if not get_option('coreaudio').auto() or (targetos == 'darwin' and have_system)
+if not get_option('coreaudio').auto() or (host_os == 'darwin' and have_system)
coreaudio = dependency('appleframeworks', modules: 'CoreAudio',
required: get_option('coreaudio'))
endif
endif
endif
+capstone = not_found
+if not get_option('capstone').auto() or have_system or have_user
+ capstone = dependency('capstone', version: '>=3.0.5',
+ method: 'pkg-config',
+ required: get_option('capstone'))
+
+ # Some versions of capstone have broken pkg-config file
+ # that reports a wrong -I path, causing the #include to
+ # fail later. If the system has such a broken version
+ # do not use it.
+ if capstone.found() and not cc.compiles('#include <capstone.h>',
+ dependencies: [capstone])
+ capstone = not_found
+ if get_option('capstone').enabled()
+ error('capstone requested, but it does not appear to work')
+ endif
+ endif
+endif
+
gmp = dependency('gmp', required: false, method: 'pkg-config')
if nettle.found() and gmp.found()
hogweed = dependency('hogweed', version: '>=3.4',
endforeach
endif
-xen = not_found
-if get_option('xen').enabled() or (get_option('xen').auto() and have_system)
- xencontrol = dependency('xencontrol', required: false,
- method: 'pkg-config')
- if xencontrol.found()
- xen_pc = declare_dependency(version: xencontrol.version(),
- dependencies: [
- xencontrol,
- # disabler: true makes xen_pc.found() return false if any is not found
- dependency('xenstore', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xenforeignmemory', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xengnttab', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xenevtchn', required: false,
- method: 'pkg-config',
- disabler: true),
- dependency('xendevicemodel', required: false,
- method: 'pkg-config',
- disabler: true),
- # optional, no "disabler: true"
- dependency('xentoolcore', required: false,
- method: 'pkg-config')])
- if xen_pc.found()
- xen = xen_pc
- endif
- endif
- if not xen.found()
- xen_tests = [ '4.11.0', '4.10.0', '4.9.0', '4.8.0', '4.7.1' ]
- xen_libs = {
- '4.11.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
- '4.10.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn', 'xentoolcore' ],
- '4.9.0': [ 'xenstore', 'xenctrl', 'xendevicemodel', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
- '4.8.0': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
- '4.7.1': [ 'xenstore', 'xenctrl', 'xenforeignmemory', 'xengnttab', 'xenevtchn' ],
- }
- xen_deps = {}
- foreach ver: xen_tests
- # cache the various library tests to avoid polluting the logs
- xen_test_deps = []
- foreach l: xen_libs[ver]
- if l not in xen_deps
- xen_deps += { l: cc.find_library(l, required: false) }
- endif
- xen_test_deps += xen_deps[l]
- endforeach
-
- # Use -D to pick just one of the test programs in scripts/xen-detect.c
- xen_version = ver.split('.')
- xen_ctrl_version = xen_version[0] + \
- ('0' + xen_version[1]).substring(-2) + \
- ('0' + xen_version[2]).substring(-2)
- if cc.links(files('scripts/xen-detect.c'),
- args: '-DCONFIG_XEN_CTRL_INTERFACE_VERSION=' + xen_ctrl_version,
- dependencies: xen_test_deps)
- xen = declare_dependency(version: ver, dependencies: xen_test_deps)
- break
- endif
- endforeach
- endif
- if xen.found()
- accelerators += 'CONFIG_XEN'
- elif get_option('xen').enabled()
- error('could not compile and link Xen test program')
- endif
-endif
-have_xen_pci_passthrough = get_option('xen_pci_passthrough') \
- .require(xen.found(),
- error_message: 'Xen PCI passthrough requested but Xen not enabled') \
- .require(targetos == 'linux',
- error_message: 'Xen PCI passthrough not available on this platform') \
- .require(cpu == 'x86' or cpu == 'x86_64',
- error_message: 'Xen PCI passthrough not available on this platform') \
- .allowed()
-
-
cacard = not_found
if not get_option('smartcard').auto() or have_system
cacard = dependency('libcacard', required: get_option('smartcard'),
version: '>=2.5.1', method: 'pkg-config')
endif
u2f = not_found
-if have_system
+if not get_option('u2f').auto() or have_system
u2f = dependency('u2f-emu', required: get_option('u2f'),
method: 'pkg-config')
endif
canokey = not_found
-if have_system
+if not get_option('canokey').auto() or have_system
canokey = dependency('canokey-qemu', required: get_option('canokey'),
method: 'pkg-config')
endif
has_statx_mnt_id = cc.has_header_symbol('sys/stat.h', 'STATX_MNT_ID', prefix: gnu_source_prefix)
have_vhost_user_blk_server = get_option('vhost_user_blk_server') \
- .require(targetos == 'linux',
+ .require(host_os == 'linux',
error_message: 'vhost_user_blk_server requires linux') \
.require(have_vhost_user,
error_message: 'vhost_user_blk_server requires vhost-user support') \
endif
endif
-have_libvduse = (targetos == 'linux')
+have_libvduse = (host_os == 'linux')
if get_option('libvduse').enabled()
- if targetos != 'linux'
+ if host_os != 'linux'
error('libvduse requires linux')
endif
elif get_option('libvduse').disabled()
have_libvduse = false
endif
-have_vduse_blk_export = (have_libvduse and targetos == 'linux')
+have_vduse_blk_export = (have_libvduse and host_os == 'linux')
if get_option('vduse_blk_export').enabled()
- if targetos != 'linux'
+ if host_os != 'linux'
error('vduse_blk_export requires linux')
elif not have_libvduse
error('vduse_blk_export requires libvduse support')
# config-host.h #
#################
+config_host_data = configuration_data()
+
audio_drivers_selected = []
if have_system
audio_drivers_available = {
# Default to native drivers first, OSS second, SDL third
audio_drivers_priority = \
[ 'pa', 'coreaudio', 'dsound', 'sndio', 'oss' ] + \
- (targetos == 'linux' ? [] : [ 'sdl' ])
+ (host_os == 'linux' ? [] : [ 'sdl' ])
audio_drivers_default = []
foreach k: audio_drivers_priority
if audio_drivers_available[k]
config_host_data.set('CONFIG_AUDIO_DRIVERS',
'"' + '", "'.join(audio_drivers_selected) + '", ')
-if get_option('cfi')
- cfi_flags=[]
- # Check for dependency on LTO
- if not get_option('b_lto')
- error('Selected Control-Flow Integrity but LTO is disabled')
- endif
- if enable_modules
- error('Selected Control-Flow Integrity is not compatible with modules')
- endif
- # Check for cfi flags. CFI requires LTO so we can't use
- # get_supported_arguments, but need a more complex "compiles" which allows
- # custom arguments
- if cc.compiles('int main () { return 0; }', name: '-fsanitize=cfi-icall',
- args: ['-flto', '-fsanitize=cfi-icall'] )
- cfi_flags += '-fsanitize=cfi-icall'
- else
- error('-fsanitize=cfi-icall is not supported by the compiler')
- endif
- if cc.compiles('int main () { return 0; }',
- name: '-fsanitize-cfi-icall-generalize-pointers',
- args: ['-flto', '-fsanitize=cfi-icall',
- '-fsanitize-cfi-icall-generalize-pointers'] )
- cfi_flags += '-fsanitize-cfi-icall-generalize-pointers'
- else
- error('-fsanitize-cfi-icall-generalize-pointers is not supported by the compiler')
- endif
- if get_option('cfi_debug')
- if cc.compiles('int main () { return 0; }',
- name: '-fno-sanitize-trap=cfi-icall',
- args: ['-flto', '-fsanitize=cfi-icall',
- '-fno-sanitize-trap=cfi-icall'] )
- cfi_flags += '-fno-sanitize-trap=cfi-icall'
- else
- error('-fno-sanitize-trap=cfi-icall is not supported by the compiler')
- endif
- endif
- add_global_arguments(cfi_flags, native: false, language: all_languages)
- add_global_link_arguments(cfi_flags, native: false, language: all_languages)
-endif
-
-have_host_block_device = (targetos != 'darwin' or
+have_host_block_device = (host_os != 'darwin' or
cc.has_header('IOKit/storage/IOMedia.h'))
dbus_display = get_option('dbus_display') \
.allowed()
have_virtfs = get_option('virtfs') \
- .require(targetos == 'linux' or targetos == 'darwin',
+ .require(host_os == 'linux' or host_os == 'darwin',
error_message: 'virtio-9p (virtfs) requires Linux or macOS') \
- .require(targetos == 'linux' or cc.has_function('pthread_fchdir_np'),
+ .require(host_os == 'linux' or cc.has_function('pthread_fchdir_np'),
error_message: 'virtio-9p (virtfs) on macOS requires the presence of pthread_fchdir_np') \
- .require(targetos == 'darwin' or libattr.found(),
+ .require(host_os == 'darwin' or libattr.found(),
error_message: 'virtio-9p (virtfs) on Linux requires libattr-devel') \
.disable_auto_if(not have_tools and not have_system) \
.allowed()
have_virtfs_proxy_helper = get_option('virtfs_proxy_helper') \
- .require(targetos != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \
+ .require(host_os != 'darwin', error_message: 'the virtfs proxy helper is incompatible with macOS') \
.require(have_virtfs, error_message: 'the virtfs proxy helper requires that virtfs is enabled') \
.disable_auto_if(not have_tools) \
.require(libcap_ng.found(), error_message: 'the virtfs proxy helper requires libcap-ng') \
endif
have_slirp_smbd = get_option('slirp_smbd') \
- .require(targetos != 'windows', error_message: 'Host smbd not supported on this platform.') \
+ .require(host_os != 'windows', error_message: 'Host smbd not supported on this platform.') \
.allowed()
if have_slirp_smbd
smbd_path = get_option('smbd')
if smbd_path == ''
- smbd_path = (targetos == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
+ smbd_path = (host_os == 'sunos' ? '/usr/sfw/sbin/smbd' : '/usr/sbin/smbd')
endif
config_host_data.set_quoted('CONFIG_SMBD_COMMAND', smbd_path)
endif
config_host_data.set('HOST_' + host_arch.to_upper(), 1)
+kvm_targets_c = '""'
+if get_option('kvm').allowed() and host_os == 'linux'
+ kvm_targets_c = '"' + '" ,"'.join(kvm_targets) + '"'
+endif
+config_host_data.set('CONFIG_KVM_TARGETS', kvm_targets_c)
+
if get_option('module_upgrades') and not enable_modules
error('Cannot enable module-upgrades as modules are not enabled')
endif
config_host_data.set('CONFIG_ATTR', libattr.found())
config_host_data.set('CONFIG_BDRV_WHITELIST_TOOLS', get_option('block_drv_whitelist_in_tools'))
config_host_data.set('CONFIG_BRLAPI', brlapi.found())
-config_host_data.set('CONFIG_BSD', targetos in bsd_oses)
+config_host_data.set('CONFIG_BSD', host_os in bsd_oses)
+config_host_data.set('CONFIG_CAPSTONE', capstone.found())
config_host_data.set('CONFIG_COCOA', cocoa.found())
-config_host_data.set('CONFIG_DARWIN', targetos == 'darwin')
+config_host_data.set('CONFIG_DARWIN', host_os == 'darwin')
config_host_data.set('CONFIG_FUZZ', get_option('fuzzing'))
config_host_data.set('CONFIG_GCOV', get_option('b_coverage'))
config_host_data.set('CONFIG_LIBUDEV', libudev.found())
-config_host_data.set('CONFIG_LINUX', targetos == 'linux')
-config_host_data.set('CONFIG_POSIX', targetos != 'windows')
-config_host_data.set('CONFIG_WIN32', targetos == 'windows')
+config_host_data.set('CONFIG_LINUX', host_os == 'linux')
+config_host_data.set('CONFIG_POSIX', host_os != 'windows')
+config_host_data.set('CONFIG_WIN32', host_os == 'windows')
config_host_data.set('CONFIG_LZO', lzo.found())
config_host_data.set('CONFIG_MPATH', mpathpersist.found())
config_host_data.set('CONFIG_BLKIO', blkio.found())
config_host_data.set('CONFIG_SECCOMP_SYSRAWRC', seccomp_has_sysrawrc)
endif
config_host_data.set('CONFIG_PIXMAN', pixman.found())
+config_host_data.set('CONFIG_SLIRP', slirp.found())
config_host_data.set('CONFIG_SNAPPY', snappy.found())
-config_host_data.set('CONFIG_SOLARIS', targetos == 'sunos')
+config_host_data.set('CONFIG_SOLARIS', host_os == 'sunos')
if get_option('tcg').allowed()
config_host_data.set('CONFIG_TCG', 1)
config_host_data.set('CONFIG_TCG_INTERPRETER', tcg_arch == 'tci')
config_host_data.set('CONFIG_VNC', vnc.found())
config_host_data.set('CONFIG_VNC_JPEG', jpeg.found())
config_host_data.set('CONFIG_VNC_SASL', sasl.found())
+if virgl.found()
+ config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT',
+ cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d',
+ prefix: '#include <virglrenderer.h>',
+ dependencies: virgl))
+endif
config_host_data.set('CONFIG_VIRTFS', have_virtfs)
config_host_data.set('CONFIG_VTE', vte.found())
config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
config_host_data.set('HAVE_SYS_DISK_H', cc.has_header('sys/disk.h'))
config_host_data.set('HAVE_SYS_IOCCOM_H', cc.has_header('sys/ioccom.h'))
config_host_data.set('HAVE_SYS_KCOV_H', cc.has_header('sys/kcov.h'))
-if targetos == 'windows'
+if host_os == 'windows'
config_host_data.set('HAVE_AFUNIX_H', cc.has_header('afunix.h'))
endif
config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include <stdlib.h>'))
-config_host_data.set('HAVE_GETLOADAVG_FUNCTION', cc.has_function('getloadavg', prefix: '#include <stdlib.h>'))
if rbd.found()
config_host_data.set('HAVE_RBD_NAMESPACE_EXISTS',
cc.has_function('rbd_namespace_exists',
int main(void) { return 0; }'''))
have_keyring = get_option('keyring') \
- .require(targetos == 'linux', error_message: 'keyring is only available on Linux') \
+ .require(host_os == 'linux', error_message: 'keyring is only available on Linux') \
.require(cc.compiles('''
#include <errno.h>
#include <asm/unistd.h>
if get_option('membarrier').disabled()
have_membarrier = false
-elif targetos == 'windows'
+elif host_os == 'windows'
have_membarrier = true
-elif targetos == 'linux'
+elif host_os == 'linux'
have_membarrier = cc.compiles('''
#include <linux/membarrier.h>
#include <sys/syscall.h>
have_vss = false
have_vss_sdk = false # old xp/2003 SDK
-if targetos == 'windows' and 'cpp' in all_languages
+if host_os == 'windows' and 'cpp' in all_languages
have_vss = cxx.compiles('''
#define __MIDL_user_allocate_free_DEFINED__
#include <vss.h>
# Older versions of MinGW do not import _lock_file and _unlock_file properly.
# This was fixed for v6.0.0 with commit b48e3ac8969d.
-if targetos == 'windows'
+if host_os == 'windows'
config_host_data.set('HAVE__LOCK_FILE', cc.links('''
#include <stdio.h>
int main(void) {
}''', name: '_lock_file and _unlock_file'))
endif
-if targetos == 'windows'
+if host_os == 'windows'
mingw_has_setjmp_longjmp = cc.links('''
#include <setjmp.h>
int main(void) {
########################
minikconf = find_program('scripts/minikconf.py')
-config_targetos = {
- (targetos == 'windows' ? 'CONFIG_WIN32' : 'CONFIG_POSIX'): 'y'
-}
-if targetos == 'darwin'
- config_targetos += {'CONFIG_DARWIN': 'y'}
-elif targetos == 'linux'
- config_targetos += {'CONFIG_LINUX': 'y'}
-endif
-if targetos in bsd_oses
- config_targetos += {'CONFIG_BSD': 'y'}
-endif
-config_all = {}
+config_all_accel = {}
config_all_devices = {}
-config_all_disas = {}
config_devices_mak_list = []
config_devices_h = {}
config_target_h = {}
(have_vhost_vdpa ? ['CONFIG_VHOST_VDPA=y'] : []) + \
(have_vhost_kernel ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
(have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \
- (targetos == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
+ (host_os == 'linux' ? ['CONFIG_LINUX=y'] : []) + \
(have_pvrdma ? ['CONFIG_PVRDMA=y'] : []) + \
(multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \
(vfio_user_server_allowed ? ['CONFIG_VFIO_USER_SERVER_ALLOWED=y'] : []) + \
foreach target : target_dirs
config_target = { 'TARGET_NAME': target.split('-')[0] }
if target.endswith('linux-user')
- if targetos != 'linux'
+ if host_os != 'linux'
if default_targets
continue
endif
endif
config_target += { 'CONFIG_LINUX_USER': 'y' }
elif target.endswith('bsd-user')
- if targetos not in bsd_oses
+ if host_os not in bsd_oses
if default_targets
continue
endif
foreach sym: accelerators
if sym == 'CONFIG_TCG' or target in accelerator_targets.get(sym, [])
config_target += { sym: 'y' }
- config_all += { sym: 'y' }
+ config_all_accel += { sym: 'y' }
if target in modular_tcg
config_target += { 'CONFIG_TCG_MODULAR': 'y' }
else
if host_arch.startswith(k) or config_target['TARGET_BASE_ARCH'].startswith(k)
foreach sym: v
config_target += { sym: 'y' }
- config_all_disas += { sym: 'y' }
endforeach
endif
endforeach
endforeach
target_dirs = actual_target_dirs
-# This configuration is used to build files that are shared by
-# multiple binaries, and then extracted out of the "common"
-# static_library target.
-#
-# We do not use all_sources()/all_dependencies(), because it would
-# build literally all source files, including devices only used by
-# targets that are not built for this compilation. The CONFIG_ALL
-# pseudo symbol replaces it.
-
-config_all += config_all_devices
-config_all += config_targetos
-config_all += config_all_disas
-config_all += {
- 'CONFIG_XEN': xen.found(),
- 'CONFIG_SYSTEM_ONLY': have_system,
- 'CONFIG_USER_ONLY': have_user,
- 'CONFIG_ALL': true,
-}
-
target_configs_h = []
foreach target: target_dirs
target_configs_h += config_target_h[target]
command: [find_program('scripts/make-config-poison.sh'),
target_configs_h])
-##############
-# Submodules #
-##############
-
-capstone = not_found
-if not get_option('capstone').auto() or have_system or have_user
- capstone = dependency('capstone', version: '>=3.0.5',
- method: 'pkg-config',
- required: get_option('capstone'))
-
- # Some versions of capstone have broken pkg-config file
- # that reports a wrong -I path, causing the #include to
- # fail later. If the system has such a broken version
- # do not use it.
- if capstone.found() and not cc.compiles('#include <capstone.h>',
- dependencies: [capstone])
- capstone = not_found
- if get_option('capstone').enabled()
- error('capstone requested, but it does not appear to work')
- endif
- endif
-endif
+###############
+# Subprojects #
+###############
libvfio_user_dep = not_found
if have_system and vfio_user_server_allowed
fdt_opt = 'disabled'
endif
-config_host_data.set('CONFIG_CAPSTONE', capstone.found())
config_host_data.set('CONFIG_FDT', fdt.found())
-config_host_data.set('CONFIG_SLIRP', slirp.found())
+
+vhost_user = not_found
+if host_os == 'linux' and have_vhost_user
+ libvhost_user = subproject('libvhost-user')
+ vhost_user = libvhost_user.get_variable('vhost_user_dep')
+endif
+
+libvduse = not_found
+if have_libvduse
+ libvduse_proj = subproject('libvduse')
+ libvduse = libvduse_proj.get_variable('libvduse_dep')
+endif
#####################
# Generated sources #
endforeach
genh += hxdep
-###################
-# Collect sources #
-###################
-
-authz_ss = ss.source_set()
-blockdev_ss = ss.source_set()
-block_ss = ss.source_set()
-chardev_ss = ss.source_set()
-common_ss = ss.source_set()
-crypto_ss = ss.source_set()
-hwcore_ss = ss.source_set()
-io_ss = ss.source_set()
-qmp_ss = ss.source_set()
-qom_ss = ss.source_set()
-system_ss = ss.source_set()
-specific_fuzz_ss = ss.source_set()
-specific_ss = ss.source_set()
-stub_ss = ss.source_set()
-trace_ss = ss.source_set()
-user_ss = ss.source_set()
-util_ss = ss.source_set()
-
-# accel modules
-qtest_module_ss = ss.source_set()
-tcg_module_ss = ss.source_set()
-
-modules = {}
-target_modules = {}
-hw_arch = {}
-target_arch = {}
-target_system_arch = {}
-target_user_arch = {}
-
###############
# Trace files #
###############
'target/hppa',
'target/i386',
'target/i386/kvm',
+ 'target/loongarch',
'target/mips/tcg',
'target/nios2',
'target/ppc',
]
endif
-vhost_user = not_found
-if targetos == 'linux' and have_vhost_user
- libvhost_user = subproject('libvhost-user')
- vhost_user = libvhost_user.get_variable('vhost_user_dep')
-endif
+###################
+# Collect sources #
+###################
-libvduse = not_found
-if have_libvduse
- libvduse_proj = subproject('libvduse')
- libvduse = libvduse_proj.get_variable('libvduse_dep')
-endif
+authz_ss = ss.source_set()
+blockdev_ss = ss.source_set()
+block_ss = ss.source_set()
+chardev_ss = ss.source_set()
+common_ss = ss.source_set()
+crypto_ss = ss.source_set()
+hwcore_ss = ss.source_set()
+io_ss = ss.source_set()
+qmp_ss = ss.source_set()
+qom_ss = ss.source_set()
+system_ss = ss.source_set()
+specific_fuzz_ss = ss.source_set()
+specific_ss = ss.source_set()
+stub_ss = ss.source_set()
+trace_ss = ss.source_set()
+user_ss = ss.source_set()
+util_ss = ss.source_set()
+
+# accel modules
+qtest_module_ss = ss.source_set()
+tcg_module_ss = ss.source_set()
+
+modules = {}
+target_modules = {}
+hw_arch = {}
+target_arch = {}
+target_system_arch = {}
+target_user_arch = {}
# NOTE: the trace/ subdirectory needs the qapi_trace_events variable
# that is filled in by qapi/.
modulecommon = declare_dependency(link_whole: libmodulecommon, compile_args: '-DBUILD_DSO')
endif
-qom_ss = qom_ss.apply(config_targetos, strict: false)
+qom_ss = qom_ss.apply({})
libqom = static_library('qom', qom_ss.sources() + genh,
dependencies: [qom_ss.dependencies()],
name_suffix: 'fa',
event_loop_base = declare_dependency(link_whole: event_loop_base,
dependencies: [qom])
-stub_ss = stub_ss.apply(config_all, strict: false)
+stub_ss = stub_ss.apply({})
util_ss.add_all(trace_ss)
-util_ss = util_ss.apply(config_all, strict: false)
+util_ss = util_ss.apply({})
libqemuutil = static_library('qemuutil',
build_by_default: false,
sources: util_ss.sources() + stub_ss.sources() + genh,
# os-posix.c contains POSIX-specific functions used by qemu-storage-daemon,
# os-win32.c does not
- blockdev_ss.add(when: 'CONFIG_POSIX', if_true: files('os-posix.c'))
- system_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
+ if host_os == 'windows'
+ system_ss.add(files('os-win32.c'))
+ else
+ blockdev_ss.add(files('os-posix.c'))
+ endif
endif
common_ss.add(files('cpu-common.c'))
target_modules += { 'accel' : { 'qtest': qtest_module_ss,
'tcg': tcg_real_module_ss }}
-########################
-# Library dependencies #
-########################
+##############################################
+# Internal static_libraries and dependencies #
+##############################################
modinfo_collect = find_program('scripts/modinfo-collect.py')
modinfo_generate = find_program('scripts/modinfo-generate.py')
foreach m, module_ss : list
if enable_modules
- module_ss = module_ss.apply(config_all, strict: false)
+ module_ss = module_ss.apply(config_all_devices, strict: false)
sl = static_library(d + '-' + m, [genh, module_ss.sources()],
dependencies: [modulecommon, module_ss.dependencies()], pic: true)
if d == 'block'
foreach target : target_dirs
if target.endswith('-softmmu')
config_target = config_target_mak[target]
- config_target += config_targetos
target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
c_args = ['-DNEED_CPU_H',
'-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
capture: true,
command: [undefsym, nm, '@INPUT@'])
-authz_ss = authz_ss.apply(config_targetos, strict: false)
+authz_ss = authz_ss.apply({})
libauthz = static_library('authz', authz_ss.sources() + genh,
dependencies: [authz_ss.dependencies()],
name_suffix: 'fa',
authz = declare_dependency(link_whole: libauthz,
dependencies: qom)
-crypto_ss = crypto_ss.apply(config_targetos, strict: false)
+crypto_ss = crypto_ss.apply({})
libcrypto = static_library('crypto', crypto_ss.sources() + genh,
dependencies: [crypto_ss.dependencies()],
name_suffix: 'fa',
crypto = declare_dependency(link_whole: libcrypto,
dependencies: [authz, qom])
-io_ss = io_ss.apply(config_targetos, strict: false)
+io_ss = io_ss.apply({})
libio = static_library('io', io_ss.sources() + genh,
dependencies: [io_ss.dependencies()],
link_with: libqemuutil,
dependencies: [zlib, qom, io])
system_ss.add(migration)
-block_ss = block_ss.apply(config_targetos, strict: false)
+block_ss = block_ss.apply({})
libblock = static_library('block', block_ss.sources() + genh,
dependencies: block_ss.dependencies(),
link_depends: block_syms,
link_args: '@block.syms',
dependencies: [crypto, io])
-blockdev_ss = blockdev_ss.apply(config_targetos, strict: false)
+blockdev_ss = blockdev_ss.apply({})
libblockdev = static_library('blockdev', blockdev_ss.sources() + genh,
dependencies: blockdev_ss.dependencies(),
name_suffix: 'fa',
blockdev = declare_dependency(link_whole: [libblockdev],
dependencies: [block, event_loop_base])
-qmp_ss = qmp_ss.apply(config_targetos, strict: false)
+qmp_ss = qmp_ss.apply({})
libqmp = static_library('qmp', qmp_ss.sources() + genh,
dependencies: qmp_ss.dependencies(),
name_suffix: 'fa',
chardev = declare_dependency(link_whole: libchardev)
-hwcore_ss = hwcore_ss.apply(config_targetos, strict: false)
+hwcore_ss = hwcore_ss.apply({})
libhwcore = static_library('hwcore', sources: hwcore_ss.sources() + genh,
name_suffix: 'fa',
build_by_default: false)
common_ss.add_all(when: 'CONFIG_SYSTEM_ONLY', if_true: [system_ss])
common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
-common_all = common_ss.apply(config_all, strict: false)
+# Note that this library is never used directly (only through extract_objects)
+# and is not built by default; therefore, source files not used by the build
+# configuration will be in build.ninja, but are never built by default.
common_all = static_library('common',
build_by_default: false,
- sources: common_all.sources() + genh,
+ sources: common_ss.all_sources() + genh,
include_directories: common_user_inc,
implicit_include_directories: false,
- dependencies: common_all.dependencies(),
+ dependencies: common_ss.all_dependencies(),
name_suffix: 'fa')
feature_to_c = find_program('scripts/feature_to_c.py')
-if targetos == 'darwin'
+if host_os == 'darwin'
entitlement = find_program('scripts/entitlement.sh')
endif
'-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)]
link_args = emulator_link_args
- config_target += config_targetos
target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
- if targetos == 'linux'
+ if host_os == 'linux'
target_inc += include_directories('linux-headers', is_system: true)
endif
if target.endswith('-softmmu')
arch_deps += t.dependencies()
hw_dir = target_name == 'sparc64' ? 'sparc64' : target_base_arch
- hw = hw_arch[hw_dir].apply(config_target, strict: false)
- arch_srcs += hw.sources()
- arch_deps += hw.dependencies()
+ if hw_arch.has_key(hw_dir)
+ hw = hw_arch[hw_dir].apply(config_target, strict: false)
+ arch_srcs += hw.sources()
+ arch_deps += hw.dependencies()
+ endif
arch_srcs += config_devices_h[target]
link_args += ['@block.syms', '@qemu.syms']
endif
if 'CONFIG_BSD_USER' in config_target
base_dir = 'bsd-user'
- target_inc += include_directories('bsd-user/' / targetos)
+ target_inc += include_directories('bsd-user/' / host_os)
target_inc += include_directories('bsd-user/host/' / host_arch)
dir = base_dir / abi
arch_srcs += files(dir / 'signal.c', dir / 'target_arch_cpu.c')
'sources': files('system/main.c'),
'dependencies': []
}]
- if targetos == 'windows' and (sdl.found() or gtk.found())
+ if host_os == 'windows' and (sdl.found() or gtk.found())
execs += [{
'name': 'qemu-system-' + target_name + 'w',
'win_subsystem': 'windows',
endif
foreach exe: execs
exe_name = exe['name']
- if targetos == 'darwin'
+ if host_os == 'darwin'
exe_name += '-unsigned'
endif
link_args: link_args,
win_subsystem: exe['win_subsystem'])
- if targetos == 'darwin'
+ if host_os == 'darwin'
icon = 'pc-bios/qemu.rsrc'
build_input = [emulator, files(icon)]
install_input = [
if get_option('plugins')
install_headers('include/qemu/qemu-plugin.h')
- if targetos == 'windows'
+ if host_os == 'windows'
# On windows, we want to deliver the qemu_plugin_api.lib file in the qemu installer,
# so that plugin authors can compile against it.
install_data(win32_qemu_plugin_api_lib, install_dir: 'lib')
subdir('contrib/vhost-user-scsi')
endif
- if targetos == 'linux'
+ if host_os == 'linux'
executable('qemu-bridge-helper', files('qemu-bridge-helper.c'),
dependencies: [qemuutil, libcap_ng],
install: true,
# Directories
summary_info += {'Install prefix': get_option('prefix')}
summary_info += {'BIOS directory': qemu_datadir}
-pathsep = targetos == 'windows' ? ';' : ':'
+pathsep = host_os == 'windows' ? ';' : ':'
summary_info += {'firmware path': pathsep.join(get_option('qemu_firmwarepath'))}
summary_info += {'binary directory': get_option('prefix') / get_option('bindir')}
summary_info += {'library directory': get_option('prefix') / get_option('libdir')}
summary_info += {'libexec directory': get_option('prefix') / get_option('libexecdir')}
summary_info += {'include directory': get_option('prefix') / get_option('includedir')}
summary_info += {'config directory': get_option('prefix') / get_option('sysconfdir')}
-if targetos != 'windows'
+if host_os != 'windows'
summary_info += {'local state directory': get_option('prefix') / get_option('localstatedir')}
summary_info += {'Manual directory': get_option('prefix') / get_option('mandir')}
else
endif
summary_info += {'iasl': iasl}
summary_info += {'genisoimage': config_host['GENISOIMAGE']}
-if targetos == 'windows' and have_ga
+if host_os == 'windows' and have_ga
summary_info += {'wixl': wixl}
endif
if slirp.found() and have_system
endif
summary_info += {'strip binaries': get_option('strip')}
summary_info += {'sparse': sparse}
-summary_info += {'mingw32 support': targetos == 'windows'}
+summary_info += {'mingw32 support': host_os == 'windows'}
summary(summary_info, bool_yn: true, section: 'Compilation')
# snarf the cross-compilation information for tests
# Targets and accelerators
summary_info = {}
if have_system
- summary_info += {'KVM support': config_all.has_key('CONFIG_KVM')}
- summary_info += {'HVF support': config_all.has_key('CONFIG_HVF')}
- summary_info += {'WHPX support': config_all.has_key('CONFIG_WHPX')}
- summary_info += {'NVMM support': config_all.has_key('CONFIG_NVMM')}
+ summary_info += {'KVM support': config_all_accel.has_key('CONFIG_KVM')}
+ summary_info += {'HVF support': config_all_accel.has_key('CONFIG_HVF')}
+ summary_info += {'WHPX support': config_all_accel.has_key('CONFIG_WHPX')}
+ summary_info += {'NVMM support': config_all_accel.has_key('CONFIG_NVMM')}
summary_info += {'Xen support': xen.found()}
if xen.found()
summary_info += {'xen ctrl version': xen.version()}
endif
- summary_info += {'Xen emulation': config_all.has_key('CONFIG_XEN_EMU')}
+ summary_info += {'Xen emulation': config_all_devices.has_key('CONFIG_XEN_EMU')}
endif
-summary_info += {'TCG support': config_all.has_key('CONFIG_TCG')}
-if config_all.has_key('CONFIG_TCG')
+summary_info += {'TCG support': config_all_accel.has_key('CONFIG_TCG')}
+if config_all_accel.has_key('CONFIG_TCG')
if get_option('tcg_interpreter')
summary_info += {'TCG backend': 'TCI (TCG with bytecode interpreter, slow)'}
else
# UI
summary_info = {}
-if targetos == 'darwin'
+if host_os == 'darwin'
summary_info += {'Cocoa support': cocoa}
endif
summary_info += {'SDL support': sdl}
summary_info += {'brlapi support': brlapi}
summary(summary_info, bool_yn: true, section: 'User interface')
+# Graphics backends
+summary_info = {}
+summary_info += {'VirGL support': virgl}
+summary_info += {'Rutabaga support': rutabaga}
+summary(summary_info, bool_yn: true, section: 'Graphics backends')
+
# Audio backends
summary_info = {}
-if targetos not in ['darwin', 'haiku', 'windows']
+if host_os not in ['darwin', 'haiku', 'windows']
summary_info += {'OSS support': oss}
summary_info += {'sndio support': sndio}
-elif targetos == 'darwin'
+elif host_os == 'darwin'
summary_info += {'CoreAudio support': coreaudio}
-elif targetos == 'windows'
+elif host_os == 'windows'
summary_info += {'DirectSound support': dsound}
endif
-if targetos == 'linux'
+if host_os == 'linux'
summary_info += {'ALSA support': alsa}
summary_info += {'PulseAudio support': pulse}
endif
# Network backends
summary_info = {}
-if targetos == 'darwin'
+if host_os == 'darwin'
summary_info += {'vmnet.framework support': vmnet}
endif
summary_info += {'AF_XDP support': libxdp}
summary_info += {'libtasn1': tasn1}
summary_info += {'PAM': pam}
summary_info += {'iconv support': iconv}
-summary_info += {'virgl support': virgl}
-summary_info += {'rutabaga support': rutabaga}
summary_info += {'blkio support': blkio}
summary_info += {'curl support': curl}
summary_info += {'Multipath support': mpathpersist}
summary_info += {'GBM': gbm}
summary_info += {'libiscsi support': libiscsi}
summary_info += {'libnfs support': libnfs}
-if targetos == 'windows'
+if host_os == 'windows'
if have_ga
summary_info += {'QGA VSS support': have_qga_vss}
endif
endif
endif
-if not supported_oses.contains(targetos)
+if not supported_oses.contains(host_os)
message()
warning('UNSUPPORTED HOST OS')
message()
- message('Support for host OS ' + targetos + 'is not currently maintained.')
+ message('Support for host OS ' + host_os + 'is not currently maintained.')
message('configure has succeeded and you can continue to build, but')
message('the QEMU project does not guarantee that QEMU will compile or')
message('work on this operating system. You can help by volunteering')
message('to maintain it and providing a build host for our continuous')
message('integration setup. This will ensure that future versions of QEMU')
- message('will keep working on ' + targetos + '.')
+ message('will keep working on ' + host_os + '.')
endif
-if host_arch == 'unknown' or not supported_oses.contains(targetos)
+if host_arch == 'unknown' or not supported_oses.contains(host_os)
message()
message('If you want to help supporting QEMU on this platform, please')
message('contact the developers at qemu-devel@nongnu.org.')
warning('bindir not included within prefix, the installation will not be relocatable.')
actually_reloc = false
endif
-if not actually_reloc and (targetos == 'windows' or get_option('relocatable'))
- if targetos == 'windows'
+if not actually_reloc and (host_os == 'windows' or get_option('relocatable'))
+ if host_os == 'windows'
message()
warning('Windows installs should usually be relocatable.')
endif