-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-libff.sh
executable file
·45 lines (37 loc) · 1.41 KB
/
install-libff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/bash
set -eux
source .github/scripts/host.sh
if [ -f $HOME/.local/lib/libff"$EXT" ]; then
echo "libff exists, exiting..."
exit 0
fi
if [ -d libff ]; then
echo "$(pwd)/libff" already exists! Using it instead of re-cloning the repo.
else
git clone https://github.com/scipr-lab/libff -b v0.2.1 --recursive
fi
cd libff
git checkout v0.2.1
git submodule init && git submodule update
ARGS=("-DCMAKE_INSTALL_PREFIX=$PREFIX" "-DWITH_PROCPS=OFF")
CXXFLAGS=""
if [ "$HOST_OS" = "macOS" ]; then
OPENSSL_PREFIX=$(brew --prefix openssl)
export LDFLAGS=-L$OPENSSL_PREFIX/lib
export CPPFLAGS=-I$OPENSSL_PREFIX/include
export CXXFLAGS=-I$OPENSSL_PREFIX/include
ARGS+=("-DOPENSSL_INCLUDE_DIR=$OPENSSL_PREFIX/include/openssl" "-DCURVE=ALT_BN128" "-DCMAKE_INSTALL_NAME_DIR=$PREFIX/lib" "-DOPENSSL_CRYPTO_LIBRARY=$OPENSSL_PREFIX/lib/libcrypto.dylib" "-DOPENSSL_SSL_LIBRARY=$OPENSSL_PREFIX/lib/libssl.dylib")
sed -i '' 's/STATIC/SHARED/' libff/CMakeLists.txt # Fix GHC segfaults from hell (idk why)
sed -i '' 's/STATIC/SHARED/' depends/CMakeLists.txt
fi
if [ "$HOST_OS" = "Linux" ] && [ "$(uname -m)" = "aarch64" ]; then
ARGS+=("-DCURVE=ALT_BN128")
fi
if [ "$HOST_OS" = "Windows" ]; then
ARGS+=("-G" "Ninja")
sed -i 's/find_library(GMP_LIBRARY gmp)/find_library(GMP_LIBRARY NAMES libgmp.a)/' CMakeLists.txt
fi
mkdir -p build
cd build
CXXFLAGS="-fPIC $CXXFLAGS" cmake "${ARGS[@]}" ..
cmake --build . && cmake --install .