-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_fast_mcljava_linux_mac.sh
executable file
·65 lines (61 loc) · 2.27 KB
/
install_fast_mcljava_linux_mac.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
mcl_version="v1.52"
# exit immediately on error
set -e
# check for operating system
os=""
if [ "$(uname)" == "Darwin" ]; then
os="mac"
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
os="linux"
else
echo "Unsupported operating system. This script only works on Linux and macOS."
exit 2
fi
# check that JAVA_INC is given
if [ $# -eq 0 ]; then
echo "Missing Java include argument"
echo "Please specify path of your JDK 'include' directory as first argument"
if [ $os == "linux" ]; then
echo "For example: ./install_fast_mcljava_linux_mac.sh /usr/lib/jvm/java-8-openjdk-amd64/include"
else # mac os
echo "For example: ./install_fast_mcljava_linux_mac.sh /Library/Java/JavaVirtualMachines/openjdk-13.0.1.jdk/Contents/Home/include"
echo "For your system, it's probably: "
javahome=$(/usr/libexec/java_home)
echo ./install_fast_mcljava_linux_mac.sh $javahome/include
fi
exit 1
fi
java_inc=$1
(
echo "----- Cloning mcl from https://github.com/herumi/mcl.git -----"
cd /tmp
git clone https://github.com/herumi/mcl.git
cd mcl
git checkout $mcl_version || exit
echo "----- Deleting currently installed version of mcl -----"
if [ $os == "linux" ]; then
sudo rm /usr/lib/libmcljava.so
else # mac os
mkdir -p ~/Library/Java/Extensions/ #check that this is included here: System.out.println(System.getProperty("java.library.path"));
rm ~/Library/Java/Extensions/libmcljava.dylib
fi
echo "----- Building mcl -----"
make -j4 || exit # build mcl library
echo "----- Building mcl java bindings and running tests -----"
echo "----- Java include path: $java_inc -----"
cd ffi/java
make test_mcl JAVA_INC=-I$java_inc || exit # build java bindings, set include manually
echo "----- Copying mcl java shared library to /usr/lib/ -----"
cd ../..
if [ $os == "linux" ]; then
sudo cp lib/libmcljava.so /usr/lib/
else # mac os
mkdir -p ~/Library/Java/Extensions/ #check that this is included here: System.out.println(System.getProperty("java.library.path"));
cp lib/libmcljava.dylib ~/Library/Java/Extensions/
fi
echo "----- Installation finished successfully. Deleting mcl repository folder -----"
cd ..
rm -rf mcl
echo "----- Done -----"
) || { echo "----- Failed installation. -----"; rm -rf /tmp/mcl; exit 3; }