c-kzg-4844/bindings/java/Makefile

74 lines
1.7 KiB
Makefile
Raw Normal View History

2022-11-24 17:16:15 +00:00
INCLUDE_DIRS = ../../src ../../blst/bindings
TARGETS=c_kzg_4844_jni.c ../../src/c_kzg_4844.c ../../lib/libblst.a
CC_FLAGS=
OPTIMIZATION_LEVEL=-O2
2022-11-24 17:16:15 +00:00
ifeq ($(OS),Windows_NT)
CLANG_EXECUTABLE=gcc
CLANG_FLAGS=-shared
JNI_INCLUDE_FOLDER=win32
OS_ARCH=amd64
LIBRARY_RESOURCE=ckzg4844jni.dll
GRADLE_COMMAND=gradlew
2022-11-24 17:16:15 +00:00
else
CLANG_EXECUTABLE=clang
UNAME_S := $(shell uname -s)
2022-12-19 15:41:02 +00:00
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Linux)
CLANG_FLAGS=-fPIC -shared
JNI_INCLUDE_FOLDER=linux
2022-12-19 15:52:54 +00:00
ifeq ($(UNAME_M),x86_64)
OS_ARCH=amd64
else
OS_ARCH=$(UNAME_M)
endif
LIBRARY_RESOURCE=libckzg4844jni.so
endif
ifeq ($(UNAME_S),Darwin)
ifeq ($(JAVA_HOME),)
JAVA_HOME := $(shell /usr/libexec/java_home)
endif
CLANG_FLAGS=-dynamiclib
JNI_INCLUDE_FOLDER=darwin
2022-12-19 15:41:02 +00:00
ifeq ($(UNAME_M),arm64)
OS_ARCH=aarch64
else
OS_ARCH=$(UNAME_M)
endif
LIBRARY_RESOURCE=libckzg4844jni.dylib
endif
GRADLE_COMMAND=./gradlew
2022-11-24 17:16:15 +00:00
endif
PRESET ?= mainnet
ifeq ($(PRESET),minimal)
FIELD_ELEMENTS_PER_BLOB ?= 4
else
FIELD_ELEMENTS_PER_BLOB ?= 4096
endif
LIBRARY_FOLDER=src/main/resources/ethereum/ckzg4844/lib/${OS_ARCH}/${PRESET}
2022-11-25 10:14:49 +00:00
ifeq ($(JAVA_HOME),)
$(error JAVA_HOME is not set and autodetection failed)
2022-11-25 10:14:49 +00:00
endif
all: build test benchmark
2022-11-24 19:46:47 +00:00
.PHONY: build
2022-11-24 19:46:47 +00:00
build:
mkdir -p ${LIBRARY_FOLDER}
${CLANG_EXECUTABLE} ${CC_FLAGS} ${CLANG_FLAGS} ${OPTIMIZATION_LEVEL} -Wall -Wno-missing-braces ${addprefix -I,${INCLUDE_DIRS}} -I"${JAVA_HOME}/include" -I"${JAVA_HOME}/include/${JNI_INCLUDE_FOLDER}" -DFIELD_ELEMENTS_PER_BLOB=${FIELD_ELEMENTS_PER_BLOB} -o ${LIBRARY_FOLDER}/${LIBRARY_RESOURCE} ${TARGETS}
2022-11-24 18:05:12 +00:00
.PHONY: test
2022-11-24 17:16:15 +00:00
test:
${GRADLE_COMMAND} clean check
2022-11-24 17:16:15 +00:00
.PHONY: benchmark
benchmark:
${GRADLE_COMMAND} clean jmh