+build/$(platform)/org/ibex/plat/$(platform).cc.o: src/org/ibex/plat/$(platform).cc src/org/ibex/plat/*.cc .configure_jpeg-6b_$(target)
+ @make $(java_headers)
+ @echo -e "\n\033[1mcompiling .cc -> .o: $<\033[0m"
+ mkdir -p `dirname $@`
+ $(g++) -c $< -o $@
+
+nonplat_java_sources := $(filter-out build/java/org/ibex/plat/$(platform).java,$(java_sources))
+build/$(platform)/$(platform).ar: $(nonplat_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 $@
+
+upstream/jpeg-6b/build-$(target)/libjpeg.a: .install_jpeg-6b_$(target)
+
+# note: binaries appear in a different order in the dependency line vs the link line
+build/$(platform)/$(target_bin): upstream/jpeg-6b/build-$(target)/libjpeg.a
+ @echo -e "\n\033[1mlinking .o -> $(target_bin)\033[0m"
+
+ rm -rf build/$(platform)/*
+ make build/$(platform)/org/ibex/plat/$(platform).cc.o
+ make build/$(platform)/builtin.o
+
+ cd upstream/gcc-3.3/build-$(target)/$(target)/libjava; \
+ (find . -name nat\*.o | grep -v JIS; \
+ echo boehm.o;\
+ echo defineclass.o;\
+ echo exception.o;\
+ echo posix-threads.o;\
+ echo posix.o;\
+ echo prims.o;\
+ echo jni.o;\
+ echo resolve.o;\
+ echo libltdl/ltdl.o;\
+ find java gnu -name \*.o -not -name '*[A-Z]*'; \
+ ) > $(shell pwd)/.natbins
+
+
+ cd upstream/gcc-3.3/build-$(target)/$(target)/libjava;\
+ (cat $(shell pwd)/.natbins; echo $(shell pwd)/build/$(platform)/org/ibex/plat/$(platform).cc.o) |\
+ grep -v shs | grep -v SHS |xargs nm |\
+ grep _ZN | c++filt --format java | grep " U " | sed 's_\.class\$$_.class_' | sed 's_ * U __' | sed 's_(.*__' \
+ > $(shell pwd)/.natcalls
+
+ rm -rf build/pruned; mkdir -p build/pruned
+ javac -classpath lib/bcel-5.1.jar:build/class -d build/class src/org/ibex/util/BytecodePruner.java
+ rm -f build/$(platform)/ibex.jar
+ cd build/class; \
+ fastjar cf ../$(platform)/ibex.jar \
+ `find . -name \*.class | grep -v ibex/plat/` \
+ org/ibex/plat/$(platform)*.class \
+ org/ibex/plat/X11*.class \
+ org/ibex/plat/GCJ*.class \
+ org/ibex/plat/POSIX*.class
+ java -cp lib/bcel-5.1.jar:build/class org.ibex.util.BytecodePruner \
+ build/$(platform)/ibex.jar:upstream/install/share/java/libgcj-3.3.jar \
+ -o build/pruned \
+ `cat .natcalls`
+
+ rm build/pruned/org/ibex/plat/GCJ*.class
+ cp build/java/org/ibex/plat/GCJ.java build/pruned/org/ibex/plat/
+ cp upstream/gcc-3.3/build-$(target)/$(target)/libjava/java/lang/Object.class build/pruned/java/lang/
+
+ rm -f build/pruned/java/lang/System*.*
+ cp upstream/gcc-3.3/src/libjava/java/lang/System.java build/pruned/java/lang/
+
+# -fnew-ra \
+# -ffunction-sections \
+# -fdata-sections \
+# -fomit-frame-pointer \
+# -fno-force-mem \
+# -fno-force-addr \
+# -fbranch-probabilities \
+# -fno-schedule-insns \
+# -fno-optimize-sibling-calls \
+# -fno-if-conversion \
+# -fno-thread-jumps \
+# -foptimize-static-class-initialization \
+# -fno-store-check \
+# -fno-bounds-check \
+# -fmerge-all-constants \
+# -fno-inline-functions \
+# -finline-limit=1 \
+
+ cd build/pruned; \
+ for A in `find . -name \*.class -or -name \*.java`; do \
+ echo compiling $$A....; \
+ ../../upstream/install/bin/$(target)-gcj \
+ -w -c -Os \
+ -fCLASSPATH=../../build/$(platform)/ibex.jar \
+ $$A && \
+ (mkdir -p ../../build/$(platform)/`dirname $$A`; mv *.o ../../build/$(platform)/`dirname $$A`); \
+ done
+
+ rm -f build/$(platform)/ibex.a
+
+ cd upstream/gcc-3.3/build-$(target)/$(target)/libjava; \
+ $(shell pwd)/upstream/install/$(target)/bin/ar cq \
+ $(shell pwd)/build/$(platform)/ibex.a \
+ `find $(shell pwd)/build/$(platform) -name \*.o`
+
+ rm -f build/$(platform)/natibex.a
+ cd upstream/gcc-3.3/build-$(target)/$(target)/libjava; \
+ $(shell pwd)/upstream/install/$(target)/bin/ar cq \
+ $(shell pwd)/build/$(platform)/natibex.a \
+ `cat $(shell pwd)/.natbins`
+# --relax,-O2,--no-whole-archive,
+ PATH=upstream/install/bin:$$PATH upstream/install/bin/$(target)-gcj \
+ -Wl,--no-gc-sections,--noinhibit-exec,-rpath,upstream/install/$(target)/lib \
+ -Wl,-nostdlib,--eh-frame-hdr,-m,elf_i386,-dynamic-linker,/lib/ld-linux.so.2 \
+ --main=org.ibex.plat.$(platform) \
+ -Lupstream/install/$(target)/lib \
+ -Lupstream/install/lib \
+ -Os -w \
+ -Wl,--whole-archive \
+ build/$(platform)/ibex.a \
+ -Wl,--no-whole-archive \
+ build/$(platform)/natibex.a \
+ upstream/jpeg-6b/build-$(target)/libjpeg.a \
+ $(link_flags) \
+ upstream/gcc-3.3/build-$(target)/$(target)/boehm-gc/.libs/libgcjgc.a \
+ -lz -ldl -lgcc -lm -lpthread -ldl -lgcc -lc -lgcc \
+ upstream/install/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3/crtend.o \
+ upstream/install/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.3/../../../../i686-pc-linux-gnu/lib/crtn.o \
+ -o $@
+# strip build/Linux/ibex.linux
+# ls -l build/Linux/ibex.linux
+# upx-ucl-beta --best build/Linux/ibex.linux
+# ls -l build/Linux/ibex.linux
+
+
+### Builtin Resources ##############################################################################
+
+builtin_src := $(shell find src/org/ibex/builtin -name '*.*' \! -name '*.xcf')
+build/res/fonts/vera: .download_vera-1.10
+ mkdir -p build/res/fonts/vera
+ cd build/res/fonts/vera; ln -fs ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/Vera.ttf
+ cd build/res/fonts/vera; ln -fs ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraMono.ttf
+ cd build/res/fonts/vera; ln -fs ../../../../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 org/ibex/builtin/scar.png
+# 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
+
+
+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/ibex/translators/Freetype.c.o build/mips/org/ibex/translators/MSPack.c.o build/mips/org/ibex/translators/main.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 \
+ --static \
+ -march=mips1 \
+ -T upstream/mips/org/xwt/mips/linker.ld \
+ -L upstream/mips/build/org/xwt/mips/ \
+ -L upstream/freetype-2.1.4/src/objs \
+ -L upstream/libmspack-20030726/build-mips-unknown-elf/ \
+ -o $@ \
+ $^ \
+ -lfreetype \
+ -lmspack \
+ -Wl,--gc-sections
+
+
+### Maintainer ######################################################################################
+
+current_build := $(shell cat next.build)
+strip_$(platform) := upstream/install/$(target)/bin/strip build/$(platform)/$(target_bin) -o
+strip_JVM := cp build/$(platform)/$(target_bin)
+install-dist:; $(strip_$(platform)) /var/www/org/xwt/dist/master/ibex-$(current_build).$(target_bin_extension).unsigned
+dist: compile
+ (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
+ mv next.build- next.build
+ echo -n "Next build will be "; cat next.build
+ nice -n 19 make all
+ make install-dist platform=Win32
+ make install-dist platform=Linux
+ make install-dist platform=Solaris
+ make install-dist platform=Darwin
+ make install-dist platform=JVM
+ echo -e "\n\n\n*** DONE ******************************************"