#!/bin/bash # this program is licenced under 0bsd verbose="false" if [ "$0" = "-v" ] || [ "$1" = "-v" ]; then verbose="true" fi for i in curl tar zcat make gcc install bash gum; do if ! command -v $i >/dev/null 2>&1; then echo "$i not found." exit 1 fi done if $verbose; then printf "Installing musl... Downloading\r" 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' | gum spin --title='Installing musl... Downloading' -- tar -xz fi cd musl-1.2.5 if $verbose; then gum spin --show-output --title="Installing musl... Configuring" -- ./configure "--prefix=$HOME/.musl" "--exec-prefix=$HOME/.musl" "--syslibdir=$HOME/.musl/lib" "--enable-wrapper=all" else gum spin --title="Installing musl... Configuring" -- ./configure "--prefix=$HOME/.musl" "--exec-prefix=$HOME/.musl" "--syslibdir=$HOME/.musl/lib" "--enable-wrapper=all" fi if $verbose; then gum spin --title="Installing musl... Compiling" --show-output -- make -j$(nproc) else gum spin --title="Installing musl... Compiling" -- make -j$(nproc) fi mkdir -p "$HOME/.musl" if $verbose; then gum spin --title="Installing musl... Installing" --show-output -- make install else gum spin --title="Installing musl... Installing" -- make install fi ln -s "$HOME/.musl/lib/libc.so" "$HOME/.musl/bin/musl-ldd" 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 "Remove the prefix change if you are distributing your compiled files."