+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
+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)
+$(target_bin): upstream/jpeg-6b/build-$(target)/libjpeg.a $(java_sources:build/java/%.java=build/$(platform)/%.java.o) build/$(platform)/org/xwt/plat/$(platform).cc.o build/$(platform)/org/xwt/builtin.res.o build/$(platform)/freetype.res.o
+ @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) $^ $(jpeg_sources:%.c=upstream/jpeg-6b/build-$(target)/%.o) -Lupstream/install/$(target)/lib $(link_flags)
+
+
+##############################################################################
+# Special treatment:
+#
+
+build/xwar/org/xwt/builtin.xwar: $(shell ls src/org/xwt/builtin/*.*)
+ @echo -e "\n\033[1mzipping * -> .xwar: builtin.xwar\033[0m"
+ mkdir -p build/xwar
+ cd src; $(jar) cvf ../build/xwar/builtin.xwar org/xwt/builtin
+
+build/$(platform)/org/xwt/builtin.res.o: build/xwar/org/xwt/builtin.xwar
+ @echo -e "\n\033[1mwrapping .xwar -> .o: builtin.res.o\033[0m"
+ @(echo "unsigned int builtin_xwar_length = "; \
+ (wc -c build/xwar/builtin.xwar | sed "s_build.*__"); \
+ echo \;; \
+ echo "unsigned char builtin_xwar[] = {"; \
+ hexdump -ve '"0x" 1/1 "%x,\n"' build/xwar/builtin.xwar; \
+ echo "};") > .builtin.c
+ $(gcc) -c .builtin.c -o build/$(platform)/org/xwt/builtin.res.o
+
+build/$(platform)/freetype.res.o: build/mips/freetype.mips
+ @echo -e "\n\033[1mwrapping .mips -> .o: freetype.res.o\033[0m"
+ @(echo "unsigned int freetype_mips_length = "; \
+ (wc -c build/mips/freetype.mips | sed "s_build.*__"); \
+ echo \;; \
+ echo "unsigned char freetype_mips[] = {"; \
+ hexdump -ve '"0x" 1/1 "%x,\n"' build/mips/freetype.mips; \
+ echo "};") > .freetype.c
+ $(gcc) -c .freetype.c -o build/$(platform)/freetype.res.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: .compile .vendor .install_gcc-3.3_$(target) $(target_bin)
+
+build/JVM/xwt.jar: .compile build/xwar/builtin.xwar build/mips/freetype.mips
+ @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 -fs ../../../xwar/builtin.xwar # HACK
+ cd build/class/org/xwt/; ln -fs ../../../mips/freetype.mips # HACK
+ cd build/class; $(jar) cfm ../JVM/xwt.jar ../JVM/.manifest `find .`;
+ rm build/class/org/xwt/builtin.xwar
+ rm build/class/org/xwt/freetype.mips
+
+
+
+##############################################################################
+# Freetype
+#
+
+build/mips/%.c.o: src/%.c
+ make .install_freetype-2.1.4_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 -I upstream/freetype-2.1.4/src/include -c -o $@ $<
+
+build/mips/freetype.mips: build/mips/org/xwt/imp/Freetype.c.o build/mips/org/xwt/imp/crt0.c.o build/mips/org/xwt/imp/syscalls.c.o
+ make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
+ @echo -e "\n\033[1mlinking .o -> .mips: $@\033[0m"
+ mkdir -p build/mips
+ upstream/install/bin/mips-unknown-elf-gcc \
+ -nostdlib \
+ --static \
+ -march=mips1 \
+ -T src/org/xwt/imp/linker.ld \
+ -Lbuild/mips \
+ -Lupstream/freetype-2.1.4/src/objs \
+ -o $@ \
+ build/mips/org/xwt/imp/Freetype.c.o \
+ --strip \
+ -lfreetype
+
+
+
+
+##############################################################################
+# Maintainer stuff: generating numbered builds, proposing patches
+#