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/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/%,smooth/smooth.c autohint/autohint.c sfnt/sfnt.c truetype/truetype.c)
54 upstream/.freetype-mips:
55 make -sC upstream .freetype-mips
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 $(gcc_path)/bin/mips-gcc:
165 @make -sC upstream gcc-3.3-mips target=mips
167 build/mips/%.o: src/org/xwt/imp/%.c $(gcc_path)/bin/mips-gcc upstream/.freetype
169 @echo "compiling $< -> $@ (mips)"
170 @$(gcc_path)/bin/mips-gcc \
172 -I upstream/freetype-2.1.4/include \
175 build/mips/freetype.mips: $(gcc_path)/bin/mips-gcc build/mips/crt0.o build/mips/syscalls.o build/mips/Freetype.o upstream/.freetype-mips
176 @echo "compiling .c -> .mips: $@"
178 @make -sC upstream newlib-1.11.0/src newlib-1.11.0/build-mips/.installed freetype-2.1.4/src target=mips
179 $(gcc_path)/bin/mips-gcc \
183 -T src/org/xwt/imp/linker.ld \
185 -Lupstream/freetype-2.1.4/objs \
187 build/mips/Freetype.o \
191 ##############################################################################
192 # Supported Platforms:
195 # compile is here to force compilation of the .class files (they get used via -Ibuild) without
196 # having the individual .o's depend on the .java's (otherwise every .o gets recompiled when one .java changes)
197 gcj: $(gcc_path)/bin/$(target)-gcj compile $(target_bin)
198 @echo -e "\\n=== $(target) ========================================="
201 @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"
204 @make gcj platform=Solaris target=sparc-sun-solaris2.7 platform_link="-L$(gcc_path)/lib -lX11 -lXext" platform_java_sources="POSIX X11"
207 @make gcj platform=Win32 target=i686-pc-mingw32 target_bin=xwt.exe platform_link="-Wl,--subsystem,windows -lcomdlg32" platform_java_sources=Win32
210 @make gcj platform=Carbon arget=powerpc-apple-darwin platform_link="$(gcc_path)/lib/libgcj.a -Wl,-framework,Carbon,-framework,OpenGL,-framework,AGL,-framework,SystemConfiguration" platform_java_sources="POSIX Carbon OpenGL"
212 JVM: build/JVM/xwt.jar
213 build/JVM/xwt.jar:.compile
214 @echo "archiving .class -> .jar: build/JVM/xwt.jar"
216 @echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > build/JVM/.manifest
217 @cd build/class; $(jar) cfm ../JVM/xwt.jar ../JVM/.manifest \
218 `find . -name \*.class | grep -v org/xwt/plat/` \
219 org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class
224 ##############################################################################
229 find . -name \*~ | xargs rm -f
230 find . -name \#\*\# | xargs rm -f
234 ##############################################################################
235 # Maintainer stuff: generating numbered builds, proposing patches
239 cvs tag -F xwt-$(current_build)
240 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
241 mv next.build- next.build
242 echo -n "Next build will be "
246 echo `date +%d-%b`" =========== build $(current_build) ================================================" >> CHANGES
248 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
252 @echo -n "Please type a one-line description of this bug: "; \
255 echo "Please type any additional comments that explain this patch."; \
256 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
257 echo "When you are done, press control-d on a new line."; \
259 ( echo -e "HELO patcher"; \
260 echo -e "MAIL FROM:$(USER)@xwt.org"; \
261 echo -e "RCPT TO: patches@xwt.org"; \
263 echo -e "From: $(USER)@xwt.org"; \
264 echo -e "To: patches@xwt.org"; \
265 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
272 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
274 current_build := $(shell cat next.build)
275 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
276 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
278 # pre-depend on compile as a sanity check
280 # this will fail if we haven't checked-in since the comment is null; we want this.
281 cvs commit -m '' > /dev/null
282 cvs tag -F xwt-$(current_build)
284 echo "***********************************************************"
285 echo "* This build is $(current_build)"
286 echo "***********************************************************"
288 ifeq ($(shell uname -n),serverbeach.megacz.com)
289 (make $(silent) dist-private 2>&1) >> .make-dist.out || \
290 (tail -n 200 .make-dist.out | mail -s "Build $(current_build) FAILED" cvs@xwt.org; false)
291 tail -n 200 .make-dist.out | \
292 mail -s "Unsigned binaries of $(current_build) are now available" cvs@xwt.org
294 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"
298 make $(silent) update-build
300 # preserve gcc across builds so we don't have to remake it
301 mkdir -p $(HOME)/dist.xwt.org-gcc
303 ln -s $(HOME)/dist.xwt.org-gcc gcc
304 mv -f gcc-/Makefile gcc/
305 mv -f gcc-/*.patch gcc/
311 echo === master.dist.xwt.org ==================================
313 echo "copying xwt.jar to distribution area..."
314 cp xwt.jar /var/www/master.dist.xwt.org/xwt-$(current_build).jar.unsigned
316 echo "stripping xwt.exe and copying it to the distribution area..."
317 $(strip) build/Win32/xwt.exe -o /var/www/master.dist.xwt.org/xwt-$(current_build).exe.unsigned
319 echo "copying xwt.linux to distribution area..."
320 $(strip) build/Linux/xwt.linux -o /var/www/master.dist.xwt.org/xwt-$(current_build).linux.unsigned
322 echo "creating source tarball in distribution area..."
323 CVSROOT=/cvs cvs export -r xwt-$(current_build) xwt
324 mv xwt xwt-$(current_build)
325 tar cvzf /var/www/master.dist.xwt.org/xwt-$(current_build).tgz xwt-$(current_build)
328 echo "*** DONE ******************************************"
336 #mips: $(prefix)/mips/lib/libm.a
337 #$(prefix)/mips/lib/libm.a: src/.newlib $(prefix)/bin/mips-gcc
338 # mkdir -p build/$(target)/newlib
339 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH \
340 # ../../../src/newlib-1.11.0/configure --nfp --enable-multilib --prefix=$(prefix) --target=mips
341 # cd build/$(target)/newlib; PATH=$(prefix)/bin:$$PATH EXTRA_CFLAGS=-mstrict-align make
342 # cd build/$(target)/newlib; make install
343 # FIXME: this is probably going to cause problems... figure out how to get by without it
345 # $(prefix)/bin/mips-gcc -c .empty.c -o $(prefix)/mips/lib/crt0.o