scripts: ext-toolchain: add support for musl
authorChristian Marangi <ansuelsmth@gmail.com>
Sun, 17 Jul 2022 15:56:59 +0000 (17:56 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 3 Oct 2022 15:40:26 +0000 (17:40 +0200)
Openwrt now supports only glibc and musl. Add support for musl and
rework the libc check to handle the new config flags and correctly
compile package basend on that.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
(cherry picked from commit 7be01fe13b4517e5edb8a4818f437d60144cdcb4)

scripts/ext-toolchain.sh

index 1f8eca30769a81cf599c439c8466220752f44801..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