diff --git a/bindings/java/Makefile b/bindings/java/Makefile index 0cd818b..b5f11e0 100644 --- a/bindings/java/Makefile +++ b/bindings/java/Makefile @@ -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 - JNI_INCLUDE_FOLDER=linux - LIBRARY_RESOURCE=libckzg4844jni.so - GRADLE_COMMAND=./gradlew + GRADLE_COMMAND=./gradlew + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + CLANG_FLAGS=-fPIC -shared + JNI_INCLUDE_FOLDER=linux + LIBRARY_RESOURCE=libckzg4844jni.so + 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 diff --git a/bindings/java/README.md b/bindings/java/README.md index 68ec40c..9028e64 100644 --- a/bindings/java/README.md +++ b/bindings/java/README.md @@ -2,15 +2,15 @@ ## 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. +* 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. ## 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 diff --git a/bindings/java/src/test/java/CKZg4844JNITest.java b/bindings/java/src/test/java/CKZg4844JNITest.java index 0857420..862c6bf 100644 --- a/bindings/java/src/test/java/CKZg4844JNITest.java +++ b/bindings/java/src/test/java/CKZg4844JNITest.java @@ -63,7 +63,6 @@ public class CKZg4844JNITest { } - private byte[] createRandomBlob() { final byte[] blob = new byte[CKzg4844JNI.BYTES_PER_BLOB]; random.nextBytes(blob);