TOOLCHAIN="."
LIBC_TYPE=""
+GCC_VERSION=""
# Library specs
return 1
}
+find_gcc_version() {
+ if [ -f $TOOLCHAIN/info.mk ]; then
+ GCC_VERSION=$(grep GCC_VERSION $TOOLCHAIN/info.mk | sed 's/GCC_VERSION=//')
+ return 0
+ fi
+
+ echo "Warning! Can't find info.mk, trying to detect with alternative way."
+
+ # Very fragile detection
+ GCC_VERSION=$(find $TOOLCHAIN/bin | grep -oE "gcc-[0-9]+\.[0-9]+\.[0-9]+$" | \
+ head -1 | sed 's/gcc-//')
+}
+
wrap_bin_cc() {
local out="$1"
echo "CONFIG_TOOLCHAIN_PREFIX=\"$prefix\"" >> "$config"
echo "CONFIG_TARGET_NAME=\"$target\"" >> "$config"
- if [ "$LIBC_TYPE" != glibc ]; then
- echo "CONFIG_TOOLCHAIN_LIBC=\"$LIBC_TYPE\"" >> "$config"
+ if [ -f "$config" ]; then
+ sed -i '/CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL/d' "$config"
+ sed -i '/CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_GLIBC/d' "$config"
+ fi
+
+ if [ "$LIBC_TYPE" == glibc ]; then
+ echo "CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_GLIBC=y" >> "$config"
+ elif [ "$LIBC_TYPE" == musl ]; then
+ echo "CONFIG_EXTERNAL_TOOLCHAIN_LIBC_USE_MUSL=y" >> "$config"
+ else
+ echo "Can't detect LIBC type. Aborting!" >&2
+ return 1
+ fi
+
+ if [ -n "$GCC_VERSION" ]; then
+ echo "CONFIG_EXTERNAL_GCC_VERSION=\"$GCC_VERSION\"" >> "$config"
+ else
+ echo "Can't detect GCC version. Aborting!" >&2
+ return 1
fi
local lib
}
probe_libc() {
+ if [ -f $TOOLCHAIN/info.mk ]; then
+ LIBC_TYPE=$(grep LIBC_TYPE $TOOLCHAIN/info.mk | sed 's/LIBC_TYPE=//')
+ return 0
+ fi
+
+ echo "Warning! Can't find info.mk, trying to detect with alternative way."
+
if [ -z "$LIBC_TYPE" ]; then
if test_uclibc; then
LIBC_TYPE="uclibc"
--config)
if probe_cc; then
probe_libc
+ find_gcc_version
print_config "$1"
exit $?
fi