1 2.SUFFIXES: .java .class 3 4ifeq ($(NEOTONIC_ROOT),) 5NEOTONIC_ROOT = .. 6endif 7 8include $(NEOTONIC_ROOT)/rules.mk 9 10NEO_UTIL_SO = libclearsilver-jni.so 11ifeq ($(OSTYPE),Darwin) 12NEO_UTIL_SO = libclearsilver-jni.jnilib 13endif 14NEO_UTIL_JAVA_SRC = HDF.java CS.java CSUtil.java CSFileLoader.java JNI.java # CGI.java 15 16NEO_UTIL_JAVA_JAR = clearsilver.jar 17NEO_UTIL_SRC = j_neo_util.c j_neo_cs.c 18NEO_UTIL_OBJ = $(NEO_UTIL_SRC:%.c=%.o) 19 20CFLAGS += $(JAVA_INCLUDE_PATH) 21DLIBS += -lneo_cgi -lneo_cs -lneo_utl 22LIBS += $(DLIBS) 23ifneq ($(OSTYPE),Darwin) 24LDFLAGS += -Wl,-soname=$(NEO_UTIL_SO) 25endif 26 27TARGETS = org_clearsilver_HDF.h org_clearsilver_CS.h $(NEO_UTIL_SO) 28 29all: $(TARGETS) test 30 31$(NEO_UTIL_JAVA_JAR): $(NEO_UTIL_JAVA_SRC) 32 $(MKDIR) org/clearsilver 33 $(JAVAC) -d . $(NEO_UTIL_JAVA_SRC) 34 $(JAR) cf $(NEO_UTIL_JAVA_JAR) org 35 $(RM) -r org 36 37org_clearsilver_HDF.h: $(NEO_UTIL_JAVA_JAR) 38 $(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.HDF 39 40org_clearsilver_CS.h: $(NEO_UTIL_JAVA_JAR) 41 $(JAVAH) -classpath $(NEO_UTIL_JAVA_JAR) -jni org.clearsilver.CS 42 43CSTest.class: CSTest.java 44 $(JAVAC) -classpath $(NEO_UTIL_JAVA_JAR) CSTest.java 45 46gold: CSTest.class 47 @/bin/sh -c "LD_LIBRARY_PATH=$(NEOTONIC_ROOT)/java-jni; export LD_LIBRARY_PATH; CLASSPATH=$(NEO_UTIL_JAVA_JAR):.; export CLASSPATH; $(JAVA_PATH)/bin/java CSTest" > javatest.gold 48 @echo "Generated gold files" 49 50test: CSTest.class 51 @echo "Running java test" 52 @failed=0; \ 53 rm -f javatest.out; \ 54 LD_LIBRARY_PATH=$(NEOTONIC_ROOT)/java-jni; export LD_LIBRARY_PATH; \ 55 CLASSPATH=$(NEO_UTIL_JAVA_JAR):.; export CLASSPATH; \ 56 $(JAVA_PATH)/bin/java CSTest > javatest.out; \ 57 diff javatest.out javatest.gold > /dev/null 2>&1; \ 58 return_code=$$?; \ 59 if [ $$return_code -ne 0 ]; then \ 60 diff javatest.out javatest.gold > javatest.err; \ 61 echo "Failed Java Test: CSTest"; \ 62 echo " See javatest.out and javatest.err"; \ 63 failed=1; \ 64 fi; \ 65 if [ $$failed -eq 1 ]; then \ 66 exit 1; \ 67 fi; 68 @echo "Passed java test" 69 70CGI.h: CGI.class 71 $(JAVAH) -jni CGI 72 73$(NEO_UTIL_SO): $(NEO_UTIL_JAVA_JAR) $(NEO_UTIL_OBJ) $(DEP_LIBS) 74 $(LDSHARED) -o $@ $(LDFLAGS) $(NEO_UTIL_OBJ) $(LIBS) 75 76# I guess we'll just stick the .jar file in the lib directory 77install: all 78 $(INSTALL) $(NEO_UTIL_SO) $(DESTDIR)$(libdir) 79 $(INSTALL) $(NEO_UTIL_JAVA_JAR) $(DESTDIR)$(libdir) 80 81clean: 82 $(RM) *.o *.so 83 $(RM) -r org 84 $(RM) org_clearsilver_*.h 85 $(RM) *.class 86 $(RM) org_clearsilver_HDF.h org_clearsilver_CS.h 87 $(RM) Makefile.depends 88 89distclean: clean 90 $(RM) -f Makefile.depends $(TARGETS) 91