require conf/multilib.conf
require conf/machine/include/tune-cortexrm.inc
require conf/machine/include/baremetal-tc.conf

# Define all of the multilibs supproted by this configuration
MULTILIB_GLOBAL_VARIANTS = "${@extend_variants(d,'MULTILIBS','multilib')}"

MULTILIBS  = "multilib:libarmv5tesoftfp multilib:libarmv5tehard"
MULTILIBS += "multilib:libnofp"
MULTILIBS += "multilib:libv7nofp multilib:libv7fpsoftfp multilib:libv7fphard"
MULTILIBS += "multilib:libv6mnofp"
MULTILIBS += "multilib:libv7mnofp"
MULTILIBS += "multilib:libv7emnofp multilib:libv7emfpsoftfp"
MULTILIBS += "multilib:libv7emfphard multilib:libv7emdpsoftfp"
MULTILIBS += "multilib:libv7emdphard"
MULTILIBS += "multilib:libv8mbasenofp"
MULTILIBS += "multilib:libv8mmainnofp multilib:libv8mmainfpsoftfp multilib:libv8mmainfphard multilib:libv8mmaindpsoftfp multilib:libv8mmaindphard"

TUNE_CCARGS = "${TUNE_CCARGS_tune-${DEFAULTTUNE}}"
TUNE_PKGARCH = "${TUNE_PKGARCH_tune-${DEFAULTTUNE}}"

# Base configuration
# CFLAGS:
DEFAULTTUNE = "armrm"

AVAILTUNES += "armrm"
PACKAGE_EXTRA_ARCHS_tune-armrm = "${TUNE_PKGARCH_tune-armrm}"
BASE_LIB_tune-armrm = "lib"
TUNE_FEATURES_tune-armrm = "arm armrm"
TUNE_CCARGS_tune-armrm = ""
TUNE_PKGARCH_tune-armrm = "armrm"


# arm/v5te/softfp
# CFLAGS:  -marm -march=armv5te+fp -mfloat-abi=softfp
DEFAULTTUNE_virtclass-multilib-libarmv5tesoftfp = "armv5tesoftfp"

AVAILTUNES += "armv5tesoftfp"
PACKAGE_EXTRA_ARCHS_tune-armv5tesoftfp = "${TUNE_PKGARCH_tune-armv5tesoftfp}"
BASE_LIB_tune-armv5tesoftfp = "lib/arm/v5te/softfp"
TUNE_FEATURES_tune-armv5tesoftfp = "arm armrm"
TUNE_CCARGS_tune-armv5tesoftfp = "-marm -march=armv5te+fp -mfloat-abi=softfp"
TUNE_PKGARCH_tune-armv5tesoftfp = "armv5tefp"


# arm/v5te/hard
# CFLAGS: -marm -march=armv5te+fp -mfloat-abi=hard
DEFAULTTUNE_virtclass-multilib-libarmv5tehard = "armv5tehard"

AVAILTUNES += "armv5tehard"
PACKAGE_EXTRA_ARCHS_tune-armv5tehard = "${TUNE_PKGARCH_tune-armv5tehard}"
BASE_LIB_tune-armv5tehard = "lib/arm/v5te/hard"
TUNE_FEATURES_tune-armv5tehard = "arm armrm"
TUNE_CCARGS_tune-armv5tehard = "-marm -march=armv5te+fp -mfloat-abi=hard"
TUNE_PKGARCH_tune-armv5tehard = "armv5tefphf"


# thumb/nofp
# CFLAGS: -mthumb -mfloat-abi=soft
DEFAULTTUNE_virtclass-multilib-libnofp = "armnofp"

AVAILTUNES += "armnofp"
PACKAGE_EXTRA_ARCHS_tune-armnofp = "${TUNE_PKGARCH_tune-armnofp}"
BASE_LIB_tune-armnofp = "lib/thumb/nofp"
TUNE_FEATURES_tune-armnofp = "arm armrm"
TUNE_CCARGS_tune-armnofp = "-mthumb -mfloat-abi=soft"
TUNE_PKGARCH_tune-armnofp = "armt"


# thumb/v7/nofp
# CFLAGS: -mthumb -march=armv7 -mfloat-abi=soft
DEFAULTTUNE_virtclass-multilib-libv7nofp = "armv7nofp"

AVAILTUNES += "armv7nofp"
PACKAGE_EXTRA_ARCHS_tune-armv7nofp = "${TUNE_PKGARCH_tune-armv7nofp}"
BASE_LIB_tune-armv7nofp = "lib/thumb/v7/nofp"
TUNE_FEATURES_tune-armv7nofp ="arm armrm"
TUNE_CCARGS_tune-armv7nofp = "-mthumb -march=armv7 -mfloat-abi=soft"
TUNE_PKGARCH_tune-armv7nofp = "armv7t"


