author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:49:12 +0200 | |
changeset 49 | 77094ec383cf |
child 53 | 6b3d7e3418c1 |
permissions | -rw-r--r-- |
49
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
1 |
CC=gcc |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
2 |
JAVA=java |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
3 |
JAVAH=javah |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
4 |
JAVAC=javac |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
5 |
LIB=lib/libConsole.so |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
ifdef JAVA_HOME |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
JAVA_DIR="$(JAVA_HOME)" |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
9 |
else |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
JAVA_DIR=/usr/lib/jvm/java-6-sun |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
11 |
endif |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
INCLUDE=-I$(JAVA_DIR)/include -I$(JAVA_DIR)/include/linux -Iinclude |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
SOURCES= \ |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
Getch.java \ |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
16 |
Console.java |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
OBJECTS= \ |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
getch.o |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
.SUFFIXES: .java |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
.c.o: |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
24 |
@echo "JAVA_HOME=$(JAVA_DIR)" |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
25 |
$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@ |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
26 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
27 |
all: Getch.class $(LIB) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
28 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
29 |
Getch.class: $(SOURCES) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
30 |
$(JAVAC) -d . $(SOURCES) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
31 |
$(JAVAH) -jni -d include Console |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
32 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
33 |
$(LIB): $(OBJECTS) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
34 |
$(CC) -shared -Wl,-soname,libConsole.so.1,-rpath,lib $(OBJECTS) -o $@ |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
35 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
36 |
.PHONY: clean |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
37 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
38 |
clean: |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
39 |
rm -f include/Getch.h include/Console.h *.class *~ $(LIB) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
40 |
rm -f $(OBJECTS) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
41 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
42 |
debug: Getch.class lib/libConsole.so |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
43 |
LD_LIBRARY_PATH=lib $(JAVA) -cp . Getch |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
44 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
45 |
run: Getch.class $(LIB) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
46 |
@echo "You need to copy libConsole.(so|dll) to $(JAVA_DIR)/jre/lib/i386" |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
47 |
$(JAVA) -cp . Getch |