forked from ethereum/c-kzg-4844
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
61 lines (53 loc) · 1.55 KB
/
Makefile
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
53
54
55
56
57
58
59
60
61
INCLUDE_DIRS = ../../src ../../blst/bindings
TARGETS=ckzg_jni.c ../../src/ckzg.c ../../lib/libblst.a
CC_FLAGS=
OPTIMIZATION_LEVEL=-O2
ifeq ($(OS),Windows_NT)
CLANG_EXECUTABLE=gcc
CLANG_FLAGS=-shared
JNI_INCLUDE_FOLDER=win32
OS_ARCH=amd64
LIBRARY_RESOURCE=ckzg4844jni.dll
GRADLE_COMMAND=gradlew
else
CLANG_EXECUTABLE=clang
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Linux)
CLANG_FLAGS=-fPIC -shared
JNI_INCLUDE_FOLDER=linux
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
ifeq ($(UNAME_M),arm64)
OS_ARCH=aarch64
else
OS_ARCH=$(UNAME_M)
endif
LIBRARY_RESOURCE=libckzg4844jni.dylib
endif
GRADLE_COMMAND=./gradlew
endif
LIBRARY_FOLDER=src/main/resources/ethereum/ckzg4844/lib/${OS_ARCH}
ifeq ($(JAVA_HOME),)
$(error JAVA_HOME is not set and autodetection failed)
endif
all: build test
.PHONY: build
build:
$(MAKE) -C ../../src/ blst
mkdir -p ${LIBRARY_FOLDER}
${CLANG_EXECUTABLE} ${CC_FLAGS} ${CLANG_FLAGS} ${OPTIMIZATION_LEVEL} -Wall -Wextra -Werror -Wno-missing-braces -Wno-unused-parameter -Wno-format ${addprefix -I,${INCLUDE_DIRS}} -I"${JAVA_HOME}/include" -I"${JAVA_HOME}/include/${JNI_INCLUDE_FOLDER}" -o ${LIBRARY_FOLDER}/${LIBRARY_RESOURCE} ${TARGETS}
.PHONY: test
test:
${GRADLE_COMMAND} clean check