-$(shell pwd)/gcc/bin/$(target)-gcj:
- cd gcc; make
-
-gcj: compile $(gcc_path)/bin/$(target)-gcj .headers link
-
-link: $(java_objects) $(cc_objects) $(c_objects) bin-$(platform)/org/xwt/builtin.o
- echo "linking .o -> $(target_bin)"
- $(ar) r bin-$(platform)/org/xwt/plat/platform.ar bin-$(platform)/org/xwt/plat/*.o
- $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ $(platform_link) bin-$(platform)/org/xwt/plat/platform.ar
-
-.headers: $(java_classes)
- cd bin; for A in `find * -name \*.class`; do \
- echo "extracting .class -> .h: $$A"; \
- $(gcjh) --classpath . `echo $$A | sed s_/_._g | sed s/.class$$//`; \
- done
- echo "extracting .class -> .h: done"
- touch .headers
+$(shell pwd)/gcc/install/bin/$(target)-gcj: .upstream
+ make -C gcc
+
+gcc/src/.freetype:
+ mkdir -p gcc/src
+ curl http://umn.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.4.tar.gz | tar xvzf - -C gcc/src
+ cd gcc/src; patch -p0 < freetype.patch
+ touch gcc/src/.freetype
+
+freetype.mips: gcc/src/.freetype
+ make -C gcc mips target=mips
+ $(gcc_path)/bin/mips-gcc \
+ --static \
+ -mabi=32 \
+ -mips1 \
+ -msoft-float \
+ -o freetype.mips \
+ -I gcc/src/freetype-2.1.4/include \
+ $(freetype_sources) \
+ -Wl,--warn-once,--strip \
+ src/org/xwt/imp/Freetype.c \
+ $(gcc_path)/mips/lib/libc.a \
+ -Wl,-T,$(gcc_path)/mips/lib/nullmon.ld
+
+bin/org/xwt/imp/Freetype.java: freetype.mips bin/org/xwt/imp/MIPS.class
+ @echo "translating .mips -> .java: $<"
+ @java -cp bin org.xwt.imp.MIPS org.xwt.imp.Freetype freetype.mips > bin/org/xwt/imp/Freetype.java
+
+# compile is here to force compilation of the .class files (they get used via -Ibin/) without
+# having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
+gcj: $(gcc_path)/bin/$(target)-gcj compile $(target_bin)
+
+$(target_bin): $(java_objects) $(cc_objects) $(c_objects) bin-$(platform)/org/xwt/builtin.o
+ @echo "linking .o -> $(target_bin)"
+ $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ $(platform_link)