scripts: fix missing character '0' issue in linksys image
[openwrt/staging/stintel.git] / scripts / ext-toolchain.sh
index 1ef3f42c50a9e4121c54c0bdb0c0ae7b5b3020fe..fe1024c18ec800a903a32aa64471065385032768 100755 (executable)
@@ -369,8 +369,18 @@ print_config() {
        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
 
        local lib
@@ -463,6 +473,13 @@ probe_cpp() {
 }
 
 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"