+include Makefile.upstream
+
+# figure out what stuff in org.xwt.plat.* this platform requires (its superclasses)
+java_sources := $(patsubst src/%.java, build/java/%.java, $(shell find src -name '*.java' | grep -v Preprocessor))
+all_java_sources := $(java_sources)
+
+nonplat_java_sources := $(filter-out build/java/org/xwt/plat/%, $(java_sources)) build/java/org/xwt/translators/Freetype.java build/java/org/xwt/translators/MSPack.java build/java/org/xwt/translators/MIPSApps.java
+plat_java_sources := $(filter build/java/org/xwt/plat/%, $(java_sources))
+
+build/java/org/xwt/translators/MIPSApps.java: build/mips/mipsapps.mips
+ make build/class/org/xwt/mips/Compiler.class
+ mkdir -p build/java/org/xwt/translators
+ @echo -e "\n\033[1mtranslating .mips -> .java: $<\033[0m"
+ (echo -e 'package org.xwt.translators;\nimport org.xwt.mips.*;\n'; \
+ java -Xint -cp build/class org.xwt.mips.Compiler MIPSApps build/mips/mipsapps.mips)\
+ | sed 's,//.*$$,,;'|tr -d '\n' > $@
+
+build/java/org/xwt/%.java: src/org/xwt/%.java
+ make build/class/org/xwt/util/Preprocessor.class
+ @echo -e "\n\033[1mpreprocessing .java -> .java: $<\033[0m"
+ mkdir -p `dirname $@`; java -cp build/class org.xwt.util.Preprocessor < $< > $@
+
+build/java/%.java: src/%.java ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
+
+build/cc/%.cc: src/%.c ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
+build/c/jpeg/%.c: upstream/jpeg-6b/src/%.c
+ @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
+build/res/%: src/% ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
+
+build/class/org/xwt/translators/MIPSApps.class: build/java/org/xwt/translators/MIPSApps.java .jikes
+ @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
+ mkdir -p build/class/org/xwt/translators
+ ./.jikes -g:none $<
+
+build/class/org/xwt/util/Preprocessor.class: src/org/xwt/util/Preprocessor.java .jikes
+ @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
+ mkdir -p build/class/org/xwt/util/
+ ./.jikes $<
+
+build/class/org/xwt/mips/Compiler.class: src/org/xwt/mips/*.java
+ make .jikes
+ @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
+ mkdir -p build/class/org/xwt/mips/
+ ./.jikes $<
+
+# this forces a clean build every time because jikes is so damn buggy
+preprocess: $(java_sources)
+compile: .compile
+.compile: build/class/org/xwt/translators/MIPSApps.class $(java_sources) .jikes
+ @echo -e "\n\033[1mcompiling .java -> .class: src/**/*.java\033[0m"
+ @rm -f $(java_sources:build/java/%.java=build/class/%.class)
+ mkdir -p build/class
+ @./.jikes $(java_sources)
+ touch .compile
+
+# PHASE 4: gcj-generated headers
+java_headers := $(all_java_sources:build/java/%.java=build/h/%.h)
+build/h/edu/stanford/ejalbert/BrowserLauncher.h:; mkdir -p $(@D); touch $@
+build/h/%.h: build/class/%.class
+ @echo -e "\n\033[1mextracting .class -> .h: $<\033[0m"
+ mkdir -p `dirname $@`
+ ls `echo $< | sed s/.class\$$//`*.class |\
+ sed s_build/class/__ | sed s/.class\$$//g | sed s_/_._g | (cd build/class; xargs $(gcjh) -d ../h --classpath .)
+
+# a hack since we've disabled gcj's awt implementation
+build/$(platform)/org/xwt/plat/Java2.java.o:
+ touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
+build/$(platform)/org/xwt/translators/MIPSApps.java.o: build/class/org/xwt/translators/MIPSApps.class
+ $(gcj) -c $< -o $@
+build/$(platform)/org/xwt/plat/AWT.java.o:
+ touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
+
+build/$(platform)/%.java.o: build/java/%.java
+ @echo -e "\n\033[1mcompiling .java -> .o: $<\033[0m"
+ mkdir -p `dirname $@`
+ $(gcj) -c $< -o $@