# This file is part of the OpenADK project. OpenADK is copyrighted
# material, please see the LICENCE file in the top-level directory.

choice
prompt "C library"
default ADK_TARGET_LIB_UCLIBC_NG if ADK_TARGET_OS_LINUX

config ADK_TARGET_LIB_UCLIBC_NG
	bool "uClibc-ng embedded C library"
	select ADK_PACKAGE_LIBGCC
	depends on (\
		ADK_TARGET_ARCH_AARCH64 || \
		ADK_TARGET_ARCH_ALPHA || \
		ADK_TARGET_ARCH_ARC || \
		ADK_TARGET_ARCH_ARM || \
		ADK_TARGET_ARCH_AVR32 || \
		ADK_TARGET_ARCH_BFIN || \
		ADK_TARGET_ARCH_C6X || \
		ADK_TARGET_ARCH_CRIS || \
		ADK_TARGET_ARCH_CSKY || \
		ADK_TARGET_ARCH_FRV || \
		ADK_TARGET_ARCH_H8300 || \
		ADK_TARGET_ARCH_HPPA || \
		ADK_TARGET_ARCH_IA64 || \
		ADK_TARGET_ARCH_LM32 || \
		ADK_TARGET_ARCH_M68K || \
		ADK_TARGET_ARCH_METAG || \
		ADK_TARGET_ARCH_MICROBLAZE || \
		ADK_TARGET_ARCH_MIPS || \
		ADK_TARGET_ARCH_MIPS64 || \
		ADK_TARGET_ARCH_NDS32 || \
		ADK_TARGET_ARCH_NIOS2 || \
		ADK_TARGET_ARCH_OR1K || \
		ADK_TARGET_ARCH_PPC || \
		ADK_TARGET_ARCH_SH || \
		ADK_TARGET_ARCH_SPARC || \
		ADK_TARGET_ARCH_SPARC64 || \
		ADK_TARGET_ARCH_X86 || \
		ADK_TARGET_ARCH_X86_64 || \
		ADK_TARGET_ARCH_XTENSA) && ADK_TARGET_OS_LINUX
	help
	  http://uclibc-ng.org

config ADK_TARGET_LIB_MUSL
	bool "musl C library"
	select ADK_PACKAGE_LIBGCC
	depends on (\
		ADK_TARGET_ARCH_AARCH64 || \
		ADK_TARGET_ARCH_ARM || \
		ADK_TARGET_ARCH_MICROBLAZE || \
		ADK_TARGET_ARCH_MIPS || \
		ADK_TARGET_ARCH_MIPS64 || \
		ADK_TARGET_ARCH_OR1K || \
		ADK_TARGET_ARCH_PPC || \
		ADK_TARGET_ARCH_PPC64 || \
		ADK_TARGET_ARCH_S390 || \
		ADK_TARGET_ARCH_SH || \
		ADK_TARGET_ARCH_X86 || \
		ADK_TARGET_ARCH_X86_64 || \
		ADK_TARGET_ARCH_XTENSA) && ADK_TARGET_OS_LINUX
	help
 	  http://musl-libc.org

config ADK_TARGET_LIB_GLIBC
	bool "GNU C library"
	select ADK_PACKAGE_LIBGCC
	depends on (\
		ADK_TARGET_ARCH_AARCH64 || \
		ADK_TARGET_ARCH_ALPHA || \
		ADK_TARGET_ARCH_ARM || \
		ADK_TARGET_ARCH_HPPA || \
		ADK_TARGET_ARCH_IA64 || \
		ADK_TARGET_ARCH_MICROBLAZE || \
		ADK_TARGET_ARCH_MIPS || \
		ADK_TARGET_ARCH_MIPS64 || \
		ADK_TARGET_ARCH_NIOS2 || \
		ADK_TARGET_ARCH_PPC || \
		ADK_TARGET_ARCH_PPC64 || \
		ADK_TARGET_ARCH_S390 || \
		ADK_TARGET_CPU_SH_SH4 || \
		ADK_TARGET_CPU_SH_SH4A || \
		ADK_TARGET_ARCH_SPARC64 || \
		ADK_TARGET_ARCH_TILE || \
		ADK_TARGET_ARCH_RISCV32 || \
		ADK_TARGET_ARCH_RISCV64 || \
		ADK_TARGET_ARCH_X86 || \
		ADK_TARGET_ARCH_X86_64) && ADK_TARGET_OS_LINUX
	help
	  http://www.gnu.org/libc

