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