5 ## Configurables ###########################################################################
7 jpeg_headers := jpeglib.h jconfig.h jmorecfg.h jerror.h jinclude.h jpegint.h jchuff.h jdhuff.h jdct.h jmemsys.h jversion.h
8 jpeg_c_sources := jdapimin.c jdapistd.c jcomapi.c jcparam.c jdmaster.c jdinput.c jdmainct.c jdcoefct.c jdpostct.c jdmarker.c
9 jpeg_c_sources += jdhuff.c jdphuff.c jddctmgr.c jidctint.c jidctfst.c jidctflt.c jidctred.c jdsample.c jdcolor.c jdmerge.c
10 jpeg_c_sources += jquant1.c jquant2.c jerror.c jutils.c jmemnobs.c jmemmgr.c
13 java_pp_sources := $(shell find src -name \*.java.pp)
14 java_pp_postproc := $(java_pp_sources:src/%.java.pp=bin/%.java)
15 java_generated_sources := $(java_pp_postproc) bin/org/xwt/imp/Freetype.java
16 java_sources := $(shell find src -name \*.java)
17 java_headers := $(java_sources:src/%.java=bin/%.h) $(java_generated_sources:bin/%.java=bin/%.h)
18 xwar_sources := $(shell ls src/org/xwt/builtin/*.png src/org/xwt/builtin/*.xwt src/org/xwt/builtin/*.xwf)
19 cc_sources := src/org/xwt/plat/$(platform).cc
20 c_sources := $(jpeg_c_sources:%.c=src/org/ijg/%.c)
23 freetype_base_sources := ftsystem.c ftmm.c ftbbox.c ftinit.c ftdebug.c ftbase.c ftglyph.c
24 freetype_other_sources := smooth/smooth.c autohint/autohint.c sfnt/sfnt.c truetype/truetype.c
25 freetype_sources := $(freetype_base_sources:%=gcc/src/freetype-2.1.4/src/base/%)
26 freetype_sources += $(freetype_other_sources:%=gcc/src/freetype-2.1.4/src/%)
29 java_objects := $(filter-out bin-$(platform)/org/xwt/plat/%, $(java_sources:src/%.java=bin-$(platform)/%.java.o))
30 java_objects += $(filter-out bin-$(platform)/org/xwt/plat/%, $(java_generated_sources:bin/%.java=bin-$(platform)/%.java.o))
31 java_objects += bin-$(platform)/org/xwt/plat/GCJ.java.o
32 java_objects += $(platform_java_sources:%=bin-$(platform)/org/xwt/plat/%.java.o)
33 cc_objects := $(cc_sources:src/%.cc=bin-$(platform)/%.cc.o)
34 c_objects := $(c_sources:src/%.c=bin-$(platform)/%.c.o)
37 gcc_path := $(shell pwd)/gcc/install
38 #gcc_optimizations := -O9 -ffast-math -fomit-frame-pointer -foptimize-sibling-calls -finline-functions
39 #gcc_optimzations += -funroll-loops -ffunction-sections -fdata-sections
40 gcc_optimizations := -O2
42 gcc_flags := $(gcc_optimizations) $(debug) -Isrc/org/ijg
43 gcj_flags := -fCLASSPATH=src
44 gcj := $(gcc_path)/bin/$(target)-gcj $(gcj_flags) $(gcc_flags)
45 g++ := $(gcc_path)/bin/$(target)-g++ $(gcc_flags)
46 gcc := $(gcc_path)/bin/$(target)-gcc $(gcc_flags)
47 gcjh := $(gcc_path)/bin/$(target)-gcjh
49 as := $(gcc_path)/$(target)/bin/as
50 ar := $(gcc_path)/$(target)/bin/ar
51 ranlib := $(gcc_path)/$(target)/bin/ranlib
52 strip := $(gcc_path)/$(target)/bin/strip
53 jar := $(shell ((type fastjar &>/dev/null) && echo fastjar) || echo jar)
56 PATH := jikes-1.18/bin:$(PATH)
59 PATH := jikes-1.18/bin:$(PATH)
62 ## Platform-Neutral ###########################################################################
64 ifneq ($(verbose),true)
65 .SILENT: $(cc_objects) $(java_objects) $(java_headers) all bin/org/xwt/builtin.xwar $(target_bin) compile
69 compile: .javac $(java_generated_sources) bin/org/xwt/builtin.xwar
70 echo "compiling .java -> .class: [all]"
72 $(shell cat .javac) -classpath lib/libgcj-minimal.jar $(java_sources) $(java_generated_sources) -d bin/ 2>&1 | \
73 grep -v ^\\[read | sed s_^\\[write\ bin/__ | sed s_.class\\]_.java_ | sed "s_^_compiling .java -> .class: src/_"
75 bin/%.class: src/%.java .javac
76 @echo "compiling .java -> .class: $<"
78 @$(shell cat .javac) -classpath lib/libgcj-minimal.jar $< -d bin/ 2>&1 | \
79 grep -v ^\\[read | sed s_^\\[write\ bin/__ | sed s_.class\\]_.java_ | sed "s_^_compiling .java -> .class: src/_"
81 $(java_pp_postproc): bin/%.java: src/%.java.pp bin/org/xwt/util/Preprocessor.class
82 @echo "preprocessing .java.pp -> .java: $<"
83 @mkdir -p `dirname $@`
84 @java -cp bin org.xwt.util.Preprocessor < $< > $@
87 all: Win32 Linux Java2 #Solaris
91 type jikes && (jikes --version | grep "Version 1.18"); \
93 echo "public class GetBootClassPath { public static void main(String[] s) { " > GetBootClassPath.java; \
94 echo "System.out.println(System.getProperty(\"sun.boot.class.path\")); } }" >> GetBootClassPath.java; \
95 javac GetBootClassPath.java; \
96 java -cp . GetBootClassPath > .bootclasspath; \
97 rm GetBootClassPath.*; \
98 echo -n "jikes -verbose -nowarn -sourcepath src/ -bootclasspath " > .javac; \
99 cat .bootclasspath >> .javac; \
101 echo "WARNING: You do not have jikes; falling back to javac. Compiles will be very slow."; \
102 echo javac > .javac; \
106 curl ftp://www-126.ibm.com/pub/jikes/1.18/jikes-1.18.tar.bz2 | tar xjvf -
107 cd jikes-1.18; ./configure --prefix=`pwd` && make && make install
108 ln -sf jikes-1.18/bin/jikes .jikes
110 bin/org/xwt/builtin.xwar: $(xwar_sources)
112 cd src; $(jar) cf ../bin/org/xwt/builtin.xwar $(xwar_sources:src/%=%)
116 find . -name \*~ | xargs rm -f
117 find . -name \#\*\# | xargs rm -f
120 cvs tag -F xwt-$(current_build)
121 (echo -n 0000; (echo "10k16o16i"; cat next.build | tr a-z A-Z; echo "1+f") | dc) | tail --bytes=5 > next.build-
122 mv next.build- next.build
123 echo -n "Next build will be "
127 echo `date +%d-%b`" =========== build $(current_build) ================================================" >> CHANGES
129 cvs commit -m 'this comment should not appear in CHANGES' next.build CHANGES
133 @echo -n "Please type a one-line description of this bug: "; \
136 echo "Please type any additional comments that explain this patch."; \
137 echo "If this patch fixes a bug, include a link to bugs.xwt.org."; \
138 echo "When you are done, press control-d on a new line."; \
140 ( echo -e "HELO patcher"; \
141 echo -e "MAIL FROM:$(USER)@xwt.org"; \
142 echo -e "RCPT TO: patches@xwt.org"; \
144 echo -e "From: $(USER)@xwt.org"; \
145 echo -e "To: patches@xwt.org"; \
146 echo -e "Subject: proposed patch to $(this_branch): $$A"; \
153 bash -c "cat .message > /dev/tcp/mail.xwt.org/25" # /dev/tcp is faked by bash; not part of the os
155 ## GCJ-Derived Platforms #######################################################################
157 # if the user doesn't change gcc_path, and it's not built, then we'll try to build it
158 $(shell pwd)/gcc/install/bin/$(target)-gcj: .upstream
163 curl http://umn.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.4.tar.gz | tar xvzf - -C gcc/src
164 cd gcc/src; patch -p0 < freetype.patch
165 touch gcc/src/.freetype
167 freetype.mips: gcc/src/.freetype
168 make -C gcc mips target=mips
169 $(gcc_path)/bin/mips-gcc \
175 -I gcc/src/freetype-2.1.4/include \
176 $(freetype_sources) \
178 src/org/xwt/imp/Freetype.c \
179 $(gcc_path)/mips/lib/libc.a \
180 -Wl,-s,-T,$(gcc_path)/mips/lib/nullmon.ld
182 bin/org/xwt/imp/Freetype.java: freetype.mips bin/org/xwt/imp/MIPS.class
183 @echo "translating .mips -> .java: $<"
184 @java -cp bin org.xwt.imp.MIPS org.xwt.imp.Freetype freetype.mips > bin/org/xwt/imp/Freetype.java
186 # compile is here to force compilation of the .class files (they get used via -Ibin/) 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)
190 $(target_bin): $(java_objects) $(cc_objects) $(c_objects) bin-$(platform)/org/xwt/builtin.o
191 @echo "linking .o -> $(target_bin)"
192 $(gcj) --main=org.xwt.Main -o bin-$(platform)/$(target_bin) $^ $(platform_link)
194 bin-$(platform)/org/xwt/builtin.o: bin/org/xwt/builtin.xwar
195 @echo "wrapping .xwar -> .o: bin/org/xwt/builtin.o"
196 @(echo "unsigned int builtin_xwar_length = ";\
197 (wc -c bin/org/xwt/builtin.xwar | sed "s_bin.*__");\
199 echo "unsigned char builtin_xwar[] = {";\
200 hexdump -ve '"0x" 1/1 "%x,\n"' bin/org/xwt/builtin.xwar;\
201 echo "};") > .builtin.c
202 $(gcc) -c .builtin.c -o bin-$(platform)/org/xwt/builtin.o
204 $(java_headers): bin/%.h: bin/%.class
205 @echo "extracting .class -> .h: $<"
206 cd bin; find `echo $< | sed s/.class$$// | sed s_^bin/__ `*.class |\
207 sed s_/_._g | sed s/.class$$// | sed s/.java$$// |\
208 xargs $(gcjh) --classpath .
210 $(java_objects): bin-$(platform)/%.java.o: src/%.java
211 @echo "compiling .java -> .o: $<"
212 mkdir -p `dirname $@`
215 # unpack and patch the ijg library
216 src/org/ijg/jmorecfg.h: src/org/ijg/jpegsrc.v6b.tar.gz src/org/ijg/jmorecfg.h.patch
217 cd src/org/ijg/; tar xzf jpegsrc.v6b.tar.gz
218 cd src/org/ijg/jpeg-6b; ./configure --target=$(target)
219 cd src/org/ijg/jpeg-6b; mv $(jpeg_c_sources) $(jpeg_headers) ..
220 cd src/org/ijg; patch -l -p0 < jmorecfg.h.patch
221 rm -rf src/org/ijg/jpeg-6b
223 $(cc_objects): bin-$(platform)/%.cc.o: src/%.cc $(java_headers) src/org/ijg/jmorecfg.h
224 @echo "compiling .cc -> .o: $<"
225 @mkdir -p `dirname $@`
226 $(g++) -I/usr/X11R6/include/ -I$(gcc_path)/include -Ibin -Iupstream/$(platform)/include -Wno-multichar -c $< -o $@
228 $(c_objects): bin-$(platform)/%.c.o: src/%.c src/org/ijg/jmorecfg.h
229 @echo "compiling .c -> .o: $<"
230 @mkdir -p `dirname $@`
231 $(gcc) -Ibin -c $< -o $@
234 mkdir -p gcc/install; curl http://www.megacz.com/upstream.tgz | tar xvzhf - -C gcc/install
238 ## Platforms ##############################################################################
241 echo -e "\\n=== Linux ========================================="
244 target=i686-pc-linux-gnu \
245 target_bin=xwt.linux \
246 platform_link="-L$(gcc_path)/lib -L/usr/X11R6/lib -lX11 -lXext --static" \
247 platform_java_sources="POSIX X11"
250 echo -e "\\n=== Solaris ========================================="
253 target=sparc-sun-solaris2.7 \
254 target_bin=xwt.solaris \
255 platform_link="-L$(gcc_path)/lib -lX11 -lXext" \
256 platform_java_sources="POSIX X11"
259 echo -e "\\n=== Win32 ========================================="
262 target=i686-pc-mingw32 \
264 platform_link="-Wl,--subsystem,windows -lcomdlg32" \
265 platform_java_sources="Win32"
268 echo -e "\\n=== Darwin ========================================="
269 ranlib upstream/Darwin/lib/*.a
270 ar x /usr/lib/libcc_dynamic.a upstream/Darwin/lib/darwin-fpsave.o
273 target=powerpc-apple-darwin \
274 target_bin=xwt.darwin \
275 platform_link="upstream/Darwin/lib/*.[oa] $(gcc_path)/lib/libgcj.a" \
276 platform_java_sources="POSIX X11"
279 echo -e "\\n=== Carbon ========================================="
282 target=powerpc-apple-darwin \
283 target_bin=xwt.carbon \
284 platform_link="$(gcc_path)/lib/libgcj.a -Xlinker -framework -Xlinker Carbon" \
285 platform_java_sources="POSIX Carbon"
287 Java2: compile bin/org/xwt/builtin.xwar
288 echo -e "\\n=== Java2 ========================================="
289 echo "archiving .class -> .jar"
291 echo -e "Manifest-Version: 1.0\nMain-Class: org.xwt.Main\n" > bin/.manifest
292 cd bin; $(jar) cvfm ../bin-Java2/xwt.jar .manifest \
293 org/xwt/builtin.xwar \
294 `find . -name \*.class | grep -v org/xwt/plat/` \
295 org/xwt/plat/AWT*.class org/xwt/plat/Java2*.class | tr \\012 \\015
299 echo "PalmOS is not yet supported"
303 ## master.dist.xwt.org ############################################################################
305 current_build := $(shell cat next.build)
306 this_branch := $(shell tail -c +2 CVS/Tag 2>/dev/null || echo HEAD)
307 this_branch_flag := $(shell test $(this_branch) = HEAD && echo || echo -r $(this_branch))
309 # pre-depend on compile as a sanity check
311 # this will fail if we haven't checked-in since the comment is null; we want this.
312 cvs commit -m '' > /dev/null
313 cvs tag -F xwt-$(current_build)
315 echo "***********************************************************"
316 echo "* This build is $(current_build)"
317 echo "***********************************************************"
319 ifeq ($(shell uname -n),serverbeach.megacz.com)
320 (make $(silent) dist-private 2>&1) >> .make-dist.out || \
321 (tail -n 200 .make-dist.out | mail -s "Build $(current_build) FAILED" cvs@xwt.org; false)
322 tail -n 200 .make-dist.out | \
323 mail -s "Unsigned binaries of $(current_build) are now available" cvs@xwt.org
325 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"
330 make $(silent) update-build
332 # preserve gcc across builds so we don't have to remake it
333 mkdir -p $(HOME)/dist.xwt.org-gcc
335 ln -s $(HOME)/dist.xwt.org-gcc gcc
336 mv -f gcc-/Makefile gcc/
337 mv -f gcc-/*.patch gcc/
343 echo === master.dist.xwt.org ==================================
345 echo "copying xwt.jar to distribution area..."
346 cp bin-Java2/xwt.jar /var/www/master.dist.xwt.org/xwt-$(current_build).jar.unsigned
348 echo "stripping xwt.exe and copying it to the distribution area..."
349 $(strip) bin-Win32/xwt.exe -o /var/www/master.dist.xwt.org/xwt-$(current_build).exe.unsigned
351 echo "copying xwt.linux to distribution area..."
352 $(strip) bin-Linux/xwt.linux -o /var/www/master.dist.xwt.org/xwt-$(current_build).linux.unsigned
354 echo "creating source tarball in distribution area..."
355 CVSROOT=/cvs cvs export -r xwt-$(current_build) xwt
356 mv xwt xwt-$(current_build)
357 tar cvzf /var/www/master.dist.xwt.org/xwt-$(current_build).tgz xwt-$(current_build)
360 echo "*** DONE ******************************************"