1 #############################################################################
6 all: JVM Darwin Linux Win32 Solaris
9 Linux: ; make gcj platform=Linux target=i686-pc-linux-gnu link_flags="-lX11 -lXext --static"
10 Solaris: ; make gcj platform=Solaris target=sparc-sun-solaris2.7 link_flags="-lX11 -lXext"
11 Win32: ; make gcj platform=Win32 target=i686-pc-mingw32 link_flags="-Wl,--subsystem,windows -lcomdlg32" target_bin=xwt.exe
12 Darwin: ; make gcj platform=Darwin target=powerpc-apple-darwin link_flags="$(darwin_linker_flags)"
17 darwin_libdir := upstream/install/powerpc-apple-darwin/lib
18 darwin_linker_flags := -Wl,-dylib_file,/usr/lib/libSystem.B.dylib:$(darwin_libdir)/libSystem.B.dylib
19 darwin_linker_flags += -Wl,-dylib_file,/usr/lib/system/libmathCommon.A.dylib:$(darwin_libdir)/libmathCommon.A.dylib
20 darwin_linker_flags += -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:$(darwin_libdir)/libGL.dylib
21 darwin_linker_flags += -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib:$(darwin_libdir)/libGLU.dylib
22 darwin_linker_flags += -lSystem.B -lmathCommon.A -lGL -lGLU
25 #############################################################################
28 target_bin := xwt.$(shell echo $(platform) | tr A-Z a-z)
29 jikes_flags := -nowarn -sourcepath src/
30 gcc_optimizations := -O2
31 #gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls
32 #gcc_optimizations += -finline-functions -funroll-loops -ffunction-sections -fdata-sections
33 gcc_flags := -nostdinc $(gcc_optimizations) -Ibuild/h -Iupstream/jpeg-6b/src/ -Iupstream/jpeg-6b/build-$(target)/
34 gcj_flags := -fCLASSPATH=build/java
35 gcj := upstream/install/bin/$(target)-gcj $(gcc_flags) $(gcj_flags)
36 gcjh := $(shell test -e `pwd`/upstream/install/bin/$(target)-gcjh && echo `pwd`/upstream/install/bin/$(target)-gcjh || echo `pwd`/upstream/install/bin/gcjh)
37 g++ := upstream/install/bin/$(target)-gcj $(gcc_flags)
38 gcc := upstream/install/bin/$(target)-gcc $(gcc_flags)
39 jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
41 include Makefile.upstream
43 # figure out what stuff in org.xwt.plat.* this platform requires (its superclasses)
44 all_java_sources := $(patsubst src/%.java, build/java/%.java, $(shell find src -name '*.java'))
45 all_java_sources += $(patsubst src/%.java.pp, build/java/%.java, $(shell find src -name '*.java.pp'))
47 java_sources := $(all_java_sources)
48 nonplat_java_sources := $(filter-out build/java/org/xwt/plat/%, $(all_java_sources))
49 plat_java_sources := $(filter build/java/org/xwt/plat/%, $(all_java_sources))
51 # FIXME: must have a relitavely new GNU sed... Apple sed fails silently (why?)
52 build/java/%.java: src/%.java ; @echo linking $@; mkdir -p $(@D); ln -s `echo $(@D) | sed 's_[^/]*\(/\|$$\)_../_g'`/$< $@
53 build/cc/%.cc: src/%.c ; @echo linking $@; mkdir -p $(@D); ln -s `echo $(@D) | sed 's_[^/]*\(/\|$$\)_../_g'`/$< $@
54 build/c/jpeg/%.c: upstream/jpeg-6b/src/%.c
55 @echo linking $@; mkdir -p $(@D); ln -s `echo $(@D) | sed 's_[^/]*\(/\|$$\)_../_g'`/$< $@
56 build/res/%: src/% ; @echo linking $@; mkdir -p $(@D); ln -s `echo $(@D) | sed 's_[^/]*\(/\|$$\)_../_g'`/$< $@
58 build/java/%.java: src/%.java.pp
59 make build/class/org/xwt/util/Preprocessor.class
60 @echo -e "\n\033[1mpreprocessing .java.pp -> .java: $<\033[0m"
63 java -cp build/class org.xwt.util.Preprocessor < $< > $@
65 build/class/%.class: build/java/%.java .jikes
66 @echo -e "\n\033[1mcompiling .java -> .class: $<\033[0m"
71 .compile: $(all_java_sources)
72 @echo -e "\n\033[1mcompiling .java -> .class: src/**/*.java\033[0m"
77 # PHASE 4: gcj-generated headers
78 java_headers := $(all_java_sources:build/java/%.java=build/h/%.h)
79 build/h/%.h: build/class/%.class
80 @echo -e "\n\033[1mextracting .class -> .h: $<\033[0m"
82 ls `echo $< | sed s/.class\$$//`*.class |\
83 sed s_build/class/__ | sed s/.class\$$//g | sed s_/_._g | (cd build/class; xargs $(gcjh) -d ../h --classpath .)
85 # a hack since we've disabled gcj's awt implementation
86 build/$(platform)/org/xwt/plat/Java2.java.o:
87 touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
88 build/$(platform)/org/xwt/plat/AWT.java.o:
89 touch .empty.c; mkdir -p $(@D); $(gcc) -c .empty.c -o $@;
91 build/$(platform)/%.java.o: build/java/%.java
92 @echo -e "\n\033[1mcompiling .java -> .o: $<\033[0m"
96 headers: $(java_headers)
98 build/$(platform)/org/xwt/plat/$(platform).cc.o: src/org/xwt/plat/$(platform).cc src/org/xwt/plat/*.cc .configure_jpeg-6b_$(target)
100 @echo -e "\n\033[1mcompiling .cc -> .o: $<\033[0m"
101 mkdir -p `dirname $@`
102 $(g++) -Iupstream/install/lib/gcc-lib/$(target)/3.3/include/ -Iupstream/install/$(target)/include -I/usr/X11R6/include/ -Ibuild/h -Wno-multichar -Iupstream/install/include -c $< -o $@
104 build/$(platform)/jpeg-6b/%.c.o: upstream/jpeg-6b/src/%.c
105 @echo -e "\n\033[1mcompiling .c -> .o: $<\033[0m"
106 mkdir -p `dirname $@`
107 $(gcc) -Ibuild/h -c $< -o $@
111 jpeg_sources := jdapimin.c jdapistd.c jcomapi.c jcparam.c jdmaster.c jdinput.c jdmainct.c jdcoefct.c jdpostct.c jdmarker.c
112 jpeg_sources += jdhuff.c jdphuff.c jddctmgr.c jidctint.c jidctfst.c jidctflt.c jidctred.c jdsample.c jdcolor.c jdmerge.c
113 jpeg_sources += jquant1.c jquant2.c jerror.c jutils.c jmemnobs.c jmemmgr.c
115 upstream/jpeg-6b/build-$(target)/libjpeg.a: .install_jpeg-6b_$(target)
116 java_objects := $(nonplat_java_sources:build/java/%.java=build/$(platform)/%.java.o)
118 build/$(platform)/$(platform).ar: $(java_objects) build/$(platform)/org/xwt/plat/$(platform).cc.o build/$(platform)/org/xwt/builtin.res.o build/$(platform)/freetype.res.o $(plat_java_sources:build/java/%.java=build/$(platform)/%.java.o)
119 @echo -e "\n\033[1marchiving .o -> .a\033[0m"
120 mkdir -p build/$(platform)
121 upstream/install/bin/$(target)-ar rc $@ $?
122 upstream/install/bin/$(target)-ranlib $@
124 $(target_bin): build/$(platform)/$(platform).ar upstream/jpeg-6b/build-$(target)/libjpeg.a
125 @echo -e "\n\033[1mlinking .o -> $(target_bin)\033[0m"
126 mkdir -p build/$(platform)
127 PATH=upstream/install/bin:$$PATH $(gcj) -v --main=org.xwt.Main -o build/$(platform)/$(target_bin) -Lupstream/install/$(target)/lib $(link_flags) $^ build/$(platform)/org/xwt/plat/$(platform).java.o
130 ##############################################################################
134 builtin_src := $(find src/org/xwt/builtin)
135 build/res/resources.jar: $(builtin_src:src/%=build/res/%) build/res/freetype.mips
136 @echo -e "\n\033[1mzipping res/* -> .jar: builtin.jar\033[0m"
137 cd build/res; $(jar) cf builtin.jar $(^:build/res/%=%)
139 build/$(platform)/builtin.o: build/res/builtin.jar
140 @echo -e "\n\033[1mwrapping .jar -> .o: resources.o\033[0m"
141 @(echo "unsigned int builtin_length = "; \
142 (wc -c build/res/builtin.jar | sed "s_build.*__"); \
144 echo "unsigned char builtin_bytes[] = {"; \
145 hexdump -ve '"0x" 1/1 "%x,\n"' build/res/builtin.jar; \
146 echo "};") > .builtin.c
147 $(gcc) -c .builtin.c -o build/$(platform)/builtin.o
149 # compile is here to force compilation of the .class files (they get used via -Ibuild) without
150 # having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
151 gcj: .vendor .install_gcc-3.3_$(target) $(target_bin)
153 build/JVM/xwt.jar: $(java_sources:build/java/%.java=build/class/%.class)
154 @echo -e "\n\033[1marchiving .class -> .jar: build/JVM/xwt.jar\033[0m"
156 echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > build/JVM/.manifest
157 cd build/class; $(jar) cfm ../JVM/xwt.jar ../JVM/.manifest `find .`;
161 ##############################################################################
165 build/mips/%.c.o: src/%.c
166 make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
168 echo -e "\n\033[1mcompiling $< -> $@ (mips)\033[0m"
169 upstream/install/bin/mips-unknown-elf-gcc -march=r3000 -I upstream/freetype-2.1.4/src/include -c -o $@ $<
171 build/res/freetype.mips: build/mips/org/xwt/translators/Freetype.c.o build/mips/org/xwt/mips/crt0.c.o build/mips/org/xwt/mips/syscalls.c.o
172 make .install_freetype-2.1.4_mips-unknown-elf target=mips-unknown-elf
173 @echo -e "\n\033[1mlinking .o -> .mips: $@\033[0m"
175 upstream/install/bin/mips-unknown-elf-gcc \
179 -T src/org/xwt/mips/linker.ld \
181 -Lupstream/freetype-2.1.4/src/objs \
183 build/mips/org/xwt/translators/Freetype.c.o \
190 ##############################################################################
191 # Maintainer stuff: generating numbered builds, proposing patches
195 cvs tag -F xwt-$(current_build)
196 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
197 mv next.build- next.build
198 echo -n "Next build will be "
202 echo `date +%d-%b`" =========== build $(current_build) ================================================" >> CHANGES
204 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
208 @echo -n "Please type a one-line description of this bug: "; \
211 echo "Please type any additional comments that explain this patch."; \
212 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
213 echo "When you are done, press control-d on a new line."; \
215 ( echo -e "HELO patcher"; \
216 echo -e "MAIL FROM:$(USER)@xwt.org"; \
217 echo -e "RCPT TO: patches@xwt.org"; \
219 echo -e "From: $(USER)@xwt.org"; \
220 echo -e "To: patches@xwt.org"; \
221 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
228 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
230 current_build := $(shell cat next.build)
231 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
232 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
234 # pre-depend on compile as a sanity check
236 # this will fail if we haven't checked-in since the comment is null; we want this.
237 cvs commit -m '' > /dev/null
238 cvs tag -F xwt-$(current_build)
240 echo "***********************************************************"
241 echo "* This build is $(current_build)"
242 echo "***********************************************************"
244 ifeq ($(shell uname -n),serverbeach.megacz.com)
245 (make $(silent) dist-private 2>&1) >> .make-dist.out || \
246 (tail -n 200 .make-dist.out | mail -s "Build $(current_build) FAILED" cvs@xwt.org; false)
247 tail -n 200 .make-dist.out | \
248 mail -s "Unsigned binaries of $(current_build) are now available" cvs@xwt.org
250 echo -e 'export JAVA_HOME=/usr/lib/j2sdk1.4\n cd /home/xwt\n date=`date +%d-%b-%H%M`\n mkdir xwt-$$date\n cd xwt-$$date\n /usr/bin/cvs -d /cvs co $(this_branch_flag) xwt\n mv xwt/* .\n mv xwt/.* .\n rmdir xwt\n touch .make-dist.out\n nohup make dist &> /dev/null &\n echo\n cat .make-dist.out' | ssh xwt@xwt.org | grep -v "make...:.\(Entering\|Leaving\).directory"
254 make $(silent) update-build
256 # preserve gcc across builds so we don't have to remake it
257 mkdir -p $(HOME)/dist.xwt.org-gcc
259 ln -s $(HOME)/dist.xwt.org-gcc gcc
260 mv -f gcc-/Makefile gcc/
261 mv -f gcc-/*.patch gcc/
267 echo === master.dist.xwt.org ==================================
269 echo "copying xwt.jar to distribution area..."
270 cp xwt.jar /var/www/master.dist.xwt.org/xwt-$(current_build).jar.unsigned
272 echo "stripping xwt.exe and copying it to the distribution area..."
273 $(strip) build/Win32/xwt.exe -o /var/www/master.dist.xwt.org/xwt-$(current_build).exe.unsigned
275 echo "copying xwt.linux to distribution area..."
276 $(strip) build/Linux/xwt.linux -o /var/www/master.dist.xwt.org/xwt-$(current_build).linux.unsigned
278 echo "creating source tarball in distribution area..."
279 CVSROOT=/cvs cvs export -r xwt-$(current_build) xwt
280 mv xwt xwt-$(current_build)
281 tar cvzf /var/www/master.dist.xwt.org/xwt-$(current_build).tgz xwt-$(current_build)
284 echo "*** DONE ******************************************"