unbroke the non-native builds
[org.ibex.core.git] / Makefile
index 91d179a..2347c91 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,11 @@
 
 #  auto directory creation with %/%: %?
 
+ifeq ($(platform),)
+# default
+platform := JVM
+endif
+
 target_Darwin := powerpc-apple-darwin
 target_Win32  := i686-pc-mingw32
 target_Solaris := sparc-sun-solaris2.7
@@ -70,7 +75,28 @@ gcj: .install_gcc-3.3_$(target)
 
 include Makefile.upstream
 
-java_sources              := $(patsubst src/%.java,     build/java/%.java, $(shell find src -name '*.java' | grep -v Preprocessor | grep -v plat/AWT | grep -v plat/Java2))
+# find the superclasses of a platform class
+#superclass_%:
+#      @if [ "$*" = "org.ibex.plat.Darwin" ]; then echo org.ibex.plat.OpenGL; fi
+#      @echo $*
+#      @grep -s extends src/$(subst .,/,$*).java | sed s_.\*extends\ __ | head -n 1 | sed s_\ .\*__ |\
+#              xargs --replace make -s superclass_org.ibex.plat.{}
+
+plat_classes_AWT     := org.ibex.plat.AWT
+plat_classes_Java2   := org.ibex.plat.Java2 $(plat_classes_AWT)
+plat_classes_JVM     := $(plat_classes_Java2)
+plat_classes_GCJ     := org.ibex.plat.GCJ
+plat_classes_Win32   := org.ibex.plat.Win32 $(plat_classes_GCJ)
+plat_classes_POSIX   := org.ibex.plat.POSIX $(plat_classes_GCJ)
+plat_classes_X11     := org.ibex.plat.X11 $(plat_classes_POSIX)
+plat_classes_Linux   := org.ibex.plat.Linux $(plat_classes_X11)
+plat_classes_Solaris := org.ibex.plat.Solaris $(plat_classes_X11)
+plat_classes_Darwin  := org.ibex.plat.Darwin org.ibex.plat.OpenGL $(plat_classes_POSIX)
+
+bleh:; @echo $(plat_classes_$(platform))
+java_src_sources          := $(patsubst %,src/%.java,$(subst .,/,$(plat_classes_$(platform))))
+java_src_sources          += $(shell find src -name '*.java' | grep -v Preprocessor | grep -v plat | grep -v NanoGoat)
+java_sources              := $(patsubst src/%.java,     build/java/%.java, $(java_src_sources))
 java_sources              += build/java/org/xwt/mips/Errno.java
 java_sources              += build/java/org/xwt/mips/Unistd.java
 java_sources              += build/java/org/xwt/mips/Syscalls.java
@@ -126,10 +152,19 @@ build/class/org/ibex/translators/MIPSApps.class: build/mips/mipsapps.mips .jikes
 
 compile: .compile
 .compile: .install_mips2java .download_bcel-5.1 $(java_sources) $(java_classes); touch $@
+
+ifeq ($(platform),JVM)
+build/class/%.class: build/java/%.java .jikes
+       @echo -e "\n\033[1mcompiling          .java -> .class: $<\033[0m"
+       rm -rf build/class
+       mkdir -p build/class
+       @./.jikes $(java_sources) -d build/class
+else
 build/class/%.class: build/java/%.java
        @echo -e "\n\033[1mcompiling          .java -> .class: $<\033[0m"
        mkdir -p $(@D)
-       $(gcj) -I$(bcel_jar) -C $< -d build/class
+       $(gcj) -C $< -d build/class
+endif
 
 build/JVM/ibex.jar: build/res/builtin.jar build/class/org/ibex/translators/MIPSApps.class
        @echo -e "\n\033[1marchiving         .class -> .jar:   build/JVM/ibex.jar\033[0m"
@@ -198,6 +233,7 @@ build/$(platform)/ibex.pruned.jar: .compile .install_jpeg-6b_$(target) build/$(p
        java -cp $(bcel_jar):build/class org.ibex.util.NanoGoat build/$(platform)/ibex.jar `cat .natcalls-$(platform)`
        mv build/$(platform)/ibex.jar.pruned $@
 
+ifneq ($(target_bin_extension),jar)
 build/$(platform)/$(target_bin): build/$(platform)/ibex.pruned.jar .natcalls-$(platform)
 
        @echo -e "\n\033[1mcompiling              .jar -> .o\033[0m"
@@ -225,7 +261,7 @@ build/$(platform)/$(target_bin): build/$(platform)/ibex.pruned.jar .natcalls-$(p
        @echo -e "\n\033[1mcompressing              $(target_bin) -> $(target_bin)\033[0m"
        upx-ucl-beta $@
        @echo; ls -l $@.phat
-
+endif
 
 ### Builtin Resources ##############################################################################