# thumb/v7+fp/softfp
# CFLAGS: -mthumb -march=armv7+fp -mfloat-abi=softfp
DEFAULTTUNE_virtclass-multilib-libv7fpsoftfp = "armv7fpsoftfp"

AVAILTUNES += "armv7fpsoftfp"
PACKAGE_EXTRA_ARCHS_tune-armv7fpsoftfp = "${TUNE_PKGARCH_tune-armv7fpsoftfp}"
BASE_LIB_tune-armv7fpsoftfp = "lib/thumb/v7+fp/softfp"
TUNE_FEATURES_tune-armv7fpsoftfp ="arm armrm"
TUNE_CCARGS_tune-armv7fpsoftfp = "-mthumb -march=armv7+fp -mfloat-abi=softfp"
TUNE_PKGARCH_tune-armv7fpsoftfp = "armv7fpt"


# thumb/v7+fp/hard
# CFLAGS: -mthumb -march=armv7+fp -mfloat-abi=hard
DEFAULTTUNE_virtclass-multilib-libv7fphard = "armv7fphard"

AVAILTUNES += "armv7fphard"
PACKAGE_EXTRA_ARCHS_tune-armv7fphard = "${TUNE_PKGARCH_tune-armv7fphard}"
BASE_LIB_tune-armv7fphard = "lib/thumb/v7+fp/hard"
TUNE_FEATURES_tune-armv7fphard ="arm armrm"
TUNE_CCARGS_tune-armv7fphard = "-mthumb -march=armv7+fp -mfloat-abi=hard"
TUNE_PKGARCH_tune-armv7fphard = "armv7fpthf"


# thumb/v6-m/nofp
# CFLAGS: -mthumb -march=armv6s-m -mfloat-abi=soft
DEFAULTTUNE_virtclass-multilib-libv6mnofp = "armv6mnofp"

# Workaround for this multilib in newlib
# newlib/libc/sys/arm/trap.S:88: Error: lo register required -- `sub ip,sp,ip
EXTRA_OECONF_append_pn-libv6mnofp-newlib     = " --disable-newlib-supplied-syscalls"

AVAILTUNES += "armv6mnofp"
PACKAGE_EXTRA_ARCHS_tune-armv6mnofp = "${TUNE_PKGARCH_tune-armv6mnofp}"
BASE_LIB_tune-armv6mnofp = "lib/thumb/v6-m/nofp"
TUNE_FEATURES_tune-armv6mnofp ="arm armrm"
TUNE_CCARGS_tune-armv6mnofp = "-mthumb -march=armv6s-m -mfloat-abi=soft"
TUNE_PKGARCH_tune-armv6mnofp = "armv6smt"


# thumb/v7-m/nofp
# CFLAGS: -mthumb -march=armv7-m -mfloat-abi=soft
DEFAULTTUNE_virtclass-multilib-libv7mnofp = "armv7mnofp"

AVAILTUNES += "armv7mnofp"
PACKAGE_EXTRA_ARCHS_tune-armv7mnofp = "${TUNE_PKGARCH_tune-armv7mnofp}"
BASE_LIB_tune-armv7mnofp = "lib/thumb/v7-m/nofp"
TUNE_FEATURES_tune-armv7mnofp ="arm armrm"
TUNE_CCARGS_tune-armv7mnofp = "-mthumb -march=armv7-m -mfloat-abi=soft"
TUNE_PKGARCH_tune-armv7mnofp = "armv7mt"


# thumb/v7e-m/nofp
# CFLAGS: -mthumb -march=armv7e-m -mfloat-abi=soft
DEFAULTTUNE_virtclass-multilib-libv7emnofp = "armv7emnofp"

AVAILTUNES += "armv7emnofp"
PACKAGE_EXTRA_ARCHS_tune-armv7emnofp = "${TUNE_PKGARCH_tune-armv7emnofp}"
BASE_LIB_tune-armv7emnofp = "lib/thumb/v7e-m/nofp"
TUNE_FEATURES_tune-armv7emnofp ="arm armrm"
TUNE_CCARGS_tune-armv7emnofp = "-mthumb -march=armv7e-m -mfloat-abi=soft"
TUNE_PKGARCH_tune-armv7emnofp = "armv7emt"


