+# 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 $@
+
+headers: $(java_headers)
+
+build/$(platform)/org/xwt/plat/$(platform).cc.o: src/org/xwt/plat/$(platform).cc src/org/xwt/plat/*.cc .configure_jpeg-6b_$(target)
+ @make headers
+ @echo -e "\n\033[1mcompiling .cc -> .o: $<\033[0m"
+ mkdir -p `dirname $@`
+ $(g++) -Iupstream/install/lib/gcc-lib/$(target)/3.3/include/ -Iupstream/install/$(target)/include -I/usr/X11R6/include/ -Ibuild/h -Wno-multichar -Iupstream/install/include -c $< -o $@
+
+build/$(platform)/jpeg-6b/%.c.o: upstream/jpeg-6b/src/%.c
+ @echo -e "\n\033[1mcompiling .c -> .o: $<\033[0m"
+ mkdir -p `dirname $@`
+ $(gcc) -Ibuild/h -c $< -o $@
+
+# PHASE 5: linking
+# FIXME use libjpeg
+jpeg_sources := jdapimin.c jdapistd.c jcomapi.c jcparam.c jdmaster.c jdinput.c jdmainct.c jdcoefct.c jdpostct.c jdmarker.c
+jpeg_sources += jdhuff.c jdphuff.c jddctmgr.c jidctint.c jidctfst.c jidctflt.c jidctred.c jdsample.c jdcolor.c jdmerge.c
+jpeg_sources += jquant1.c jquant2.c jerror.c jutils.c jmemnobs.c jmemmgr.c
+
+upstream/jpeg-6b/build-$(target)/libjpeg.a: .install_jpeg-6b_$(target)
+java_objects := $(nonplat_java_sources:build/java/%.java=build/$(platform)/%.java.o)
+
+build/$(platform)/$(platform).ar: $(java_objects) $(plat_java_sources:build/java/%.java=build/$(platform)/%.java.o)
+ @echo -e "\n\033[1marchiving .o -> .a\033[0m"
+ mkdir -p build/$(platform)
+ rm -f $@
+ upstream/install/$(target)/bin/ar rc $@ $^
+ upstream/install/$(target)/bin/ranlib $@
+
+$(target_bin): build/$(platform)/org/xwt/plat/$(platform).cc.o upstream/jpeg-6b/build-$(target)/libjpeg.a build/$(platform)/builtin.o build/$(platform)/$(platform).ar
+ @echo -e "\n\033[1mlinking .o -> $(target_bin)\033[0m"
+ mkdir -p build/$(platform)
+ PATH=upstream/install/bin:$$PATH $(gcj) -v --main=org.xwt.Main -o build/$(platform)/$(target_bin) -Lupstream/install/$(target)/lib build/$(platform)/org/xwt/plat/$(platform).java.o $^ $(link_flags)
+
+
+##############################################################################
+# Special treatment:
+#
+
+builtin_src := $(shell find src/org/xwt/builtin -name '*.*' \! -name '*.xcf')
+build/res/fonts/vera: .download_vera-1.10
+ mkdir -p build/res/fonts/vera
+ cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/Vera.ttf
+ cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraMono.ttf
+ cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraSe.ttf
+build/res/builtin.jar: $(builtin_src:src/%=build/res/%) build/res/fonts/vera
+ @echo -e "\n\033[1mzipping res/* -> .jar: builtin.jar\033[0m"
+ cd build/res; $(jar) cf builtin.jar $(^:build/res/%=%)
+
+build/$(platform)/builtin.o: build/res/builtin.jar
+ @echo -e "\n\033[1mwrapping .jar -> .o: resources.o\033[0m"
+ @(echo "unsigned int builtin_length = "; \
+ (wc -c build/res/builtin.jar | sed "s_build.*__"); \
+ echo \;; \
+ echo "unsigned char builtin_bytes[] = {"; \
+ hexdump -ve '"0x" 1/1 "%x,\n"' build/res/builtin.jar; \
+ echo "};") > .builtin.c
+ $(gcc) -c .builtin.c -o build/$(platform)/builtin.o
+
+# compile is here to force compilation of the .class files (they get used via -Ibuild) without
+# having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
+gcj: .vendor .compile .install_gcc-3.3_$(target) $(target_bin)
+
+build/JVM/xwt.jar: .compile build/res/builtin.jar
+ @echo -e "\n\033[1marchiving .class -> .jar: build/JVM/xwt.jar\033[0m"
+ mkdir -p build/JVM
+ echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > build/JVM/.manifest
+ cd build/class/org/xwt; ln -sf ../../../res/builtin.jar
+ cd build/class; $(jar) cfm ../JVM/xwt.jar ../JVM/.manifest \
+ `find . \! -type d \! -path './org/xwt/mips/*'` \
+ $(patsubst %,org/xwt/mips/%*.class, Runtime Registers Syscalls Errno)
+
+
+
+##############################################################################
+# Freetype
+#
+
+build/mips/%.c.o: src/%.c .download_libmspack-20030726
+ make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
+ make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
+ mkdir -p $(@D)
+ echo -e "\n\033[1mcompiling $< -> $@ (mips)\033[0m"
+ upstream/install/bin/mips-unknown-elf-gcc -march=r3000 \
+ -Iupstream/freetype-2.1.4/src/include \
+ -Iupstream/libmspack-20030726/src/mspack \
+ -c -o $@ $<
+
+build/mips/mipsapps.mips: build/mips/org/xwt/translators/Freetype.c.o build/mips/org/xwt/translators/MSPack.c.o build/mips/org/xwt/translators/main.c.o build/mips/org/xwt/mips/crt0.c.o build/mips/org/xwt/mips/syscalls.c.o
+ make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
+ make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
+ @echo -e "\n\033[1mlinking .o -> .mips: $@\033[0m"
+ mkdir -p build/mips build/res
+ upstream/install/bin/mips-unknown-elf-gcc \
+ -nostdlib \
+ --static \
+ -march=mips1 \
+ -T src/org/xwt/mips/linker.ld \
+ -Lbuild/mips \
+ -Lupstream/freetype-2.1.4/src/objs \
+ -Lupstream//libmspack-20030726/build-mips-unknown-elf/ \
+ -o $@ \
+ $^ \
+ -lfreetype \
+ -lmspack \
+ -Wl,--gc-sections
+
+##############################################################################
+# Maintainer stuff: generating numbered builds, proposing patches
+#