-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from jserv/java-integration
Better Java integration
- Loading branch information
Showing
4 changed files
with
65 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
UNAME_S := $(shell uname -s) | ||
|
||
# if JAVA_HOME is not set, guess it according to system configurations | ||
ifndef JAVA_HOME | ||
ifeq ($(UNAME_S),Darwin) | ||
# macOS | ||
JAVA_HOME := $(shell /usr/libexec/java_home) | ||
else | ||
# Default to Linux | ||
JAVAC := $(shell which javac) | ||
ifndef JAVAC | ||
$(error "javac is not available. Please check JDK installation") | ||
endif | ||
JAVA_HOME := $(shell readlink -f $(JAVAC) | sed "s:bin/javac::") | ||
endif | ||
endif # JAVA_HOME | ||
|
||
JAVAH = javah | ||
ifdef JAVA_HOME | ||
JAVAH = $(JAVA_HOME)/bin/javah | ||
endif | ||
JAVAH := $(shell which $(JAVAH)) | ||
ifndef JAVAH | ||
$(error "javah is not available. Please check JDK installation") | ||
endif | ||
|
||
CURL := $(shell which curl) | ||
ifndef CURL | ||
$(error "curl is not available.") | ||
endif | ||
|
||
SHELL_HACK := $(shell mkdir -p $(OUT)/com/iota/iri/hash) | ||
|
||
GITHUB_REPO ?= chenwei-tw/iri/feat/new_pow_interface | ||
PearlDriverSRC := src/main/java/com/iota/iri/hash/PearlDiver.java | ||
|
||
$(OUT)/com/iota/iri/hash/PearlDiver.java: $(OUT)/com/iota/iri/hash | ||
$(VECHO) " CURL\t$@\n" | ||
$(Q)$(CURL) -s -o $@ \ | ||
"https://github.com/raw/$(GITHUB_REPO)/$(PearlDriverSRC)" | ||
|
||
$(OUT)/jni/iri-pearldiver-exlib.h: $(OUT)/com/iota/iri/hash/PearlDiver.java | ||
$(VECHO) " JAVAH\t$@\n" | ||
$(Q)$(JAVAH) -classpath $(OUT) -o $@ com.iota.iri.hash.PearlDiver | ||
|
||
ifeq ($(UNAME_S),Darwin) | ||
# macOS | ||
CFLAGS_JNI := -I$(JAVA_HOME)/include/darwin | ||
else | ||
# Default to Linux | ||
CFLAGS_JNI := -I$(JAVA_HOME)/include/linux | ||
endif | ||
|
||
CFLAGS_JNI += -I$(JAVA_HOME)/include | ||
CFLAGS_JNI += -I$(OUT)/jni | ||
|
||
jni/iri-pearldiver-exlib.c: $(OUT)/jni/iri-pearldiver-exlib.h | ||
|
||
$(OUT)/jni/%.o: jni/%.c | ||
$(VECHO) " CC\t$@\n" | ||
$(Q)$(CC) -o $@ $(CFLAGS) $(CFLAGS_JNI) -c -MMD -MF $@.d $< |