libsodium/dist-build/wasm32-wasi.sh

46 lines
1.1 KiB
Bash
Raw Normal View History

2019-05-30 10:04:55 -04:00
#! /bin/sh
export PATH="/opt/zig/bin:/opt/zig:/usr/local/opt/llvm/bin:$PATH"
2019-05-30 10:04:55 -04:00
export PREFIX="$(pwd)/libsodium-wasm32-wasi"
mkdir -p $PREFIX || exit 1
export CC="zig cc"
export CFLAGS="-DED25519_NONDETERMINISTIC=1 --target=wasm32-wasi -O2"
export LDFLAGS="-s -Wl,--stack-first"
2019-05-30 10:04:55 -04:00
export NM="llvm-nm"
export AR="llvm-ar"
export RANLIB="llvm-ranlib"
export STRIP="llvm-strip"
make distclean >/dev/null
2019-05-30 10:04:55 -04:00
if [ "x$1" = "x--bench" ]; then
export BENCHMARKS=1
export CPPFLAGS="-DBENCHMARKS -DITERATIONS=100"
fi
if [ -n "$LIBSODIUM_MINIMAL_BUILD" ]; then
export LIBSODIUM_ENABLE_MINIMAL_FLAG="--enable-minimal"
else
export LIBSODIUM_ENABLE_MINIMAL_FLAG=""
fi
if ! ./configure ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
--prefix="$PREFIX" \
--host=wasm32-wasi \
--disable-ssp --disable-shared --without-pthreads; then
cat config.log
exit 1
fi
2019-05-30 10:04:55 -04:00
NPROCESSORS=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)
PROCESSORS=${NPROCESSORS:-3}
if [ -z "$BENCHMARKS" ]; then
make -j${PROCESSORS} check && make install && make distclean >/dev/null
2019-05-30 10:04:55 -04:00
else
make -j${PROCESSORS} && make check
fi