author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 05 Mar 2010 22:03:16 +0100 | |
changeset 112 | 9bfb339a8156 |
parent 102 | b8ff193b1a01 |
child 149 | 5acf77b9b7a0 |
permissions | -rw-r--r-- |
66
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
1 |
CC = gcc |
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
2 |
JAVA = java |
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
3 |
JAVAH = javah |
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
4 |
JAVAC = javac |
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
5 |
LIB = lib/libConsole.so |
49
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 |
|
66
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
13 |
INCLUDE = -I$(JAVA_DIR)/include -I$(JAVA_DIR)/include/linux -Iinclude |
49
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
|
66
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
15 |
SOURCES = Getch.java |
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
16 |
SOURCES += Console.java |
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
17 |
|
2b4f786d9073
Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
55
diff
changeset
|
18 |
OBJECTS = cross_getch.o |
49
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
.SUFFIXES: .java |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
.c.o: |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
@echo "JAVA_HOME=$(JAVA_DIR)" |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
24 |
$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@ |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
25 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
26 |
all: Getch.class $(LIB) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
27 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
28 |
Getch.class: $(SOURCES) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
29 |
$(JAVAC) -d . $(SOURCES) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
30 |
$(JAVAH) -jni -d include Console |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
31 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
32 |
$(LIB): $(OBJECTS) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
33 |
$(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
|
34 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
35 |
.PHONY: clean |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
36 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
37 |
clean: |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
38 |
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
|
39 |
rm -f $(OBJECTS) |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
40 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
41 |
debug: Getch.class lib/libConsole.so |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
42 |
LD_LIBRARY_PATH=lib $(JAVA) -cp . Getch |
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
43 |
|
77094ec383cf
libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
44 |
run: Getch.class $(LIB) |
102
b8ff193b1a01
Property java.library.path
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
66
diff
changeset
|
45 |
$(JAVA) -Djava.library.path=lib -cp . Getch |