1 #############################################################################
6 all: JVM Linux Win32 Java2 #Solaris
7 .SILENT: $(cc_objects) $(java_objects) $(java_headers) all build/xwar/builtin.xwar $(target_bin) compile
10 #############################################################################
13 target_bin := xwt.$(shell echo $(target) | tr A-Z a-z)
14 jikes_flags := -verbose -nowarn -sourcepath src/
15 gcc_path := upstream/install
16 gcc_optimizations := -O2
17 #gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls -finline-functions -funroll-loops -ffunction-sections -fdata-sections
18 gcc_flags := $(gcc_optimizations)
19 gcj_flags := -fCLASSPATH=src
20 gcj := $(gcc_path)/bin/$(target)-gcj $(gcc_flags) $(gcj_flags)
21 g++ := $(gcc_path)/bin/$(target)-g++ $(gcc_flags)
22 gcc := $(gcc_path)/bin/$(target)-gcc $(gcc_flags)
23 gcjh := $(gcc_path)/bin/$(target)-gcjh
24 as := $(gcc_path)/$(target)/bin/as
25 ar := $(gcc_path)/$(target)/bin/ar
26 ranlib := $(gcc_path)/$(target)/bin/ranlib
27 strip := $(gcc_path)/$(target)/bin/strip
28 jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
32 #############################################################################
35 # The Makefile has been divided into phases; each phase depends on the
36 # previous one. Subphases of the same phase (ie 1a, 1b) are not
37 # interdependent. You can think of the build process as proceeding
38 # through the phases in order, but processing subphases within a given
43 # PHASE 1a: human-written inputs
44 handwritten_java_sources := $(shell find src -name \*.java)
45 handwritten_java_pp_sources := $(shell find src -name \*.java.pp)
46 handwritten_mips_sources := $(shell find src -name \*.mips.c)
47 handwritten_cc_sources := src/org/xwt/plat/$(platform).cc
48 handwritten_c_sources := $(jpeg_c_sources:%.c=src/org/ijg/%.c)
49 handwritten_xwar_sources := $(shell ls src/org/xwt/builtin/*.png src/org/xwt/builtin/*.xwt src/org/xwt/builtin/*.xwf)
52 # PHASE 1b: upstream code
53 jpeg_c_sources := jdapimin.c jdapistd.c jcomapi.c jcparam.c jdmaster.c jdinput.c jdmainct.c jdcoefct.c jdpostct.c jdmarker.c
54 jpeg_c_sources += jdhuff.c jdphuff.c jddctmgr.c jidctint.c jidctfst.c jidctflt.c jidctred.c jdsample.c jdcolor.c jdmerge.c
55 jpeg_c_sources += jquant1.c jquant2.c jerror.c jutils.c jmemnobs.c jmemmgr.c
56 jpeg_sources := $(jpeg_c_sources:%.c=upstream/jpeg-6b/src/%.c)
58 make -sC upstream jpeg-6b/.installed
60 freetype_sources := $(patsubst %,upstream/freetype-2.1.4/src/src/base/%,ftsystem.c ftmm.c ftbbox.c ftinit.c ftdebug.c ftbase.c ftglyph.c)
61 freetype_sources += $(patsubst %,upstream/freetype-2.1.4/src/src/%,smooth/smooth.c autohint/autohint.c sfnt/sfnt.c truetype/truetype.c)
63 make -sC upstream freetype-2.1.4/.installed
66 make -sC upstream .jikes
68 $(gcc_path)/bin/$(target)-gcj:
69 make -sC upstream gcc-3.3-$(target)
72 # PHASE 2: ready-to-compile java files (either symlinked to phase 1a sources or else generated from them)
73 java_sources := $(handwritten_java_sources:src/%.java=build/java/%.java)
74 java_sources += $(handwritten_java_pp_sources:src/%.java.pp=build/java/%.java)
75 java_sources += $(handwritten_mips_sources:src/%.mips.c=build/java/%.java)
76 java_sources += build/java/org/xwt/Builtin.java
77 $(handwritten_java_sources:src/%.java=build/java/%.java): build/java/%.java: src/%.java
78 @echo "symlinking : $<"
79 @mkdir -p `dirname $@`; \
81 A=`echo $@ | sed 's_[^/]*/_../_g'`; \
87 # PHASE 3: class files
88 class_files := $(java_sources:build/java/%.java=build/class/%.class)
89 class_files += build/class/org/xwt/imp/Freetype.class
91 $(class_files): build/class/%.class: build/java/%.java upstream/.jikes
92 @echo "compiling .java -> .class: $<"
96 compile: $(java_sources)
97 @echo "compiling .java -> .class: src/**/*.java"
99 @upstream/.jikes $(java_sources)
101 # PHASE 4: gcj-generated headers
102 java_headers := $(build_java_sources:build/java/%.java=build/h/%.h)
103 $(java_headers): build/h/%.h: build/%.class
104 @echo "extracting .class -> .h: $<"
105 cd build; find `echo $< | sed s/.class$$// | sed s_^build/__ `*.class |\
106 sed s_/_._g | sed s/.class$$// | sed s/.java$$// |\
107 xargs $(gcjh) --classpath .
109 # PHASE 4: object files
110 java_object_files := $(filter-out build/$(platform)/org/xwt/plat/%, $(java_sources:src/%.java=build/$(platform)/%.java.o))
111 java_object_files += $(pathsubst %,build/$(platform)/org/xwt/plat/%.java.o,GCJ $(platform_java_sources))
112 java_object_files += build/$(platform)/org/xwt/imp/Freetype.java.o
113 cc_object_files := $(handwritten_cc_sources:src/%.cc=build/$(platform)/%.cc.o)
114 c_object_files := $(handwritten_c_sources:src/%.c=build/$(platform)/%.c.o)
115 $(java_objects): build/$(platform)/%.java.o: build/java/%.java
116 @echo "compiling .java -> .o: $<"
117 @mkdir -p `dirname $@`
119 $(cc_object_files): build/$(platform)/%.cc.o: src/%.cc $(java_headers) src/org/ijg/jmorecfg.h
120 @echo "compiling .cc -> .o: $<"
121 @mkdir -p `dirname $@`
122 $(g++) -I/usr/X11R6/include/ -I$(gcc_path)/include -Ibuild/h -Iupstream/$(platform)/include -Wno-multichar -c $< -o $@
123 $(c_object_files): build/$(platform)/%.c.o: src/%.c src/org/ijg/jmorecfg.h
124 @echo "compiling .c -> .o: $<"
125 @mkdir -p `dirname $@`
126 $(gcc) -Ibuild/h -c $< -o $@
129 $(target_bin): $(objects)
130 @echo "linking .o -> $(target_bin)"
131 $(gcj) --main=org.xwt.Main -o build/$(platform)/$(target_bin) $^ $(platform_link)
134 ##############################################################################
138 build/java/org/xwt/Builtin.java:: $(handwritten_xwar_sources)
139 @mkdir -p `dirname $@` build build/java build/class build/h build
140 @echo "zipping/uuencoding .xwt -> .java: build/java/org/xwt/Builtin.java"
141 @echo "package org.xwt;" > build/java/org/xwt/Builtin.java
142 @echo "class Builtin {" >> build/java/org/xwt/Builtin.java
143 @echo "public static String encoded = " >> build/java/org/xwt/Builtin.java
144 @cd src; $(jar) cf - $(handwritten_xwar_sources:src/%=%) | \
145 uuencode foo | tail -n +2 | grep -v '^end$$' | grep -v '^`$$' | \
146 sed 's_\(.+\)_"\1" +_' >> ../build/java/org/xwt/Builtin.java
147 @echo "\"\"; }" >> build/java/org/xwt/Builtin.java
149 postprocessed_sources := $(handwritten_java_pp_sources:src/%.pp=build/java/%)
150 $(postprocessed_sources): build/java/%.java: src/%.java.pp build/class/org/xwt/util/Preprocessor.class
151 @echo "preprocessing .java.pp -> .java: $<"
152 @mkdir -p `dirname $@`
154 @java -cp build/class org.xwt.util.Preprocessor < $< > $@
156 build/java/org/xwt/imp/Freetype.java:: build/mips/freetype.mips build/class/org/xwt/imp/MIPS.class
157 @echo "translating .mips -> .java: $@"
158 @mkdir -p build/java/org/xwt/imp/
160 @java -cp build/class org.xwt.imp.MIPS org.xwt.imp.Freetype build/mips/freetype.mips > build/java/org/xwt/imp/Freetype.java
162 build/mips/freetype.mips: $(freetype_mips_objects)
163 @echo "compiling .c -> .mips: $@"
165 @make -sC upstream newlib-1.11.0/src newlib-1.11.0/build-mips/.installed gcc-3.3-mips freetype-2.1.4/src .headers target=mips
166 @$(gcc_path)/bin/mips-gcc \
172 -I upstream/freetype-2.1.4/src/include \
173 $(freetype_sources) \
177 src/org/xwt/imp/Freetype.c \
182 ##############################################################################
183 # Supported Platforms:
186 # compile is here to force compilation of the .class files (they get used via -Ibuild) without
187 # having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
188 gcj: $(gcc_path)/bin/$(target)-gcj compile $(target_bin)
189 @echo -e "\\n=== $(target) ========================================="
192 @make gcj platform=Linux target=i686-pc-linux-gnu platform_link="-L$(gcc_path)/lib -L/usr/X11R6/lib -lX11 -lXext --static" platform_java_sources="POSIX X11"
195 @make gcj platform=Solaris target=sparc-sun-solaris2.7 platform_link="-L$(gcc_path)/lib -lX11 -lXext" platform_java_sources="POSIX X11"
198 @make gcj platform=Win32 target=i686-pc-mingw32 target_bin=xwt.exe platform_link="-Wl,--subsystem,windows -lcomdlg32" platform_java_sources=Win32
201 @make gcj platform=Carbon arget=powerpc-apple-darwin platform_link="$(gcc_path)/lib/libgcj.a -Xlinker -framework -Xlinker Carbon" platform_java_sources="POSIX Carbon"
204 @echo -e "\\n=== JVM ========================================="
205 @echo "archiving .class -> .jar: build/JVM/xwt.jar"
207 @echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > build/JVM/.manifest
208 @cd build/class; $(jar) cvfm ../JVM/xwt.jar ../JVM/.manifest \
209 `find . -name \*.class | grep -v org/xwt/plat/` \
210 org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class | tr \\012 \\015 | \
216 ##############################################################################
221 find . -name \*~ | xargs rm -f
222 find . -name \#\*\# | xargs rm -f
226 ##############################################################################
227 # Maintainer stuff: generating numbered builds, proposing patches
231 cvs tag -F xwt-$(current_build)
232 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
233 mv next.build- next.build
234 echo -n "Next build will be "
238 echo `date +%d-%b`" =========== build $(current_build) ================================================" >> CHANGES
240 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
244 @echo -n "Please type a one-line description of this bug: "; \
247 echo "Please type any additional comments that explain this patch."; \
248 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
249 echo "When you are done, press control-d on a new line."; \
251 ( echo -e "HELO patcher"; \
252 echo -e "MAIL FROM:$(USER)@xwt.org"; \
253 echo -e "RCPT TO: patches@xwt.org"; \
255 echo -e "From: $(USER)@xwt.org"; \
256 echo -e "To: patches@xwt.org"; \
257 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
264 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
266 current_build := $(shell cat next.build)
267 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
268 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
270 # pre-depend on compile as a sanity check
272 # this will fail if we haven't checked-in since the comment is null; we want this.
273 cvs commit -m '' > /dev/null
274 cvs tag -F xwt-$(current_build)
276 echo "***********************************************************"
277 echo "* This build is $(current_build)"
278 echo "***********************************************************"
280 ifeq ($(shell uname -n),serverbeach.megacz.com)
281 (make $(silent) dist-private 2>&1) >> .make-dist.out || \
282 (tail -n 200 .make-dist.out | mail -s "Build $(current_build) FAILED" cvs@xwt.org; false)
283 tail -n 200 .make-dist.out | \
284 mail -s "Unsigned binaries of $(current_build) are now available" cvs@xwt.org
286 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"
290 make $(silent) update-build
292 # preserve gcc across builds so we don't have to remake it
293 mkdir -p $(HOME)/dist.xwt.org-gcc
295 ln -s $(HOME)/dist.xwt.org-gcc gcc
296 mv -f gcc-/Makefile gcc/
297 mv -f gcc-/*.patch gcc/
303 echo === master.dist.xwt.org ==================================
305 echo "copying xwt.jar to distribution area..."
306 cp xwt.jar /var/www/master.dist.xwt.org/xwt-$(current_build).jar.unsigned
308 echo "stripping xwt.exe and copying it to the distribution area..."
309 $(strip) build/Win32/xwt.exe -o /var/www/master.dist.xwt.org/xwt-$(current_build).exe.unsigned
311 echo "copying xwt.linux to distribution area..."
312 $(strip) build/Linux/xwt.linux -o /var/www/master.dist.xwt.org/xwt-$(current_build).linux.unsigned
314 echo "creating source tarball in distribution area..."
315 CVSROOT=/cvs cvs export -r xwt-$(current_build) xwt
316 mv xwt xwt-$(current_build)
317 tar cvzf /var/www/master.dist.xwt.org/xwt-$(current_build).tgz xwt-$(current_build)
320 echo "*** DONE ******************************************"
328 #mips: $(prefix)/mips/lib/libm.a
329 #$(prefix)/mips/lib/libm.a: src/.newlib $(prefix)/bin/mips-gcc
330 # mkdir -p build/$(target)/newlib
331 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH \
332 # ../../../src/newlib-1.11.0/configure --nfp --enable-multilib --prefix=$(prefix) --target=mips
333 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH EXTRA_CFLAGS=-mstrict-align make
334 # cd build/$(target)/newlib; make install
335 # FIXME: this is probably going to cause problems... figure out how to get by without it
337 # $(prefix)/bin/mips-gcc -c .empty.c -o $(prefix)/mips/lib/crt0.o