# Makefile for Java part of JavaGDBM # Katherine Don, 2005 #JAVAC = $(JAVA_HOME)/bin/javac #JAVAH = $(JAVA_HOME)/bin/javah #JAR = $(JAVA_HOME)/bin/jar JAVAC = @JAVAC@ # 'javah' existed until JDK 1.7, transitional in JDK 1.8, then removed by JDK 1.9 (use 'javac -h' instead) # Makefile rules below test for 'javah' and use it if it found, otherwise runs with 'javac -h' version # # Since we're committed to JAVA_HOME being set, so jni.h header files can be found, # then we can lean on JAVA_HOME here to more precisely check for the existence of javah # within JAVA_HOME, and not accidentally pick up on another (older) JDK that is also # installed on the system, and does come with a 'javah' but is unlikely to be able # to cope with newer (e.g. JDK 11) version class files JAVAH = $(JAVA_HOME)/bin/javah JAR = jar JAVACFLAGS = @JAVACFLAGS@ JAVAGDBMHOME=../ JAVACLASSDIR=./classes JAVASRCDIR=. JAVACOPTIONS= -deprecation -g -O JAVACLASSPATH=$(JAVACLASSDIR): all: setup compile setup: mkdir -p $(JAVACLASSDIR) compile: setup $(JAVAC) $(JAVACFLAGS) -d $(JAVACLASSDIR) -sourcepath $(JAVASRCDIR) $(JAVACOPTIONS) au/com/pharos/*/*.java # $(JAVAC) -h $(JAVAGDBMHOME)/jni -classpath $(JAVACLASSPATH) -d java au/com/pharos/gdbm/GdbmFile.java @echo Checking for javah ... # $(eval found = $(shell which javah 2>/dev/null | wc -l)) $(eval found = $(shell command -v $(JAVAH) | wc -l)) @if test "$(found)" = "1" ; then \ echo "... found" ; \ echo $(JAVAH) -o $(JAVAGDBMHOME)/jni/GdbmFile.h -classpath $(JAVACLASSPATH) au.com.pharos.gdbm.GdbmFile ; \ $(JAVAH) -o $(JAVAGDBMHOME)/jni/GdbmFile.h -classpath $(JAVACLASSPATH) au.com.pharos.gdbm.GdbmFile ; \ else \ echo "... not found => using 'javac -h'" ; \ echo $(JAVAC) -h $(JAVAGDBMHOME)/jni -classpath $(JAVACLASSPATH) -d java ../java/au/com/pharos/gdbm/GdbmFile.java ; \ $(JAVAC) -h $(JAVAGDBMHOME)/jni -classpath $(JAVACLASSPATH) -d java ../java/au/com/pharos/gdbm/GdbmFile.java ; \ fi jar cf $(JAVAGDBMHOME)/javagdbm.jar -C $(JAVACLASSDIR) au clean: rm -rf $(JAVACLASSDIR) $(JAVAGDBMHOME)/javagdbm.jar $(JAVAGDBMHOME)/jni/GdbmFile.h install: distclean: clean rm -f Makefile