libConsole/Makefile
changeset 49 77094ec383cf
child 53 6b3d7e3418c1
new file mode 100644
--- /dev/null
+++ b/libConsole/Makefile
@@ -0,0 +1,47 @@
+CC=gcc
+JAVA=java
+JAVAH=javah
+JAVAC=javac
+LIB=lib/libConsole.so
+
+ifdef JAVA_HOME
+	JAVA_DIR="$(JAVA_HOME)"
+else
+	JAVA_DIR=/usr/lib/jvm/java-6-sun
+endif
+
+INCLUDE=-I$(JAVA_DIR)/include -I$(JAVA_DIR)/include/linux -Iinclude
+SOURCES= \
+	Getch.java \
+	Console.java
+
+OBJECTS= \
+	getch.o
+
+.SUFFIXES: .java
+
+.c.o:
+	@echo "JAVA_HOME=$(JAVA_DIR)"
+	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@
+
+all: Getch.class $(LIB)
+
+Getch.class: $(SOURCES)
+	$(JAVAC) -d . $(SOURCES)
+	$(JAVAH) -jni -d include Console
+
+$(LIB): $(OBJECTS)
+	$(CC) -shared -Wl,-soname,libConsole.so.1,-rpath,lib $(OBJECTS) -o $@
+
+.PHONY: clean
+
+clean:
+	rm -f include/Getch.h include/Console.h *.class *~ $(LIB)
+	rm -f $(OBJECTS)
+
+debug: Getch.class lib/libConsole.so
+	LD_LIBRARY_PATH=lib $(JAVA) -cp . Getch
+
+run: Getch.class $(LIB)
+	@echo "You need to copy libConsole.(so|dll) to $(JAVA_DIR)/jre/lib/i386"
+	$(JAVA) -cp . Getch