-## Configurables ###########################################################################
-
-# inputs
-jikes_java_sources := $(shell find src -name *.java)
-gcj_java_sources := $(shell find src -name *.java \! -path src/org/xwt/plat/\*) src/org/xwt/plat/GCJ.java $(platform_java_sources)
-xwar_sources := $(shell ls src/org/xwt/builtin/*.png src/org/xwt/builtin/*.xwt src/org/xwt/builtin/*.xwf)
-cc_sources := src/org/xwt/plat/$(platform).cc
-
-# outputs
-jikes_java_objects := $(jikes_java_sources:src/%.java=bin/%.class)
-cc_objects := $(cc_sources:src/%.cc=bin-$(platform)/%-nat.o)
-gcj_java_objects := $(gcj_java_sources:src/%.java=bin-$(platform)/%.o)
-
-# tools
-gcc_path := $(shell pwd)/gcc
-gcc_flags := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls -finline-functions -funroll-loops -g
-gcj_flags := -fCLASSPATH=bin
-gcj := $(gcc_path)/bin/$(target)-gcj $(gcj_flags) $(gcc_flags)
-gcc := $(gcc_path)/bin/$(target)-g++ $(gcc_flags)
-gcjh := $(gcc_path)/bin/gcjh
-ar := $(gcc_path)/$(target)/bin/ar
-strip := $(gcc_path)/$(target)/bin/strip
+all: JVM Linux Win32 Darwin Solaris
+
+clean:
+ rm -rf .jikes .configure* .install* build .compile .build*
+ find upstream -name config.cache -exec rm {} \;
+
+JVM: build/JVM/xwt.jar
+Linux: ; make gcj platform=Linux target=i686-pc-linux-gnu link_flags="-lX11 -lXext"
+Solaris: ; make gcj platform=Solaris target=sparc-sun-solaris2.7 link_flags="-lX11 -lXext"
+Win32: ; make gcj platform=Win32 target=i686-pc-mingw32 link_flags="-Wl,--subsystem,windows -lcomdlg32" target_bin=xwt.exe
+Darwin: ; make gcj platform=Darwin target=powerpc-apple-darwin link_flags="$(darwin_linker_flags)"
+
+# default
+platform := JVM
+
+darwin_libdir := upstream/install/powerpc-apple-darwin/lib
+darwin_linker_flags := -Wl,-dylib_file,/usr/lib/libSystem.B.dylib:$(darwin_libdir)/libSystem.B.dylib
+darwin_linker_flags += -Wl,-dylib_file,/usr/lib/system/libmathCommon.A.dylib:$(darwin_libdir)/libmathCommon.A.dylib
+darwin_linker_flags += -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:$(darwin_libdir)/libGL.dylib
+darwin_linker_flags += -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib:$(darwin_libdir)/libGLU.dylib
+darwin_linker_flags += -lSystem.B -lmathCommon.A -lGL -lGLU
+
+
+#############################################################################
+# Configurables:
+#
+target_bin := xwt.$(shell echo $(platform) | tr A-Z a-z)
+jikes_flags := -nowarn -sourcepath src/
+gcc_optimizations := -O2
+#gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls
+#gcc_optimizations += -finline-functions -funroll-loops -ffunction-sections -fdata-sections
+gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src/ -Iupstream/jpeg-6b/build-$(target)/
+gcj_flags := -fCLASSPATH=build/java
+gcj := upstream/install/bin/$(target)-gcj $(gcc_flags) $(gcj_flags)
+gcjh := $(shell test -e `pwd`/upstream/install/bin/$(target)-gcjh && echo `pwd`/upstream/install/bin/$(target)-gcjh || echo `pwd`/upstream/install/bin/gcjh)
+g++ := upstream/install/bin/$(target)-gcj $(gcc_flags)
+gcc := upstream/install/bin/$(target)-gcc $(gcc_flags)