add more OS handling in the Makefile

This commit is contained in:
Stefan Bratanov 2022-11-24 18:05:12 +00:00
parent 3025c882ea
commit e765142a57
3 changed files with 18 additions and 10 deletions

View File

@ -2,20 +2,29 @@ INCLUDE_DIRS = ../../src ../../blst/bindings
ifeq ($(OS),Windows_NT)
CLANG_EXECUTABLE=gcc
CLANG_FLAGS=
CLANG_FLAGS=-shared
JNI_INCLUDE_FOLDER=win32
LIBRARY_RESOURCE=ckzg4844jni.dll
GRADLE_COMMAND=gradlew
else
CLANG_EXECUTABLE=clang
CLANG_FLAGS=-fPIC
GRADLE_COMMAND=./gradlew
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CLANG_FLAGS=-fPIC -shared
JNI_INCLUDE_FOLDER=linux
LIBRARY_RESOURCE=libckzg4844jni.so
GRADLE_COMMAND=./gradlew
endif
ifeq ($(UNAME_S),Darwin)
CLANG_FLAGS=-dynamiclib
JNI_INCLUDE_FOLDER=darwin
LIBRARY_RESOURCE=libckzg4844jni.dylib
endif
endif
c_kzg_4844_jni:
${CLANG_EXECUTABLE} -O -Wall -shared ${CLANG_FLAGS} ${addprefix -I,${INCLUDE_DIRS}} -I"${JAVA_HOME}/include" -I"${JAVA_HOME}/include/${JNI_INCLUDE_FOLDER}" -o src/main/resources/lib/${LIBRARY_RESOURCE} c_kzg_4844_jni.c c_kzg_4844.o ../../lib/libblst.a
${CLANG_EXECUTABLE} ${CLANG_FLAGS} -O -Wall ${addprefix -I,${INCLUDE_DIRS}} -I"${JAVA_HOME}/include" -I"${JAVA_HOME}/include/${JNI_INCLUDE_FOLDER}" -o src/main/resources/lib/${LIBRARY_RESOURCE} c_kzg_4844_jni.c c_kzg_4844.o ../../lib/libblst.a
test:
${GRADLE_COMMAND} clean test

View File

@ -3,14 +3,14 @@
## Prerequisites
* Follow the instructions in the [README.md](../../README.md) to install blst and build the C-KZG code.
* JAVA_HOME environment variable is set to a JDK with an `include` folder containing a jni.h file.
* `JAVA_HOME` environment variable is set to a JDK with an `include` folder containing a jni.h file.
## Build
```bash
make c_kzg_4844_jni
```
This will install the library in the `src/main/resources/lib` folder according to your os and arch
This will install the library in the `src/main/resources/lib` folder according to your OS
## Test
```bash

View File

@ -63,7 +63,6 @@ public class CKZg4844JNITest {
}
private byte[] createRandomBlob() {
final byte[] blob = new byte[CKzg4844JNI.BYTES_PER_BLOB];
random.nextBytes(blob);