# thumb/v7e-m+fp/softfp
# CFLAGS: -mthumb -march=armv7e-m+fp -mfloat-abi=softfp
DEFAULTTUNE_virtclass-multilib-libv7emfpsoftfp = "armv7emfpsoftfp"

AVAILTUNES += "armv7emfpsoftfp"
PACKAGE_EXTRA_ARCHS_tune-armv7emfpsoftfp = "${TUNE_PKGARCH_tune-armv7emfpsoftfp}"
BASE_LIB_tune-armv7emfpsoftfp = "lib/thumb/v7e-m+fp/softfp"
TUNE_FEATURES_tune-armv7emfpsoftfp ="arm armrm"
TUNE_CCARGS_tune-armv7emfpsoftfp = "-mthumb -march=armv7e-m+fp -mfloat-abi=softfp"
TUNE_PKGARCH_tune-armv7emfpsoftfp = "armv7emfpt"


# thumb/v7e-m+fp/hard
# CFLAGS: -mthumb -march=armv7e-m+fp -mfloat-abi=hard
DEFAULTTUNE_virtclass-multilib-libv7emfphard = "armv7emfphard"

AVAILTUNES += "armv7emfphard"
PACKAGE_EXTRA_ARCHS_tune-armv7emfphard = "${TUNE_PKGARCH_tune-armv7emfphard}"
BASE_LIB_tune-armv7emfphard = "lib/thumb/v7e-m+fp/hard"
TUNE_FEATURES_tune-armv7emfphard ="arm armrm"
TUNE_CCARGS_tune-armv7emfphard = "-mthumb -march=armv7e-m+fp -mfloat-abi=hard"
TUNE_PKGARCH_tune-armv7emfphard = "armv7emfpthf"


# thumb/v7e-m+dp/softfp
# CFLAGS: -mthumb -march=armv7e-m+fp.dp -mfloat-abi=softfp
DEFAULTTUNE_virtclass-multilib-libv7emdpsoftfp = "armv7emdpsoftfp"

AVAILTUNES += "armv7emdpsoftfp"
PACKAGE_EXTRA_ARCHS_tune-armv7emdpsoftfp = "${TUNE_PKGARCH_tune-armv7emdpsoftfp}"
BASE_LIB_tune-armv7emdpsoftfp = "lib/thumb/v7e-m+dp/softfp"
TUNE_FEATURES_tune-armv7emdpsoftfp ="arm armrm"
TUNE_CCARGS_tune-armv7emdpsoftfp = "-mthumb -march=armv7e-m+fp.dp -mfloat-abi=softfp"
TUNE_PKGARCH_tune-armv7emdpsoftfp = "armv7emdp"

# thumb/v7e-m+dp/hard
# CFLAGS: -mthumb -march=armv7e-m+fp.dp -mfloat-abi=hard
DEFAULTTUNE_virtclass-multilib-libv7emdphard = "armv7emdphard"

AVAILTUNES += "armv7emdphard"
PACKAGE_EXTRA_ARCHS_tune-armv7emdphard = "${TUNE_PKGARCH_tune-armv7emdphard}"
BASE_LIB_tune-armv7emdphard = "lib/thumb/v7e-m+dp/hard"
TUNE_FEATURES_tune-armv7emdphard ="arm armrm"
TUNE_CCARGS_tune-armv7emdphard = "-mthumb -march=armv7e-m+fp.dp -mfloat-abi=hard"
TUNE_PKGARCH_tune-armv7emdphard = "armv7emdpthf"


# thumb/v8-m.base/nofp
# CFLAGS: -mthumb -march=armv8-m.base -mfloat-abi=soft
DEFAULTTUNE_virtclass-multilib-libv8mbasenofp = "armv8mbasenofp"

# Workaround for this multilib in newlib
# newlib/libc/sys/arm/trap.S:88: Error: lo register required -- `sub ip,sp,ip'
EXTRA_OECONF_append_pn-libv8mbasenofp-newlib = " --disable-newlib-supplied-syscalls"

AVAILTUNES += "armv8mbasenofp"
PACKAGE_EXTRA_ARCHS_tune-armv8mbasenofp = "${TUNE_PKGARCH_tune-armv8mbasenofp}"
BASE_LIB_tune-armv8mbasenofp = "lib/thumb/v8-m.base/nofp"
TUNE_FEATURES_tune-armv8mbasenofp ="arm armrm"
TUNE_CCARGS_tune-armv8mbasenofp = "-mthumb -march=armv8-m.base -mfloat-abi=soft"
TUNE_PKGARCH_tune-armv8mbasenofp = "armv8mbaset"