config ADK_TARGET_LIB_NEWLIB
	bool "newlib C library"
	select ADK_TARGET_WITHOUT_THREADS
	depends on (\
		ADK_TARGET_ARCH_AARCH64 || \
		ADK_TARGET_ARCH_ARC || \
		ADK_TARGET_ARCH_ARM || \
		ADK_TARGET_ARCH_BFIN || \
		ADK_TARGET_ARCH_CR16 || \
		ADK_TARGET_ARCH_CRIS || \
		ADK_TARGET_ARCH_CSKY || \
		ADK_TARGET_ARCH_EPIPHANY || \
		ADK_TARGET_ARCH_FRV || \
		ADK_TARGET_ARCH_FT32 || \
		ADK_TARGET_ARCH_H8300 || \
		ADK_TARGET_ARCH_IA64 || \
		ADK_TARGET_ARCH_LM32 || \
		ADK_TARGET_ARCH_M32C || \
		ADK_TARGET_ARCH_M32R || \
		ADK_TARGET_ARCH_M68K || \
		ADK_TARGET_ARCH_MICROBLAZE || \
		ADK_TARGET_ARCH_MIPS || \
		ADK_TARGET_ARCH_MN10300 || \
		ADK_TARGET_ARCH_MOXIE || \
		ADK_TARGET_ARCH_MSP430 || \
		ADK_TARGET_ARCH_NIOS2 || \
		ADK_TARGET_ARCH_NDS32 || \
		ADK_TARGET_ARCH_OR1K || \
		ADK_TARGET_ARCH_PPC || \
		ADK_TARGET_ARCH_RISCV32 || \
		ADK_TARGET_ARCH_RISCV64 || \
		ADK_TARGET_ARCH_RX || \
		ADK_TARGET_ARCH_SH || \
		ADK_TARGET_ARCH_SPARC || \
		ADK_TARGET_ARCH_SPARC64 || \
		ADK_TARGET_ARCH_V850 || \
		ADK_TARGET_ARCH_X86 || \
		ADK_TARGET_ARCH_X86_64 || \
		ADK_TARGET_ARCH_XTENSA) && \
		(ADK_TARGET_OS_BAREMETAL || ADK_TARGET_OS_FROSTED)
	help
	  https://sourceware.org/newlib/

endchoice

choice
prompt "C library version"

config ADK_TARGET_LIB_UCLIBC_NG_1_0_26
	bool "1.0.26"
	depends on ADK_TARGET_LIB_UCLIBC_NG

config ADK_TARGET_LIB_UCLIBC_NG_GIT
	bool "git"
	depends on ADK_TARGET_LIB_UCLIBC_NG

config ADK_TARGET_LIB_GLIBC_2_26
	bool "2.26"
	depends on ADK_TARGET_LIB_GLIBC && !ADK_TARGET_ARCH_RISCV32 && !ADK_TARGET_ARCH_RISCV64

config ADK_TARGET_LIB_GLIBC_RISCV
	bool "riscv"
	depends on ADK_TARGET_LIB_GLIBC && ADK_TARGET_ARCH_RISCV32 || ADK_TARGET_ARCH_RISCV64

config ADK_TARGET_LIB_GLIBC_GIT
	bool "git"
	depends on ADK_TARGET_LIB_GLIBC && !ADK_TARGET_ARCH_RISCV32 && !ADK_TARGET_ARCH_RISCV64

config ADK_TARGET_LIB_MUSL_1_1_16
	bool "1.1.16"
	depends on ADK_TARGET_LIB_MUSL

config ADK_TARGET_LIB_MUSL_GIT
	bool "git"
	depends on ADK_TARGET_LIB_MUSL

config ADK_TARGET_LIB_NEWLIB_2_5_0
	bool "2.5.0"
	depends on ADK_TARGET_LIB_NEWLIB && !ADK_TARGET_ARCH_RISCV && !ADK_TARGET_OS_FROSTED

config ADK_TARGET_LIB_NEWLIB_RISCV
	bool "2.4.0-riscv"
	depends on ADK_TARGET_LIB_NEWLIB && ADK_TARGET_ARCH_RISCV

config ADK_TARGET_LIB_NEWLIB_FROSTED
	bool "frosted-git"
	depends on ADK_TARGET_LIB_NEWLIB && ADK_TARGET_OS_FROSTED

config ADK_TARGET_LIB_NEWLIB_GIT
	bool "git"
	depends on ADK_TARGET_LIB_NEWLIB && !ADK_TARGET_ARCH_RISCV && !ADK_TARGET_OS_FROSTED

endchoice

choice
prompt "Threading"

config ADK_TARGET_WITH_NPTL
	bool "enable NPTL"
	depends on ADK_TARGET_SUPPORTS_NPTL && ADK_TARGET_SUPPORTS_THREADS && !ADK_TARGET_LIB_NEWLIB

config ADK_TARGET_WITH_LT
	bool "enable Linuxthreads"
	depends on ADK_TARGET_SUPPORTS_LT && ADK_TARGET_SUPPORTS_THREADS && ADK_TARGET_LIB_UCLIBC_NG

config ADK_TARGET_WITHOUT_THREADS
	bool "disable threads"
	depends on ADK_TARGET_LIB_UCLIBC_NG || ADK_TARGET_LIB_NEWLIB

endchoice

config ADK_TARGET_SUPPORTS_THREADS
	bool

