uClibc: Split configuration tweaker into per-arch functions.

Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
Alexey Neyman 2016-04-04 08:25:07 -07:00
parent 0fdc1887a7
commit bf3eceb5d9
11 changed files with 174 additions and 113 deletions

View File

@ -17,5 +17,23 @@ CT_DoArchGlibcAdjustTuple() {
:;
}
# Helper for uClibc configurators: select the architecture
# Usage: CT_DoArchUClibcSelectArch <config-file> <architecture>
CT_DoArchUClibcSelectArch() {
local cfg="${1}"
local arch="${2}"
${sed} -i -r -e '/^TARGET_.*/d' "${cfg}"
CT_KconfigEnableOption "TARGET_${arch}" "${cfg}"
CT_KconfigSetOption "TARGET_ARCH" "${arch}" "${cfg}"
}
# uClibc: Adjust configuration file according to the CT-NG configuration
# Usage CT_DoArchUClibcConfig <config-file>
CT_DoArchUClibcConfig() {
CT_DoLog WARN "Support for '${CT_ARCH}' is not implemented in uClibc config tweaker."
CT_DoLog WARN "Exact configuration file must be provided."
}
# Override from the actual arch implementation as needed.
. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh"

View File

@ -39,3 +39,22 @@ CT_DoArchTupleValues() {
CT_TARGET_SYS="${CT_TARGET_SYS}hf"
fi
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "arm"
# FIXME: CONFIG_ARM_OABI does not exist in neither uClibc/uClibc-ng
# FIXME: CONFIG_ARM_EABI does not seem to affect anything in either of them, too
# (both check the compiler's built-in define, __ARM_EABI__ instead) except for
# a check for match between toolchain configuration and uClibc-ng in
# uClibc_arch_features.h
if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then
CT_KconfigDisableOption "CONFIG_ARM_OABI" "${cfg}"
CT_KconfigEnableOption "CONFIG_ARM_EABI" "${cfg}"
else
CT_KconfigDisableOption "CONFIG_ARM_EABI" "${cfg}"
CT_KconfigEnableOption "CONFIG_ARM_OABI" "${cfg}"
fi
}

View File

@ -1 +1,7 @@
# Compute M68k-specific values
CT_DoArchUClibcConfig() {
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "m68k"
}

View File

@ -19,3 +19,9 @@ CT_DoArchTupleValues () {
esac
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "microblaze"
}

View File

@ -14,3 +14,36 @@ CT_DoArchTupleValues() {
CT_ARCH_ABI_CFLAG="-mabi=${CT_ARCH_mips_ABI}"
CT_ARCH_WITH_ABI="--with-abi=${CT_ARCH_mips_ABI}"
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "${CT_ARCH}"
CT_KconfigDisableOption "CONFIG_MIPS_O32_ABI" "${cfg}"
CT_KconfigDisableOption "CONFIG_MIPS_N32_ABI" "${cfg}"
CT_KconfigDisableOption "CONFIG_MIPS_N64_ABI" "${cfg}"
case "${CT_ARCH_mips_ABI}" in
32)
CT_KconfigEnableOption "CONFIG_MIPS_O32_ABI" "${cfg}"
;;
n32)
CT_KconfigEnableOption "CONFIG_MIPS_N32_ABI" "${cfg}"
;;
64)
CT_KconfigEnableOption "CONFIG_MIPS_N64_ABI" "${cfg}"
;;
esac
# FIXME: uClibc (!ng) allows to select ISA in the config; should
# match from the selected ARCH_ARCH level... For now, delete and
# fall back to default.
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_1" "${cfg}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_2" "${cfg}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_3" "${cfg}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_4" "${cfg}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32" "${cfg}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32R2" "${cfg}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64" "${cfg}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64R2" "${cfg}"
}

View File

@ -71,3 +71,20 @@ CT_DoArchMultilibTarget ()
# Set the target variable
eval ${target_var}=\"${target_}\"
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "powerpc"
CT_KconfigDisableOption "CONFIG_E500" "${cfg}"
CT_KconfigDisableOption "CONFIG_CLASSIC" "${cfg}"
CT_KconfigDeleteOption "TARGET_SUBARCH" "${cfg}"
if [ "${CT_ARCH_powerpc_ABI}" = "spe" ]; then
CT_KconfigEnableOption "CONFIG_E500" "${cfg}"
CT_KconfigSetOption "TARGET_SUBARCH" "e500" "${cfg}"
else
CT_KconfigEnableOption "CONFIG_CLASSIC" "${cfg}"
CT_KconfigSetOption "TARGET_SUBARCH" "classic" "${cfg}"
fi
}