# thumb/v8-m.main/nofp
# CFLAGS: -mthumb -march=armv8-m.main -mfloat-abi=soft
DEFAULTTUNE_virtclass-multilib-libv8mmainnofp = "armv8mmainnofp"

AVAILTUNES += "armv8mmainnofp"
PACKAGE_EXTRA_ARCHS_tune-armv8mmainnofp = "${TUNE_PKGARCH_tune-armv8mmainnofp}"
BASE_LIB_tune-armv8mmainnofp = "lib/thumb/v8-m.main/nofp"
TUNE_FEATURES_tune-armv8mmainnofp ="arm armrm"
TUNE_CCARGS_tune-armv8mmainnofp = "-mthumb -march=armv8-m.main -mfloat-abi=soft"
TUNE_PKGARCH_tune-armv8mmainnofp = "armv8mmaint"


# thumb/v8-m.main+fp/softfp
# CFLAGS: -mthumb -march=armv8-m.main+fp -mfloat-abi=softfp
DEFAULTTUNE_virtclass-multilib-libv8mmainfpsoftfp = "armv8mmainfpsoftfp"

AVAILTUNES += "armv8mmainfpsoftfp"
PACKAGE_EXTRA_ARCHS_tune-armv8mmainfpsoftfp = "${TUNE_PKGARCH_tune-armv8mmainfpsoftfp}"
BASE_LIB_tune-armv8mmainfpsoftfp = "lib/thumb/v8-m.main+fp/softfp"
TUNE_FEATURES_tune-armv8mmainfpsoftfp ="arm armrm"
TUNE_CCARGS_tune-armv8mmainfpsoftfp = "-mthumb -march=armv8-m.main+fp -mfloat-abi=softfp"
TUNE_PKGARCH_tune-armv8mmainfpsoftfp = "armv8mmainfpt"

# thumb/v8-m.main+fp/hard
# CFLAGS: -mthumb -march=armv8-m.main+fp -mfloat-abi=hard
DEFAULTTUNE_virtclass-multilib-libv8mmainfphard = "armv8mmainfphard"

AVAILTUNES += "armv8mmainfphard"
PACKAGE_EXTRA_ARCHS_tune-armv8mmainfphard = "${TUNE_PKGARCH_tune-armv8mmainfphard}"
BASE_LIB_tune-armv8mmainfphard = "lib/thumb/v8-m.main+fp/hard"
TUNE_FEATURES_tune-armv8mmainfphard ="arm armrm"
TUNE_CCARGS_tune-armv8mmainfphard = "-mthumb -march=armv8-m.main+fp -mfloat-abi=hard"
TUNE_PKGARCH_tune-armv8mmainfphard = "armv8mmainfpthf"


# thumb/v8-m.main+dp/softfp
# CFLAGS: -mthumb -march=armv8-m.main+fp.dp -mfloat-abi=softfp
DEFAULTTUNE_virtclass-multilib-libv8mmaindpsoftfp = "armv8mmaindpsoftfp"

AVAILTUNES += "armv8mmaindpsoftfp"
PACKAGE_EXTRA_ARCHS_tune-armv8mmaindpsoftfp = "${TUNE_PKGARCH_tune-armv8mmaindpsoftfp}"
BASE_LIB_tune-armv8mmaindpsoftfp = "lib/thumb/v8-m.main+dp/softfp"
TUNE_FEATURES_tune-armv8mmaindpsoftfp ="arm armrm"
TUNE_CCARGS_tune-armv8mmaindpsoftfp = "-mthumb -march=armv8-m.main+fp.dp -mfloat-abi=softfp"
TUNE_PKGARCH_tune-armv8mmaindpsoftfp = "armv8mmainfpdpt"


# thumb/v8-m.main+dp/hard
# CFLAGS: -mthumb -march=armv8-m.main+fp.dp -mfloat-abi=hard
DEFAULTTUNE_virtclass-multilib-libv8mmaindphard = "armv8mmaindphard"

AVAILTUNES += "armv8mmaindphard"
PACKAGE_EXTRA_ARCHS_tune-armv8mmaindphard = "${TUNE_PKGARCH_tune-armv8mmaindphard}"
BASE_LIB_tune-armv8mmaindphard = "lib/thumb/v8-m.main+dp/hard"
TUNE_FEATURES_tune-armv8mmaindphard ="arm armrm"
TUNE_CCARGS_tune-armv8mmaindphard = "-mthumb -march=armv8-m.main+fp.dp -mfloat-abi=hard"
TUNE_PKGARCH_tune-armv8mmaindphard = "armv8mmainfpdpthf"
