forked from jmcardon/tsec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sodium_setup.sh
executable file
·52 lines (40 loc) · 1.1 KB
/
sodium_setup.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
#!/usr/bin/env bash
cd tsec-libsodium/jni
#Setup script adapted from android libsodium library
set -e
if [ -z "$JAVA_HOME" ]; then
echo "ERROR You should set JAVA_HOME"
echo "Exiting!"
exit 1
fi
echo "${JAVA_HOME}"
C_INCLUDE_PATH="${JAVA_HOME}/include:${JAVA_HOME}/include/linux:/System/Library/Frameworks/JavaVM.framework/Headers"
export C_INCLUDE_PATH
rm -f *.java
rm -f *.c
rm -f *.so
export PATH=/usr/local/bin:$PATH
swig -java -package tsec.jni sodium.i
rm -f ../src/main/scala/tsec/jni/SodiumJNI.java
cp SodiumJNI.java ../src/main/scala/tsec/jni
case "$OSTYPE" in
darwin*)
jnilib=libsodiumjni.dylib
destlib=/Library/Java/Extensions
sudo update_dyld_shared_cache
;;
*)
jnilib=libsodiumjni.so
destlib=/usr/lib
sudo ldconfig
;;
esac
echo $jnilib
echo $destlib
echo $destlib/$jnilib
gcc -I../usr/local/include/sodium -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -I${JAVA_HOME}/include/darwin sodium_wrap.c -shared -fPIC -L/usr/local/lib -L/usr/lib -lsodium -o $jnilib
sudo rm -f $destlib/$jnilib
sudo cp $jnilib $destlib
rm -f *.java
rm -f *.c
rm -f *.so