From 5fbe240b514842d8d5c60913d9060194063d2df1 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Tue, 19 Apr 2022 20:47:15 +0200 Subject: [PATCH] Updated Linux build script + added script to build musl libc for all target platforms. --- etc/utils/linux/mk-musl.sh | 33 +++++++++++++++++++++++++++++++++ mk-release.sh | 30 +++++++++++++++--------------- 2 files changed, 48 insertions(+), 15 deletions(-) create mode 100755 etc/utils/linux/mk-musl.sh diff --git a/etc/utils/linux/mk-musl.sh b/etc/utils/linux/mk-musl.sh new file mode 100755 index 0000000..9b972a6 --- /dev/null +++ b/etc/utils/linux/mk-musl.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# sudo apt install crossbuild-essential-i386 +# sudo apt install crossbuild-essential-arm64 +set -e +cd -- "$(dirname -- "${BASH_SOURCE[0]}")" + +function mk_musl() { + local outdir="/usr/local/musl/${1}-linux-gnu" + local build="musl-build-${1}" + rm -rf "${build}" && mkdir -p "${build}" + tar -xvf "musl-latest.tar.gz" --strip-components=1 -C "${build}" + pushd "${build}" + if [ -z "${2}" ]; then + ./configure --prefix="${outdir}" + else + ./configure --host="${2}" --prefix="${outdir}" + fi + make + sudo rm -rf "${outdir}" + sudo make install + popd +} + +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" + +mk_musl x86_64 +mk_musl i686 i686-linux-gnu +mk_musl aarch64 aarch64-linux-gnu diff --git a/mk-release.sh b/mk-release.sh index bf652b7..bd9cbc8 100755 --- a/mk-release.sh +++ b/mk-release.sh @@ -1,23 +1,23 @@ #!/bin/bash +# See "etc/utils/linux/mk-musl.sh" in order to build musl libc! set -e cd -- "$(dirname -- "${BASH_SOURCE[0]}")" -mkdir -p "out" +function mk_slunk() { + local command="make -B CC=/usr/local/musl/${1}-linux-gnu/bin/musl-gcc STATIC=1 STRIP=1 FLTO=1" + if [ ! -z "${2}" ]; then + command="${command} ${2}" + fi + $BASH -x -c "${command}" + cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-${1}" +} + +rm -rf "out" && mkdir -p "out" + $BASH -x -c "make clean" -case "$(getconf LONG_BIT)" in - "64") - $BASH -x -c "make -B CC=musl-gcc CPU=64 FLTO=1 STATIC=1 STRIP=1 MARCH=x86-64 MTUNE=nocona" - cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-x64" - ;; - "32") - $BASH -x -c "make -B CC=musl-gcc CPU=32 FLTO=1 STATIC=1 STRIP=1 MARCH=pentiumpro MTUNE=generic" - cp -vf "frontend/bin/slunkcrypt" "out/slunkcrypt-i686" - ;; - *) - echo "Unknown platform!" - exit 1 - ;; -esac +mk_slunk "x86_64" "MARCH=x86-64 MTUNE=nocona" +mk_slunk "i686" "MARCH=pentiumpro MTUNE=generic" +mk_slunk "aarch64" printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n"