elftoolchain

This commit is contained in:
cowmonk 2025-11-15 13:08:46 -07:00
parent 58d098dfae
commit a9a3077633
16 changed files with 260 additions and 14 deletions

View file

@ -1,7 +1,7 @@
#!/bin/sh
set -eu
SOURCES_FILE=./sources.list
source ./scripts/config.sh
while IFS= read -r url; do \
[ -z "$url" ] && continue; \
@ -10,6 +10,6 @@ if [ -e "./sources/$fname" ]; then \
printf "SKIP: %s (already exists)\n" "$fname"; \
else \
printf "GET: %s -> %s\n" "$url" "$fname"; \
curl -o "./sources/$fname" "$url" || { printf "ERROR: failed to download %s\n" "$url"; exit 1; }; \
curl -f -L -O -S --output-dir "./sources/" "$url" || { printf "ERROR: failed to download %s\n" "$url"; exit 1; }; \
fi; \
done < "$SOURCES_FILE"; \

15
scripts/config.sh Executable file
View file

@ -0,0 +1,15 @@
# musllvm default flags
# --------------------------------
# feel free to change these however you like
#
#
# these are shared between the Makefile and scripts
#
ARCH=$(uname -m)
SOURCES_FILE=./sources.list
FROOT="${ARCH}-musllvm"
CROSS="./build/cross" # cross directory
# MAKEFLAGS to parse the amounto of cores used
MAKEFLAGS="-j$(nproc) -l$(nproc)"

42
scripts/elftoolchain-cross.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/sh
set -eu
source ./scripts/config.sh
ELF_TAR=$(ls ./sources/elftoolchain-*.tar.* 2>/dev/null | head -n 1 | xargs basename)
if [ -z "$ELF_TAR" ]; then
echo "ERR: No Musl tarball found in sources directory"
exit 1
fi
ELF_SOURCE="${ELF_TAR%%.tar.*}"
if command -v "clang" >/dev/null 2>&1 && command -v "lld" >/dev/null 2>&1; then
export CC="clang"
else
export CC="cc"
fi
if [ ! -d ./build/"$ELF_SOURCE" ]; then
echo "Extracting Elftoolchain tarball to ./build/"
tar -xpf ./sources/"$ELF_TAR" -C ./build
else
echo "Elftoolchain source already extracted."
fi
echo "Buliding musl headers"
if [ -f "./build/$ELF_SOURCE" ]; then
echo "ELFTOOLCHAIN already built, skipping..."
exit
fi
cd ./build/"$ELF_SOURCE"
echo "patching elftoolchain-cross..."
patch -Np1 < ../../patches/elftoolchain/*
echo "Installing elftoolchain-cross..."
bmake WITH_ADDITIONAL_DOCUMENTATION=no \
WITH_TESTS=no \
MANTARGET=man

View file

@ -1,8 +1,8 @@
#!/bin/sh
set -eu
ARCH=$(uname -m)
FROOT="$ARCH-musllvm"
source ./scripts/config.sh
LINUX_TAR=$(ls ./sources/linux-*.tar.* 2>/dev/null | head -n 1 | xargs basename)
if [ -z "$LINUX_TAR" ]; then
echo "ERR: No Linux tarball found in sources directory"

View file

@ -1,8 +1,8 @@
#!/bin/sh
set -eu
ARCH=$(uname -m)
FROOT="../$ARCH-musllvm" # make install in source dir
source ./scripts/config.sh
MUSL_TAR=$(ls ./sources/musl-*.tar.* 2>/dev/null | head -n 1 | xargs basename)
if [ -z "$MUSL_TAR" ]; then
echo "ERR: No Musl tarball found in sources directory"
@ -32,4 +32,7 @@ fi
cd ./build/"$MUSL_SOURCE"
echo "Installing musl headers..."
DESTDIR=$FROOT make ARCH=$(uname -m) install-headers
./configure \
--prefix=/
DESTDIR=../../$CROSS make ARCH=$(uname -m) install-headers