2019-04-08 11:47:33 -07:00
|
|
|
#! /bin/sh
|
|
|
|
|
2022-01-22 15:34:25 -07:00
|
|
|
export PATH="/opt/zig/bin:/opt/zig:/opt/homebrew/bin:$PATH"
|
2019-04-08 11:47:33 -07:00
|
|
|
|
|
|
|
export PREFIX="$(pwd)/libsodium-wasm32-wasi"
|
|
|
|
|
|
|
|
mkdir -p $PREFIX || exit 1
|
|
|
|
|
2021-07-19 03:12:56 -07:00
|
|
|
export CC="zig cc"
|
2022-11-21 05:01:44 -07:00
|
|
|
export CFLAGS="--target=wasm32-wasi -O3"
|
2023-02-07 05:01:40 -07:00
|
|
|
export LDFLAGS="-s"
|
2021-07-19 03:12:56 -07:00
|
|
|
export AR="zig ar"
|
|
|
|
export RANLIB="zig ranlib"
|
2019-04-08 11:47:33 -07:00
|
|
|
|
2020-07-04 06:32:13 -07:00
|
|
|
make distclean >/dev/null
|
2019-04-08 11:47:33 -07:00
|
|
|
|
2019-04-08 14:23:07 -07:00
|
|
|
if [ "x$1" = "x--bench" ]; then
|
|
|
|
export BENCHMARKS=1
|
2022-12-20 00:30:59 -07:00
|
|
|
export CPPFLAGS="-DBENCHMARKS -DITERATIONS=200"
|
2022-01-22 16:04:57 -07:00
|
|
|
else
|
|
|
|
export CPPFLAGS="-DED25519_NONDETERMINISTIC=1"
|
2019-04-08 14:23:07 -07:00
|
|
|
fi
|
|
|
|
|
2019-04-09 02:40:28 -07:00
|
|
|
if [ -n "$LIBSODIUM_MINIMAL_BUILD" ]; then
|
2019-04-08 11:47:33 -07:00
|
|
|
export LIBSODIUM_ENABLE_MINIMAL_FLAG="--enable-minimal"
|
|
|
|
else
|
|
|
|
export LIBSODIUM_ENABLE_MINIMAL_FLAG=""
|
|
|
|
fi
|
|
|
|
|
2021-07-19 03:12:56 -07:00
|
|
|
if ! ./configure ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
|
|
|
--prefix="$PREFIX" \
|
2020-07-04 06:32:13 -07:00
|
|
|
--host=wasm32-wasi \
|
2024-05-19 02:21:41 -07:00
|
|
|
--disable-pie --disable-ssp --disable-shared --without-pthreads; then
|
2021-07-19 03:12:56 -07:00
|
|
|
cat config.log
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-04-08 11:47:33 -07:00
|
|
|
|
|
|
|
NPROCESSORS=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)
|
|
|
|
PROCESSORS=${NPROCESSORS:-3}
|
|
|
|
|
2019-04-08 14:23:07 -07:00
|
|
|
if [ -z "$BENCHMARKS" ]; then
|
2020-07-04 06:32:13 -07:00
|
|
|
make -j${PROCESSORS} check && make install && make distclean >/dev/null
|
2019-04-08 16:12:07 -07:00
|
|
|
else
|
|
|
|
make -j${PROCESSORS} && make check
|
2019-04-08 14:23:07 -07:00
|
|
|
fi
|