1 CC = gcc |
1 CC = gcc |
2 JAVA = java |
2 JAVA = java |
3 JAVAH = javah |
3 JAVAH = javah |
4 JAVAC = javac |
4 JAVAC = javac |
5 LIB = lib/libConsole.so |
5 TC = Console |
|
6 LIB = lib/lib$(TC).so |
|
7 |
|
8 SOURCES = Getch.java |
|
9 SOURCES += $(TC).java |
|
10 |
|
11 OBJECTS = cross_getch.o |
6 |
12 |
7 ifdef JAVA_HOME |
13 ifdef JAVA_HOME |
8 JAVA_DIR="$(JAVA_HOME)" |
14 JAVA_DIR="$(JAVA_HOME)" |
9 else |
15 else |
10 JAVA_DIR=/usr/lib/jvm/java-6-sun |
16 JAVA_DIR=/usr/lib/jvm/java-6-sun |
11 endif |
17 endif |
12 |
18 |
13 INCLUDE = -I$(JAVA_DIR)/include -I$(JAVA_DIR)/include/linux -Iinclude |
19 INCLUDE = -I$(JAVA_DIR)/include -I$(JAVA_DIR)/include/linux -Iinclude |
14 |
20 |
15 SOURCES = Getch.java |
|
16 SOURCES += Console.java |
|
17 |
|
18 OBJECTS = cross_getch.o |
|
19 |
|
20 .SUFFIXES: .java |
21 .SUFFIXES: .java |
21 |
22 |
22 .c.o: |
23 .c.o: |
23 @echo "JAVA_HOME=$(JAVA_DIR)" |
24 @echo "JAVA_HOME=$(JAVA_DIR)" |
24 $(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@ |
25 $(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@ |
25 |
26 |
26 all: Getch.class $(LIB) |
27 all: $(TC).class $(LIB) |
27 |
28 |
28 Getch.class: $(SOURCES) |
29 $(TC).class: $(SOURCES) |
29 $(JAVAC) -d . $(SOURCES) |
30 $(JAVAC) -d . $(SOURCES) |
30 $(JAVAH) -jni -d include Console |
31 $(JAVAH) -jni -d include $(TC) |
31 |
32 |
32 $(LIB): $(OBJECTS) |
33 $(LIB): $(OBJECTS) |
33 $(CC) -shared -Wl,-soname,libConsole.so.1,-rpath,lib $(OBJECTS) -o $@ |
34 $(CC) -shared -Wl,-soname,lib$(TC).so.1,-rpath,lib $(OBJECTS) -o $@ |
34 |
35 |
35 .PHONY: clean |
36 .PHONY: clean |
36 |
37 |
37 clean: |
38 clean: |
38 rm -f include/Getch.h include/Console.h *.class *~ $(LIB) |
39 rm -f include/$(TC).h *.class *~ $(LIB) |
39 rm -f $(OBJECTS) |
40 rm -f $(OBJECTS) |
40 |
41 |
41 debug: Getch.class lib/libConsole.so |
42 debug: all |
42 LD_LIBRARY_PATH=lib $(JAVA) -cp . Getch |
43 LD_LIBRARY_PATH=lib $(JAVA) -cp . Getch |
43 |
44 |
44 run: Getch.class $(LIB) |
45 run: all |
45 $(JAVA) -Djava.library.path=lib -cp . Getch |
46 $(JAVA) -Djava.library.path=lib -cp . Getch |