View File

@ -35,3 +35,18 @@ CT_DoArchTupleValues () {
esac
CT_ARCH_FLOAT_CFLAG=
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
# FIXME: uclibc (!ng) seems to support sh64 (sh5), too
CT_DoArchUClibcSelectArch "${cfg}" "sh"
CT_KconfigDisableOption "CONFIG_SH3" "${cfg}"
CT_KconfigDisableOption "CONFIG_SH4" "${cfg}"
CT_KconfigDisableOption "CONFIG_SH4A" "${cfg}"
case "${CT_ARCH_SH_VARIAN}" in
sh3) CT_KconfigEnableOption "CONFIG_SH3" "${cfg}";;
sh4) CT_KconfigEnableOption "CONFIG_SH4" "${cfg}";;
sh4a) CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}";;
esac
}

View File

@ -70,3 +70,10 @@ CT_DoArchGlibcAdjustTuple() {
# Set the target variable
eval ${target_var}=\"${target_}\"
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "${CT_ARCH}"
# FIXME: select CONFIG_SPARC_V7/V8/V9/V9B according to the CPU selector
}

View File

@ -100,3 +100,33 @@ CT_DoArchGlibcAdjustTuple() {
# Set the target variable
eval ${target_var}=\"${target_}\"
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
if [ "${CT_ARCH_BITNESS}" = 64 ]; then
CT_DoArchUClibcSelectArch "${cfg}" "x86_64"
else
CT_DoArchUClibcSelectArch "${cfg}" "i386"
fi
# FIXME This doesn't cover all cases of x86_32 on uClibc (!ng)
CT_KconfigDisableOption "CONFIG_386" "${cfg}"
CT_KconfigDisableOption "CONFIG_486" "${cfg}"
CT_KconfigDisableOption "CONFIG_586" "${cfg}"
CT_KconfigDisableOption "CONFIG_686" "${cfg}"
case ${CT_TARGET_ARCH} in
i386)
CT_KconfigEnableOption "CONFIG_386" "${cfg}"
;;
i486)
CT_KconfigEnableOption "CONFIG_486" "${cfg}"
;;
i586)
CT_KconfigEnableOption "CONFIG_586" "${cfg}"
;;
i686)
CT_KconfigEnableOption "CONFIG_686" "${cfg}"
;;
esac
}

View File

@ -70,3 +70,9 @@ CT_ConfigureXtensa() {
CT_Popd
}
CT_DoArchUClibcConfig() {
local cfg="${1}"
CT_DoArchUClibcSelectArch "${cfg}" "xtensa"
}

View File

