use darcs to fetch upstream repos
[org.ibex.core.git] / Makefile
1 ############################################################################# 
2 #
3 # The Ibex Makefile
4 #
5
6 #  auto directory creation with %/%: %?
7
8 ifeq ($(platform),)
9 # default
10 platform := Java2
11 endif
12
13 target_Darwin := powerpc-apple-darwin
14 target_Win32  := i686-pc-mingw32
15 target_Solaris := sparc-sun-solaris2.7
16 target_Linux := i686-pc-linux-gnu
17 target := $(target_$(platform))
18
19 all:         Java2 Linux Win32 Darwin Solaris
20
21 clean:      ; rm -rf build; rm build/class/org/ibex/util/Preprocessor.class
22 dist-clean:
23         rm -rf .configure* .install* build .compile .build*
24         find upstream -name config.cache -exec rm {} \;
25         test -e upstream/org.ibex.nestedvm && make -C upstream/org.ibex.nestedvm clean
26         rm .install_org.ibex.nestedvm
27
28 libwing_Linux := -Lupstream/install/i686-pc-linux-gnu/lib/
29 libwing_Linux +=   upstream/install/i686-pc-linux-gnu/lib/libWINGs.a
30 libwing_Linux +=   upstream/install/i686-pc-linux-gnu/lib/libwraster.a
31
32 libwing_Solaris := -Lupstream/install/sparc-sun-solaris2.7/lib/
33 libwing_Solaris +=   upstream/install/sparc-sun-solaris2.7/lib/libWINGs.a
34 libwing_Solaris +=   upstream/install/sparc-sun-solaris2.7/lib/libwraster.a
35
36 Java2:      build/Java2/ibex.jar
37 JVM:;       @make Java2
38 Linux:    ; @make gcj platform=Linux   link_flags="$(libwing_Linux) -lXpm -lX11 -lXext"
39 Solaris:  ; @make gcj platform=Solaris link_flags="$(libwing_Solaris) -lXpm -lX11 -lXext -lpthread"
40 Win32:    ; @make gcj platform=Win32   link_flags="-Wl,--subsystem,windows -lcomdlg32"
41 Darwin:   ; @make gcj platform=Darwin  link_flags="$(darwin_linker_flags)"
42
43 darwin_libdir       := upstream/install/powerpc-apple-darwin/lib
44 darwin_linker_flags := -Wl,-dylib_file,/usr/lib/libSystem.B.dylib:$(darwin_libdir)/libSystem.B.dylib
45 darwin_linker_flags += -Wl,-dylib_file,/usr/lib/system/libmathCommon.A.dylib:$(darwin_libdir)/libmathCommon.A.dylib
46 darwin_ogl_libdir   := /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries
47 darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir)/libGL.dylib:$(darwin_libdir)/libGL.dylib
48 darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir):$(darwin_libdir)/libGLU.dylib
49 darwin_linker_flags += -lSystem.B -lmathCommon.A -lGL -lGLU
50
51 target_bin_extension_$(platform) := $(shell echo $(platform) | tr A-Z a-z)
52 target_bin_extension_Win32       := exe
53 target_bin_extension_Java2       := jar
54 target_bin_extension             := $(target_bin_extension_$(platform))
55 target_bin                       := ibex.$(target_bin_extension)
56
57 gcc_optimizations  := -Os
58 #gcc_optimizations  := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls
59 #gcc_optimizations  += -finline-functions -funroll-loops -ffunction-sections -fdata-sections
60 gcc_flags          := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src -Iupstream/jpeg-6b/build-$(target) -g
61 gcc_flags          += -Iupstream/install/lib/gcc-lib/$(target)/3.3/include -Iupstream/install/$(target)/include
62 gcc_flags          += -ffunction-sections -fdata-sections -fno-omit-frame-pointer
63 gcj                := upstream/install/bin/$(target)-gcj $(gcc_flags) -fCLASSPATH=build/java
64 gcj                += -fassume-compiled -fmerge-all-constants -finhibit-reflection
65 gcj                += -foptimize-static-class-initialization -feliminate-dwarf2-dups -w
66 gcjh               := $(shell pwd)/upstream/install/bin/$(shell test -e upstream/install/bin/$(target)-gcjh && echo $(target)-)gcjh
67 g++                := upstream/install/bin/$(target)-gcj $(gcc_flags) -Iupstream/install/include -Wno-multichar
68 gcc                := upstream/install/bin/$(target)-gcc $(gcc_flags)
69 nm                 := upstream/install/$(target)/bin/nm
70 jar                := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
71 ifeq ($(platform),Java2)
72 javac   := javac -classpath upstream/bcel-5.1/src/bcel-5.1.jar   -d build/class/ -sourcepath build/java/
73 else
74 javac   := $(gcj) -fCLASSPATH=upstream/bcel-5.1/src/bcel-5.1.jar -d build/class/          -Ibuild/java -Iupstream/gnu.regexp-1.1.4/src/src -C
75 endif
76
77 gcj: .install_gcc-3.3_$(target)
78         @make build/$(platform)/$(target_bin) link_flags="$(link_flags)" platform=$(platform)
79
80 include Makefile.upstream
81
82 # find the superclasses of a platform class
83 #superclass_%:
84 #       @if [ "$*" = "org.ibex.plat.Darwin" ]; then echo org.ibex.plat.OpenGL; fi
85 #       @echo $*
86 #       @grep -s extends src/$(subst .,/,$*).java | sed s_.\*extends\ __ | head -n 1 | sed s_\ .\*__ |\
87 #               xargs --replace make -s superclass_org.ibex.plat.{}
88
89 plat_classes_Platform := org.ibex.plat.Platform
90 plat_classes_AWT      := org.ibex.plat.AWT $(plat_classes_Platform)
91 plat_classes_Java2    := org.ibex.plat.Java2 org.ibex.plat.JVM $(plat_classes_AWT)
92 plat_classes_GCJ      := org.ibex.plat.GCJ $(plat_classes_Platform)
93 plat_classes_Win32    := org.ibex.plat.Win32 $(plat_classes_GCJ)
94 plat_classes_POSIX    := org.ibex.plat.POSIX $(plat_classes_GCJ)
95 plat_classes_X11      := org.ibex.plat.X11 $(plat_classes_POSIX)
96 plat_classes_Linux    := org.ibex.plat.Linux $(plat_classes_X11)
97 plat_classes_Solaris  := org.ibex.plat.Solaris $(plat_classes_X11)
98 plat_classes_Darwin   := org.ibex.plat.Darwin org.ibex.plat.OpenGL $(plat_classes_POSIX)
99
100 plat_java_src_sources     := $(patsubst %,build/java/%.java,$(subst .,/,$(plat_classes_$(platform))))
101 java_src_sources          := $(shell find src -name '*.java' | grep -v Preprocessor | grep -v /plat/)
102 java_src_sources          += $(plat_java_src_sources)
103 java_sources              := $(patsubst src/%.java,     build/java/%.java, $(java_src_sources))
104
105 # FIXME ugly
106 java_sources              += build/java/org/xwt/mips/util/SeekableByteArray.java
107 java_sources              += build/java/org/xwt/mips/util/SeekableData.java
108 java_sources              += build/java/org/xwt/mips/util/SeekableFile.java
109 java_sources              += build/java/org/xwt/mips/util/SeekableInputStream.java
110 java_sources              += build/java/org/xwt/mips/Registers.java
111 java_sources              += build/java/org/xwt/mips/Runtime.java
112 java_sources              += build/java/org/xwt/mips/UsermodeConstants.java
113
114 java_sources              += build/java/org/ibex/crypto/DER.java
115 java_sources              += build/java/org/ibex/crypto/Digest.java
116 java_sources              += build/java/org/ibex/crypto/HMAC.java
117 java_sources              += build/java/org/ibex/crypto/MD2.java
118 java_sources              += build/java/org/ibex/crypto/MD5.java
119 java_sources              += build/java/org/ibex/crypto/PKCS1.java
120 java_sources              += build/java/org/ibex/crypto/RC4.java
121 java_sources              += build/java/org/ibex/crypto/RSA.java
122 java_sources              += build/java/org/ibex/crypto/SHA1.java
123 java_sources              += build/java/org/ibex/crypto/X509.java
124 java_sources              += build/java/org/ibex/crypto/Base64.java
125 java_sources              += build/java/org/ibex/net/ssl/RootCerts.java
126 java_sources              += build/java/org/ibex/net/SSL.java
127
128 java_sources              += build/java/gnu/regexp/CharIndexed.java
129 java_sources              += build/java/gnu/regexp/CharIndexedCharArray.java
130 java_sources              += build/java/gnu/regexp/CharIndexedInputStream.java
131 java_sources              += build/java/gnu/regexp/CharIndexedString.java
132 java_sources              += build/java/gnu/regexp/CharIndexedStringBuffer.java
133 java_sources              += build/java/gnu/regexp/RE.java
134 java_sources              += build/java/gnu/regexp/REException.java
135 java_sources              += build/java/gnu/regexp/REFilterInputStream.java
136 java_sources              += build/java/gnu/regexp/REMatch.java
137 java_sources              += build/java/gnu/regexp/REMatchEnumeration.java
138 java_sources              += build/java/gnu/regexp/RESyntax.java
139 java_sources              += build/java/gnu/regexp/REToken.java
140 java_sources              += build/java/gnu/regexp/RETokenAny.java
141 java_sources              += build/java/gnu/regexp/RETokenBackRef.java
142 java_sources              += build/java/gnu/regexp/RETokenChar.java
143 java_sources              += build/java/gnu/regexp/RETokenEnd.java
144 java_sources              += build/java/gnu/regexp/RETokenEndSub.java
145 java_sources              += build/java/gnu/regexp/RETokenLookAhead.java
146 java_sources              += build/java/gnu/regexp/RETokenWordBoundary.java
147 java_sources              += build/java/gnu/regexp/RETokenOneOf.java
148 java_sources              += build/java/gnu/regexp/RETokenPOSIX.java
149 java_sources              += build/java/gnu/regexp/RETokenRange.java
150 java_sources              += build/java/gnu/regexp/RETokenRepeated.java
151 java_sources              += build/java/gnu/regexp/RETokenStart.java
152 java_sources              += build/java/gnu/regexp/UncheckedRE.java
153 java_sources              += build/java/gnu/regexp/CharIndexedReader.java
154 java_sources              += build/java/gnu/regexp/REFilterReader.java
155
156 java_classes              := $(java_sources:build/java/%.java=build/class/%.class)
157 java_classes              += build/class/gnu/regexp/CharUnit.class build/class/gnu/regexp/IntPair.class
158
159 .PRECIOUS: $(java_classes) $(java_sources) *.java
160
161 ### Java Source Files ##############################################################################
162
163 build/cc/%.cc:     src/%.c    ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
164 build/res/%:       src/%      ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
165
166 build/java/org/ibex/%.java: src/org/ibex/%.java build/class/org/ibex/util/Preprocessor.class
167         @echo -e "\033[1mpreprocessing      .java -> .java:  $<\033[0m"
168         @mkdir -p `dirname $@`; java -cp build/class:upstream/gnu.regexp-1.1.4/src/src org.ibex.util.Preprocessor < $< > $@
169
170 upstream/org.ibex.crypto/%.java:;   @make .download_org.ibex.crypto
171 upstream/org.ibex.nestedvm/%.java:; @make .download_org.ibex.nestedvm
172 link_upstream =  build/java/$(1): $(2)/$(1);
173 link_upstream += @echo -e "\033[1mlinking            .java -> .java:  $$@\033[0m";
174 link_upstream += mkdir -p $$(@D);
175 link_upstream += ln -fs `echo $$(@D)/ | sed 's_[^/]*//*_../_g'`/$$< $$@
176 $(call link_upstream,org/xwt/mips/%.java,upstream/org.ibex.nestedvm/src,.download_org.ibex.nestedvm)
177 $(call link_upstream,org/ibex/crypto/%.java,upstream/org.ibex.crypto/src,.download_org.ibex.crypto)
178 $(call link_upstream,org/ibex/net/ssl/%.java,upstream/org.ibex.crypto/src,.download_org.ibex.crypto)
179 $(call link_upstream,org/ibex/net/SSL.java,upstream/org.ibex.crypto/src,.download_org.ibex.crypto)
180 $(call link_upstream,gnu/regexp/%.java,upstream/gnu.regexp-1.1.4/src/src)
181 $(call link_upstream,%.java,src)
182 $(call link_upstream,%.cc,src)
183
184
185 ### Java Class Files ##############################################################################
186
187 compile: .compile
188 .compile: .download_org.ibex.nestedvm .download_bcel-5.1 $(java_sources) $(java_classes); touch $@
189
190 build/class/org/ibex/util/Preprocessor.class: src/org/ibex/util/Preprocessor.java src/org/ibex/util/Vec.java .download_gnu.regexp-1.1.4
191         @echo -e "\n\033[1mcompiling          .java -> .class: $<\033[0m"
192         @mkdir -p build/class/org/ibex/util build/class/gnu/regexp build/java build/class
193         $(javac) src/org/ibex/util/Preprocessor.java src/org/ibex/util/Vec.java upstream/gnu.regexp-1.1.4/src/src/gnu/regexp/*.java
194
195 build/class/org/ibex/util/MIPSApps.class: build/mips/mipsapps.mips .install_org.ibex.nestedvm 
196         @mkdir -p build/java/org/ibex/util
197         @echo -e "\n\033[1mtranslating        .mips -> .class:  $<\033[0m"
198         java -cp upstream/org.ibex.nestedvm/build:upstream/org.ibex.nestedvm/upstream/build/bcel-5.1/bcel-5.1.jar \
199                 org.xwt.mips.Compiler org.ibex.util.MIPSApps $< -outfile $@
200
201 $(java_classes): build/class/org/ibex/util/Preprocessor.class $(java_sources)
202         @echo -e "\n\033[1mcompiling          .java -> .class: $<\033[0m"
203         @mkdir -p build/java build/class
204         $(javac) $(java_sources) -d build/class
205
206 build/Java2/ibex.jar: .compile build/res/builtin.jar build/class/org/ibex/util/MIPSApps.class
207         @echo -e "\n\033[1marchiving         .class -> .jar:   build/Java2/ibex.jar\033[0m"
208         mkdir -p build/Java2
209         echo -e "Manifest-Version: 1.0\nMain-Class: org.ibex.core.Main\n" > build/Java2/.manifest
210         cd build/class/org/ibex; ln -sf ../../../res/builtin.jar
211         cd build/class; $(jar) cfm ../Java2/ibex.jar ../Java2/.manifest `find . -name \*.class -or -name \*.jar`
212
213
214 ### Headers ##################################################################################
215
216 java_headers          := $(java_sources:build/java/%.java=build/h/%.h) 
217 build/h/%.h: build/class/%.class .compile
218         @echo -e "\n\033[1mextracting        .class -> .h:     $<\033[0m"
219         mkdir -p `dirname $@`
220         ls `echo $< | sed s/.class\$$//`*.class |\
221                  sed s_build/class/__ | sed s/.class\$$//g | sed s_/_._g | (cd build/class; xargs $(gcjh) -d ../h --classpath .)
222
223
224 ### Native Code ##############################################################################
225
226 # a hack since we've disabled gcj's awt implementation
227 build/$(platform)/org/ibex/plat/Linux.cc.o: .install_WindowMaker-0.80.2_$(target) 
228 build/$(platform)/org/ibex/plat/Solaris.cc.o: .install_WindowMaker-0.80.2_$(target) 
229
230 libjava_dir := $(shell pwd)/upstream/gcc-3.3/build-$(target)/$(target)/libjava
231 nat_libjava_files_ := boehm.o exception.o posix-threads.o posix.o prims.o resolve.o java/net/natInetAddress.o
232 nat_libjava_files_ += java/net/natPlainSocketImpl.o java/util/zip/nat*.o gnu/gcj/runtime/natFirstThread.o
233 nat_libjava_files_ += gnu/gcj/runtime/natNameFinder.o gnu/gcj/runtime/natStackTrace.o gnu/gcj/runtime/natSharedLibLoader.o
234 nat_libjava_files_ += gnu/gcj/runtime/natStringBuffer.o gnu/gcj/runtime/natVMClassLoader.o gnu/gcj/runtime/natFinalizerThread.o
235 nat_libjava_files_ += $(shell cd $(libjava_dir) 2>/dev/null; find java/lang -name \*.o -not -name '*[A-Z]*' 2>/dev/null)
236 nat_libjava_files_ += $(shell cd $(libjava_dir) 2>/dev/null; find java/lang -name nat\*.o 2>/dev/null)
237 nat_libjava_files := $(nat_libjava_files_:%=$(libjava_dir)/%)
238 nat_libjava_files += $(libjava_dir)/java/io/natFile.o $(libjava_dir)/java/io/natFileDescriptor.o
239
240 build/$(platform)/org/ibex/plat/$(platform).cc.o: src/org/ibex/plat/$(platform).cc src/org/ibex/plat/*.cc .configure_jpeg-6b_$(target)
241         @make $(java_headers)
242         @echo -e "\n\033[1mcompiling            .cc -> .o:     $<\033[0m"
243         mkdir -p `dirname $@`
244         $(g++) -Iupstream/gcc-3.3/build-$(target)/$(target)/libjava -c $< -o $@
245
246
247 bcel_jar := upstream/bcel-5.1/src/bcel-5.1.jar
248 build/$(platform)/ibex.pruned.jar: .compile $(java_classes) .install_jpeg-6b_$(target) build/$(platform)/builtin.o build/$(platform)/org/ibex/plat/$(platform).cc.o
249         @echo -e "\n\033[1mpruning              .jar -> .jar\033[0m"
250 ifneq ($(platform),Darwin)
251         cp upstream/install/share/java/libgcj-3.3.jar build/$(platform)/ibex.jar
252         cd build/class; jar uf ../$(platform)/ibex.jar $(java_classes:build/class/%.class=%*.class)
253         ($(nm) $(nat_libjava_files) build/$(platform)/org/ibex/plat/$(platform).cc.o; echo org.ibex.plat.$(platform).main) |\
254                 grep _ZN | c++filt --format java | grep " U " | sed 's_ * U __' | sed 's_(.*__' \
255                 | java -cp $(bcel_jar):build/class org.ibex.util.NanoGoat build/$(platform)/ibex.jar | tee nanogoat.log
256         mkdir tmp; cd tmp; fastjar xvf ../build/$(platform)/ibex.jar.pruned; rm gnu/gcj/runtime/FirstThread*; cp ../build/class/org/ibex/plat/GCJ* org/ibex/plat/; cp -r ../build/class/org/xwt/mips/* org/xwt/mips/; mkdir -p $(shell pwd)/build/$(platform)/java/lang; mv java/lang/Class.class $(shell pwd)/build/$(platform)/java/lang; fastjar cvf ../build/$(platform)/ibex.jar.pruned .; cd ..; rm -rf tmp
257         mv build/$(platform)/ibex.jar.pruned $@
258 endif
259 ifeq ($(platform),Darwin)
260         cd build/class; jar cf ../$(platform)/ibex.pruned.jar \
261                                         org/ibex/plat/Platform*.class \
262                                         $(filter-out org/ibex/util/NanoGoat%,$(java_classes:build/class/%.class=%*.class))
263 endif
264
265 ifeq ($(platform),Win32)
266 filedes := $(shell pwd)/upstream/gcc-3.3/src/libjava/java/io/natFileWin32.cc
267 filedes += $(shell pwd)/upstream/gcc-3.3/src/libjava/java/io/natFileDescriptorWin32.cc
268 else
269 filedes := $(shell pwd)/upstream/gcc-3.3/src/libjava/java/io/natFilePosix.cc
270 filedes += $(shell pwd)/upstream/gcc-3.3/src/libjava/java/io/natFileDescriptorPosix.cc
271 endif
272
273 ifneq ($(target_bin_extension),jar)
274 build/$(platform)/$(target_bin): build/$(platform)/ibex.pruned.jar src/org/ibex/plat/*.cc build/$(platform)/builtin.o $(java_headers)
275
276         @echo -e "\n\033[1mlinking              .jar -> $(target_bin).phat\033[0m"
277 ifneq ($(platform),Darwin)
278 # -Os
279         cd build/$(platform); $(shell pwd)/upstream/install/bin/$(target)-gcj        \
280                 -fCLASSPATH=$(shell pwd)/upstream/install/share/java/libgcj-3.3.jar  \
281                 -finhibit-reflection                                                 \
282                 -fno-store-check                                                     \
283                 -c java/lang/Class.class
284         cd upstream/gcc-3.3/src/libjava/java/lang;\
285                 ln -sf ../../../../build-$(target)/$(target)/libjava/java/lang/natConcreteProcess.cc
286 endif
287 # we need -fno-store-check since we can't dynamically resolve references to array classes
288         PATH=upstream/install/bin:$$PATH upstream/install/bin/$(target)-gcj              \
289                 --main=org.ibex.plat.$(platform)                                         \
290                 -Dfile.encoding=UTF8                                                     \
291                 -DPREFIX=\"\"                                                            \
292                 -Lupstream/install/$(target)/lib -Lupstream/install/lib                  \
293                 -finhibit-reflection                                                     \
294                 -fno-store-check                                                         \
295                 -w -g                                                                    \
296                 -Iupstream/jpeg-6b/build-$(target)/                                      \
297                 -Iupstream/jpeg-6b/src                                                   \
298                 -Ibuild/h                                                                \
299                 -Iupstream/gcc-3.3/src/gcc \
300                 -Iupstream/gcc-3.3/build-i686-pc-linux-gnu/i686-pc-linux-gnu/boehm-gc/    \
301                 -Iupstream/gcc-3.3/build-i686-pc-linux-gnu/i686-pc-linux-gnu/boehm-gc/include    \
302                 -Iupstream/gcc-3.3/src/boehm-gc                                           \
303                 -Iupstream/gcc-3.3/src/boehm-gc/include                                       \
304                 -Iupstream/gcc-3.3/build-i686-pc-linux-gnu/i686-pc-linux-gnu/libjava/    \
305                 -Iupstream/gcc-3.3/build-i686-pc-linux-gnu/i686-pc-linux-gnu/libjava/include    \
306                 -Iupstream/gcc-3.3/src/libjava                                           \
307                 -Iupstream/gcc-3.3/src/libjava/include                                       \
308                 -Ufile \
309                 build/$(platform)/ibex.pruned.jar                                        \
310                 src/org/ibex/plat/$(platform).cc                                         \
311                 build/$(platform)/builtin.o                                              \
312                 upstream/jpeg-6b/build-$(target)/libjpeg.a                               \
313                 $(link_flags)                                                            \
314                 $(libjava_dir)/../boehm-gc/.libs/libgcjgc.a                              \
315 ifneq ($(platform),Darwin)
316                 $(nat_libjava_files_:%.o=$(shell pwd)/upstream/gcc-3.3/src/libjava/%.c*) \
317                 $(filedes)                                                               \
318                 build/$(platform)/Class.o                                                \
319                 $(libjava_dir)/gnu/gcj/runtime/FirstThread.o                             \
320                 -Wl,-O2,--relax,--gc-sections,--noinhibit-exec,--no-whole-archive        \
321                 -lz -o $@.phat \
322 else
323                 $(libjava_dir)/.libs/libgcj.a                                            \
324                 -o $@ \
325 endif
326
327 ifneq ($(platform),Darwin)
328         @echo; ls -l $@.phat
329
330         @echo -e "\n\033[1mstripping              $(target_bin).phat -> $(target_bin)\033[0m"
331         strip $@.phat -o $@
332         @echo; ls -l $@.phat
333
334         @echo -e "\n\033[1mcompressing              $(target_bin) -> $(target_bin)\033[0m"
335         upx-ucl-beta $@
336         @echo; ls -l $@.phat
337 endif
338 endif
339
340 ### Builtin Resources ##############################################################################
341
342 builtin_src := $(shell find src/org/ibex/core/builtin -name '*.*' \! -name '*.xcf')
343 build/res/fonts/vera: .download_vera-1.10
344         mkdir -p build/res/fonts/vera
345         cd build/res/fonts/vera; ln -fs ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/Vera.ttf
346         cd build/res/fonts/vera; ln -fs ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraMono.ttf
347         cd build/res/fonts/vera; ln -fs ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraSe.ttf
348 build/res/builtin.jar: $(builtin_src:src/%=build/res/%) build/res/fonts/vera
349         @echo -e "\n\033[1mzipping            res/* -> .jar: builtin.jar\033[0m"
350         cd build/res; $(jar) cf builtin.jar org/ibex/core/builtin/scar.png fonts
351 build/$(platform)/builtin.o: build/res/builtin.jar
352         @echo -e "\n\033[1mwrapping            .jar -> .o: resources.o\033[0m"
353         @mkdir -p $(@D)
354         @(echo "unsigned int builtin_length = ";                                \
355                 (wc -c build/res/builtin.jar | sed "s_build.*__");              \
356                 echo \;;                                                        \
357                 echo "unsigned char builtin_bytes[] = {";                       \
358                 hexdump -ve '"0x" 1/1 "%x,\n"' build/res/builtin.jar;           \
359                 echo "};") > .builtin.c
360         $(gcc) -c .builtin.c -o build/$(platform)/builtin.o
361
362 build/mips/%.c.o: src/%.c .download_libmspack-20030726 .install_org.ibex.nestedvm
363         make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
364         make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
365         mkdir -p $(@D)
366         echo -e "\n\033[1mcompiling $< -> $@ (mips)\033[0m"
367         upstream/install/bin/mips-unknown-elf-gcc -march=r3000 \
368                 -Iupstream/freetype-2.1.4/src/include  \
369                 -Iupstream/libmspack-20030726/src/mspack \
370                 -c -o $@ $<
371
372 build/mips/mipsapps.mips: build/mips/org/ibex/graphics/Freetype.c.o build/mips/org/ibex/util/MSPack.c.o
373         make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
374         make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
375         @echo -e "\n\033[1mlinking               .o -> .mips:  $@\033[0m"
376         mkdir -p build/mips build/res
377         upstream/install/bin/mips-unknown-elf-gcc \
378                 --static \
379                 -march=mips1 \
380                 -T upstream/nestedvm/src/org/xwt/mips/linker.ld \
381                 -L upstream/nestedvm/build/org/xwt/mips/ \
382                 -L upstream/freetype-2.1.4/src/objs \
383                 -L upstream/libmspack-20030726/build-mips-unknown-elf/ \
384                 -o $@ \
385                 $^ \
386                 -lfreetype \
387                 -lmspack   \
388                 -Wl,--gc-sections
389
390
391 ### Maintainer ######################################################################################
392
393 current_build         := $(shell cat next.build)
394 strip_$(platform)     := upstream/install/$(target)/bin/strip build/$(platform)/$(target_bin) -o 
395 strip_Java2             := cp build/$(platform)/$(target_bin)
396 install-dist:;     $(strip_$(platform)) /var/www/org/xwt/dist/master/ibex-$(current_build).$(target_bin_extension).unsigned
397 dist: compile
398         (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
399         mv next.build- next.build
400         echo -n "Next build will be "; cat next.build
401         nice -n 19 make all
402         make install-dist platform=Win32
403         make install-dist platform=Linux
404         make install-dist platform=Solaris
405         make install-dist platform=Darwin
406         make install-dist platform=Java2
407         echo -e "\n\n\n*** DONE ******************************************"
408
409 propose-patch:
410         @darcs send --edit-description -o .darcspatch -T patches@xwt.org http://core.ibex.org/
411         @(echo "To: patches@xwt.org";\
412          SUB=`grep -A10000 New.patches .darcspatch | grep '^\\[' | cut -b 2- | tr \\\n , | sed s_,_,\ _g | sed "s_, *\\$$__"`;\
413          echo "Subject: $$SUB";\
414          echo;\
415          cat .darcspatch) | /usr/sbin/sendmail -bm -f $(USER)@xwt.org patches@xwt.org;
416         @rm .darcspatch 
417
418 commit: propose-patch
419         darcs push --and-apply xwt@xwt.org:/var/www/org/ibex/core/
420
421 doc/%.pdf: build/class/org/ibex/util/XML.class build/class/org/ibex/util/Doc.class doc/%.xml
422         cd $(@D); java -cp ../../build/class org.ibex.util.Doc slides < `basename $*`.xml > `basename $*`.tex
423         cd $(@D); pdflatex `basename $*`.tex
424         open doc/$*.pdf