1 #############################################################################
3 # The XWT upstream code Makefile
6 # deal with Apple's brokenness
7 setcc := $(shell test `uname` = Darwin && echo "CC=\"/usr/bin/gcc3 -no-cpp-precomp\"")
10 url_newlib-1.11.0 := ftp://sources.redhat.com/pub/newlib/newlib-1.11.0.tar.gz
11 url_binutils-2.13.2.1 := ftp://ftp.gnu.org/gnu/binutils/binutils-2.13.2.1.tar.gz
12 url_w32api-2.3 := http://umn.dl.sourceforge.net/sourceforge/mingw/w32api-2.3.tar.gz
13 url_mingw-runtime-3.0 := http://umn.dl.sourceforge.net/sourceforge/mingw/mingw-runtime-3.0.tar.gz
14 url_freetype-2.1.4 := http://umn.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.4.tar.gz
15 url_gcc-3.3 := http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-3.3/gcc-3.3.tar.gz
16 url_jpeg-6b := http://www.ijg.org/files/jpegsrc.v6b.tar.gz
17 url_jikes-1.18 := http://www.megacz.com/tmp/jikes-1.18.tgz #ftp://www-126.ibm.com/pub/jikes/1.18/jikes-1.18.tar.gz
18 url_libmspack-20030726 := http://www.kyz.uklinux.net/downloads/libmspack-20030726.tar.gz
20 .install_binutils-2.13.2.1_powerpc-apple-darwin: .vendor
21 rm -rf upstream/darwin-linker/src
22 cd upstream/darwin-linker; tar xvzf ../install/powerpc-apple-darwin/cctools-478.tgz
23 ifneq ($(shell uname),Darwin)
24 cd upstream/darwin-linker/src/cctools; for A in ../../patches/*.patch; do patch -p0 < $$A; done
25 cp upstream/darwin-linker/src/cctools/ld/fake-mach.c upstream/darwin-linker/src/cctools/libstuff
26 cd upstream/darwin-linker/src/; mkdir macosx-include; cd macosx-include; chmod +x ../../links.sh; ../../links.sh
28 make -C upstream/darwin-linker/src/cctools/libstuff
29 make -C upstream/darwin-linker/src/cctools/misc
30 touch upstream/darwin-linker/src/cctools/misc/makeUser.c upstream/darwin-linker/src/cctools/misc/make.h
31 make -C upstream/darwin-linker/src/cctools/misc libtool.NEW
32 make -C upstream/darwin-linker/src/cctools/ld; true
33 make -C upstream/darwin-linker/src/cctools/as
34 make -C upstream/darwin-linker/src/cctools/ar
35 mkdir -p upstream/install/powerpc-apple-darwin/bin
36 cp upstream/darwin-linker/src/cctools/ld/ld_dir/ld.NEW upstream/install/powerpc-apple-darwin/bin/ld.NEW
37 echo -e "#!/bin/sh\n"`pwd`"/upstream/install/powerpc-apple-darwin/bin/ld.NEW -dylib_file /usr/lib/system/libmathCommon.A.dylib:"`pwd`"/upstream/install/powerpc-apple-darwin/lib/libmathCommon.A.dylib -L"`pwd`"/upstream/install/powerpc-apple-darwin/lib \$$@\n" > upstream/install/powerpc-apple-darwin/bin/ld
38 chmod +x upstream/install/powerpc-apple-darwin/bin/ld
39 echo -e "#!/bin/sh\n"`pwd`"/upstream/install/powerpc-apple-darwin/bin/apple-libtool \$$1 -o \$$1\n" > upstream/install/powerpc-apple-darwin/bin/ranlib
40 chmod +x upstream/install/powerpc-apple-darwin/bin/ranlib
41 cp upstream/darwin-linker/src/cctools/misc/libtool.NEW upstream/install/powerpc-apple-darwin/bin/apple-libtool
42 cp upstream/darwin-linker/src/cctools/misc/strip.NEW upstream/install/powerpc-apple-darwin/bin/strip
43 cp upstream/darwin-linker/src/cctools/as/appc_dir/as upstream/install/powerpc-apple-darwin/bin/as
44 cp upstream/darwin-linker/src/cctools/ar/ar.NEW upstream/install/powerpc-apple-darwin/bin/ar.NEW
45 echo -e "#!/bin/sh\n"`pwd`"/upstream/install/powerpc-apple-darwin/bin/ar.NEW \$$@\n"`pwd`"/upstream/install/powerpc-apple-darwin/bin/ranlib \$$2\n" > upstream/install/powerpc-apple-darwin/bin/ar
46 chmod +x upstream/install/powerpc-apple-darwin/bin/ar
47 mkdir -p upstream/install/bin
48 cd upstream/install/bin; ln -sf ../powerpc-apple-darwin/bin/ld powerpc-apple-darwin-ld
49 cd upstream/install/bin; ln -sf ../powerpc-apple-darwin/bin/as powerpc-apple-darwin-as
50 cd upstream/install/bin; ln -sf ../powerpc-apple-darwin/bin/ar powerpc-apple-darwin-ar
51 cd upstream/install/bin; ln -sf ../powerpc-apple-darwin/bin/ranlib powerpc-apple-darwin-ranlib
52 cd upstream/install/bin; ln -sf ../powerpc-apple-darwin/bin/strip powerpc-apple-darwin-strip
53 echo -e "#!/bin/sh\nc++filt \$$@\n" > upstream/install/bin/c++filt3; chmod +x upstream/install/bin/c++filt3
54 cd upstream/install/powerpc-apple-darwin/bin; ln -sf ../../bin/c++filt3
57 # building gcc requires binutils
58 .configure_gcc-3.3_$(target): .install_binutils-2.13.2.1_$(target)
60 # building newlib requires gcc
61 .configure_newlib-1.11.0_$(target): .install_gcc-3.3_$(target)
64 configure_gcc-3.3 += --enable-languages=c,c++,java --enable-gc-type=boehm --disable-jvmpi
65 ifneq ($(platform),Solaris)
66 configure_gcc-3.3 += --disable-shared
68 configure_gcc-3.3 += --enable-shared
70 configure_gcc-3.3 += --disable-java-awt --disable-interpreter --enable-static --enable-libgcj
71 ifneq ($(shell uname),$(platform))
72 ifneq ($(target),mips-unknown-elf)
73 configure_gcc-3.3 += --with-gnu-ld=$(shell pwd)/upstream/install/bin/$(target)-ld
74 configure_gcc-3.3 += --with-as=$(shell pwd)/upstream/install/bin/$(target)-as
75 configure_gcc-3.3 += --with-headers=$(shell pwd)/upstream/install/$(target)/include
78 configure_gcc-3.3_powerpc-apple-darwin += --enable-threads=posix --disable-hash-synchronization --disable-multilib
79 configure_gcc-3.3_i686-pc-mingw32 += --enable-threads=win32 --enable-hash-synchronization
80 configure_gcc-3.3_i686-pc-linux-gnu += --enable-threads=posix --enable-hash-synchronization
81 configure_gcc-3.3_sparc-sun-solaris2.7 += --enable-threads=posix --disable-multilib
82 configure_gcc-3.3_mips-unknown-elf += --with-gnu-ld=$(shell pwd)/upstream/install/bin/$(target)-ld
83 configure_gcc-3.3_mips-unknown-elf += --with-as=$(shell pwd)/upstream/install/bin/$(target)-as
84 configure_gcc-3.3_mips-unknown-elf += --enable-languages=c --nfp --enable-multilib --disable-threads
86 # libjpeg's configury doesn't obey --target
87 environment_jpeg-6b_$(target) += PATH=$(shell pwd)/upstream/install/$(target)/bin:$$PATH
88 environment_jpeg-6b_$(target) += CC=$(shell pwd)/upstream/install/bin/$(target)-gcc
89 environment_jpeg-6b_$(target) += AR="$(shell pwd)/upstream/install/$(target)/bin/ar rc"
90 environment_jpeg-6b_$(target) += AR2=$(shell pwd)/upstream/install/$(target)/bin/ranlib
92 # libmspack configury doesn't obey --target
93 environment_libmspack-20030726_$(target) += PATH=$(shell pwd)/upstream/install/$(target)/bin:$$PATH
94 environment_libmspack-20030726_$(target) += CC=$(shell pwd)/upstream/install/bin/$(target)-gcc
95 environment_libmspack-20030726_$(target) += AR="$(shell pwd)/upstream/install/$(target)/bin/ar"
96 environment_libmspack-20030726_$(target) += AR2=$(shell pwd)/upstream/install/$(target)/bin/ranlib
98 environment_gcc_3.3_$(target) += PATH=$(shell pwd)/upstream/install/bin:$$PATH
100 .PRECIOUS: .vendor .download_% .configure_%_$(target) .install_%_$(target)
102 # vendor-supplied binaries and headers; this is stuff that comes with various OSes
103 vendor: .vendor; @true
105 @echo -e "\n\033[1mdownloading vendor-supplied headers and libraries...\033[0m"
106 mkdir -p upstream/install
107 curl http://www.megacz.com/vendor.tgz | tar xzf - -C upstream/install
108 mkdir -p upstream/install/i686-pc-mingw32
109 curl $(url_w32api-2.3) | tar xzf - -C upstream/install/i686-pc-mingw32
110 curl $(url_mingw-runtime-3.0) | tar xzf - -C upstream/install/i686-pc-mingw32
111 ifeq ($(shell uname),Linux)
112 rm -rf upstream/install/i686-pc-linux-gnu/include
113 ln -sf /usr/include upstream/install/i686-pc-linux-gnu/include
118 @echo -e "\n\033[1mdownloading $*...\033[0m"
120 curl $(url_$*) | tar xzf - -C upstream/$*
121 mv upstream/$*/$* upstream/$*/src; true
122 (test -e upstream/$*/patches && cd upstream/$*/src && for A in ../patches/*.patch; do patch -p0 -l < $$A; done); true
125 .configure_%_$(target): .download_%
126 @echo -e "\n\033[1mconfiguring $*...\033[0m"
127 mkdir -p upstream/$*/build-$(target)
128 cd upstream/$*/build-$(target); \
129 $(setcc) $(environment_$*_$(target)) ../src/configure \
131 --prefix=`cd ../..; pwd`/install \
133 $(configure_$*_$(target))
136 .configure_libmspack-20030726_$(target): .download_libmspack-20030726 .install_gcc-3.3_$(target) .install_newlib-1.11.0_$(target)
137 mkdir -p upstream/libmspack-20030726/build-$(target)
138 cd upstream/libmspack-20030726/build-$(target); ln -sf ../libmspack/mspack/* .
141 .install_libmspack-20030726_$(target): .build_libmspack-20030726_$(target)
144 .install_freetype-2.1.4_mips-unknown-elf: .install_gcc-3.3_mips-unknown-elf .install_newlib-1.11.0_mips-unknown-elf .download_freetype-2.1.4
145 cd upstream/freetype-2.1.4/src; make setup ansi; PATH=$$PATH:`pwd`/../../install/bin make CC=mips-unknown-elf-gcc AR=mips-unknown-elf-ar
146 upstream/install/bin/mips-unknown-elf-ranlib upstream/freetype-2.1.4/src/objs/libfreetype.a
149 .build_%_$(target): .configure_%_$(target)
150 @echo -e "\n\033[1mbuilding $*...\033[0m"
151 cd upstream/$*/build-$(target); \
152 $(setcc) PATH=$$PATH:`pwd`/../../install/bin \
153 $(environment_$*_$(target)) \
154 make $(setcc) $(environment_$*_$(target))
157 .install_%_$(target): .build_%_$(target)
158 @echo -e "\n\033[1minstalling $*...\033[0m"
159 cd upstream/$*/build-$(target); \
160 $(setcc) PATH=$$PATH:`pwd`/../../install/bin \
161 $(environment_$*_$(target)) \
162 make install $(setcc) $(environment_$*_$(target))
165 # jikes has a special target to autodetect a pre-installed jikes, and to autodetect the JVM's $CLASSPATH
167 @echo -e "\n\033[1mdetecting your jikes installation...\033[0m"
168 echo "#!/bin/sh" > .jikes
169 echo 'for A in `find build/class -name \*.class`; do mv $$A $$A.old; done;' >> .jikes
170 echo -n 'PATH=upstream/install/bin:$$PATH jikes -classpath lib/libgcj-minimal.jar $$@ -d build/class/ -sourcepath build/java/ ' >> .jikes
171 (type jikes && (jikes --version | grep "Version 1.18")) || make .install_jikes-1.18_ target=
172 echo -n "$(jikes_flags) -bootclasspath " >> .jikes
173 echo "public class GetBootClassPath { public static void main(String[] s) { " > GetBootClassPath.java
174 echo "System.out.println(System.getProperty(\"sun.boot.class.path\")); } }" >> GetBootClassPath.java
175 javac GetBootClassPath.java
176 java -cp . GetBootClassPath >> .jikes
177 rm GetBootClassPath.*
178 echo 'EXIT=$$?' >> .jikes
179 echo 'for A in `find build/class -name \*.class`; do test -e $$A.old && cmp -s $$A $$A.old && mv $$A.old $$A; done' >> .jikes
180 echo 'for A in `find build/class -name \*.class`; do test -e $$A.old && rm $$A.old; done' >> .jikes
181 echo 'exit $$EXIT' >> .jikes