1 #############################################################################
7 all: JVM Linux Win32 Darwin Solaris
11 rm -rf .jikes .configure* .install* build .compile .build*
12 find upstream -name config.cache -exec rm {} \;
13 test -e upstream/mips && make -C upstream/mips clean
15 JVM: build/JVM/xwt.jar
16 Linux: ; make gcj platform=Linux link_flags="-lX11 -lXext"
17 Solaris: ; make gcj platform=Solaris link_flags="-lX11 -lXext -lpthread"
18 Win32: ; make gcj platform=Win32 link_flags="-Wl,--subsystem,windows -lcomdlg32"
19 Darwin: ; make gcj platform=Darwin link_flags="$(darwin_linker_flags)"
24 darwin_libdir := upstream/install/powerpc-apple-darwin/lib
25 darwin_linker_flags := -Wl,-dylib_file,/usr/lib/libSystem.B.dylib:$(darwin_libdir)/libSystem.B.dylib
26 darwin_linker_flags += -Wl,-dylib_file,/usr/lib/system/libmathCommon.A.dylib:$(darwin_libdir)/libmathCommon.A.dylib
27 darwin_ogl_libdir := /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries
28 darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir)/libGL.dylib:$(darwin_libdir)/libGL.dylib
29 darwin_linker_flags += -Wl,-dylib_file,$(darwin_ogl_libdir):$(darwin_libdir)/libGLU.dylib
30 darwin_linker_flags += -lSystem.B -lmathCommon.A -lGL -lGLU
32 target_bin_extension_$(platform) := (shell echo $(platform) | tr A-Z a-z)
33 target_bin_extension_Win32 := exe
34 target_bin_extension_JVM := jar
35 target_bin_extension := target_bin_extension_$(target)
36 target_bin := xwt.$(target_bin_extension)
38 jikes_flags := -nowarn -sourcepath src/
39 gcc_optimizations := -O2
40 #gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls
41 #gcc_optimizations += -finline-functions -funroll-loops -ffunction-sections -fdata-sections
43 gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src/ -Iupstream/jpeg-6b/build-$(target)/
44 gcj_flags := -fCLASSPATH=build/java
45 g++_flags := -Iupstream/install/lib/gcc-lib/$(target)/3.3/include/ -Iupstream/install/$(target)/include -Wno-multichar
46 gcj := upstream/install/bin/$(target)-gcj $(gcc_flags) $(gcj_flags)
47 gcjh := $(shell pwd)/upstream/install/bin/$(shell test -e upstream/install/bin/$(target)-gcjh && echo $(target)-)gcjh
48 g++ := upstream/install/bin/$(target)-gcj $(gcc_flags)
49 gcc := upstream/install/bin/$(target)-gcc $(gcc_flags) $(g++_flags)
50 jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
52 target_Darwin := powerpc-apple-darwin
53 target_Win32 := i686-pc-mingw32
54 target_Solaris := sparc-sun-solaris2.7
55 target_Linux := i686-pc-linux-gnu
56 target := $(target_$(platform))
58 gcj: .install_gcc-3.3_$(target); make $(target_bin) link_flags="$(link_flags)" platform=$(platform)
60 include Makefile.upstream
62 java_sources := $(patsubst src/%.java, build/java/%.java, $(shell find src -name '*.java' | grep -v Preprocessor))
65 ### Java Class Files ##############################################################################
67 build/class/org/xwt/translators/MIPSApps.class: build/mips/mipsapps.mips .jikes
68 mkdir -p build/java/org/xwt/translators
69 @echo -e "\n\033[1mtranslating .mips -> .java: $<\033[0m"
70 (echo -e 'package org.xwt.translators;\nimport org.xwt.mips.*;\n'; \
71 java -Xint -cp upstream/mips/build org.xwt.mips.Compiler MIPSApps build/mips/mipsapps.mips) \
72 | sed 's,//.*$$,,;'| tr -d '\n') > build/java/org/xwt/translators/MIPSApps.java
73 @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
74 ./.jikes -g:none build/java/org/xwt/translators/MIPSApps.java
76 build/java/org/xwt/%.java: src/org/xwt/%.java
77 make build/class/org/xwt/util/Preprocessor.class
78 @echo -e "\n\033[1mpreprocessing .java -> .java: $<\033[0m"
79 mkdir -p `dirname $@`; java -cp build/class org.xwt.util.Preprocessor < $< > $@
81 build/java/%.java: src/%.java ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
82 build/cc/%.cc: src/%.c ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
83 build/res/%: src/% ; @echo linking $@; mkdir -p $(@D); ln -fs `echo $(@D)/ | sed 's_[^/]*//*_../_g'`/$< $@
85 build/class/org/xwt/util/Preprocessor.class: src/org/xwt/util/Preprocessor.java .jikes
86 @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
87 mkdir -p build/class/org/xwt/util/
90 oldcompile:; CLASSPATH=$$CLASSPATH:lib/libgcj-minimal.jar:upstream/mips/build javac -d build/class `find build/java/ -name \*.java`
92 .compile: $(java_sources) .jikes
93 @echo -e "\n\033[1mcompiling .java -> .class: src/**/*.java\033[0m"
94 @rm -f $(java_sources:build/java/%.java=build/class/%.class)
96 @./.jikes $(java_sources)
99 build/JVM/xwt.jar: .compile build/res/builtin.jar
100 @echo -e "\n\033[1marchiving .class -> .jar: build/JVM/xwt.jar\033[0m"
102 echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > build/JVM/.manifest
103 cd build/class/org/xwt; ln -sf ../../../res/builtin.jar
104 cd build/class; $(jar) cfm ../JVM/xwt.jar ../JVM/.manifest \
105 `find . \! -type d \! -path './org/xwt/mips/*'` \
106 $(patsubst %,../../upstream/mips/build/org/xwt/mips/%*.class, Runtime Registers Syscalls Errno)
109 ### GCJH Headers ##############################################################################
111 java_headers := $(java_sources:build/java/%.java=build/h/%.h)
112 build/h/edu/stanford/ejalbert/BrowserLauncher.h:; mkdir -p $(@D); touch $@
113 build/h/%.h: build/class/%.class .compile
114 @echo -e "\n\033[1mextracting .class -> .h: $<\033[0m"
115 mkdir -p `dirname $@`
116 ls `echo $< | sed s/.class\$$//`*.class |\
117 sed s_build/class/__ | sed s/.class\$$//g | sed s_/_._g | (cd build/class; xargs $(gcjh) -d ../h --classpath .)
120 ### Native Code ##############################################################################
122 # a hack since we've disabled gcj's awt implementation
123 build/$(platform)/org/xwt/plat/Java2.java.o: ; touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
124 build/$(platform)/org/xwt/plat/AWT.java.o: ; touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
126 build/$(platform)/org/xwt/translators/MIPSApps.java.o: build/class/org/xwt/translators/MIPSApps.class
127 @echo -e "\n\033[1mcompiling .class -> .o: $<\033[0m"
128 mkdir -p `dirname $@`
129 $(gcj) -Os -c $< -o $@
131 build/$(platform)/%.java.o: build/java/%.java
132 @echo -e "\n\033[1mcompiling .java -> .o: $<\033[0m"
133 mkdir -p `dirname $@`
136 build/$(platform)/org/xwt/plat/$(platform).cc.o: src/org/xwt/plat/$(platform).cc src/org/xwt/plat/*.cc .configure_jpeg-6b_$(target)
137 @make $(java_headers)
138 @echo -e "\n\033[1mcompiling .cc -> .o: $<\033[0m"
139 mkdir -p `dirname $@`
142 build/$(platform)/$(platform).ar: $(java_sources:build/java/%.java=build/$(platform)/%.java.o)
143 @echo -e "\n\033[1marchiving .o -> .a\033[0m"
144 mkdir -p build/$(platform)
146 upstream/install/$(target)/bin/ar rc $@ $^
147 upstream/install/$(target)/bin/ranlib $@
149 upstream/jpeg-6b/build-$(target)/libjpeg.a: .install_jpeg-6b_$(target)
150 $(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
151 @echo -e "\n\033[1mlinking .o -> $(target_bin)\033[0m"
152 mkdir -p build/$(platform)
153 PATH=upstream/install/bin:$$PATH $(gcj) -v --main=org.xwt.Main -o $@ -Lupstream/install/$(target)/lib build/$(platform)/org/xwt/plat/$(platform).java.o $^ $(link_flags)
156 ### Builtin Resources ##############################################################################
158 builtin_src := $(shell find src/org/xwt/builtin -name '*.*' \! -name '*.xcf')
159 build/res/fonts/vera: .download_vera-1.10
160 mkdir -p build/res/fonts/vera
161 cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/Vera.ttf
162 cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraMono.ttf
163 cd build/res/fonts/vera; ln -s ../../../../upstream/vera-1.10/ttf-bitstream-vera-1.10/VeraSe.ttf
164 build/res/builtin.jar: $(builtin_src:src/%=build/res/%) build/res/fonts/vera
165 @echo -e "\n\033[1mzipping res/* -> .jar: builtin.jar\033[0m"
166 cd build/res; $(jar) cf builtin.jar $(^:build/res/%=%)
167 build/$(platform)/builtin.o: build/res/builtin.jar
168 @echo -e "\n\033[1mwrapping .jar -> .o: resources.o\033[0m"
169 @(echo "unsigned int builtin_length = "; \
170 (wc -c build/res/builtin.jar | sed "s_build.*__"); \
172 echo "unsigned char builtin_bytes[] = {"; \
173 hexdump -ve '"0x" 1/1 "%x,\n"' build/res/builtin.jar; \
174 echo "};") > .builtin.c
175 $(gcc) -c .builtin.c -o build/$(platform)/builtin.o
178 build/mips/%.c.o: src/%.c .download_libmspack-20030726
179 make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
180 make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
182 echo -e "\n\033[1mcompiling $< -> $@ (mips)\033[0m"
183 upstream/install/bin/mips-unknown-elf-gcc -march=r3000 \
184 -Iupstream/freetype-2.1.4/src/include \
185 -Iupstream/libmspack-20030726/src/mspack \
188 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
189 make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
190 make .install_libmspack-20030726_mips-unknown-elf target=mips-unknown-elf
191 @echo -e "\n\033[1mlinking .o -> .mips: $@\033[0m"
192 mkdir -p build/mips build/res
193 upstream/install/bin/mips-unknown-elf-gcc \
196 -T upstream/mips/org/xwt/mips/linker.ld \
197 -L upstream/mips/build/org/xwt/mips/ \
198 -L upstream/freetype-2.1.4/src/objs \
199 -L upstream/libmspack-20030726/build-mips-unknown-elf/ \
207 ### Maintainer ######################################################################################
210 @echo -n "Please type a one-line description of this bug: "; \
213 echo "Please type any additional comments that explain this patch."; \
214 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
215 echo "When you are done, press control-d on a new line."; \
217 ( echo -e "HELO patcher"; \
218 echo -e "MAIL FROM:$(USER)@xwt.org"; \
219 echo -e "RCPT TO: patches@xwt.org"; \
221 echo -e "From: $(USER)@xwt.org"; \
222 echo -e "To: patches@xwt.org"; \
223 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
230 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
232 current_build := $(shell cat next.build)
233 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
234 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
236 strip_$(target) := upstream/install/$(target)/bin/strip build/$(platform)/$(target_bin) -o
237 strip_JVM := cp build/$(platform)/$(target_bin)
238 install-dist:; $(strip_$(target)) /var/www/master.dist.xwt.org/xwt-$(current_build).$(target_bin_extension).unsigned
240 ifneq ($(shell uname -n),megacz.com)
241 echo "***********************************************************"
242 echo "* This build is $(current_build) *"
243 echo "***********************************************************"
244 cvs commit -m '' > /dev/null # this will fail if we haven't checked-in since the comment is null; we want this.
245 echo -e 'cd /home/xwt/\nrm -rf xwt\n/usr/bin/cvs co xwt\nnohup make -C xwt dist 2>&1 >> .make-dist.out &\n' |\
246 ssh xwt@xwt.org | grep -v "make...:.\(Entering\|Leaving\).directory"
248 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
249 mv next.build- next.build
250 echo -n "Next build will be "; cat next.build
251 cvs update CHANGES; echo -e \n`date +%d-%b`" =========== build $(current_build) ================" >> CHANGES
252 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
254 make install-dist platform=Win32
255 make install-dist platform=Linux
256 make install-dist platform=Solaris
257 make install-dist platform=Darwin
258 make install-dist platform=JVM
259 echo -e "\n\n\n*** DONE ******************************************"