+runtime_classes = Runtime Registers UsermodeConstants util/Seekable
+unix_runtime_classes = $(runtime_classes) UnixRuntime util/Platform util/InodeCache
+
+tex.jar: $(mips_objects) $(runtime_classes:%=build/org/ibex/nestedvm/%.class) build/tests/TeX.class
+ echo -e "Manifest-Version: 1.0\nMain-Class: Tex\n" > .manifest
+ cp upstream/build/tex/TeX.class build
+ cd build && jar cfm ../$@ ../.manifest \
+ $(runtime_classes:%=org/ibex/nestedvm/%.class) \
+ org/ibex/nestedvm/Runtime\$$*.class \
+ org/ibex/nestedvm/util/Seekable\$$*.class
+
+runtime.jar: $(runtime_classes:%=build/org/ibex/nestedvm/%.class)
+ cd build && jar cf ../$@ \
+ $(runtime_classes:%=org/ibex/nestedvm/%.class) \
+ org/ibex/nestedvm/Runtime\$$*.class \
+ org/ibex/nestedvm/util/Seekable\$$*.class
+
+unix_runtime.jar: $(unix_runtime_classes:%=build/org/ibex/nestedvm/%.class)
+ cd build && jar cf ../$@ \
+ $(unix_runtime_classes:%=org/ibex/nestedvm/%.class) \
+ org/ibex/nestedvm/Runtime\$$*.class \
+ org/ibex/nestedvm/util/Seekable\$$*.class \
+ org/ibex/nestedvm/UnixRuntime\$$*.class \
+ org/ibex/nestedvm/util/Platform\$$*.class \
+ org/ibex/nestedvm/util/Sort*.class
+
+.manifest:
+ printf "Manifest-Version: 1.0\nMain-Class: org.ibex.nestedvm.RuntimeCompiler\n" > $@
+
+nestedvm.jar: $(java_classes) .manifest
+ cd build && jar cfm ../$@ ../.manifest $(java_classes:build/%.class=%*.class)
+ cd $(CLASSGEN_PATH) && jar uf $(mips2java_root)/$@ .
+
+.gcclass_hints: $(java_sources)
+ sed -n 's/.*GCCLASS_HINT: \([^ ]*\) \([^ ]*\).*/hint:\1:\2/p' $(java_sources) > $@
+
+compact_runtime_compiler.jar: $(java_classes) .manifest $(tasks)/build_darcs_gcclass .gcclass_hints
+ mkdir -p tmp/pruned
+ rm -rf tmp/pruned/*
+ $(JAVA) -cp \
+ upstream/build/gcclass/build:upstream/build/gcclass/upstream/bcel-5.2/bcel-5.2.jar \
+ com.brian_web.gcclass.GCClass \
+ "$(classpath)" tmp/pruned org.ibex.nestedvm.RuntimeCompiler.main `cat .gcclass_hints`
+ cd tmp/pruned && jar cfm ../../$@ ../../.manifest .
+
+sizecheck: compact_runtime_compiler.jar
+ @for c in `find tmp/pruned -name '*.class'|fgrep -v '$$'`; do \
+ for f in `echo $$c|sed 's,\.class$$,,;'`*.class; do gzip -c $$f; done | wc -c | tr -d '\n'; \
+ echo -e "\t`echo $$c | sed 's,tmp/pruned/org/ibex,,;s,\.class$$,,;s,/,.,g;'`"; \
+ done | sort -rn | awk '{ sum += $$1; print } END { print sum,"Total"; }'
+
+
+# This is only for Brian to use... don't mess with it
+rebuild-constants: $(tasks)/build_libc
+ @mkdir -p `dirname $@`
+ ( \
+ cat \
+ src/org/ibex/nestedvm/syscalls.h \
+ $(usr)/mips-unknown-elf/include/nestedvm/socket.h \
+ $(usr)/mips-unknown-elf/include/sys/{errno.h,unistd.h,syslimits.h,sysctl.h}; \
+ $(MIPS_CC) -E -dM $(usr)/mips-unknown-elf/include/sys/fcntl.h | awk '$$2 ~ /^[OF]_/ { print; }'; \
+ ) | ( \
+ echo "// THIS FILE IS AUTOGENERATED! DO NOT EDIT!"; \
+ echo "// run \"make rebuild-constants\" if it needs to be updated"; \
+ echo ""; \
+ echo "package org.ibex.nestedvm;"; \
+ echo "public interface UsermodeConstants {"; \
+ tr '\t' ' ' | sed -n ' \
+ s/ */ /g; \
+ s/ *# *define \([A-Z_][A-Za-z0-9_]*\) \([0-9][0-9a-fA-Fx]*\)/ public static final int \1 = \2;/p'; \
+ echo "}"; \
+ ) > src/org/ibex/nestedvm/UsermodeConstants.java