2003/02/25 23:18:30
[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: new-release 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
65 ## GCJ-Derived Platforms #######################################################################
66
67 # if the user doesn't change gcc_path, and it's not built, then we'll try to build it
68 $(shell pwd)/gcc/bin/$(target)-gcj:
69         cd gcc; make
70
71 gcj: compile $(gcc_path)/bin/$(target)-gcj .headers link
72
73 link: $(gcj_java_objects) $(cc_objects)
74         $(ar) r bin-$(platform)/org/xwt/plat/platform.ar bin-$(platform)/org/xwt/plat/*.o
75         $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ $(platform_link) bin-$(platform)/org/xwt/plat/platform.ar
76
77 .headers: $(jikes_java_objects)
78         cd bin; for A in `find * -name \*.class`; do \
79                 echo -ne "\033[K\\r.class -> .h:     $$A\\r"; \
80                 $(gcjh) --classpath . `echo $$A | sed s_/_._g | sed s/.class$$//`; \
81                 done
82         echo -e "\033[K\\r.class -> .h:     done"
83         touch .headers
84
85 # turn off optimization of Trap.java due to a compiler bug
86 bin-$(platform)/org/xwt/Trap.o: gcj_flags := -O0 -g
87
88 $(gcj_java_objects): bin-$(platform)/%.o: src/%.java $(jikes_java_objects)
89         echo -ne "\033[K\\r .java -> .o:     $<\\r"
90         mkdir -p `dirname $@`
91         $(gcj) -c $< -o $@
92
93 $(cc_objects): bin-$(platform)/%-nat.o: src/%.cc
94         echo -ne "\033[K\\r   .cc -> .o:     $$A\\r"
95         $(gcc) -Ibin -c $< -o $@
96
97 bin-$(platform)/org/xwt/builtin.xwar: $(xwar_sources)
98         echo "bundling         -> .xwar"
99         $(gcj) --resource org/xwt/builtin.xwar -c $< -o $@
100
101
102
103 ## Platforms ##############################################################################
104
105 Linux:
106         echo -e "\\n=== Linux ========================================="
107         make gcj \
108                 platform=Linux \
109                 target=i686-pc-linux-gnu \
110                 target_bin=xwt.linux \
111                 platform_link="-L$(gcc-path)/lib -L/usr/X11R6/lib -lX11 -lXext --static" \
112                 platform_java_sources="src/org/xwt/plat/POSIX.java src/org/xwt/plat/X11.java"
113
114 Win32:
115         echo -e "\\n=== Win32 ========================================="
116         make gcj \
117                 platform=Win32 \
118                 target=i686-pc-mingw32 \
119                 target_bin=xwt.exe \
120                 platform_link="-Wl,--subsystem,windows -lcomdlg32" \
121                 platform_java_sources=src/org/xwt/plat/Win32.java
122
123 Java2: $(jikes_java_objects) bin/org/xwt/builtin.xwar
124         mkdir -p bin-Java12
125         echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > bin/.manifest
126         cd bin; fastjar cvf ../bin-Java12/xwt.jar -m .manifest \
127                 org/xwt/builtin.xwar \
128                 `find . -name \*.class | grep -v org/xwt/plat/` \
129                 org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class
130
131 $(java2_objects:bin/%=%)
132
133 PalmOS:
134         echo "PalmOS is not yet supported"
135         false
136
137
138 ## dist.xwt.org ############################################################################
139
140 current_build         := $(shell cat next.build)
141
142 new-release:
143         test `uname -n` = gosset.megacz.com || \
144                 (echo -e "um, new-release is only intended for use on xwt.org...\nedit the Makefile if you really know what you're doing."; false)
145         echo "***********************************************************"
146         echo "*  This build is $(current_build)"
147         echo "***********************************************************"
148
149         make --silent update-build
150         (make --silent new-release-private &> .make-new-release.out) || \
151                 (cat .make-new-release.out | mail -s "Build $(current_build) FAILED" cvs@xwt.org; false)
152         cat .make-new-release.out | \
153                 mail -s "Unsigned binaries of build $(current_build) are now available" cvs@xwt.org
154
155 new-release-private:
156         # preserve gcc across builds so we don't have to remake it
157         mv gcc/Makefile Makefile.gcc
158         mkdir -p ~/dist.xwt.org-gcc
159         rm -rf gcc
160         ln -s ~/dist.xwt.org-gcc gcc
161         mv Makefile.gcc gcc/Makefile
162
163         # build it
164         make all
165
166         cp bin-Java2/xwt.jar /var/www/dist.xwt.org/xwt-$(current_build).jar.unsigned
167         cp bin-Win32/xwt.exe /var/www/dist.xwt.org/xwt-$(current_build).exe.unsigned
168         cp bin-Linux/xwt.linux /var/www/dist.xwt.org/xwt-$(current_build).linux.unsigned
169