- cd gcc; make
-
-gcj: compile $(gcc_path)/bin/$(target)-gcj .headers link
-
-link: $(gcj_java_objects) $(cc_objects)
- 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: $(jikes_java_objects)
- cd bin; for A in `find * -name \*.class`; do \
- echo -ne "\033[K\\rextracting .class -> .h: $$A\\r"; \
- $(gcjh) --classpath . `echo $$A | sed s_/_._g | sed s/.class$$//`; \
- done
- echo -e "\033[K\\rextracting .class -> .h: done"
- touch .headers
-
-# turn off optimization of Trap.java due to a compiler bug
-bin-$(platform)/org/xwt/Trap.o: gcj_flags := -O0 -g
-
-$(gcj_java_objects): bin-$(platform)/%.o: src/%.java $(jikes_java_objects)
- echo -ne "\033[K\\rcompiling .java -> .o: $<\\r"
+ make -C gcc
+
+# java_classes 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 $(java_classes) $(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)
+
+bin-$(platform)/org/xwt/builtin.o: bin/org/xwt/builtin.xwar
+ @echo "wrapping .xwar -> .o: bin/org/xwt/builtin.o"
+ @(echo "unsigned int builtin_xwar_length = ";\
+ (wc -c bin/org/xwt/builtin.xwar | sed "s_bin.*__");\
+ echo \;;\
+ echo "unsigned char builtin_xwar[] = {";\
+ hexdump -ve '"0x" 1/1 "%x,\n"' bin/org/xwt/builtin.xwar;\
+ echo "};") > .builtin.c
+ $(gcc) -c .builtin.c -o bin-$(platform)/org/xwt/builtin.o
+
+$(java_headers): bin/%.h: bin/%.class
+ @echo "extracting .class -> .h: $<"
+ cd bin; find `echo $< | sed s/.class$$// | sed s_^bin/__ `*.class |\
+ sed s_/_._g | sed s/.class$$// | sed s/.java$$// |\
+ xargs $(gcjh) --classpath .
+
+$(java_objects): bin-$(platform)/%.java.o: src/%.java
+ @echo "compiling .java -> .o: $<"