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

.PHONY: all
all: HLerpApplet.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= \
	HLerpApplet.class \
        MyGraphics.class \
        GraphicsAntiAliasingSetter.class \
        HyperbolicUtils.class \
        Isometry2.class \
        Complex.class \
        MyMath.class \
        VecMath.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...
# XXX argh! getting the $ in there is going to be a problem...
# XXX should we just jar *.class?  for now, it's not a problem
# XXX since I didn't make QuarantinedFunctions a subclass, for other reasons
SUBCLASSES= \
        GraphicsAntiAliasingSetter_QuarantinedFunctions.class \
        HyperbolicUtils'$$'*.class \
        HLerpApplet'$$'*.class \
	${NULL}


.SUFFIXES: .prejava .class
.prejava.class:
	javacpp ${CPPFLAGS} ${JAVAC} $*.prejava
	javarenumber $*.class
HLerpApplet.jar: ${CLASSES}
	(javarenumber ${SUBCLASSES} > /dev/null 2>&1 || true)
	echo jar cf HLerpApplet.jar ${CLASSES} ${SUBCLASSES}
	jar cf HLerpApplet.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
# XXX remove the following
HLerpApplet.jar: Makefile

# Make sure modules are compiled in order of dependence...
# XXX don't need most of the crap in HyperbolicUtils
Isometry2.class: Complex.class
MyGraphics.class: MyMath.class VecMath.class
HyperbolicUtils.class: Isometry2.class VecMath.class MyMath.class Isometry2HashTable.class
HLerpApplet.class: MyGraphics.class GraphicsAntiAliasingSetter.class HyperbolicUtils.class
${CLASSES}: macros.h

# To make and send:
#       make clean
#       make jar
#       make
#       make send
#
.PHONY: jar
jar:
	(cd ..; jar cvf HLerpApplet.src.jar HLerpApplet)

.PHONY: send
send:
	rrr "scp HLerpApplet.php HLerpApplet.jar ../HLerpApplet.src.jar www.hadron.org:public_html"

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