Skip to content

Instantly share code, notes, and snippets.

@jedisct1
Created Jun 4, 2021
Embed
What would you like to do?
#! /bin/sh
if ! command zig version >/dev/null; then
echo "Zig >= 0.8.0 is required" >&2
exit 1
fi
TARGET="x86_64-linux-gnu"
export PREFIX="$(pwd)/libsodium-${TARGET}"
mkdir -p $PREFIX || exit 1
TMPDIR="/tmp"
BINDIR="${TMPDIR}/bin"
export CC="${BINDIR}/cc"
mkdir -p "$BINDIR"
echo "#! /bin/sh" >"$CC"
echo "exec zig cc --target=${TARGET} \"\$@\"" >"$CC"
chmod +x "$CC"
export CC="zig cc"
export LD="zig lib"
export AR="zig ar"
export RANLIB="zig ranlib"
export STRIP="true"
make distclean >/dev/null
if [ -n "$LIBSODIUM_MINIMAL_BUILD" ]; then
export LIBSODIUM_ENABLE_MINIMAL_FLAG="--enable-minimal"
else
export LIBSODIUM_ENABLE_MINIMAL_FLAG=""
fi
./configure ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
--prefix="$PREFIX" --host="${TARGET}" ||
exit 1
NPROCESSORS=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)
PROCESSORS=${NPROCESSORS:-3}
make -j${PROCESSORS} install && make distclean >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment