Compat with linux host

This commit is contained in:
Salomon BRYS
2020-06-29 11:41:34 +02:00
parent ff37b86ff3
commit 548fb27c33
4 changed files with 50 additions and 17 deletions

View File

@@ -1,9 +1,6 @@
#!/usr/bin/env bash
set -e
ANDROID_NDK=/Users/salomonbrys/Library/Android/sdk/ndk/21.3.6528147
TOOLCHAIN=darwin-x86_64
[[ -z "$ANDROID_NDK" ]] && echo "Please set the ANDROID_NDK variable" && exit 1
[[ -z "$ARCH" ]] && echo "Please set the ARCH variable" && exit 1
[[ -z "$TOOLCHAIN" ]] && echo "Please set the TOOLCHAIN variable" && exit 1

View File

@@ -1,7 +1,11 @@
#!/usr/bin/env bash
set -e
[[ -z "$TARGET" ]] && echo "Please set the PLATFORM variable" && exit 1
[[ -z "$TARGET" ]] && echo "Please set the TARGET variable" && exit 1
if [ "$(id -u)" == "0" ]; then
[[ -z "$TO_UID" ]] && echo "Please set the TO_UID variable" && exit 1
fi
cd secp256k1
@@ -9,6 +13,8 @@ if [ "$TARGET" == "mingw" ]; then
CONF_OPTS="CFLAGS=-fpic --host=x86_64-w64-mingw32"
elif [ "$TARGET" == "linux" ]; then
CONF_OPTS="CFLAGS=-fpic"
elif [ "$TARGET" == "darwin" ]; then
CONF_OPTS="--host=x86_64-w64-darwin"
fi
./autogen.sh
@@ -16,19 +22,26 @@ fi
make clean
make
[[ ! -z "$TO_UID" ]] && chown -R $TO_UID:$TO_UID .
cd ..
mkdir -p build/$TARGET
cp -v secp256k1/.libs/libsecp256k1.a build/$TARGET/
[[ ! -z "$TO_UID" ]] && chown -R $TO_UID:$TO_UID build
CC=gcc
JNI_HEADERS=$TARGET
if [ "$TARGET" == "linux" ]; then
OUTFILE=libsecp256k1-jni.so
ADD_LIB=-lgmp
elif [ "$TARGET" == "darwin" ]; then
OUTFILE=libsecp256k1-jni.dylib
ADD_LIB=-lgmp
if [ -z "$CROSS_TRIPLE" ]; then
ADD_LIB=-lgmp
fi
elif [ "$TARGET" == "mingw" ]; then
OUTFILE=secp256k1-jni.dll
CC=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static-gcc
@@ -37,3 +50,7 @@ elif [ "$TARGET" == "mingw" ]; then
fi
$CC -shared $CC_OPTS -o build/$TARGET/$OUTFILE jni/src/org_bitcoin_NativeSecp256k1.c jni/src/org_bitcoin_Secp256k1Context.c -Ijni/headers/ -Ijni/headers/$JNI_HEADERS/ -Isecp256k1/ -lsecp256k1 -Lbuild/$TARGET/ $ADD_LIB
[[ ! -z "$TO_UID" ]] && chown -R $TO_UID:$TO_UID build
echo "Build done for $TARGET"