2003/04/20 06:29:50
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:58:57 +0000 (06:58 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:58:57 +0000 (06:58 +0000)
darcs-hash:20040130065857-2ba56-02decce904fa10dea80645557652697ac18f2296.gz

Makefile
src/org/xwt/Main.java
src/org/xwt/Platform.java
src/org/xwt/plat/Darwin.cc [new file with mode: 0644]

index 65b56b7..4e7b850 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,34 +11,40 @@ jpeg_c_sources += jquant1.c jquant2.c jerror.c jutils.c jmemnobs.c jmemmgr.c
 
 # inputs
 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)
+java_headers           := $(java_sources:src/%.java=bin/%.h)
 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
 c_sources              := $(jpeg_c_sources:%.c=src/org/ijg/%.c)
 
 # outputs
 java_classes           := $(java_sources:src/%.java=bin/%.class)
-java_objects           := $(gcj_java_sources:src/%.java=bin-$(platform)/%.java.o)
+java_objects           := $(filter-out bin-$(platform)/org/xwt/plat/%, $(java_sources:src/%.java=bin-$(platform)/%.java.o))
+java_objects           += bin-$(platform)/org/xwt/plat/GCJ.java.o
+java_objects           += $(platform_java_sources:%=bin-$(platform)/org/xwt/plat/%.java.o)
 cc_objects             := $(cc_sources:src/%.cc=bin-$(platform)/%.cc.o)
 c_objects              := $(c_sources:src/%.c=bin-$(platform)/%.c.o)
 
 # tools
 gcc_path               := $(shell pwd)/gcc
-#gcc_optimizations      := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls -finline-functions -funroll-loops
+#gcc_optimizations      := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls -finline-functions
+#gcc_optimzations       += -funroll-loops -ffunction-sections -fdata-sections
 gcc_optimizations      := -O0
 debug                  := 
-gcc_flags              := $(gcc_optimizations) $(debug) -ffunction-sections -fdata-sections -Isrc/org/ijg
+gcc_flags              := $(gcc_optimizations) $(debug) -Isrc/org/ijg
 gcj_flags              := -fCLASSPATH=bin 
 gcj                    := $(gcc_path)/bin/$(target)-gcj $(gcj_flags) $(gcc_flags)
 g++                    := $(gcc_path)/bin/$(target)-g++ $(gcc_flags)
 gcc                    := $(gcc_path)/bin/$(target)-gcc $(gcc_flags)
-gcjh                   := $(gcc_path)/bin/$(target)-gcjh
+gcjh                   := $(gcc_path)/bin/gcjh
+
+as                     := $(gcc_path)/$(target)/bin/as
 ar                     := $(gcc_path)/$(target)/bin/ar
+ranlib                 := $(gcc_path)/$(target)/bin/ranlib
 strip                  := $(gcc_path)/$(target)/bin/strip
 jar                    := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
 
-# platforms
-all_platforms          := Win32 Linux Java2
+# path
+PATH                   := jikes-1.18/bin:$(PATH)
 
 # path
 PATH                   := jikes-1.18/bin:$(PATH)
@@ -47,13 +53,14 @@ PATH                   := jikes-1.18/bin:$(PATH)
 ## Platform-Neutral ###########################################################################
 
 ifneq ($(verbose),true)
-.SILENT: $(java_classes) .headers $(java_objects) $(all_platforms) bin/org/xwt/builtin.xwar .bootclasspath .javac
+.SILENT: $(java_classes) $(cc_objects) $(java_objects) $(java_headers) all bin/org/xwt/builtin.xwar .bootclasspath .javac $(target_bin)
 silent := --silent
 endif
 
 compile: $(java_classes) bin/org/xwt/builtin.xwar
 
-all: $(all_platforms)
+# platforms
+all: Win32 Linux Java2 Darwin
 
 .javac:
        if \
@@ -77,11 +84,10 @@ jikes:
        ln -sf jikes-1.18/bin/jikes .jikes
 
 $(java_classes): $(java_sources) .javac
-       test "$(JAVA_HOME)"x != x || (echo "you forgot to set your JAVA_HOME environment variable"; false)
        echo "compiling   .java -> .class:"
        mkdir -p bin