@ -193,96 +193,8 @@ manage_uClibc_config() {
dst="$2"
# Start with fresh files
CT_DoExecLog ALL rm -f "${dst}"
CT_DoExecLog ALL mkdir -p "$(dirname ${dst})"
CT_DoExecLog ALL cp "${src}" "${dst}"
# Hack our target in the config file.
case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
x86:32) arch=i386;;
x86:64) arch=x86_64;;
sh:32) arch="sh";;
*) arch="${CT_ARCH}";;
esac
# Also remove stripping: its the responsibility of the
# firmware builder to strip or not.
${sed} -i -r -e '/^TARGET_.*/d' "${dst}"
CT_KconfigEnableOption "TARGET_${arch}" "${dst}"
CT_KconfigSetOption "TARGET_ARCH" "${arch}" "${dst}"
CT_KconfigDisableOption "DOSTRIP" "${dst}"
# Ah. We may one day need architecture-specific handler here...
case "${arch}" in
arm*)
if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then
CT_KconfigDisableOption "CONFIG_ARM_OABI" "${dst}"
CT_KconfigEnableOption "CONFIG_ARM_EABI" "${dst}"
else
CT_KconfigDisableOption "CONFIG_ARM_EABI" "${dst}"
CT_KconfigEnableOption "CONFIG_ARM_OABI" "${dst}"
fi
;;
i386)
# FIXME This doesn't cover all cases of x86_32...
case ${CT_TARGET_ARCH} in
i386)
CT_KconfigEnableOption "CONFIG_386" "${dst}"
;;
i486)
CT_KconfigEnableOption "CONFIG_486" "${dst}"
;;
i586)
CT_KconfigEnableOption "CONFIG_586" "${dst}"
;;
i686)
CT_KconfigEnableOption "CONFIG_686" "${dst}"
;;
esac
;;
mips*)
CT_KconfigDisableOption "CONFIG_MIPS_O32_ABI" "${dst}"
CT_KconfigDisableOption "CONFIG_MIPS_N32_ABI" "${dst}"
CT_KconfigDisableOption "CONFIG_MIPS_N64_ABI" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_1" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_2" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_3" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_4" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32R2" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64" "${dst}"
CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64R2" "${dst}"
case "${CT_ARCH_mips_ABI}" in
32)
CT_KconfigEnableOption "CONFIG_MIPS_O32_ABI" "${dst}"
;;
n32)
CT_KconfigEnableOption "CONFIG_MIPS_N32_ABI" "${dst}"
;;
64)
CT_KconfigEnableOption "CONFIG_MIPS_N64_ABI" "${dst}"
;;
esac
;;
powerpc*)
CT_KconfigDisableOption "CONFIG_E500" "${dst}"
CT_KconfigDisableOption "CONFIG_CLASSIC" "${dst}"
CT_KconfigDeleteOption "TARGET_SUBARCH" "${dst}"
if [ "${CT_ARCH_powerpc_ABI}" = "spe" ]; then
CT_KconfigEnableOption "CONFIG_E500" "${dst}"
CT_KconfigSetOption "TARGET_SUBARCH" "e500" "${dst}"
else
CT_KconfigEnableOption "CONFIG_CLASSIC" "${dst}"
CT_KconfigSetOption "TARGET_SUBARCH" "classic" "${dst}"
fi
;;
sh)
# all we really support right now is sh4:32
CT_KconfigEnableOption "CONFIG_SH4" "${dst}"
;;
esac
# Accomodate for old and new uClibc versions, where the
# way to select between big/little endian has changed
case "${CT_ARCH_ENDIAN}" in
big)
CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}"
@ -298,8 +210,6 @@ manage_uClibc_config() {
;;
esac
# Accomodate for old and new uClibc versions, where the
# MMU settings has different config knobs
if [ "${CT_ARCH_USE_MMU}" = "y" ]; then
CT_KconfigEnableOption "ARCH_USE_MMU" "${dst}"
else
@ -392,29 +302,23 @@ manage_uClibc_config() {
fi
# Push the threading model
case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in
none:)
CT_KconfigDisableOption "UCLIBC_HAS_THREADS" "${dst}"
CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}"
CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}"
CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in
none:)
;;
linuxthreads:old)
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
CT_KconfigEnableOption "LINUXTHREADS_OLD" "${dst}"
CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}"
CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
;;
linuxthreads:new)
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}"
CT_KconfigEnableOption "LINUXTHREADS_NEW" "${dst}"
CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
;;
nptl:)
CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}"
CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}"
CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}"
CT_KconfigEnableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}"
;;
*)
@ -426,29 +330,22 @@ manage_uClibc_config() {
CT_KconfigEnableOption "PTHREADS_DEBUG_SUPPORT" "${dst}"
# Force on debug options if asked for
case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
0)
CT_KconfigDisableOption "DODEBUG" "${dst}"
CT_KconfigDisableOption "DODEBUG_PT" "${dst}"
CT_KconfigDisableOption "DOASSERTS" "${dst}"
CT_KconfigDisableOption "SUPPORT_LD_DEBUG" "${dst}"
CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}"
CT_KconfigDisableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}"
case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in
0)
;;
1)
CT_KconfigEnableOption "DODEBUG" "${dst}"
CT_KconfigDisableOption "DODEBUG_PT" "${dst}"
CT_KconfigDisableOption "DOASSERTS" "${dst}"
CT_KconfigDisableOption "SUPPORT_LD_DEBUG" "${dst}"
CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}"
CT_KconfigDisableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}"
;;
2)
CT_KconfigEnableOption "DODEBUG" "${dst}"
CT_KconfigDisableOption "DODEBUG_PT" "${dst}"
CT_KconfigEnableOption "DOASSERTS" "${dst}"
CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}"
CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}"
CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}"
;;
3)
@ -460,6 +357,13 @@ manage_uClibc_config() {
CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}"
;;
esac
# Remove stripping: its the responsibility of the
# firmware builder to strip or not.
CT_KconfigDisableOption "DOSTRIP" "${dst}"
# Now allow architecture to tweak as it wants
CT_DoArchUClibcConfig "${dst}"
}
do_libc_post_cc() {