Commit d7e66191 authored by Martin Deinhofer's avatar Martin Deinhofer
Browse files

adapted makefile to compile java source and run project

parent 3b49154c
......@@ -3,7 +3,7 @@
#include "HelloJNI.h"
// Implementation of native method sayHello() of HelloJNI class
JNIEXPORT void JNICALL Java_java_1exercises7_11_11_HelloJNI_sayHello(JNIEnv *env, jobject thisObj) {
JNIEXPORT void JNICALL Java_java_1exercises8_11_11_HelloJNI_sayHello(JNIEnv *env, jobject thisObj) {
printf("Hello World!\n");
return;
}
# Define a variable for classpath
CLASS_PATH = ../bin
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_131
JAVA_SRC_PATH = ../src
JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
# Define a virtual path for .class in the bin directory
vpath %.class $(CLASS_PATH)
all : hello.dll java_exercises7_2_1_HelloJNI.dll
all : libhello.so
run :
java -cp $(CLASS_PATH) -Djava.library.path=../jni java_exercises8_1_1.HelloJNI
java_exercises8_1_1/HelloJNI.class:
javac -cp $(CLASS_PATH) -d $(CLASS_PATH) $(JAVA_SRC_PATH)/java_exercises8_1_1/HelloJNI.java
# Targets for java_exercises_7_1_1
# Targets for java_exercises8_1_1
# $@ matches the target, $< matches the first dependancy
hello.dll : HelloJNI.o
gcc -Wl,--add-stdcall-alias -shared -o $@ $<
libhello.so : HelloJNI.o
gcc -shared -o $@ $<
# $@ matches the target, $< matches the first dependancy
HelloJNI.o : HelloJNI.c HelloJNI.h
gcc -I"$(JAVA_HOME)\include" -I"$(JAVA_HOME)\include\win32" -c $< -o $@
gcc -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/linux" -c $< -o $@
# $* matches the target filename without the extension
HelloJNI.h : java_exercises7_1_1/HelloJNI.class
javah -o HelloJNI.h -classpath $(CLASS_PATH) java_exercises7_1_1.$*
HelloJNI.h : java_exercises8_1_1/HelloJNI.class
javah -o HelloJNI.h -classpath $(CLASS_PATH) java_exercises8_1_1.$*
# Targets for java_exercises_7_2_1
# $@ matches the target, $< matches the first dependancy
java_exercises7_2_1_HelloJNI.dll : java_exercises7_2_1_HelloJNI.o
gcc -Wl,--add-stdcall-alias -shared -o $@ $<
#java_exercises7_2_1_HelloJNI.dll : java_exercises7_2_1_HelloJNI.o
# gcc -Wl,--add-stdcall-alias -shared -o $@ $<
# $@ matches the target, $< matches the first dependancy
java_exercises7_2_1_HelloJNI.o : java_exercises7_2_1_HelloJNI.c java_exercises7_2_1_HelloJNI.h
gcc -I"$(JAVA_HOME)\include" -I"$(JAVA_HOME)\include\win32" -c $< -o $@
#java_exercises7_2_1_HelloJNI.o : java_exercises7_2_1_HelloJNI.c java_exercises7_2_1_HelloJNI.h
# gcc -I"$(JAVA_HOME)\include" -I"$(JAVA_HOME)\include\win32" -c $< -o $@
java_exercises7_2_1_HelloJNI.h : java_exercises7_2_1/HelloJNI.class
javah -classpath $(CLASS_PATH) java_exercises7_2_1.HelloJNI
#java_exercises7_2_1_HelloJNI.h : java_exercises7_2_1/HelloJNI.class
# javah -classpath $(CLASS_PATH) java_exercises7_2_1.HelloJNI
clean :
rm HelloJNI.h HelloJNI.o hello.dll java_exercises7_2_1_HelloJNI.dll java_exercises7_2_1_HelloJNI.h java_exercises7_2_1_HelloJNI.o
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment