2015-08-29 06:54:05 +03:00
|
|
|
|
|
|
|
.PHONY: gen_const clean
|
|
|
|
|
2015-08-25 13:21:47 +03:00
|
|
|
JAVA_HOME := $(shell jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));')
|
|
|
|
|
|
|
|
JAVA_INC := $(shell realpath $(JAVA_HOME)/../include)
|
|
|
|
|
|
|
|
JAVA_PLATFORM_INC := $(shell dirname `find $(JAVA_INC) -name jni_md.h`)
|
|
|
|
|
|
|
|
UNICORN_INC=../../include
|
|
|
|
|
|
|
|
SAMPLES := $(shell ls samples/*.java)
|
2015-08-25 21:41:14 +03:00
|
|
|
SRC := $(shell ls unicorn/*.java)
|
|
|
|
|
|
|
|
OS := $(shell uname)
|
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
LIB_EXT=.dylib
|
|
|
|
endif
|
|
|
|
ifeq ($(OS),Linux)
|
|
|
|
LIB_EXT=.so
|
|
|
|
else
|
|
|
|
LIB_EXT=.dll
|
|
|
|
endif
|
2015-08-25 13:21:47 +03:00
|
|
|
|
|
|
|
CC=gcc
|
|
|
|
CFLAGS=-fPIC
|
|
|
|
LDFLAGS=-shared -fPIC
|
|
|
|
LIBS=-lunicorn
|
|
|
|
LIBDIR=-L../../
|
|
|
|
INCS=-I$(JAVA_INC) -I$(JAVA_PLATFORM_INC) -I$(UNICORN_INC)
|
|
|
|
|
|
|
|
JC=javac
|
|
|
|
CLASSPATH=./
|
|
|
|
|
|
|
|
.SUFFIXES: .java .class
|
|
|
|
|
|
|
|
%.class: %.java
|
|
|
|
$(JC) $(JFLAGS) $<
|
|
|
|
|
|
|
|
OBJS=unicorn_Unicorn.o
|
|
|
|
|
|
|
|
JARFILE=unicorn.jar
|
|
|
|
|
|
|
|
all: lib jar samples
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
$(CC) -c $(CFLAGS) $(INCS) $< -o $@
|
|
|
|
|
|
|
|
unicorn_Unicorn.h: unicorn/Unicorn.java
|
|
|
|
javah unicorn.Unicorn
|
|
|
|
|
|
|
|
unicorn_Unicorn.o: unicorn_Unicorn.c unicorn_Unicorn.h
|
|
|
|
$(CC) -c $(CFLAGS) $(INCS) $< -o $@
|
|
|
|
|
2015-08-25 21:41:14 +03:00
|
|
|
libunicorn_java$(LIB_EXT): unicorn_Unicorn.o
|
2015-08-25 13:21:47 +03:00
|
|
|
|
2015-08-25 21:41:14 +03:00
|
|
|
lib: libunicorn_java$(LIB_EXT) unicorn_Unicorn.h
|
2015-08-25 13:21:47 +03:00
|
|
|
$(CC) -o $< $(LDFLAGS) $(OBJS) $(LIBDIR) $(LIBS)
|
|
|
|
|
|
|
|
samples: $(SAMPLES:.java=.class)
|
2015-08-25 21:41:14 +03:00
|
|
|
jarfiles: $(SRC:.java=.class)
|
2015-08-25 13:21:47 +03:00
|
|
|
|
2015-08-25 21:41:14 +03:00
|
|
|
jar: jarfiles
|
2015-08-25 13:21:47 +03:00
|
|
|
jar cf $(JARFILE) unicorn/*.class
|
|
|
|
|
|
|
|
install: lib jar
|
2015-08-25 21:41:14 +03:00
|
|
|
cp libunicorn_java$(LIB_EXT) $(JAVA_HOME)/lib/ext
|
|
|
|
cp $(JARFILE) $(JAVA_HOME)/lib/ext
|
2015-08-29 06:54:05 +03:00
|
|
|
|
|
|
|
gen_const:
|
|
|
|
cd .. && python const_generator.py java
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm unicorn/*.class
|
|
|
|
rm samples/*.class
|
|
|
|
rm *.so
|
|
|
|
rm *.dylib
|
|
|
|
rm *.dll
|