-       $(shell cat .javac) -classpath lib/libgcj-minimal.jar $(java_sources) -d bin/
-       echo "compiling   .java -> .class: done"
+       $(shell cat .javac) -classpath lib/libgcj-minimal.jar $(java_sources) -d bin/ 2>&1 | \
+               grep -v ^\\[read | sed s_^\\[write\ bin/__ | sed s_.class\\]_.java_ | sed "s_^_compiling   .java -> .class: src/_"
 
 bin/org/xwt/builtin.xwar: $(xwar_sources)
        mkdir -p bin/org/xwt
@@ -132,25 +138,36 @@ propose-patch:
 
 # if the user doesn't change gcc_path, and it's not built, then we'll try to build it
 $(shell pwd)/gcc/bin/$(target)-gcj:
-       cd gcc; make
+       make -C gcc
 
-gcj: compile $(gcc_path)/bin/$(target)-gcj .headers link
+# java_classes is here to force compilation of the .class files (they get used via -Ibin/) without
+# having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
+gcj: $(gcc_path)/bin/$(target)-gcj $(java_classes) $(target_bin)
 
-link: $(java_objects) $(cc_objects) $(c_objects) bin-$(platform)/org/xwt/builtin.o
-       echo "linking        .o -> $(target_bin)"
-       $(ar) r bin-$(platform)/org/xwt/plat/platform.ar bin-$(platform)/org/xwt/plat/*.o
-       $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ -lstdc++ $(platform_link) bin-$(platform)/org/xwt/plat/platform.ar
+$(target_bin): $(java_objects) $(cc_objects) $(c_objects) bin-$(platform)/org/xwt/builtin.o
+       @echo "linking        .o -> $(target_bin)"
+       $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ $(platform_link) 
 
-.headers: $(java_classes)
-       cd bin; for A in `find * -name \*.class`; do \
-               echo "extracting .class -> .h:     $$A"; \
-               $(gcjh) --classpath . `echo $$A | sed s_/_._g | sed s/.class$$//`; \
-               done
-       echo "extracting .class -> .h:     done"
-       touch .headers
-
-# turn off optimization of Trap.java due to a compiler bug
-bin-$(platform)/org/xwt/Trap.o: gcj_flags := -O0 -g
+bin-$(platform)/org/xwt/builtin.o: bin/org/xwt/builtin.xwar
+       @echo "wrapping    .xwar -> .o:     bin/org/xwt/builtin.o"
+       @(echo "unsigned int builtin_xwar_length = ";\
+         (du -b bin/org/xwt/builtin.xwar | sed "s_bin.*__");\
+         echo \;;\
+         echo "unsigned char builtin_xwar[] = {";\
+         hexdump -ve '"0x" 1/1 "%x,\n"' bin/org/xwt/builtin.xwar;\
+         echo "};") > .builtin.c
+       $(gcc) -c .builtin.c -o bin-$(platform)/org/xwt/builtin.o
+
+$(java_headers): bin/%.h: bin/%.class
+       @echo "extracting .class -> .h:     $<"
+       cd bin; find `echo $< | sed s/.class$$// | sed s_^bin/__ `*.class |\
+               sed s_/_._g | sed s/.class$$// | sed s/.java$$// |\
+                       xargs $(gcjh) --classpath .
+
+$(java_objects): bin-$(platform)/%.java.o: src/%.java
+       @echo "compiling   .java -> .o:     $<"
+       mkdir -p `dirname $@`
+       $(gcj) -c $< -o $@
 
 # unpack and patch the ijg library
 src/org/ijg/jmorecfg.h: src/org/ijg/jpegsrc.v6b.tar.gz src/org/ijg/jmorecfg.h.patch
@@ -160,26 +177,18 @@ src/org/ijg/jmorecfg.h: src/org/ijg/jpegsrc.v6b.tar.gz src/org/ijg/jmorecfg.h.pa
        cd src/org/ijg; patch -p0 < jmorecfg.h.patch
        rm -rf src/org/ijg/jpeg-6b
 
-$(java_objects): bin-$(platform)/%.java.o: src/%.java $(java_classes)
-       @echo "compiling   .java -> .o:     $<"
-       @mkdir -p `dirname $@`
-       $(gcj) -c $< -o $@
-
-$(cc_objects): bin-$(platform)/%.cc.o: src/%.cc src/org/ijg/jmorecfg.h
+$(cc_objects): bin-$(platform)/%.cc.o: src/%.cc $(java_headers)
        @echo "compiling     .cc -> .o:     $<"
        @mkdir -p `dirname $@`
-       $(g++) -Ibin -c $< -o $@
+       $(g++) -I/usr/X11R6/include/ -I$(gcc_path)/include -Ibin -c $< -o $@
 
 $(c_objects): bin-$(platform)/%.c.o: src/%.c src/org/ijg/jmorecfg.h
        @echo "compiling      .c -> .o:     $<"
        @mkdir -p `dirname $@`
        $(gcc) -Ibin -c $< -o $@
 
-bin-$(platform)/org/xwt/builtin.o: bin/org/xwt/builtin.xwar
-       @echo "wrapping    .xwar -> .o"
-       $(gcj) --resource org/xwt/builtin.xwar -c $< -o $@
-
-
+upstream:
+       cvs -d :pserver:cvs@cvs.xwt.org:/cvs co upstream
 
 ## Platforms ##############################################################################
 
@@ -189,8 +198,8 @@ Linux:
                platform=Linux \
                target=i686-pc-linux-gnu \
                target_bin=xwt.linux \
-               platform_link="-L$(gcc-path)/lib -L/usr/X11R6/lib -lX11 -lXext --static" \
-               platform_java_sources="src/org/xwt/plat/POSIX.java src/org/xwt/plat/X11.java"
+               platform_link="-L$(gcc_path)/lib -L/usr/X11R6/lib -lX11 -lXext --static" \
+               platform_java_sources="POSIX X11"
 
 Win32:
        echo -e "\\n=== Win32 ========================================="
@@ -198,8 +207,18 @@ Win32:
                platform=Win32 \
                target=i686-pc-mingw32 \
                target_bin=xwt.exe \
-               platform_link="-Wl,--subsystem,windows -lcomdlg32" \
-               platform_java_sources=src/org/xwt/plat/Win32.java
+               platform_link="-Wl,--subsystem,windows -lcomdlg32"
+
+Darwin: upstream
+       echo -e "\\n=== Darwin ========================================="
+       ranlib upstream/darwin/*.a
+       ar x /usr/lib/libcc_dynamic.a upstream/darwin/darwin-fpsave.o
+       make gcj \
+               platform=Darwin \
+               target=powerpc-apple-darwin \
+               target_bin=xwt.darwin \
+               platform_link="upstream/darwin/*.[oa] $(gcc_path)/lib/libgcj.a" \
+               platform_java_sources="POSIX X11"
 
 Java2: $(java_classes) bin/org/xwt/builtin.xwar
        echo -e "\\n=== Java2 ========================================="
@@ -212,8 +231,6 @@ Java2: $(java_classes) bin/org/xwt/builtin.xwar
                org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class | tr \\012 \\015
        echo
 
-$(java2_objects:bin/%=%)
-
 PalmOS:
        echo "PalmOS is not yet supported"
        false
index 630e04e..4eabbce 100644 (file)
@@ -83,7 +83,7 @@ public class Main extends Applet {
             PNG png = PNG.decode(new ByteArrayInputStream(Base64.decode(scarPicture_png_base64)), "bundled scar image");
             Surface.scarPicture = Platform.createPicture(png.getData(), png.getWidth(), png.getHeight());
 
-            InputStream is = Main.class.getClassLoader().getResourceAsStream("org/xwt/builtin.xwar");
+            InputStream is = Platform.getBuiltinInputStream();
             if (is == null) Platform.criticalAbort("unable to load builtin.xwar");
             Resources.loadArchive(is);
            
@@ -120,7 +120,7 @@ public class Main extends Applet {
             ThreadMessage.newthread(new JSObject.JSFunction() {
                     public Object call(Context cx, Scriptable thisObj, Scriptable ctorObj, Object[] arg) throws JavaScriptException {
                         new Box(initialTemplate_f, null);
-            doneInitializing = true;
+                       doneInitializing = true;
             if (Surface.allSurfaces.size() == 0) {
                 Log.log(this, "exiting because all surfaces are gone");
                 Platform.exit();
index 80076d3..5bb1687 100644 (file)
@@ -213,6 +213,11 @@ public class Platform {
     /** returns true iff the platform has a case-sensitive filesystem */
     protected boolean _isCaseSensitive() { return true; }
 
+    /** returns an InputStream to the builtin xwar */
+    protected InputStream _getBuiltinInputStream() {
+       return Platform.class.getClassLoader().getResourceAsStream("org/xwt/builtin.xwar");
+    }
+
     /** returns the value of the environment variable key, or null if no such key exists */
     protected String _getEnv(String key) {
         try {
@@ -303,6 +308,9 @@ public class Platform {
     /** creates and returns a picture */
     public static Picture createPicture(int[] data, int w, int h) { return platform._createPicture(data, w, h); }
 
+    /** returns an InputStream to the builtin xwar */
+    public static InputStream getBuiltinInputStream() { return platform._getBuiltinInputStream(); }
+       
     /** creates and returns a picture */
     public static Picture createPicture(ImageDecoder i) { return platform._createPicture(i.getData(), i.getWidth(), i.getHeight()); }
 
diff --git a/src/org/xwt/plat/Darwin.cc b/src/org/xwt/plat/Darwin.cc
new file mode 100644 (file)
index 0000000..824aa56
--- /dev/null
@@ -0,0 +1,2 @@
+#include <sys/types.h>
+#include "X11.cc"