# If you don't have javacpp,
# get it from http://www.hadron.org/~dhatch/.
# You'll also need cpp.

.PHONY: all
all: MipFilterApplet.jar


JAVAC = jikes -g -classpath /usr/java/jdk1.3.1/jre/lib/rt.jar
#JAVAC = jikes -g -classpath /usr/java/j2sdk1.4.0/jre/lib/rt.jar
#JAVAC = javac -g
# XXX kaffe just dumps core on my system
#JAVAC = kaffe -g -classpath /usr/java/j2sdk1.4.0/jre/lib/rt.jar

# XXX the -DMAIN following should probably be removed for production version
CPPFLAGS = -DMAIN

CLASSES= \
	MipFilterApplet.class \
        MyGraphics.class  \
        VecMath.class \
        MyMath.class \
        Format.class \
	${NULL}
# classes which which we don't need to build explicitly
# (they are built as side effects of other classes)
# but which need to be included in the jar file...
SUBCLASSES= \
        # MipFilterApplet'$$'*.class \
	${NULL}

.SUFFIXES: .prejava .class
.prejava.class:
	javacpp ${CPPFLAGS} ${JAVAC} $*.prejava
	javarenumber $*.class
MipFilterApplet.jar: ${CLASSES}
	(javarenumber ${SUBCLASSES} > /dev/null 2>&1 || true)
	jar cf MipFilterApplet.jar ${CLASSES} ${SUBCLASSES}
# XXX the javarenumber command above is a hack since I can't figure out
# XXX how to get it to do the right thing during compile time
MipFilterApplet.jar: Makefile

# Make sure modules are compiled in order of dependence...
MipFilterApplet.class: MyGraphics.class VecMath.class Format.class
MyGraphics.class: MyMath.class VecMath.class

${CLASSES}: macros.h

.PHONY: jar
jar:
	(cd ..; jar cvf MipFilterApplet.src.jar MipFilterApplet)

# XXX should automate this better. currently the way to send
# XXX is to do this manually:
#       make clean
#       make jar
#       make
#       make send
# 
.PHONY: send
send:
	rrr "scp MipFilterApplet.php MipFilterApplet.jar ../MipFilterApplet.src.jar www.hadron.org:public_html"

.PHONY: clean
clean:
	rm -f core *.jar *.class *.java.lines *.java