config ADK_TARGET_SUPPORTS_NPTL
	bool

config ADK_TARGET_SUPPORTS_LT
	bool

config ADK_TARGET_LIBC_UTILS
	bool
	default n if ADK_TARGET_ARCH_C6X
	default n if ADK_TARGET_ARCH_LM32
	default n if ADK_TARGET_ARCH_H8300
	default y

config ADK_TARGET_LIBC
	string
	default "uclibc-ng" if ADK_TARGET_LIB_UCLIBC_NG
	default "glibc" if ADK_TARGET_LIB_GLIBC
	default "musl" if ADK_TARGET_LIB_MUSL
	default "newlib" if ADK_TARGET_LIB_NEWLIB

config ADK_LIBC_VERSION
	string
	default "1.0.26" if ADK_TARGET_LIB_UCLIBC_NG_1_0_26
	default "1.1.16" if ADK_TARGET_LIB_MUSL_1_1_16
	default "2.26" if ADK_TARGET_LIB_GLIBC_2_26
	default "2.4.0" if ADK_TARGET_LIB_NEWLIB_2_4_0
	default "2.4.0-riscv" if ADK_TARGET_LIB_NEWLIB_RISCV
	default "git" if ADK_TARGET_LIB_UCLIBC_NG_GIT || \
		         ADK_TARGET_LIB_MUSL_GIT || \
		         ADK_TARGET_LIB_GLIBC_GIT || \
			 ADK_TARGET_LIB_NEWLIB_GIT

config ADK_TARGET_SUFFIX
	string
	default "gnueabihf" if ADK_TARGET_LIB_GLIBC && ADK_TARGET_ARCH_ARM && ADK_TARGET_HARD_FLOAT
	default "gnueabi" if ADK_TARGET_LIB_GLIBC && ADK_TARGET_ARCH_ARM
	default "gnuabi64" if ADK_TARGET_LIB_GLIBC && ADK_TARGET_ABI_N64
	default "gnuabin32" if ADK_TARGET_LIB_GLIBC && ADK_TARGET_ABI_N32
	default "gnuabi32" if ADK_TARGET_LIB_GLIBC && ADK_TARGET_ABI_O64
	default "gnu32" if ADK_TARGET_LIB_GLIBC && ADK_TARGET_ABI_32 && ADK_LINUX_64
	default "gnux32" if ADK_TARGET_LIB_GLIBC && ADK_TARGET_ABI_X32 && ADK_LINUX_64
	default "gnu" if ADK_TARGET_LIB_GLIBC
	default "uclibceabihf" if ADK_TARGET_LIB_UCLIBC_NG && ADK_TARGET_ARCH_ARM && ADK_TARGET_HARD_FLOAT
	default "uclibceabi" if ADK_TARGET_LIB_UCLIBC_NG && ADK_TARGET_ARCH_ARM
	default "uclinuxeabi" if ADK_TARGET_LIB_UCLIBC_NG && ADK_TARGET_ARCH_ARM && ADK_TARGET_WITHOUT_MMU
	default "uclibcabi64" if ADK_TARGET_LIB_UCLIBC_NG && ADK_TARGET_ABI_N64
	default "uclibcabin32" if ADK_TARGET_LIB_UCLIBC_NG && ADK_TARGET_ABI_N32
	default "uclibcabi32" if ADK_TARGET_LIB_UCLIBC_NG && ADK_TARGET_ABI_O32
	default "uclibc32" if ADK_TARGET_LIB_UCLIBC_NG && ADK_TARGET_ABI_32 && ADK_LINUX_64
	default "uclibc" if ADK_TARGET_LIB_UCLIBC_NG
	default "musleabihf" if ADK_TARGET_LIB_MUSL && ADK_TARGET_ARCH_ARM && ADK_TARGET_HARD_FLOAT
	default "musleabi" if ADK_TARGET_LIB_MUSL && ADK_TARGET_ARCH_ARM
	default "muslabi64" if ADK_TARGET_LIB_MUSL && ADK_TARGET_ABI_N64
	default "muslabin32" if ADK_TARGET_LIB_MUSL && ADK_TARGET_ABI_N32
	default "muslabi32" if ADK_TARGET_LIB_MUSL && ADK_TARGET_ABI_O32
	default "musl32" if ADK_TARGET_LIB_MUSL && ADK_TARGET_ABI_32 && ADK_LINUX_64
	default "muslx32" if ADK_TARGET_LIB_MUSL && ADK_TARGET_ABI_X32 && ADK_LINUX_64
	default "muslfdpic" if ADK_TARGET_LIB_MUSL && ADK_TARGET_BINFMT_FDPIC
	default "musl" if ADK_TARGET_LIB_MUSL
	default "eabi" if ADK_TARGET_LIB_NEWLIB && ADK_TARGET_ARCH_ARM
	default "elf" if ADK_TARGET_LIB_NEWLIB
