2022-04-19 20:47:15 +02:00
|
|
|
#!/bin/bash
|
2024-06-05 00:23:48 +02:00
|
|
|
# Prerequisites: sudo apt install crossbuild-essential-*
|
2022-04-19 20:47:15 +02:00
|
|
|
set -e
|
|
|
|
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"
|
|
|
|
|
|
|
|
function mk_musl() {
|
2024-06-05 00:23:48 +02:00
|
|
|
if [[ -n "${2}" && -z "$(which "${2}-gcc")" ]]; then
|
|
|
|
echo "Warning: Cross-compiler for target \"${2}\" not found -> skipping!"
|
|
|
|
return
|
|
|
|
fi
|
2022-05-21 17:21:09 +02:00
|
|
|
local outdir="/usr/local/musl/${1}"
|
2022-04-19 20:47:15 +02:00
|
|
|
local build="musl-build-${1}"
|
|
|
|
rm -rf "${build}" && mkdir -p "${build}"
|
|
|
|
tar -xvf "musl-latest.tar.gz" --strip-components=1 -C "${build}"
|
|
|
|
pushd "${build}"
|
2022-05-07 18:55:22 +02:00
|
|
|
local optdirs="$(find './src' -mindepth 1 -maxdepth 1 -type d -printf '%f,' | sed 's/,$//g')"
|
2022-04-19 20:47:15 +02:00
|
|
|
if [ -z "${2}" ]; then
|
2022-05-07 18:55:22 +02:00
|
|
|
./configure --enable-optimize="${optdirs}" --disable-shared --prefix="${outdir}"
|
2022-04-19 20:47:15 +02:00
|
|
|
else
|
2022-05-07 18:55:22 +02:00
|
|
|
./configure --enable-optimize="${optdirs}" --disable-shared --prefix="${outdir}" --host="${2}"
|
2022-04-19 20:47:15 +02:00
|
|
|
fi
|
|
|
|
make
|
|
|
|
sudo rm -rf "${outdir}"
|
|
|
|
sudo make install
|
|
|
|
popd
|
2024-06-05 00:23:48 +02:00
|
|
|
rm -rf "${build}"
|
2022-04-19 20:47:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$(gcc -dumpmachine)" != "x86_64-linux-gnu" ]; then
|
|
|
|
echo "This script is supposed to run on the native \"x86_64-linux-gnu\" platform !!!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
curl -vkf -o "musl-latest.tar.gz" "https://musl.libc.org/releases/musl-latest.tar.gz"
|
|
|
|
|
2024-06-05 00:23:48 +02:00
|
|
|
mk_musl arm64 aarch64-linux-gnu
|
|
|
|
mk_musl armel arm-linux-gnueabi
|
|
|
|
mk_musl armhf arm-linux-gnueabihf
|
|
|
|
mk_musl i686 i686-linux-gnu
|
|
|
|
mk_musl mips64el mips64el-linux-gnuabi64
|
|
|
|
mk_musl mips64 mips64-linux-gnuabi64
|
|
|
|
mk_musl mips64r6el mipsisa64r6el-linux-gnuabi64
|
|
|
|
mk_musl mips64r6 mipsisa64r6-linux-gnuabi64
|
|
|
|
mk_musl mipsel mipsel-linux-gnu
|
|
|
|
mk_musl mips mips-linux-gnu
|
|
|
|
mk_musl mipsr6el mipsisa32r6el-linux-gnu
|
|
|
|
mk_musl mipsr6 mipsisa32r6-linux-gnu
|
|
|
|
mk_musl riscv64 riscv64-linux-gnu
|
|
|
|
mk_musl s390x s390x-linux-gnu
|
|
|
|
mk_musl x86_64 x86_64-linux-gnu
|
|
|
|
|
|
|
|
#mk_musl ppc64le powerpc64le-linux-gnu
|
|
|
|
#mk_musl powerpc powerpc-linux-gnu
|