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 $(platform) | 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) -Ibuild/h -Iupstream/jpeg-6b/src/
19 gcj_flags += -fCLASSPATH=build/java
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)
24 gcjh := $(gcc_path)/bin/gcjh
25 as := $(gcc_path)/$(target)/bin/as
26 ar := $(gcc_path)/$(target)/bin/ar
27 ranlib := $(gcc_path)/$(target)/bin/ranlib
28 strip := $(gcc_path)/$(target)/bin/strip
29 jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
33 #############################################################################
36 # The Makefile has been divided into phases; each phase depends on the
37 # previous one. Subphases of the same phase (ie 1a, 1b) are not
38 # interdependent. You can think of the build process as proceeding
39 # through the phases in order, but processing subphases within a given
44 # PHASE 1a: upstream code
45 jpeg_c_sources := jdapimin.c jdapistd.c jcomapi.c jcparam.c jdmaster.c jdinput.c jdmainct.c jdcoefct.c jdpostct.c jdmarker.c
46 jpeg_c_sources += jdhuff.c jdphuff.c jddctmgr.c jidctint.c jidctfst.c jidctflt.c jidctred.c jdsample.c jdcolor.c jdmerge.c
47 jpeg_c_sources += jquant1.c jquant2.c jerror.c jutils.c jmemnobs.c jmemmgr.c
48 jpeg_sources := $(jpeg_c_sources:%.c=upstream/jpeg-6b/src/%.c)
50 make -sC upstream jpeg-6b/src
52 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)
53 freetype_sources += $(patsubst %,upstream/freetype-2.1.4/src/src/%,smooth/smooth.c autohint/autohint.c sfnt/sfnt.c truetype/truetype.c)
55 make -sC upstream freetype-2.1.4/.installed
58 make -sC upstream .jikes
60 $(gcc_path)/bin/$(target)-gcj:
61 make -sC upstream gcc-3.3-$(target)
64 # PHASE 1b: human-written inputs
65 handwritten_java_sources := $(shell find src -name \*.java)
66 handwritten_java_pp_sources := $(shell find src -name \*.java.pp)
67 handwritten_mips_sources := $(shell find src -name \*.mips.c)
68 handwritten_cc_sources := src/org/xwt/plat/$(platform).cc
69 handwritten_c_sources := $(jpeg_sources)
70 handwritten_xwar_sources := $(shell ls src/org/xwt/builtin/*.png src/org/xwt/builtin/*.xwt src/org/xwt/builtin/*.xwf)
73 # PHASE 2: ready-to-compile java files (either symlinked to phase 1a sources or else generated from them)
74 java_sources := $(handwritten_java_sources:src/%.java=build/java/%.java)
75 java_sources += $(handwritten_java_pp_sources:src/%.java.pp=build/java/%.java)
76 java_sources += $(handwritten_mips_sources:src/%.mips.c=build/java/%.java)
77 java_sources += build/java/org/xwt/Builtin.java
78 #java_sources += build/java/org/xwt/imp/Freetype.java
79 $(handwritten_java_sources:src/%.java=build/java/%.java): build/java/%.java: src/%.java
80 @echo "symlinking: $@"
81 @mkdir -p `dirname $@`; \
83 A=`echo $@ | sed 's_[^/]*/_../_g'`; \
89 # PHASE 3: class files
90 class_files := $(java_sources:build/java/%.java=build/class/%.class)
91 $(class_files): build/class/%.class: build/java/%.java upstream/.jikes
92 @echo "compiling .java -> .class: $<"
97 .compile: $(java_sources)
98 @echo "compiling .java -> .class: src/**/*.java"
100 @upstream/.jikes $(java_sources)
103 # PHASE 4: gcj-generated headers
104 java_headers := $(java_sources:build/java/%.java=build/h/%.h)
105 $(java_headers): build/h/%.h: build/class/%.class .compile
106 @echo "extracting .class -> .h: $<"
107 @mkdir -p `dirname $@`
108 @ls `echo $< | sed s/.class\$$//`*.class |\
109 sed s_build/class/__ | sed s/.class\$$//g | sed s_/_._g | (cd build/class; xargs ../../$(gcjh) -d ../h --classpath .)
111 # PHASE 4: object files
112 java_object_files := $(filter-out build/$(platform)/org/xwt/plat/%,$(java_sources:build/java/%=build/$(platform)/%.o))
113 java_object_files += $(patsubst %,build/$(platform)/org/xwt/plat/%.java.o,GCJ $(platform_java_sources))
114 cc_object_files := $(handwritten_cc_sources:src/%.cc=build/$(platform)/%.cc.o)
115 c_object_files := $(handwritten_c_sources:upstream/jpeg-6b/src/%.c=build/$(platform)/jpeg-6b/%.c.o)
116 $(java_object_files): build/$(platform)/%.java.o: build/java/%.java
117 @echo "compiling .java -> .o: $<"
118 @mkdir -p `dirname $@`
120 $(cc_object_files): build/$(platform)/%.cc.o: src/%.cc $(java_headers)
121 @echo "compiling .cc -> .o: $<"
122 @mkdir -p `dirname $@`
123 @$(g++) -I/usr/X11R6/include/ -I$(gcc_path)/include -Ibuild/h -Iupstream/$(platform)/include -Wno-multichar -c $< -o $@
124 $(c_object_files): build/$(platform)/jpeg-6b/%.c.o: upstream/jpeg-6b/src/%.c
125 @echo "compiling .c -> .o: $<"
126 @mkdir -p `dirname $@`
127 @$(gcc) -Ibuild/h -c $< -o $@
130 $(target_bin): $(java_object_files) $(cc_object_files) $(c_object_files)
131 @echo "linking .o -> $(target_bin)"
132 @mkdir -p build/$(platform)
133 @$(gcj) --main=org.xwt.Main -o build/$(platform)/$(target_bin) $^ $(platform_link)
136 ##############################################################################
140 build/java/org/xwt/Builtin.java:: $(handwritten_xwar_sources)
141 @mkdir -p `dirname $@` build build/java build/class build/h build
142 @echo "zipping/uuencoding .xwt -> .java: build/java/org/xwt/Builtin.java"
143 @echo "package org.xwt;" > build/java/org/xwt/Builtin.java
144 @echo "class Builtin {" >> build/java/org/xwt/Builtin.java
145 @echo "public static String encoded = " >> build/java/org/xwt/Builtin.java
146 @cd src; $(jar) cf - $(handwritten_xwar_sources:src/%=%) | \
147 uuencode foo | tail -n +2 | grep -v '^end$$' | grep -v '^`$$' | \
148 sed 's_\(.+\)_"\1" +_' >> ../build/java/org/xwt/Builtin.java
149 @echo "\"\"; }" >> build/java/org/xwt/Builtin.java
151 postprocessed_sources := $(handwritten_java_pp_sources:src/%.pp=build/java/%)
152 $(postprocessed_sources): build/java/%.java: src/%.java.pp build/class/org/xwt/util/Preprocessor.class
153 @echo "preprocessing .java.pp -> .java: $<"
154 @mkdir -p `dirname $@`
156 @java -cp build/class org.xwt.util.Preprocessor < $< > $@
158 build/java/org/xwt/imp/Freetype.java:: build/mips/freetype.mips build/class/org/xwt/imp/MIPS.class
159 @echo "translating .mips -> .java: $@"
160 @mkdir -p build/java/org/xwt/imp/
162 @java -cp build/class org.xwt.imp.MIPS org.xwt.imp.Freetype build/mips/freetype.mips > build/java/org/xwt/imp/Freetype.java
164 build/mips/freetype.mips: $(freetype_mips_objects)
165 @echo "compiling .c -> .mips: $@"
167 @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
168 @$(gcc_path)/bin/mips-gcc \
174 -I upstream/freetype-2.1.4/src/include \
175 $(freetype_sources) \
179 src/org/xwt/imp/Freetype.c \
184 ##############################################################################
185 # Supported Platforms:
188 # compile is here to force compilation of the .class files (they get used via -Ibuild) without
189 # having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
190 gcj: $(gcc_path)/bin/$(target)-gcj compile $(target_bin)
191 @echo -e "\\n=== $(target) ========================================="
194 @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"
197 @make gcj platform=Solaris target=sparc-sun-solaris2.7 platform_link="-L$(gcc_path)/lib -lX11 -lXext" platform_java_sources="POSIX X11"
200 @make gcj platform=Win32 target=i686-pc-mingw32 target_bin=xwt.exe platform_link="-Wl,--subsystem,windows -lcomdlg32" platform_java_sources=Win32
203 @make gcj platform=Carbon arget=powerpc-apple-darwin platform_link="$(gcc_path)/lib/libgcj.a -Xlinker -framework -Xlinker Carbon" platform_java_sources="POSIX Carbon"
205 JVM: build/JVM/xwt.jar
206 build/JVM/xwt.jar:.compile
207 @echo "archiving .class -> .jar: build/JVM/xwt.jar"
209 @echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > build/JVM/.manifest
210 @cd build/class; $(jar) cfm ../JVM/xwt.jar ../JVM/.manifest \
211 `find . -name \*.class | grep -v org/xwt/plat/` \
212 org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class
217 ##############################################################################
222 find . -name \*~ | xargs rm -f
223 find . -name \#\*\# | xargs rm -f
227 ##############################################################################
228 # Maintainer stuff: generating numbered builds, proposing patches
232 cvs tag -F xwt-$(current_build)
233 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
234 mv next.build- next.build
235 echo -n "Next build will be "
239 echo `date +%d-%b`" =========== build $(current_build) ================================================" >> CHANGES
241 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
245 @echo -n "Please type a one-line description of this bug: "; \
248 echo "Please type any additional comments that explain this patch."; \
249 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
250 echo "When you are done, press control-d on a new line."; \
252 ( echo -e "HELO patcher"; \
253 echo -e "MAIL FROM:$(USER)@xwt.org"; \
254 echo -e "RCPT TO: patches@xwt.org"; \
256 echo -e "From: $(USER)@xwt.org"; \
257 echo -e "To: patches@xwt.org"; \
258 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
265 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
267 current_build := $(shell cat next.build)
268 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
269 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
271 # pre-depend on compile as a sanity check
273 # this will fail if we haven't checked-in since the comment is null; we want this.
274 cvs commit -m '' > /dev/null
275 cvs tag -F xwt-$(current_build)
277 echo "***********************************************************"
278 echo "* This build is $(current_build)"
279 echo "***********************************************************"
281 ifeq ($(shell uname -n),serverbeach.megacz.com)
282 (make $(silent) dist-private 2>&1) >> .make-dist.out || \
283 (tail -n 200 .make-dist.out | mail -s "Build $(current_build) FAILED" cvs@xwt.org; false)
284 tail -n 200 .make-dist.out | \
285 mail -s "Unsigned binaries of $(current_build) are now available" cvs@xwt.org
287 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"
291 make $(silent) update-build
293 # preserve gcc across builds so we don't have to remake it
294 mkdir -p $(HOME)/dist.xwt.org-gcc
296 ln -s $(HOME)/dist.xwt.org-gcc gcc
297 mv -f gcc-/Makefile gcc/
298 mv -f gcc-/*.patch gcc/
304 echo === master.dist.xwt.org ==================================
306 echo "copying xwt.jar to distribution area..."
307 cp xwt.jar /var/www/master.dist.xwt.org/xwt-$(current_build).jar.unsigned
309 echo "stripping xwt.exe and copying it to the distribution area..."
310 $(strip) build/Win32/xwt.exe -o /var/www/master.dist.xwt.org/xwt-$(current_build).exe.unsigned
312 echo "copying xwt.linux to distribution area..."
313 $(strip) build/Linux/xwt.linux -o /var/www/master.dist.xwt.org/xwt-$(current_build).linux.unsigned
315 echo "creating source tarball in distribution area..."
316 CVSROOT=/cvs cvs export -r xwt-$(current_build) xwt
317 mv xwt xwt-$(current_build)
318 tar cvzf /var/www/master.dist.xwt.org/xwt-$(current_build).tgz xwt-$(current_build)
321 echo "*** DONE ******************************************"
329 #mips: $(prefix)/mips/lib/libm.a
330 #$(prefix)/mips/lib/libm.a: src/.newlib $(prefix)/bin/mips-gcc
331 # mkdir -p build/$(target)/newlib
332 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH \
333 # ../../../src/newlib-1.11.0/configure --nfp --enable-multilib --prefix=$(prefix) --target=mips
334 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH EXTRA_CFLAGS=-mstrict-align make
335 # cd build/$(target)/newlib; make install
336 # FIXME: this is probably going to cause problems... figure out how to get by without it
338 # $(prefix)/bin/mips-gcc -c .empty.c -o $(prefix)/mips/lib/crt0.o