config BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS
	bool
	default y if BR2_aarch64
	default y if BR2_arm || BR2_armeb
	default y if BR2_i386 || BR2_x86_64
	default y if BR2_mips || BR2_mipsel || BR2_mips64 || BR2_mips64el
	default y if BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le
	default y if BR2_riscv
	default y if BR2_sh4 || BR2_sh4a
	default y if BR2_sparc || BR2_sparc64
	depends on BR2_PACKAGE_LIBNSPR_ARCH_SUPPORT # libnspr

config BR2_PACKAGE_SPIDERMONKEY_JIT_ARCH_SUPPORTS
	bool
	default y if BR2_aarch64  || BR2_arm || BR2_armeb || BR2_i386 || BR2_x86_64

config BR2_PACKAGE_SPIDERMONKEY
	bool "spidermonkey"
	depends on BR2_HOST_GCC_AT_LEAST_4_9
	depends on BR2_INSTALL_LIBSTDCPP
	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS
	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9
	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # needs pthread_getattr_np()
	depends on BR2_USE_MMU # fork in executable tools.
	depends on BR2_USE_WCHAR
	depends on !BR2_TOOLCHAIN_USES_UCLIBC # No way to check for fenv support.
	depends on !BR2_STATIC_LIBS # dlopen
	select BR2_PACKAGE_HOST_PYTHON
	select BR2_PACKAGE_HOST_PYTHON_SSL
	select BR2_PACKAGE_LIBNSPR
	select BR2_PACKAGE_ZLIB
	help
	  SpiderMonkey is the code-name for Mozilla Firefox's C++
	  implementation of JavaScript. It is intended to be embedded in
	  other applications that provide host environments for
	  JavaScript.

	  https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey

if BR2_PACKAGE_SPIDERMONKEY

config BR2_PACKAGE_SPIDERMONKEY_JS_SHELL
	bool "JS shell"
	help
	  Build the JavaScript shell.

	  WARNING: increases target image size by around 24 MiB.

endif

comment "spidermonkey needs a glibc or musl toolchain with C++, wchar, dynamic library, NPTL, gcc >= 4.9"
	depends on BR2_USE_MMU
	depends on BR2_PACKAGE_SPIDERMONKEY_ARCH_SUPPORTS
	depends on BR2_TOOLCHAIN_USES_UCLIBC || \
		!BR2_INSTALL_LIBSTDCPP || \
		BR2_STATIC_LIBS || \
		!BR2_TOOLCHAIN_HAS_THREADS_NPTL || \
		!BR2_HOST_GCC_AT_LEAST_4_9 || \
		!BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \
		!BR2_USE_WCHAR