#!/bin/bash # this program is MIT licenced # (c) 2026 TheOddCell verbose="false" if [ "$0" = "-v" ] || [ "$1" = "-v" ]; then verbose="true" fi for i in pv curl tar zcat make gcc install bash; do if ! command -v $i >/dev/null 2>&1; then echo "$i not found." exit 1 fi done printf "Installing musl... Downloading\r" if $verbose; then curl -fL 'https://musl.libc.org/releases/musl-1.2.5.tar.gz' | tar -xvz else curl -fsSL 'https://musl.libc.org/releases/musl-1.2.5.tar.gz' | tar -xz fi cd musl-1.2.5 printf "Installing musl... Configuring\r" if $verbose; then ./configure "--prefix=$HOME/.musl" "--exec-prefix=$HOME/.musl" "--syslibdir=$HOME/.musl/lib" else ./configure "--prefix=$HOME/.musl" "--exec-prefix=$HOME/.musl" "--syslibdir=$HOME/.musl/lib" >/dev/null 2>&1 fi printf "Installing musl... Compiling \r" if $verbose; then make -j$(nproc) else make -j$(nproc) >/dev/null 2>&1 fi printf "Installing musl... Installing to ~/.musl\r" mkdir -p "$HOME/.musl" if $verbose; then make install else make install >/dev/null 2>&1 fi printf "Installing musl... Cleaning up \r" cd .. rm -rf musl-1.2.5 echo "Musl has been installed to ~/.musl; please add ~/.musl/bin to your PATH." echo "To uninstall, remove it from PATH and delete the ~/.musl folder" echo 'Example compiling command: CC="musl-gcc -static" ./configure --prefix=$HOME/.musl && make' echo "Be sure to make the prefix be in .musl if you are dynamicly linking and/or installing locally for yourself."