config BR2_PACKAGE_LIBVIRT_ARCH_SUPPORTS
	bool
	default y if BR2_aarch64
	default y if BR2_i386
	default y if BR2_x86_64
	depends on BR2_USE_MMU # fork()

comment "libvirt needs udev /dev management, a toolchain w/ threads, dynamic library, kernel headers >= 3.12 (4.11 for AArch64)"
	depends on BR2_PACKAGE_LIBVIRT_ARCH_SUPPORTS
	depends on !BR2_PACKAGE_HAS_UDEV || BR2_STATIC_LIBS || !BR2_USE_MMU || \
		!BR2_TOOLCHAIN_HAS_THREADS || \
		!(BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12 && \
		  (BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_11 || !BR2_aarch64))

config BR2_PACKAGE_LIBVIRT
	bool "libvirt"
	depends on BR2_PACKAGE_LIBVIRT_ARCH_SUPPORTS
	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12
	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_11 || !BR2_aarch64
	depends on BR2_PACKAGE_HAS_UDEV
	depends on !BR2_STATIC_LIBS
	depends on BR2_USE_WCHAR
	depends on BR2_TOOLCHAIN_HAS_THREADS
	depends on BR2_USE_WCHAR
	select BR2_PACKAGE_GNUTLS
	# configure: You must install the pciaccess module to build with udev
	select BR2_PACKAGE_LIBPCIACCESS
	select BR2_PACKAGE_LIBGLIB2
	select BR2_PACKAGE_LIBTIRPC
	select BR2_PACKAGE_LIBXML2
	select BR2_PACKAGE_ZLIB
	# run-time dependencies
	select BR2_PACKAGE_CGROUPFS_MOUNT if !BR2_INIT_SYSTEMD
	help
	  Libvirt is collection of software that provides a convenient
	  way to manage virtual machines and other virtualization
	  functionality, such as storage and network interface
	  management. These software pieces include an API library, a
	  daemon (libvirtd), and a command line utility (virsh).

	  https://libvirt.org/

if BR2_PACKAGE_LIBVIRT

config BR2_PACKAGE_LIBVIRT_DAEMON
	bool "libvirtd"
	default y
	select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
	select BR2_PACKAGE_DNSMASQ
	select BR2_PACKAGE_EBTABLES
	select BR2_PACKAGE_IPTABLES
	select BR2_PACKAGE_IPROUTE2
	# These are required because there is no way to unequivocally select a modern netcat
	select BR2_PACKAGE_NMAP      if !BR2_PACKAGE_NETCAT_OPENBSD
	select BR2_PACKAGE_NMAP_NCAT if !BR2_PACKAGE_NETCAT_OPENBSD
	select BR2_PACKAGE_RADVD
	help
	  Build the libvirt daemon (libvirtd) otherwise build only the
	  utility programs.

# Stateful drivers are useful only when building the daemon.
if BR2_PACKAGE_LIBVIRT_DAEMON

config BR2_PACKAGE_LIBVIRT_QEMU
	bool "qemu"
	depends on BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS # libseccomp
	depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8 # qemu
	select BR2_PACKAGE_HWDATA         # libpciaccess
	select BR2_PACKAGE_HWDATA_PCI_IDS # libpciaccess
	select BR2_PACKAGE_LIBSECCOMP
	select BR2_PACKAGE_QEMU
	select BR2_PACKAGE_QEMU_SYSTEM if BR2_PACKAGE_QEMU_CUSTOM_TARGETS = ""
	select BR2_PACKAGE_YAJL
	help
	  QEMU/KVM support

comment "qemu needs a toolchain with gcc >= 8"
	depends on BR2_PACKAGE_LIBSECCOMP_ARCH_SUPPORTS
	depends on BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_8

config BR2_PACKAGE_LIBVIRT_LXC
	bool "lxc"
	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 # lxc
	select BR2_PACKAGE_LXC
	help
	  Linux Container support

comment "lxc needs a toolchain w/ gcc >= 4.7"
	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7

endif

endif
