config BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
	bool
	# Only tested on these architectures
	default y if BR2_aarch64
	default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5
	default y if BR2_i386
	default y if BR2_mips
	default y if BR2_mipsel
	default y if BR2_powerpc64
	default y if BR2_powerpc64le
	default y if BR2_riscv
	default y if BR2_s390x
	default y if BR2_x86_64

comment "QEMU requires a toolchain with wchar, threads, gcc >= 8"
	depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
	depends on BR2_USE_MMU
	depends on !(BR2_TOOLCHAIN_HAS_THREADS && BR2_USE_WCHAR) || \
		!BR2_TOOLCHAIN_GCC_AT_LEAST_8

menuconfig BR2_PACKAGE_QEMU
	bool "QEMU"
	depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8
	depends on BR2_TOOLCHAIN_HAS_THREADS
	depends on BR2_USE_WCHAR # gettext
	depends on BR2_USE_MMU # fork()
	select BR2_PACKAGE_LIBGLIB2
	select BR2_PACKAGE_ZLIB
	help
	  QEMU is a generic and open source machine emulator and
	  virtualizer.

	  When used as a machine emulator, QEMU can run OSes and
	  programs made for one machine (e.g. an ARM board) on a
	  different machine (e.g.  your own PC). By using dynamic
	  translation, it achieves very good performance.

	  When used as a virtualizer, QEMU achieves near native
	  performances by executing the guest code directly on the
	  host CPU. QEMU supports virtualization when executing under
	  the Xen hypervisor or using the KVM kernel module in
	  Linux. When using KVM, QEMU can virtualize x86, server and
	  embedded PowerPC, and S390 guests.

	  https://www.qemu.org/

if BR2_PACKAGE_QEMU

comment "Emulators selection"

config BR2_PACKAGE_QEMU_SYSTEM
	bool "Enable systems emulation"
	depends on !BR2_STATIC_LIBS # dtc
	select BR2_PACKAGE_PIXMAN
	select BR2_PACKAGE_QEMU_FDT if !BR2_PACKAGE_QEMU_CHOOSE_TARGETS
	# Make sure at least one of tcg or kvm is enabled
	select BR2_PACKAGE_QEMU_SYSTEM_TCG if !BR2_PACKAGE_QEMU_SYSTEM_KVM
	help
	  Say 'y' to build system emulators/virtualisers.

if BR2_PACKAGE_QEMU_SYSTEM

config BR2_PACKAGE_QEMU_SYSTEM_KVM
	bool "Enable KVM system virtualisation"
	default y
	help
	  Say 'y' here to enable a QEMU with KVM support.
	  If unsure, say 'y'

config BR2_PACKAGE_QEMU_SYSTEM_TCG
	bool "Enable TCG system emulation"
	default y
	help
	  Say 'y' here to enable QEMU binaries which can emulate foreign
	  architectures using the TCG JIT.

config BR2_PACKAGE_QEMU_BLOBS
	bool "Install binary blobs"
	default y
	help
	  Say 'y' here (the default) to install binary blobs (such as
	  BIOS or firmwares for the different machines simulated by
	  QEMU). Say 'n' to not install those blobs.

	  Note: Some machines may be unbootable without those blobs.
	  If unsure, say 'y'.

