+subdir('libdecnumber')
+subdir('target')
+subdir('dump')
+
+block_ss.add(files(
+ 'block.c',
+ 'blockjob.c',
+ 'job.c',
+ 'qemu-io-cmds.c',
+))
+block_ss.add(when: 'CONFIG_REPLICATION', if_true: files('replication.c'))
+
+subdir('nbd')
+subdir('scsi')
+subdir('block')
+
+blockdev_ss.add(files(
+ 'blockdev.c',
+ 'blockdev-nbd.c',
+ 'iothread.c',
+ 'job-qmp.c',
+))
+
+# 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'))
+softmmu_ss.add(when: 'CONFIG_WIN32', if_true: [files('os-win32.c')])
+
+softmmu_ss.add_all(blockdev_ss)
+softmmu_ss.add(files(
+ 'bootdevice.c',
+ 'dma-helpers.c',
+ 'qdev-monitor.c',
+), sdl)
+
+softmmu_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c'))
+softmmu_ss.add(when: 'CONFIG_SECCOMP', if_true: [files('qemu-seccomp.c'), seccomp])
+softmmu_ss.add(when: ['CONFIG_FDT', fdt], if_true: [files('device_tree.c')])
+
+common_ss.add(files('cpus-common.c'))
+
+subdir('softmmu')
+subdir('backends')
+subdir('disas')
+subdir('migration')
+subdir('monitor')
+subdir('net')
+subdir('replay')
+subdir('hw')
+subdir('accel')
+subdir('linux-user')
+
+linux_user_ss.add(files('gdbstub.c', 'thunk.c'))
+specific_ss.add_all(when: 'CONFIG_LINUX_USER', if_true: linux_user_ss)
+
+# needed for fuzzing binaries
+subdir('tests/qtest/libqos')
+
+block_mods = []
+softmmu_mods = []
+foreach d, list : modules
+ foreach m, module_ss : list
+ if enable_modules and targetos != 'windows'
+ module_ss = module_ss.apply(config_host, strict: false)
+ sl = static_library(d + '-' + m, [genh, module_ss.sources()],
+ dependencies: [modulecommon, module_ss.dependencies()], pic: true)
+ if d == 'block'
+ block_mods += sl
+ else
+ softmmu_mods += sl
+ endif
+ else
+ if d == 'block'
+ block_ss.add_all(module_ss)
+ else
+ softmmu_ss.add_all(module_ss)
+ endif
+ endif
+ endforeach
+endforeach
+
+nm = find_program('nm')
+undefsym = find_program('scripts/undefsym.sh')
+block_syms = custom_target('block.syms', output: 'block.syms',
+ input: [libqemuutil, block_mods],
+ capture: true,
+ command: [undefsym, nm, '@INPUT@'])
+qemu_syms = custom_target('qemu.syms', output: 'qemu.syms',
+ input: [libqemuutil, softmmu_mods],
+ capture: true,
+ command: [undefsym, nm, '@INPUT@'])
+
+block_ss = block_ss.apply(config_host, strict: false)
+libblock = static_library('block', block_ss.sources() + genh,
+ dependencies: block_ss.dependencies(),
+ link_depends: block_syms,
+ name_suffix: 'fa',
+ build_by_default: false)
+
+block = declare_dependency(link_whole: [libblock],
+ link_args: '@block.syms',
+ dependencies: [crypto, io])
+
+qmp_ss = qmp_ss.apply(config_host, strict: false)
+libqmp = static_library('qmp', qmp_ss.sources() + genh,
+ dependencies: qmp_ss.dependencies(),
+ name_suffix: 'fa',
+ build_by_default: false)
+
+qmp = declare_dependency(link_whole: [libqmp])
+
+foreach m : block_mods + softmmu_mods
+ shared_module(m.name(),
+ name_prefix: '',
+ link_whole: m,
+ install: true,
+ install_dir: config_host['qemu_moddir'])
+endforeach
+
+common_ss.add_all(when: 'CONFIG_SOFTMMU', if_true: softmmu_ss)
+common_ss.add_all(when: 'CONFIG_USER_ONLY', if_true: user_ss)
+
+common_all = common_ss.apply(config_all, strict: false)
+common_all = static_library('common',
+ build_by_default: false,
+ sources: common_all.sources() + genh,
+ dependencies: common_all.dependencies(),
+ name_suffix: 'fa')
+
+foreach target : target_dirs
+ config_target = config_target_mak[target]
+ target_name = config_target['TARGET_NAME']
+ arch = config_target['TARGET_BASE_ARCH']
+ arch_srcs = []
+
+ target_inc = [include_directories('target' / config_target['TARGET_BASE_ARCH'])]
+ if targetos == 'linux'
+ target_inc += include_directories('linux-headers', is_system: true)
+ endif
+ if target.endswith('-softmmu')
+ qemu_target_name = 'qemu-system-' + target_name
+ target_type='system'
+ t = target_softmmu_arch[arch].apply(config_target, strict: false)
+ arch_srcs += t.sources()
+
+ hw_dir = target_name == 'sparc64' ? 'sparc64' : arch
+ hw = hw_arch[hw_dir].apply(config_target, strict: false)
+ arch_srcs += hw.sources()
+
+ arch_srcs += config_devices_h[target]
+ else
+ abi = config_target['TARGET_ABI_DIR']
+ target_type='user'
+ qemu_target_name = 'qemu-' + target_name
+ if 'CONFIG_LINUX_USER' in config_target
+ base_dir = 'linux-user'
+ target_inc += include_directories('linux-user/host/' / config_host['ARCH'])
+ else
+ base_dir = 'bsd-user'
+ endif
+ target_inc += include_directories(
+ base_dir,
+ base_dir / abi,
+ )
+ if 'CONFIG_LINUX_USER' in config_target
+ dir = base_dir / abi
+ arch_srcs += files(dir / 'signal.c', dir / 'cpu_loop.c')
+ if config_target.has_key('TARGET_SYSTBL_ABI')
+ arch_srcs += \
+ syscall_nr_generators[abi].process(base_dir / abi / config_target['TARGET_SYSTBL'],
+ extra_args : config_target['TARGET_SYSTBL_ABI'])
+ endif
+ endif
+ endif
+
+ t = target_arch[arch].apply(config_target, strict: false)
+ arch_srcs += t.sources()
+
+ target_common = common_ss.apply(config_target, strict: false)
+ objects = common_all.extract_objects(target_common.sources())
+
+ # TODO: Change to generator once obj-y goes away
+ config_target_h = custom_target(target + '-config-target.h',
+ input: meson.current_build_dir() / target / 'config-target.mak',
+ output: target + '-config-target.h',
+ capture: true,
+ command: [create_config, '@INPUT@'])
+
+ target_specific = specific_ss.apply(config_target, strict: false)
+ arch_srcs += target_specific.sources()
+
+ static_library('qemu-' + target,
+ sources: arch_srcs + [config_target_h] + genh,
+ objects: objects,
+ include_directories: target_inc,
+ c_args: ['-DNEED_CPU_H',
+ '-DCONFIG_TARGET="@0@-config-target.h"'.format(target),
+ '-DCONFIG_DEVICES="@0@-config-devices.h"'.format(target)],
+ name_suffix: 'fa')
+endforeach