Browse Source

Libsodium improvements + upgrade to 1.0.18

libsodium 1.0.16 is no longer supported and we also now download from
our own fork on Github, so the URL doesn't change.

We also now use all threads to compile, if we can detect them, on
all supported OS's.
deadstrip
Duke Leto 4 years ago
parent
commit
1f8606ae89
  1. 44
      res/libsodium/buildlibsodium.sh

44
res/libsodium/buildlibsodium.sh

@ -1,32 +1,52 @@
#!/bin/bash
# Copyright (c) 2019-2020 The Hush developers
# Released under the GPLv3
VERSION=1.0.18
LIB="libsodium"
DIR="$LIB-$VERSION"
FILE="$DIR.tar.gz"
URL=https://github.com/MyHush/libsodium/releases/download/${VERSION}/${FILE}
# First thing to do is see if libsodium.a exists in the res folder. If it does, then there's nothing to do
if [ -f res/libsodium.a ]; then
if [ -f res/${LIB}.a ]; then
exit 0
fi
echo "Building libsodium"
echo "Building $LIB"
# Go into the libsodium directory
cd res/$LIB
if [ ! -f $FILE ]; then
curl -LO $URL
fi
# Go into the lib sodium directory
cd res/libsodium
if [ ! -f libsodium-1.0.16.tar.gz ]; then
curl -LO https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz
if [ ! -d $DIR ]; then
tar xf $FILE
fi
if [ ! -d libsodium-1.0.16 ]; then
tar xf libsodium-1.0.16.tar.gz
# Try to use full core count to build
if [ "$UNAME" == "Linux" ] ; then
JOBS=$(nproc)
elif [ "$UNAME" == "FreeBSD" ] ; then
JOBS=$(nproc)
elif [ "$UNAME" == "Darwin" ] ; then
JOBS=$(sysctl -n hw.ncpu)
else
JOBS=4
fi
# Now build it
cd libsodium-1.0.16
cd $DIR
LIBS="" ./configure
make clean
echo "Building $LIB with $JOBS cores..."
if [[ "$OSTYPE" == "darwin"* ]]; then
make CFLAGS="-mmacosx-version-min=10.11" CPPFLAGS="-mmacosx-version-min=10.11" -j4
make CFLAGS="-mmacosx-version-min=10.11" CPPFLAGS="-mmacosx-version-min=10.11" -j$JOBS
else
make -j4
make -j$JOBS
fi
cd ..
# copy the library to the parents's res/ folder
cp libsodium-1.0.16/src/libsodium/.libs/libsodium.a ../
cp $DIR/src/libsodium/.libs/libsodium.a ../

Loading…
Cancel
Save