2003/02/25 22:44:58
[org.ibex.core.git] / Makefile
1 #
2 # The XWT Makefile
3 #
4
5 ## Configurables ###########################################################################
6
7 # inputs
8 jikes_java_sources     := $(shell find src -name *.java)
9 gcj_java_sources       := $(shell find src -name *.java -not -path src/org/xwt/plat/\*) src/org/xwt/plat/GCJ.java $(platform_java_sources)
10 xwar_sources           := $(ls src/org/xwt/builtin/*.png src/org/xwt/builtin/*.xwt src/org/xwt/builtin/*.xwf)
11 cc_sources             := src/org/xwt/plat/$(platform).cc
12
13 # outputs
14 jikes_java_objects     := $(jikes_java_sources:src/%.java=bin/%.class)
15 cc_objects             := $(cc_sources:src/%.cc=bin-$(platform)/%-nat.o)
16 gcj_java_objects       := $(gcj_java_sources:src/%.java=bin-$(platform)/%.o)
17
18 # tools
19 gcc_path               := $(shell pwd)/gcc
20 gcc_flags              := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls -finline-functions -funroll-loops -g
21 gcj_flags              := -fCLASSPATH=bin 
22 gcj                    := $(gcc_path)/bin/$(target)-gcj $(gcj_flags) $(gcc_flags)
23 gcc                    := $(gcc_path)/bin/$(target)-g++ $(gcc_flags)
24 gcjh                   := $(gcc_path)/bin-$(target)-gcjh
25 ar                     := $(gcc_path)/$(target)/bin/ar
26 jikes                  := jikes -extdirs ${JAVA_HOME}/jre/lib -nowarn
27
28 # platforms
29 all_platforms          := Win32 Linux Java2
30
31
32 ## Platform-Neutral ###########################################################################
33
34 .SILENT: update-build $(jikes_java_objects) .headers $(gcj_java_objects) $(all_platforms) PalmOS bin/org/xwt/builtin.xwar
35
36 compile: $(jikes_java_objects) bin/org/xwt/builtin.xwar
37
38 all: $(all_platforms)
39
40 $(jikes_java_objects): $(jikes_java_sources)
41         echo -ne " .java -> .class:\\r"
42         mkdir -p bin
43         $(jikes) -sourcepath src/ -classpath lib/libgcj-minimal.jar $(jikes_java_sources) -d bin/
44         echo " .java -> .class: done"
45
46 bin/org/xwt/builtin.xwar: $(xwar_sources)
47         mkdir -p bin/org/xwt
48         cd src; fastjar cf ../bin/org/xwt/builtin.xwar $(xwar_sources:src/%=%)
49
50 clean:
51         rm -rf bin-* bin
52         find . -name \*~ | xargs rm -f
53         find . -name \#\*\# | xargs rm -f
54
55 update-build:
56         (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
57         mv next.build- next.build
58         echo -n "Next build will be "
59         cat next.build
60         echo committing...
61         cvs commit -m 'updated build' next.build
62         echo committed.
63
64 ## GCJ-Derived Platforms #######################################################################
65
66 # if the user doesn't change gcc_path, and it's not built, then we'll try to build it
67 $(shell pwd)/gcc/bin/$(target)-gcj:
68         cd gcc; make
69
70 gcj: compile $(gcc_path)/bin/$(target)-gcj .headers link
71
72 link: $(gcj_java_objects) $(cc_objects)
73         $(ar) r bin-$(platform)/org/xwt/plat/platform.ar bin-$(platform)/org/xwt/plat/*.o
74         $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ $(platform_link) bin-$(platform)/org/xwt/plat/platform.ar
75
76 .headers: $(jikes_java_objects)
77         cd bin; for A in `find * -name \*.class`; do \
78                 echo -ne "\033[K\\r.class -> .h:     $$A\\r"; \
79                 $(gcjh) --classpath . `echo $$A | sed s_/_._g | sed s/.class$$//`; \
80                 done
81         echo -e "\033[K\\r.class -> .h:     done"
82         touch .headers
83
84 # turn off optimization of Trap.java due to a compiler bug
85 bin-$(platform)/org/xwt/Trap.o: gcj_flags := -O0 -g
86
87 $(gcj_java_objects): bin-$(platform)/%.o: src/%.java $(jikes_java_objects)
88         echo -ne "\033[K\\r .java -> .o:     $<\\r"
89         mkdir -p `dirname $@`
90         $(gcj) -c $< -o $@
91
92 $(cc_objects): bin-$(platform)/%-nat.o: src/%.cc
93         echo -ne "\033[K\\r   .cc -> .o:     $$A\\r"
94         $(gcc) -Ibin -c $< -o $@
95
96 bin-$(platform)/org/xwt/builtin.xwar: $(xwar_sources)
97         echo "bundling         -> .xwar"
98         $(gcj) --resource org/xwt/builtin.xwar -c $< -o $@
99
100
101
102 ## Platforms ##############################################################################
103
104 Linux:
105         echo -e "\\n=== Linux ========================================="
106         make gcj \
107                 platform=Linux \
108                 target=i686-pc-linux-gnu \
109                 target_bin=xwt.linux \
110                 platform_link="-L$(gcc-path)/lib -L/usr/X11R6/lib -lX11 -lXext --static" \
111                 platform_java_sources="src/org/xwt/plat/POSIX.java src/org/xwt/plat/X11.java"
112
113 Win32:
114         echo -e "\\n=== Win32 ========================================="
115         make gcj \
116                 platform=Win32 \
117                 target=i686-pc-mingw32 \
118                 target_bin=xwt.exe \
119                 platform_link="-Wl,--subsystem,windows -lcomdlg32" \
120                 platform_java_sources=src/org/xwt/plat/Win32.java
121
122 Java2: $(jikes_java_objects) bin/org/xwt/builtin.xwar
123         mkdir -p bin-Java12
124         echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > bin/.manifest
125         cd bin; fastjar cvf ../bin-Java12/xwt.jar -m .manifest \
126                 org/xwt/builtin.xwar \
127                 `find . -name \*.class | grep -v org/xwt/plat/` \
128                 org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class
129
130 $(java2_objects:bin/%=%)
131
132 PalmOS:
133         echo "PalmOS is not yet supported"
134         false
135