libConsole/Makefile
author Markus Bröker <mbroeker@largo.dyndns.tv>
Fri, 19 Nov 2010 10:48:23 +0100
changeset 156 2898369b1cdc
parent 149 5acf77b9b7a0
child 166 ecd6492274ad
permissions -rw-r--r--
check for the linux-specific proc filesystem... committer: Markus Bröker <mbroeker@largo.homelinux.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
     5
   TC = Console
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
     6
  LIB = lib/lib$(TC).so
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
     7
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
     8
SOURCES  = Getch.java
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
     9
SOURCES += $(TC).java
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    10
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    11
OBJECTS  = cross_getch.o
49
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
ifdef JAVA_HOME
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    14
	JAVA_DIR="$(JAVA_HOME)"
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    15
else
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    16
	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
    17
endif
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    18
66
2b4f786d9073 Common Makefile Style NAME += OBJECT
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 55
diff changeset
    19
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
    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
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    27
all: $(TC).class $(LIB)
49
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    28
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    29
$(TC).class: $(SOURCES)
49
77094ec383cf libConsole: a java native interface example
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff changeset
    30
	$(JAVAC) -d . $(SOURCES)
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    31
	$(JAVAH) -jni -d include $(TC)
49
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)
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    34
	$(CC) -shared -Wl,-soname,lib$(TC).so.1,-rpath,lib $(OBJECTS) -o $@
49
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:
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    39
	rm -f include/$(TC).h *.class *~ $(LIB)
49
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
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    42
debug: all
49
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
149
5acf77b9b7a0 working Makefile rules O_O
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 102
diff changeset
    45
run: all
102
b8ff193b1a01 Property java.library.path
Markus Bröker <mbroeker@largo.dyndns.tv>
parents: 66
diff changeset
    46
	$(JAVA) -Djava.library.path=lib -cp . Getch