libConsole/Makefile
author Markus Bröker <mbroeker@largo.dyndns.tv>
Fri, 27 Dec 2013 16:00:09 +0100
changeset 167 7c6b221900bf
parent 166 ecd6492274ad
permissions -rw-r--r--
Proper Datatypes to leave the 80's

   CC = gcc
 JAVA = java
JAVAH = javah
JAVAC = javac
   TC = Console
  LIB = lib/lib$(TC).so

SOURCES  = Getch.java
SOURCES += $(TC).java

OBJECTS  = cross_getch.o

ifdef JAVA_HOME
	JAVA_DIR="$(JAVA_HOME)"
else
	JAVA_DIR=/usr/lib/jvm/java-6-openjdk-amd64
endif

INCLUDE = -I$(JAVA_DIR)/include -I$(JAVA_DIR)/include/linux -Iinclude -fPIC

.SUFFIXES: .java

.c.o:
	@echo "JAVA_HOME=$(JAVA_DIR)"
	$(CC) -c $(CFLAGS) $(INCLUDE) $< -o $@

all: $(TC).class $(LIB)

$(TC).class: $(SOURCES)
	$(JAVAC) -d . $(SOURCES)
	$(JAVAH) -jni -d include $(TC)

$(LIB): $(OBJECTS)
	$(CC) -shared -Wl,-soname,lib$(TC).so.1,-rpath,lib $(OBJECTS) -o $@

.PHONY: clean

clean:
	rm -f include/$(TC).h *.class *~ $(LIB)
	rm -f $(OBJECTS)

debug: all
	LD_LIBRARY_PATH=lib $(JAVA) -cp . Getch

run: all
	$(JAVA) -Djava.library.path=lib -cp . Getch