-Linux: ; make gcj platform=Linux target=i686-pc-linux-gnu link_flags="-lX11 -lXext --static"
-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=-Wl,-framework,Carbon,-framework,OpenGL,-framework,AGL,-framework,SystemConfiguration
+Linux: ; make gcj platform=Linux link_flags="-lX11 -lXext"
+Solaris: ; make gcj platform=Solaris link_flags="-lX11 -lXext -lpthread"
+Win32: ; make gcj platform=Win32 link_flags="-Wl,--subsystem,windows -lcomdlg32"
+Darwin: ; make gcj platform=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_ogl_libdir := /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries
+darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir)/libGL.dylib:$(darwin_libdir)/libGL.dylib
+darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir):$(darwin_libdir)/libGLU.dylib
+darwin_linker_flags += -lSystem.B -lmathCommon.A -lGL -lGLU
+
+target_bin_extension_$(platform) := (shell echo $(platform) | tr A-Z a-z)
+target_bin_extension_Win32 := exe
+target_bin_extension_JVM := jar
+target_bin_extension := target_bin_extension_$(target)
+target_bin := xwt.$(target_bin_extension)
+
+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
+g++_flags := -Iupstream/install/lib/gcc-lib/$(target)/3.3/include/ -Iupstream/install/$(target)/include -Wno-multichar
+gcj := upstream/install/bin/$(target)-gcj $(gcc_flags) $(gcj_flags)
+gcjh := $(shell pwd)/upstream/install/bin/$(shell test -e upstream/install/bin/$(target)-gcjh && echo $(target)-)gcjh
+g++ := upstream/install/bin/$(target)-gcj $(gcc_flags)
+gcc := upstream/install/bin/$(target)-gcc $(gcc_flags) $(g++_flags)
+jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
+
+target_Darwin := powerpc-apple-darwin
+target_Win32 := i686-pc-mingw32
+target_Solaris := sparc-sun-solaris2.7
+target_Linux := i686-pc-linux-gnu
+target := $(target_$(platform))
+
+gcj: .install_gcc-3.3_$(target); make $(target_bin) link_flags="$(link_flags)" platform=$(platform)