# criu only builds on certain architectures
config BR2_PACKAGE_CRIU_ARCH_SUPPORTS
	bool
	default y if BR2_ARM_CPU_ARMV6
	default y if BR2_ARM_CPU_ARMV7A
	default y if BR2_ARM_CPU_ARMV7M
	default y if BR2_ARM_CPU_ARMV8A && !BR2_aarch64_be
	default y if BR2_aarch64
	default y if BR2_x86_64
	default y if BR2_powerpc64le # Only support powerpc64 with LE
	# CRIU has "some" support for s390 but it is not included due to
	# BE/LE endian issues.
	depends on BR2_USE_MMU # libcap
	depends on BR2_PACKAGE_HOST_PROTOBUF_ARCH_SUPPORTS # protobuf-c
	depends on BR2_PACKAGE_PROTOBUF_ARCH_SUPPORTS
	depends on BR2_PACKAGE_LIBBSD_ARCH_SUPPORTS

config BR2_PACKAGE_CRIU
	bool "criu"
	depends on BR2_PACKAGE_CRIU_ARCH_SUPPORTS
	depends on BR2_HOST_GCC_AT_LEAST_7 # protobuf-c
	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_8 # -march=armv7-a+fp, protobuf
	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_18 # rseq.h
	depends on !BR2_TOOLCHAIN_USES_UCLIBC # no aio.h
	depends on !BR2_STATIC_LIBS # protobuf, libbsd
	depends on BR2_INSTALL_LIBSTDCPP # protobuf
	depends on BR2_TOOLCHAIN_HAS_THREADS # protobuf, libnl
	depends on BR2_USE_WCHAR # libbsd
	select BR2_PACKAGE_HOST_PYTHON3_SSL
	select BR2_PACKAGE_PROTOBUF
	select BR2_PACKAGE_PROTOBUF_C
	select BR2_PACKAGE_LIBAIO
	select BR2_PACKAGE_LIBBSD
	select BR2_PACKAGE_LIBCAP
	select BR2_PACKAGE_LIBNET
	select BR2_PACKAGE_LIBNL
	select BR2_PACKAGE_PYTHON3
	help
	  Checkpoint/Restore In Userspace (CRIU), is a software
	  tool for the Linux operating system to make it possible
	  to freeze a running application and checkpoint it to
	  persistent storage as a collection of files.

	  https://criu.org/Main_Page

comment "criu needs a glibc or musl toolchain w/ threads, host gcc >= 7, gcc >= 8, headers >= 4.18, C++, dynamic library, wchar"
	depends on BR2_PACKAGE_CRIU_ARCH_SUPPORTS
	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_8 || !BR2_TOOLCHAIN_HAS_THREADS \
		|| !BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_18 \
		|| BR2_TOOLCHAIN_USES_UCLIBC || !BR2_INSTALL_LIBSTDCPP \
		|| BR2_STATIC_LIBS || !BR2_USE_WCHAR \
		|| !BR2_HOST_GCC_AT_LEAST_7
