From 8dad8628b3bf3ddf37cace742363f1389eed8c3e Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 17 Sep 2022 16:29:11 +0200 Subject: [PATCH] Added simple build scripts for Linux, FreeBSD, Win32 and MacOS X platforms. --- dist/freebsd/mk-release.sh | 9 +++++++++ dist/linux/mk-musl-libc.sh | 36 ++++++++++++++++++++++++++++++++++++ dist/linux/mk-release.sh | 10 ++++++++++ dist/macosx/mk-release.sh | 11 +++++++++++ dist/win32/mk-release.cmd | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+) create mode 100755 dist/freebsd/mk-release.sh create mode 100755 dist/linux/mk-musl-libc.sh create mode 100755 dist/linux/mk-release.sh create mode 100755 dist/macosx/mk-release.sh create mode 100644 dist/win32/mk-release.cmd diff --git a/dist/freebsd/mk-release.sh b/dist/freebsd/mk-release.sh new file mode 100755 index 0000000..254a7c8 --- /dev/null +++ b/dist/freebsd/mk-release.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# pkg install gmake gcc12 +set -e +cd -- "$(dirname -- "$0")/../.." + +gmake -B CC=gcc12 XCFLAGS="-m32" MARCH=i586 MTUNE=pentium2 OUTNAME="crc64-i686" +gmake -B CC=gcc12 XCFLAGS="-m64" MARCH=x86-64 MTUNE=znver3 OUTNAME="crc64-x86_64" + +echo "Build completed successfully." diff --git a/dist/linux/mk-musl-libc.sh b/dist/linux/mk-musl-libc.sh new file mode 100755 index 0000000..ed76990 --- /dev/null +++ b/dist/linux/mk-musl-libc.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# sudo apt install curl crossbuild-essential-{i386,armel,armhf,arm64,mipsel,mips64el} +set -e +cd -- "$(dirname -- "${BASH_SOURCE[0]}")" + +function mk_musl() { + printf "\033[1;36m\nBuilding musl-libc for: ${1}\033[0m\n\n" + local outdir="/usr/local/musl/${1}" + local build="musl-build-${1}" + rm -rf "${build}" && mkdir -p "${build}" + tar -xvf "musl-latest.tar.gz" --strip-components=1 -C "${build}" + pushd "${build}" + local optdirs="$(find './src' -mindepth 1 -maxdepth 1 -type d -printf '%f,' | sed 's/,$//g')" + CFLAGS="${3}" ./configure --enable-optimize="${optdirs}" --disable-shared --prefix="${outdir}" ${2:+--host=$2} + 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 "" "-march=x86-64 -mtune=znver3" +mk_musl i686 i686-linux-gnu "-march=i586 -mtune=pentium2" +mk_musl armel arm-linux-gnueabi +mk_musl armhf arm-linux-gnueabihf +mk_musl arm64 aarch64-linux-gnu +mk_musl mipsel mipsel-linux-gnu +mk_musl mips64el mips64el-linux-gnuabi64 + +printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n" diff --git a/dist/linux/mk-release.sh b/dist/linux/mk-release.sh new file mode 100755 index 0000000..fd44e19 --- /dev/null +++ b/dist/linux/mk-release.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." + +find /usr/local/musl -mindepth 2 -type f -executable \( -name 'musl-gcc' -or -name 'musl-clang' \) -printf '%P\0' | \ +while IFS= read -r -d '' filename; do + make -B CC="/usr/local/musl/${filename}" OUTNAME="crc64-$(grep -Po '^[^/\\]+' <<< "${filename}")" +done + +printf "\033[1;32m\nBuild completed successfully.\033[0m\n\n" diff --git a/dist/macosx/mk-release.sh b/dist/macosx/mk-release.sh new file mode 100755 index 0000000..95dc1c2 --- /dev/null +++ b/dist/macosx/mk-release.sh @@ -0,0 +1,11 @@ +#!/bin/zsh +# xcode-select -install +set -e +cd -- "$(dirname -- "$0")/../.." + +make -B MARCH= MTUNE= STATIC=0 STRIP=0 XCFLAGS="-target x86_64-apple-darwin" OUTNAME="crc64-x86_64" +make -B MARCH= MTUNE= STATIC=0 STRIP=0 XCFLAGS="-target arm64-apple-darwin" OUTNAME="crc64-arm64" + +strip crc64-* + +echo "Build completed successfully." diff --git a/dist/win32/mk-release.cmd b/dist/win32/mk-release.cmd new file mode 100644 index 0000000..9abeabc --- /dev/null +++ b/dist/win32/mk-release.cmd @@ -0,0 +1,34 @@ +@echo off +setlocal enabledelayedexpansion +cd "%~dp0\..\..\win32" + +if "%MSVC_PATH%"=="" ( + set "MSVC_PATH=C:\Program Files\Microsoft Visual Studio\2022\Community\VC" +) + +if not exist "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" ( + echo MSVC not found. Please check MSVC_PATH and try again ^^!^^!^^! + pause + goto:eof +) + +for %%p in (x86,x64,ARM64) do ( + echo ------------------------------------------------------------------------------ + echo [%%p] + echo ------------------------------------------------------------------------------ + call "%MSVC_PATH%\Auxiliary\Build\vcvarsall.bat" %%~p + for %%t in (Clean,Rebuild) do ( + MSBuild.exe /property:Configuration=Release /property:Platform=%%p /target:%%t /verbosity:normal "%CD%\crc64.sln" + if not "!ERRORLEVEL!"=="0" goto:BuildFailed + ) + echo. +) + +echo Build completed successfully. +pause +goto:eof + +:BuildFailed +echo. +echo Build has failed ^^!^^!^^! +pause