diff options
author | Prakash Ramrakhyani <prakash.ramrakhyani@arm.com> | 2011-09-13 12:06:13 -0500 |
---|---|---|
committer | Prakash Ramrakhyani <prakash.ramrakhyani@arm.com> | 2011-09-13 12:06:13 -0500 |
commit | e4830ad2eb85b9fef8f6e01b6bcbe34983f1d912 (patch) | |
tree | 6d5f7c1a14144a0825221a4414eb2edb9193212e /util/m5/Makefile.arm | |
parent | 28a2236ec18e3d5a82d6f7caffbf8285aec48b38 (diff) | |
download | gem5-e4830ad2eb85b9fef8f6e01b6bcbe34983f1d912.tar.xz |
gem5ops: Implement Java JNI for gem5Ops
These ops allow gem5 ops to be called from within java programs like the following:
import jni.gem5Op;
public class HelloWorld {
public static void main(String[] args) {
gem5Op gem5 = new gem5Op();
System.out.println("Rpns0:" + gem5.rpns());
System.out.println("Rpns1:" + gem5.rpns());
}
static {
System.loadLibrary("gem5OpJni");
}
}
When building you need to make sure classpath include gem5OpJni.jar:
javac -classpath $CLASSPATH:/path/to/gem5OpJni.jar HelloWorld.java
and when running you need to make sure both the java and library path are set:
java -classpath $CLASSPATH:/path/to/gem5OpJni.jar -Djava.library.path=/path/to/libgem5OpJni.so HelloWorld
Diffstat (limited to 'util/m5/Makefile.arm')
-rw-r--r-- | util/m5/Makefile.arm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/util/m5/Makefile.arm b/util/m5/Makefile.arm index 94c222644..80c562a06 100644 --- a/util/m5/Makefile.arm +++ b/util/m5/Makefile.arm @@ -47,8 +47,16 @@ CC=$(CROSS_COMPILE)gcc AS=$(CROSS_COMPILE)as LD=$(CROSS_COMPILE)ld -CFLAGS=-O2 +JC=javac +JH=javah +JR=jar +### JDK_PATH must be set to build gem5OpJni +#JDK_PATH=/path/to/jdk/version_number + +CFLAGS=-O2 -I $(JDK_PATH)/include/ -I $(JDK_PATH)/include/linux + OBJS=m5.o m5op_arm.o +JNI_OBJS=m5op_arm.o jni_gem5Op.o all: m5 @@ -61,5 +69,13 @@ all: m5 m5: $(OBJS) $(CC) -o $@ $(OBJS) +gem5OpJni: gem5OpJni.jar $(JNI_OBJS) + $(CC) --shared -o lib$@.so $(JNI_OBJS) + +gem5OpJni.jar: + $(JC) jni/gem5Op.java; \ + $(JH) jni.gem5Op; \ + $(JR) cvf $@ jni/*.class + clean: - rm -f *.o m5 + rm -f *.o m5 libgemOpJni.so gem5OpJni.jar jni/*.class |