config BR2_PACKAGE_QEMU_SLIRP
	bool "Enable user mode networking (SLIRP)"
	select BR2_PACKAGE_SLIRP
	help
	  Enable user mode network stack, which is the default
	  networking backend. It requires no administrator privileges
	  and generally is the easiest to use but has some
	  limitations:

	  - there is a lot of overhead so the performance is poor;
	  - in general ICMP does not work (can't ping from/to a guest)
	  - on Linux hosts, ping does work from within the guest, but it
	    needs initial setup by root (once per host)
	  - the guest is not directly accessible from the host or the
	    external network

	  User Networking is implemented using "slirp", which provides a
	  full TCP/IP stack within QEMU and uses that stack to implement
	  a virtual NAT'd network.

	  Notice that this option does not disable other networking
	  modes.

config BR2_PACKAGE_QEMU_SDL
	bool "Enable SDL frontend"
	select BR2_PACKAGE_SDL2
	help
	  Say 'y' to enable the SDL frontend, that is, a graphical
	  window presenting the VM's display.

config BR2_PACKAGE_QEMU_FDT
	bool "Enable FDT"
	select BR2_PACKAGE_DTC
	help
	  Say 'y' here to have QEMU capable of constructing Device
	  Trees, and passing them to the VMs.

config BR2_PACKAGE_QEMU_TRACING
	bool "Enable tracing"
	help
	  Say 'y' to enable the "log" tracing infrastructure in QEMU,
	  used for debugging, profiling, and observing execution. For
	  detailed documentation, see

	  https://www.qemu.org/docs/master/devel/tracing.html

endif # BR2_PACKAGE_QEMU_SYSTEM

comment "systems emulation needs a toolchain w/ dynamic library"
	depends on BR2_STATIC_LIBS

config BR2_PACKAGE_QEMU_LINUX_USER
	bool "Enable Linux user-land emulation"
	help
	  Say 'y' to build Linux user-land emulators.

# Note: bsd-user can not be build on Linux

config BR2_PACKAGE_QEMU_CHOOSE_TARGETS
	bool "Select individual emulator targets"
	depends on BR2_PACKAGE_QEMU_SYSTEM_TCG || BR2_PACKAGE_QEMU_LINUX_USER
	help
	  By default, all targets system targets are built. If you
	  only need a subset of the emulated targets, say 'y' here and
	  enable at least one target, below.

if BR2_PACKAGE_QEMU_CHOOSE_TARGETS

config BR2_PACKAGE_QEMU_TARGET_AARCH64
	bool "aarch64"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  ARM 64-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_AARCH64_BE
	bool "aarch64_be (linux-user, only)"
	depends on BR2_PACKAGE_QEMU_LINUX_USER
	help
	  ARM 64-bit architecture, big-endian.

config BR2_PACKAGE_QEMU_TARGET_ALPHA
	bool "alpha"
	help
	  DEC Alpha 64-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_ARM
	bool "arm"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  ARM EABI architecture, little-endian.

config BR2_PACKAGE_QEMU_TARGET_ARMEB
	bool "armeb (linux-user, only)"
	depends on BR2_PACKAGE_QEMU_LINUX_USER
	help
	  ARM EABI architecture, big-endian.

config BR2_PACKAGE_QEMU_TARGET_AVR
	bool "avr (system, only)"
	depends on BR2_PACKAGE_QEMU_SYSTEM
	help
	  AVR 8-bit microcontroller architecture.

config BR2_PACKAGE_QEMU_TARGET_HEXAGON
	bool "hexagon (linux-user, only)"
	depends on BR2_PACKAGE_QEMU_LINUX_USER
	help
	  Qualcomm's Hexagon VLSI DSP architecture.

config BR2_PACKAGE_QEMU_TARGET_HPPA
	bool "hppa"
	help
	  HP PA-RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_I386
	bool "i386"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  Intel i386 32-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_LOONGARCH64
	bool "loongarch64"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  Loongson 64-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_M68K
	bool "m68k"
	help
	  Motorola 68000 architecture.

config BR2_PACKAGE_QEMU_TARGET_MICROBLAZE
	bool "microblaze"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  Xilinx MicroBlaze soft processor.

config BR2_PACKAGE_QEMU_TARGET_MICROBLAZEEL
	bool "microblazeel"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  Xilinx MicroBlaze EL soft processor.

config BR2_PACKAGE_QEMU_TARGET_MIPS
	bool "mips"
	help
	  MIPS 32-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_MIPSEL
	bool "mipsel"
	help
	  MIPS 32-bit architecture, little-endian.

config BR2_PACKAGE_QEMU_TARGET_MIPS64
	bool "mips64"
	help
	  MIPS 64-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_MIPS64EL
	bool "mips64el"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  MIPS 64-bit architecture, little-endian.

config BR2_PACKAGE_QEMU_TARGET_MIPSN32
	bool "mipsn32 (linux-user, only)"
	depends on BR2_PACKAGE_QEMU_LINUX_USER
	help
	  MIPS N32 architecture.

config BR2_PACKAGE_QEMU_TARGET_MIPSN32EL
	bool "mipsn32el (linux-user, only)"
	depends on BR2_PACKAGE_QEMU_LINUX_USER
	help
	  MIPS N32 architecture, little-endian.

config BR2_PACKAGE_QEMU_TARGET_OR1K
	bool "or1k"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  OpenRISC 1000 architecture.

config BR2_PACKAGE_QEMU_TARGET_PPC
	bool "ppc"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  PoewerPC 32-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_PPC64
	bool "ppc64"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  PoewerPC 64-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_PPC64LE
	bool "ppc64le (linux-user, only)"
	depends on BR2_PACKAGE_QEMU_LINUX_USER
	help
	  PoewerPC 64-bit architecture, little-endian.

config BR2_PACKAGE_QEMU_TARGET_RISCV32
	bool "riscv32"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  RISC-V 32-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_RISCV64
	bool "riscv64"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  RISC-V 64-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_RX
	bool "rx (system-only)"
	depends on BR2_PACKAGE_QEMU_SYSTEM
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  Renesas Electronics RX 32-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_S390X
	bool "s390x"
	help
	  IBM z/Architecture 64-bit mainframe (s390x)

config BR2_PACKAGE_QEMU_TARGET_SH4
	bool "sh4"
	help
	  Super-H 32-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_SH4EB
	bool "sh4eb"
	help
	  Super-H EB 32-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_SPARC
	bool "sparc"
	help
	  SPARC 32-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_SPARC32PLUS
	bool "sparc32plus (linux-user, only)"
	depends on BR2_PACKAGE_QEMU_LINUX_USER
	help
	  SPARC 32-bit RISC architecture (Sun's v8plus).

config BR2_PACKAGE_QEMU_TARGET_SPARC64
	bool "sparc64"
	help
	  SPARC 64-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_TRICORE
	bool "tricore (system, only)"
	depends on BR2_PACKAGE_QEMU_SYSTEM
	help
	  Infineon TriCore 32-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_X86_64
	bool "x86_64"
	select BR2_PACKAGE_QEMU_FDT if BR2_PACKAGE_QEMU_SYSTEM
	help
	  Intel x86 64-bit architecture.

config BR2_PACKAGE_QEMU_TARGET_XTENSA
	bool "xtensa"
	help
	  Xtensa 32-bit RISC architecture.

config BR2_PACKAGE_QEMU_TARGET_XTENSAEB
	bool "xtensaeb"
	help
	  Xtensa 32-bit RISC architecture, big-endian.

endif # BR2_PACKAGE_QEMU_CHOOSE_TARGETS

comment "Tools selection"

config BR2_PACKAGE_QEMU_TOOLS
	bool "Enable tools"
	help
	  Say 'y' here to include tools packaged with QEMU
	  (e.g. qemu-img).

config BR2_PACKAGE_QEMU_GUEST_AGENT
	bool "Enable guest agent"
	help
	  Say 'y' here to include an agent to run on guests, which
	  communicates with the host over a virtio-serial channel
	  named "org.qemu.guest_agent.0".

endif # BR2_PACKAGE_QEMU
