1 #############################################################################
6 target_Darwin := powerpc-apple-darwin
7 target_Win32 := i686-pc-mingw32
8 target_Solaris := sparc-sun-solaris2.7
9 target_Linux := i686-pc-linux-gnu
10 target := $(target_$(platform))
12 all: JVM Linux Win32 Darwin Solaris
16 rm -rf .jikes .configure* .install* build .compile .build*
17 find upstream -name config.cache -exec rm {} \;
18 test -e upstream/mips && make -C upstream/mips clean
20 JVM: build/JVM/xwt.jar
21 Linux: ; make gcj platform=Linux link_flags="-lX11 -lXext"
22 Solaris: ; make gcj platform=Solaris link_flags="-lX11 -lXext -lpthread"
23 Win32: ; make gcj platform=Win32 link_flags="-Wl,--subsystem,windows -lcomdlg32"
24 Darwin: ; make gcj platform=Darwin link_flags="$(darwin_linker_flags)"
26 darwin_libdir := upstream/install/powerpc-apple-darwin/lib
27 darwin_linker_flags := -Wl,-dylib_file,/usr/lib/libSystem.B.dylib:$(darwin_libdir)/libSystem.B.dylib
28 darwin_linker_flags += -Wl,-dylib_file,/usr/lib/system/libmathCommon.A.dylib:$(darwin_libdir)/libmathCommon.A.dylib
29 darwin_ogl_libdir := /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries
30 darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir)/libGL.dylib:$(darwin_libdir)/libGL.dylib
31 darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir):$(darwin_libdir)/libGLU.dylib
32 darwin_linker_flags += -lSystem.B -lmathCommon.A -lGL -lGLU
34 target_bin_extension_$(platform) := $(shell echo $(platform) | tr A-Z a-z)
35 target_bin_extension_Win32 := exe
36 target_bin_extension_JVM := jar
37 target_bin_extension := $(target_bin_extension_$(platform))
38 target_bin := xwt.$(target_bin_extension)
40 jikes_flags := -nowarn
41 gcc_optimizations := -O2
42 #gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls
43 #gcc_optimizations += -finline-functions -funroll-loops -ffunction-sections -fdata-sections
45 gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src -Iupstream/jpeg-6b/build-$(target)
46 gcc_flags += -Iupstream/install/lib/gcc-lib/$(target)/3.3/include -Iupstream/install/$(target)/include
47 gcj := upstream/install/bin/$(target)-gcj $(gcc_flags) -fCLASSPATH=build/java
48 gcjh := $(shell pwd)/upstream/install/bin/$(shell test -e upstream/install/bin/$(target)-gcjh && echo $(target)-)gcjh
49 g++ := upstream/install/bin/$(target)-gcj $(gcc_flags) -Iupstream/install/include -Wno-multichar
50 gcc := upstream/install/bin/$(target)-gcc $(gcc_flags)
51 jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
53 gcj: .install_gcc-3.3_$(target); make build/$(platform)/$(target_bin) link_flags="$(link_flags)" platform=$(platform)
55 include Makefile.upstream
57 java_sources := $(patsubst src/%.java, build/java/%.java, $(shell find src -name '*.java' | grep -v Preprocessor))
58 java_sources += build/java/org/xwt/mips/Errno.java
59 java_sources += build/java/org/xwt/mips/Unistd.java
60 java_sources += build/java/org/xwt/mips/Syscalls.java
61 java_sources += build/java/org/xwt/mips/Registers.java
62 java_sources += build/java/org/xwt/mips/Runtime.java
63 java_sources += build/java/org/xwt/mips/UnixRuntime.java
64 java_sources += build/java/org/xwt/mips/util/SeekableByteArray.java
65 java_sources += build/java/org/xwt/mips/util/SeekableData.java
66 java_sources += build/java/org/xwt/mips/util/SeekableFile.java
67 java_sources += build/java/org/xwt/mips/util/SeekableInputStream.java
69 build/java/org/xwt/mips/util/%: .install_mips2java
72 @cd $(@D); ln -sf ../../../../../../upstream/mips/org/xwt/mips/util/$*
73 build/java/org/xwt/mips/%: .install_mips2java
76 @test -e upstream/mips/build/org/xwt/mips/$* && (cd $(@D); \
77 ln -sf ../../../../../upstream/mips/build/org/xwt/mips/$*); true
78 @test -e upstream/mips/org/xwt/mips/$* && (cd $(@D); \
79 ln -sf ../../../../../upstream/mips/org/xwt/mips/$*); true
82 ### Java Class Files ##############################################################################
84 build/class/org/xwt/translators/MIPSApps.class: build/mips/mipsapps.mips .jikes
85 mkdir -p build/java/org/xwt/translators
86 @echo -e "\n\033[1mtranslating .mips -> .java: $<\033[0m"
87 (echo -e 'package org.xwt.translators;\nimport org.xwt.mips.*;\n'; \
88 java -Xint -cp upstream/mips/build org.xwt.mips.Compiler MIPSApps build/mips/mipsapps.mips) \
89 | sed 's,//.*$$,,;'| tr -d '\n') > build/java/org/xwt/translators/MIPSApps.java
90 @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
91 ./.jikes -g:none build/java/org/xwt/translators/MIPSApps.java
93 build/java/org/xwt/%.java: src/org/xwt/%.java
94 make build/class/org/xwt/util/Preprocessor.class
95 @echo -e "\n\033[1mpreprocessing .java -> .java: $<\033[0m"
96 mkdir -p `dirname $@`; java -cp build/class org.xwt.util.Preprocessor < $< > $@
98 build/java/%.java: src/%.java ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
99 build/cc/%.cc: src/%.c ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
100 build/res/%: src/% ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
102 build/class/org/xwt/util/Preprocessor.class: src/org/xwt/util/Preprocessor.java .jikes
103 @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
104 mkdir -p build/class/org/xwt/util/
107 oldcompile:; CLASSPATH=$$CLASSPATH:lib/libgcj-minimal.jar:upstream/mips/build javac -d build/class `find build/java/ -name \*.java`
109 .compile: $(java_sources) .jikes .install_mips2java
110 @echo -e "\n\033[1mcompiling .java -> .class: src/**/*.java\033[0m"
111 @rm -f $(java_sources:build/java/%.java=build/class/%.class)
113 @./.jikes $(java_sources)
116 build/JVM/xwt.jar: .compile build/res/builtin.jar
117 @echo -e "\n\033[1marchiving .class -> .jar: build/JVM/xwt.jar\033[0m"
119 echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > build/JVM/.manifest
120 cd build/class/org/xwt; ln -sf ../../../res/builtin.jar
121 cd build/class; $(jar) cfm ../JVM/xwt.jar ../JVM/.manifest \
122 `find . \! -type d \! -path './org/xwt/mips/*'` \
123 $(patsubst %,../../upstream/mips/build/org/xwt/mips/%*.class, Runtime Registers Syscalls Errno)
126 ### GCJH Headers ##############################################################################
128 java_headers := $(java_sources:build/java/%.java=build/h/%.h)
129 build/h/edu/stanford/ejalbert/BrowserLauncher.h:; mkdir -p $(@D); touch $@
130 build/h/%.h: build/class/%.class .compile
131 @echo -e "\n\033[1mextracting .class -> .h: $<\033[0m"
132 mkdir -p `dirname $@`
133 ls `echo $< | sed s/.class\$$//`*.class |\
134 sed s_build/class/__ | sed s/.class\$$//g | sed s_/_._g | (cd build/class; xargs $(gcjh) -d ../h --classpath .)
137 ### Native Code ##############################################################################
139 # a hack since we've disabled gcj's awt implementation
140 build/$(platform)/org/xwt/plat/Java2.java.o: ; touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
141 build/$(platform)/org/xwt/plat/AWT.java.o: ; touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
143 build/$(platform)/org/xwt/translators/MIPSApps.java.o: build/class/org/xwt/translators/MIPSApps.class
144 @echo -e "\n\033[1mcompiling .class -> .o: $<\033[0m"
145 mkdir -p `dirname $@`
146 $(gcj) -Os -c $< -o $@
148 build/$(platform)/%.java.o: build/java/%.java
149 @echo -e "\n\033[1mcompiling .java -> .o: $<\033[0m"
150 mkdir -p `dirname $@`
153 build/$(platform)/org/xwt/plat/$(platform).cc.o: src/org/xwt/plat/$(platform).cc src/org/xwt/plat/*.cc .configure_jpeg-6b_$(target)
154 @make $(java_headers)
155 @echo -e "\n\033[1mcompiling .cc -> .o: $<\033[0m"
156 mkdir -p `dirname $@`
159 nonplat_java_sources := $(filter-out build/java/org/xwt/plat/$(platform).java,$(java_sources))
160 build/$(platform)/$(platform).ar: $(nonplat_java_sources:build/java/%.java=build/$(platform)/%.java.o)
161 @echo -e "\n\033[1marchiving .o -> .a\033[0m"
162 mkdir -p build/$(platform)
164 upstream/install/$(target)/bin/ar rc $@ $^
165 upstream/install/$(target)/bin/ranlib $@
167 upstream/jpeg-6b/build-$(target)/libjpeg.a: .install_jpeg-6b_$(target)
168 build/$(platform)/$(target_bin): build/$(platform)/org/xwt/plat/$(platform).cc.o upstream/jpeg-6b/build-$(target)/libjpeg.a build/$(platform)/builtin.o build/$(platform)/$(platform).ar build/$(platform)/org/xwt/plat/$(platform).java.o
169 @echo -e "\n\033[1mlinking .o -> $(target_bin)\033[0m"
170 mkdir -p build/$(platform)
171 PATH=upstream/install/bin:$$PATH $(gcj) -v --main=org.xwt.plat.$(platform) -o $@ -Lupstream/install/$(target)/lib $^ $(link_flags)
174 ### Builtin Resources ##############################################################################
176 builtin_src := $(shell find src/org/xwt/builtin -name '*.*' \! -name '*.xcf')
177 build/res/fonts/vera: .download_vera-1.10
178 mkdir -p build/res/fonts/vera
179 cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/Vera.ttf
180 cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraMono.ttf
181 cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraSe.ttf
182 build/res/builtin.jar: $(builtin_src:src/%=build/res/%) build/res/fonts/vera
183 @echo -e "\n\033[1mzipping res/* -> .jar: builtin.jar\033[0m"
184 cd build/res; $(jar) cf builtin.jar $(^:build/res/%=%)
185 build/$(platform)/builtin.o: build/res/builtin.jar
186 @echo -e "\n\033[1mwrapping .jar -> .o: resources.o\033[0m"
187 @(echo "unsigned int builtin_length = "; \
188 (wc -c build/res/builtin.jar | sed "s_build.*__"); \
190 echo "unsigned char builtin_bytes[] = {"; \
191 hexdump -ve '"0x" 1/1 "%x,\n"' build/res/builtin.jar; \
192 echo "};") > .builtin.c
193 $(gcc) -c .builtin.c -o build/$(platform)/builtin.o
196 build/mips/%.c.o: src/%.c .download_libmspack-20030726
197 make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
198 make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
200 echo -e "\n\033[1mcompiling $< -> $@ (mips)\033[0m"
201 upstream/install/bin/mips-unknown-elf-gcc -march=r3000 \
202 -Iupstream/freetype-2.1.4/src/include \
203 -Iupstream/libmspack-20030726/src/mspack \
206 build/mips/mipsapps.mips: build/mips/org/xwt/translators/Freetype.c.o build/mips/org/xwt/translators/MSPack.c.o build/mips/org/xwt/translators/main.c.o
207 make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
208 make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
209 @echo -e "\n\033[1mlinking .o -> .mips: $@\033[0m"
210 mkdir -p build/mips build/res
211 upstream/install/bin/mips-unknown-elf-gcc \
214 -T upstream/mips/org/xwt/mips/linker.ld \
215 -L upstream/mips/build/org/xwt/mips/ \
216 -L upstream/freetype-2.1.4/src/objs \
217 -L upstream/libmspack-20030726/build-mips-unknown-elf/ \
225 ### Maintainer ######################################################################################
228 @echo -n "Please type a one-line description of this bug: "; \
231 echo "Please type any additional comments that explain this patch."; \
232 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
233 echo "When you are done, press control-d on a new line."; \
235 ( echo -e "HELO patcher"; \
236 echo -e "MAIL FROM:$(USER)@xwt.org"; \
237 echo -e "RCPT TO: patches@xwt.org"; \
239 echo -e "From: $(USER)@xwt.org"; \
240 echo -e "To: patches@xwt.org"; \
241 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
248 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
250 current_build := $(shell cat next.build)
251 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
252 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
254 strip_$(target) := upstream/install/$(target)/bin/strip build/$(platform)/$(target_bin) -o
255 strip_JVM := cp build/$(platform)/$(target_bin)
256 install-dist:; $(strip_$(target)) /var/www/master.dist.xwt.org/xwt-$(current_build).$(target_bin_extension).unsigned
258 ifneq ($(shell uname -n),megacz.com)
259 echo "***********************************************************"
260 echo "* This build is $(current_build) *"
261 echo "***********************************************************"
262 cvs commit -m '' > /dev/null # this will fail if we haven't checked-in since the comment is null; we want this.
263 echo -e 'cd /home/xwt/\nrm -rf xwt\n/usr/bin/cvs -d /cvs co xwt\nnohup make -C xwt dist 2>&1 >> .make-dist.out &\n' |\
264 ssh xwt@xwt.org | grep -v "make...:.\(Entering\|Leaving\).directory"
266 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
267 mv next.build- next.build
268 echo -n "Next build will be "; cat next.build
269 cvs update CHANGES; echo -e \n`date +%d-%b`" =========== build $(current_build) ================" >> CHANGES
270 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
272 make install-dist platform=Win32
273 make install-dist platform=Linux
274 make install-dist platform=Solaris
275 make install-dist platform=Darwin
276 make install-dist platform=JVM
277 echo -e "\n\n\n*** DONE ******************************************"