2003/02/25 21:37:08
[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 Java
30
31
32 ## Platform-Neutral ###########################################################################
33
34 .SILENT: $(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-*
52         find . -name \*~ | xargs rm -f
53         find . -name \#\*\# | xargs rm -f
54
55
56 ## GCJ-Derived Platforms #######################################################################
57
58 # if the user doesn't change gcc_path, and it's not built, then we'll try to build it
59 $(shell pwd)/gcc/bin/$(target)-gcj:
60         cd gcc; make
61
62 gcj: compile $(gcc_path)/bin/$(target)-gcj .headers link
63
64 link: $(gcj_java_objects) $(cc_objects)
65         $(ar) r bin-$(platform)/org/xwt/plat/platform.ar bin-$(platform)/org/xwt/plat/*.o
66         $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ $(platform_link) bin-$(platform)/org/xwt/plat/platform.ar
67
68 .headers: $(jikes_java_objects)
69         cd bin; for A in `find * -name \*.class`; do \
70                 echo -ne "\033[K\\r.class -> .h:     $$A\\r"; \
71                 $(gcjh) --classpath . `echo $$A | sed s_/_._g | sed s/.class$$//`; \
72                 done
73         echo -e "\033[K\\r.class -> .h:     done"
74         touch .headers
75
76 # turn off optimization of Trap.java due to a compiler bug
77 bin-$(platform)/org/xwt/Trap.o: gcj_flags := -O0 -g
78
79 $(gcj_java_objects): bin-$(platform)/%.o: src/%.java $(jikes_java_objects)
80         echo -ne "\033[K\\r .java -> .o:     $<\\r"
81         mkdir -p `dirname $@`
82         $(gcj) -c $< -o $@
83
84 $(cc_objects): bin-$(platform)/%-nat.o: src/%.cc
85         echo -ne "\033[K\\r   .cc -> .o:     $$A\\r"
86         $(gcc) -Ibin -c $< -o $@
87
88 bin-$(platform)/org/xwt/builtin.xwar: $(xwar_sources)
89         echo "bundling         -> .xwar"
90         $(gcj) --resource org/xwt/builtin.xwar -c $< -o $@
91
92
93
94 ## Platforms ##############################################################################
95
96 Linux:
97         echo -e "\\n=== Linux ========================================="
98         make gcj \
99                 platform=Linux \
100                 target=i686-pc-linux-gnu \
101                 target_bin=xwt.linux \
102                 platform_link="-L$(gcc-path)/lib -L/usr/X11R6/lib -lX11 -lXext --static" \
103                 platform_java_sources="src/org/xwt/plat/POSIX.java src/org/xwt/plat/X11.java"
104
105 Win32:
106         echo -e "\\n=== Win32 ========================================="
107         make gcj \
108                 platform=Win32 \
109                 target=i686-pc-mingw32 \
110                 target_bin=xwt.exe \
111                 platform_link="-Wl,--subsystem,windows -lcomdlg32" \
112                 platform_java_sources=src/org/xwt/plat/Win32.java
113
114 Java: compile
115
116 PalmOS:
117         echo "PalmOS is not yet supported"
118         false
119