makefile 1.29 KB
Newer Older
1
# Define common variables
Martin Deinhofer's avatar
Martin Deinhofer committed
2
CLASS_PATH = ../bin
3
JAVA_SRC_PATH = ../src
4
JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt
5

6
7
8
9
#Paths to libmcp23s17 and libpifacecad
LIB_MCP23S17=../../libmcp23s17
LIB_PIFACECAD=../../libpifacecad

Martin Deinhofer's avatar
Martin Deinhofer committed
10
11
12
13

# Define a virtual path for .class in the bin directory
vpath %.class $(CLASS_PATH)

14
15
16
17
18
all : libhello.so

run :
	java -cp $(CLASS_PATH) -Djava.library.path=../jni java_exercises8_1_1.HelloJNI

19
java_exercises8_1_1/HelloJNI.class: $(JAVA_SRC_PATH)/java_exercises8_1_1/HelloJNI.java
20
	javac -cp $(CLASS_PATH) -d $(CLASS_PATH) $(JAVA_SRC_PATH)/java_exercises8_1_1/HelloJNI.java
Martin Deinhofer's avatar
Martin Deinhofer committed
21

22
# Targets for java_exercises8_1_1
Martin Deinhofer's avatar
Martin Deinhofer committed
23
# $@ matches the target, $< matches the first dependancy
24
libhello.so : HelloJNI.o
25
	gcc -shared -o $@ $< -L$(LIB_PIFACECAD) -lpifacecad -L$(LIB_MCP23S17) -lmcp23s17
Martin Deinhofer's avatar
Martin Deinhofer committed
26
27
28

# $@ matches the target, $< matches the first dependancy
HelloJNI.o : HelloJNI.c HelloJNI.h
29
	gcc -Wall -fPIC -I"$(JAVA_HOME)/include" -I"$(JAVA_HOME)/include/linux" -I$(LIB_PIFACECAD)/src -I$(LIB_MCP23S17)/src -c $< -o $@ -L$(LIB_PIFACECAD) -lpifacecad -L$(LIB_MCP23S17) -lmcp23s17
Martin Deinhofer's avatar
Martin Deinhofer committed
30
31

# $* matches the target filename without the extension
32
33
HelloJNI.h : java_exercises8_1_1/HelloJNI.class
	javah -o HelloJNI.h -classpath $(CLASS_PATH) java_exercises8_1_1.$*
Martin Deinhofer's avatar
Martin Deinhofer committed
34
35

clean :
36
	rm -rf HelloJNI.h HelloJNI.o libhello.so $(CLASS_PATH)/*