1 #############################################################################
6 all: 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/prefix
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 := $(find src -name \*.java)
45 handwritten_java_pp_sources := $(find src -name \*.java.pp)
46 handwritten_mips_sources := $(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/%.c)
58 make -C upstream .jpeg-6b
60 freetype_sources := $(patsubst %,upstream/freetype-2.1.4/base/%,ftsystem.c ftmm.c ftbbox.c ftinit.c ftdebug.c ftbase.c ftglyph.c)
61 freetype_sources += $(patsubst %,upstream/freetype-2.1.4/%,smooth/smooth.c autohint/autohint.c sfnt/sfnt.c truetype/truetype.c)
62 $(freetype_sources): upstream/.freetype-2.1.4a
63 make -C upstream .freetype-2.1.4
66 make -C upstream .jikes
68 $(gcc_path)/bin/$(target)-gcj:
69 make -C upstream .gcc-$(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 build/java/%.java: src/%.java
79 A=`echo $@ | sed 's_[^/]*/_../_g'`; \
85 # PHASE 3: class files
86 class_files := $(java_sources:build/java/%.java=build/class/%.class)
87 class_files += build/class/org/xwt/imp/Freetype.class
88 build/%.class: build/java/%.java src/%.java upstream/.jikes mkdir_build
89 @$(shell cat upstream/.jikes) -classpath lib/libgcj-minimal.jar $< -d build/ 2>&1 | \
90 grep -v ^\\[read | sed s_^\\[write\ build/__ | sed s_.class\\]_.java_ | sed "s_^_compiling .java -> .class: src/_"
93 # PHASE 4: gcj-generated headers
94 java_headers := $(build_java_sources:build/java/%.java=build/h/%.h)
95 $(java_headers): build/h/%.h: build/%.class
96 @echo "extracting .class -> .h: $<"
97 cd build; find `echo $< | sed s/.class$$// | sed s_^build/__ `*.class |\
98 sed s_/_._g | sed s/.class$$// | sed s/.java$$// |\
99 xargs $(gcjh) --classpath .
101 # PHASE 4: object files
102 java_object_files := $(filter-out build/$(platform)/org/xwt/plat/%, $(java_sources:src/%.java=build/$(platform)/%.java.o))
103 java_object_files += $(pathsubst %,build/$(platform)/org/xwt/plat/%.java.o,GCJ $(platform_java_sources))
104 java_object_files += build/$(platform)/org/xwt/imp/Freetype.java.o
105 cc_object_files := $(handwritten_cc_sources:src/%.cc=build/$(platform)/%.cc.o)
106 c_object_files := $(handwritten_c_sources:src/%.c=build/$(platform)/%.c.o)
107 $(java_objects): build/$(platform)/%.java.o: src/%.java
108 @echo "compiling .java -> .o: $<"
109 mkdir -p `dirname $@`
111 $(cc_object_files): build/$(platform)/%.cc.o: src/%.cc $(java_headers) src/org/ijg/jmorecfg.h
112 @echo "compiling .cc -> .o: $<"
113 @mkdir -p `dirname $@`
114 $(g++) -I/usr/X11R6/include/ -I$(gcc_path)/include -Ibuild/h -Iupstream/$(platform)/include -Wno-multichar -c $< -o $@
115 $(c_object_files): build/$(platform)/%.c.o: src/%.c src/org/ijg/jmorecfg.h
116 @echo "compiling .c -> .o: $<"
117 @mkdir -p `dirname $@`
118 $(gcc) -Ibuild/h -c $< -o $@
121 $(target_bin): $(objects)
122 @echo "linking .o -> $(target_bin)"
123 $(gcj) --main=org.xwt.Main -o build/$(platform)/$(target_bin) $^ $(platform_link)
126 ##############################################################################
130 build/java/org/xwt/Builtin.java: $(handwritten_xwar_sources) mkdir_build
131 @echo "wrapping .xwar -> .o: build/java/org/xwt/Builtin.java"
132 echo "package org.xwt;" > build/java/org/xwt/Builtin.java
133 echo "class Builtin {" >> build/java/org/xwt/Builtin.java
134 echo "public static String encoded = " >> build/java/org/xwt/Builtin.java
135 cd src; $(jar) cf - $(xwar_sources:src/%=%) | uuencode foo | tail -n +2 | grep -v '^end$$' | grep -v '^`$$' | sed 's_(.+)_"\1" +_' >> ../build/java/org/xwt/Builtin.java
136 echo "\"\"; } >> build/java/org/xwt/Builtin.java
138 postprocessed_sources := $(handwritten_java_pp_sources:src/%.pp=build/java/%)
139 $(postprocessed_sources): build/java/%.java: src/%.java.pp build/org/xwt/util/Preprocessor.class
140 @echo "preprocessing .java.pp -> .java: $<"
141 @mkdir -p `dirname $@`
142 @java -cp build org.xwt.util.Preprocessor < $< > $@
144 build/java/org/xwt/imp/Freetype.java: build/mips/freetype.mips build/class/org/xwt/imp/MIPS.class
145 @echo "translating .mips -> .java: $<"
146 @mkdir -p build/java/org/xwt/imp/
147 @java -cp build org.xwt.imp.MIPS org.xwt.imp.Freetype build/mips/freetype.mips > build/java/org/xwt/imp/Freetype.java
149 build/mips/freetype.mips: upstream/.freetype
150 make -C upstream .gcc-mips target=mips
151 $(gcc_path)/bin/mips-gcc \
157 -I gcc/src/freetype-2.1.4/include \
158 $(freetype_sources) \
160 src/org/xwt/imp/Freetype.c \
161 -Wl,-s,-T,$(gcc_path)/mips/lib/nullmon.ld
165 ##############################################################################
166 # Supported Platforms:
169 # compile is here to force compilation of the .class files (they get used via -Ibuild) without
170 # having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
171 gcj: $(gcc_path)/bin/$(target)-gcj compile $(target_bin)
172 echo -e "\\n=== $(target) ========================================="
175 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"
178 make gcj platform=Solaris target=sparc-sun-solaris2.7 platform_link="-L$(gcc_path)/lib -lX11 -lXext" platform_java_sources="POSIX X11"
181 make gcj platform=Win32 target=i686-pc-mingw32 target_bin=xwt.exe platform_link="-Wl,--subsystem,windows -lcomdlg32" platform_java_sources=Win32
184 make gcj platform=Carbon arget=powerpc-apple-darwin platform_link="$(gcc_path)/lib/libgcj.a -Xlinker -framework -Xlinker Carbon" platform_java_sources="POSIX Carbon"
186 JVM: compile build/xwar/builtin.xwar
187 echo -e "\\n=== JVM ========================================="
188 echo "archiving .class -> .jar"
190 echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > bin/.manifest
191 cd build; $(jar) cvfm ../xwt.jar .manifest \
192 org/xwt/builtin.xwar \
193 `find . -name \*.class | grep -v org/xwt/plat/` \
194 org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class | tr \\012 \\015
199 ##############################################################################
204 mkdir -p build build/java build/class build/h build
206 find . -name \*~ | xargs rm -f
207 find . -name \#\*\# | xargs rm -f
211 ##############################################################################
212 # Maintainer stuff: generating numbered builds, proposing patches
216 cvs tag -F xwt-$(current_build)
217 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
218 mv next.build- next.build
219 echo -n "Next build will be "
223 echo `date +%d-%b`" =========== build $(current_build) ================================================" >> CHANGES
225 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
229 @echo -n "Please type a one-line description of this bug: "; \
232 echo "Please type any additional comments that explain this patch."; \
233 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
234 echo "When you are done, press control-d on a new line."; \
236 ( echo -e "HELO patcher"; \
237 echo -e "MAIL FROM:$(USER)@xwt.org"; \
238 echo -e "RCPT TO: patches@xwt.org"; \
240 echo -e "From: $(USER)@xwt.org"; \
241 echo -e "To: patches@xwt.org"; \
242 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
249 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
251 current_build := $(shell cat next.build)
252 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
253 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
255 # pre-depend on compile as a sanity check
257 # this will fail if we haven't checked-in since the comment is null; we want this.
258 cvs commit -m '' > /dev/null
259 cvs tag -F xwt-$(current_build)
261 echo "***********************************************************"
262 echo "* This build is $(current_build)"
263 echo "***********************************************************"
265 ifeq ($(shell uname -n),serverbeach.megacz.com)
266 (make $(silent) dist-private 2>&1) >> .make-dist.out || \
267 (tail -n 200 .make-dist.out | mail -s "Build $(current_build) FAILED" cvs@xwt.org; false)
268 tail -n 200 .make-dist.out | \
269 mail -s "Unsigned binaries of $(current_build) are now available" cvs@xwt.org
271 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"
275 make $(silent) update-build
277 # preserve gcc across builds so we don't have to remake it
278 mkdir -p $(HOME)/dist.xwt.org-gcc
280 ln -s $(HOME)/dist.xwt.org-gcc gcc
281 mv -f gcc-/Makefile gcc/
282 mv -f gcc-/*.patch gcc/
288 echo === master.dist.xwt.org ==================================
290 echo "copying xwt.jar to distribution area..."
291 cp xwt.jar /var/www/master.dist.xwt.org/xwt-$(current_build).jar.unsigned
293 echo "stripping xwt.exe and copying it to the distribution area..."
294 $(strip) build/Win32/xwt.exe -o /var/www/master.dist.xwt.org/xwt-$(current_build).exe.unsigned
296 echo "copying xwt.linux to distribution area..."
297 $(strip) build/Linux/xwt.linux -o /var/www/master.dist.xwt.org/xwt-$(current_build).linux.unsigned
299 echo "creating source tarball in distribution area..."
300 CVSROOT=/cvs cvs export -r xwt-$(current_build) xwt
301 mv xwt xwt-$(current_build)
302 tar cvzf /var/www/master.dist.xwt.org/xwt-$(current_build).tgz xwt-$(current_build)
305 echo "*** DONE ******************************************"
308 compile: .javac $(java_sources) build/xwar/builtin.xwar build/org/xwt/imp/Freetype.class
309 echo "compiling .java -> .class: src/**/*.java"
311 cp build/org/xwt/imp/MIPS.class build/org/xwt/imp/MIPS.class.old
312 $(shell cat .javac) -classpath lib/libgcj-minimal.jar $(java_sources) -d build/ 2>&1 | \
313 grep -v ^\\[read | sed s_^\\[write\ build/__ | sed s_.class\\]_.java_ | sed "s_^_compiling .java -> .class: src/_"
314 cmp build/org/xwt/imp/MIPS.class build/org/xwt/imp/MIPS.class.old && mv build/org/xwt/imp/MIPS.class.old build/org/xwt/imp/MIPS.class
320 #mips: $(prefix)/mips/lib/libm.a
321 #$(prefix)/mips/lib/libm.a: src/.newlib $(prefix)/bin/mips-gcc
322 # mkdir -p build/$(target)/newlib
323 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH \
324 # ../../../src/newlib-1.11.0/configure --nfp --enable-multilib --prefix=$(prefix) --target=mips
325 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH EXTRA_CFLAGS=-mstrict-align make
326 # cd build/$(target)/newlib; make install
327 # FIXME: this is probably going to cause problems... figure out how to get by without it
329 # $(prefix)/bin/mips-gcc -c .empty.c -o $(prefix)/mips/lib/crt0.o