2003/09/08 01:16:44
[org.ibex.core.git] / Makefile.upstream
1 #############################################################################
2 #
3 # The XWT upstream code Makefile
4 #
5
6 # deal with Apple's brokenness
7 setcc := CC="$(patsubst Darwin,/usr/bin/gcc3 -no-cpp-precomp,$(findstring Darwin,$(shell uname)))"
8 setcc += PATH=`pwd`/upstream/install/bin:$$PATH
9
10 # where to get stuff
11 url_newlib-1.11.0      := ftp://sources.redhat.com/pub/newlib/newlib-1.11.0.tar.gz
12 url_binutils-2.13.2.1  := ftp://ftp.gnu.org/gnu/binutils/binutils-2.13.2.1.tar.gz 
13 url_w32api-2.3         := http://umn.dl.sourceforge.net/sourceforge/mingw/w32api-2.3.tar.gz
14 url_mingw-runtime-3.0  := http://umn.dl.sourceforge.net/sourceforge/mingw/mingw-runtime-3.0.tar.gz
15 url_freetype-2.1.4     := http://umn.dl.sourceforge.net/sourceforge/freetype/freetype-2.1.4.tar.gz
16 url_gcc-3.3            := http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-3.3/gcc-3.3.tar.gz 
17 url_jpeg-6b            := http://www.ijg.org/files/jpegsrc.v6b.tar.gz
18 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
19
20 .install_binutils-2.13.2.1_powerpc-apple-darwin: .vendor
21         cd upstream/darwin-linker; tar xvzf ../install/powerpc-apple-darwin/cctools-478.tgz
22         cd upstream/darwin-linker/src/cctools; for A in ../../patches/*.patch; do patch -p0 < $$A; done
23         cp upstream/darwin-linker/src/cctools/ld/fake-mach.c upstream/darwin-linker/src/cctools/libstuff
24         cd upstream/darwin-linker/src/; mkdir macosx-include; cd macosx-include; ../../links.sh
25         make -C upstream/darwin-linker/src/cctools/libstuff
26         make -C upstream/darwin-linker/src/cctools/misc
27         make -C upstream/darwin-linker/src/cctools/ld; true
28         make -C upstream/darwin-linker/src/cctools/as
29         make -C upstream/darwin-linker/src/cctools/ar
30         mkdir -p upstream/install/powerpc-apple-darwin/bin
31         cp upstream/darwin-linker/src/cctools/ld/ld_dir/ld.NEW upstream/install/powerpc-apple-darwin/bin/ld.NEW
32         echo -e "#!/bin/sh\n"`pwd`/upstream/install/powerpc-apple-darwin/bin/ld.NEW -dylib_file /usr/lib/system/libmathCommon.A.dylib:`pwd`/xwt/upstream/install/powerpc-apple-darwin/lib/libmathCommon.A.dylib -Z -L`pwd`/upstream/install/powerpc-apple-darwin/lib $$@ > upstream/install/powerpc-apple-darwin/bin/ld
33         chmod +x upstream/install/powerpc-apple-darwin/bin/ld
34         cp upstream/darwin-linker/src/cctools/misc/strip.NEW upstream/install/powerpc-apple-darwin/bin/strip
35         cp upstream/darwin-linker/src/cctools/as/appc_dir/as upstream/install/powerpc-apple-darwin/bin/as
36         cp upstream/darwin-linker/src/cctools/ar/ar.NEW upstream/install/powerpc-apple-darwin/bin/ar
37         mkdir -p upstream/install/bin
38         cd upstream/install/bin; ln -s ../powerpc-apple-darwin/bin/ld powerpc-apple-darwin-ld
39         cd upstream/install/bin; ln -s ../powerpc-apple-darwin/bin/as powerpc-apple-darwin-as
40         cd upstream/install/bin; ln -s ../powerpc-apple-darwin/bin/ar powerpc-apple-darwin-ar
41         cd upstream/install/bin; ln -s ../powerpc-apple-darwin/bin/strip powerpc-apple-darwin-strip
42         echo -e "#!/bin/sh\nc++filt $$@\n" > upstream/install/bin/c++filt3; chmod +x upstream/install/bin/c++filt3
43         touch $@
44
45 # building gcc requires binutils
46 .configure_gcc-3.3_$(target): .install_binutils-2.13.2.1_$(target)
47
48 # how to configure it
49 configure_gcc-3.3                       := --enable-languages=c,c++,java --enable-gc-type=boehm --disable-shared --disable-jvmpi
50 configure_gcc-3.3                       += --disable-java-awt --disable-interpreter --enable-static
51 configure_gcc-3.3                       += --with-gnu-ld --with-gnu-as --enable-libgcj
52 configure_gcc-3.3-powerpc-apple         := --enable-threads=posix --disable-hash-synchronization 
53 configure_gcc-3.3-powerpc-apple         := --with-headers=../../install/$(target)/include
54 configure_gcc-3.3-i686-pc-mingw32       := --enable-threads=win32 --enable-hash-synchronization
55 configure_gcc-3.3-i686-pc-linux-gnu     := --enable-threads=posix --enable-hash-synchronization
56 configure_gcc-3.3-sparc-sun-solaris2.7  := --enable-threads=posix --disable-multilib
57 configure_gcc-3.3-mips                  := --enable-languages=c --nfp --with-newlib=yes --enable-multilib --disable-threads
58
59 .PRECIOUS: .vendor .download_% .configure_%_$(target) .install_%_$(target)
60
61 # vendor-supplied binaries and headers; this is stuff that comes with various OSes
62 vendor: .vendor; @true
63 .vendor:
64         @echo -e "\n\033[1mdownloading vendor-supplied headers and libraries...\033[0m"
65         mkdir -p upstream/install
66         curl http://www.megacz.com/vendor.tgz | tar xzf - -C upstream/install
67         mkdir -p upstream/install/i686-pc-mingw32
68         curl $(url_w32api-2.3) | tar xzf - -C upstream/install/i686-pc-mingw32
69         curl $(url_mingw-runtime-3.0) | tar xzf - -C upstream/install/i686-pc-mingw32
70         touch .vendor
71
72 .download_%:
73         @echo -e "\n\033[1mdownloading $*...\033[0m"
74         mkdir -p upstream/$*
75         curl $(url_$*) | tar xzf - -C upstream/$*
76         mv upstream/$*/$* upstream/$*/src; true
77         (test -e upstream/$*/patches && cd upstream/$*/src && for A in ../patches/*.patch; do patch -p0 < $$A; done); true
78         touch $@
79
80 .configure_%_$(target): .download_% 
81         @echo -e "\n\033[1mconfiguring $*...\033[0m"
82         mkdir -p upstream/$*/build-$(target)
83         cd upstream/$*/build-$(target); \
84                 $(setcc) ../src/configure \
85                 --target=$(target) \
86                 --prefix=`pwd`/../../install \
87                 $(configure_$*) \
88                 $(configure_$*-$(target))
89         touch $@
90
91 .install_%_$(target): .configure_%_$(target)
92         @echo -e "\n\033[1mbuilding $*...\033[0m"
93         cd upstream/$*/build-$(target); $(setcc) PATH=$$PATH:`pwd`/../../install/bin make
94         @echo -e "\n\033[1minstalling $*...\033[0m"
95         cd upstream/$*/build-$(target); $(setcc) PATH=$$PATH:`pwd`/../../install/bin make install
96         touch $@
97
98 .install_freetype-2.1.4_$(target): .download_freetype-2.1.4_$(target) .install_binutils-2.13.2.1_$(target) .install_gcc-3.3_$(target)
99         @echo -e "\n\033[1mbuilding freetype $*...\033[0m"
100         cd upstream/freetype-2.1.4/src; make setup ansi; PATH=$$PATH:`pwd`/../install/bin make CC=mips-gcc AR=mips-ar
101         ../install/bin/mips-ranlib freetype-2.1.4/objs/libfreetype.a
102         touch $@
103
104 # jikes has a special target to autodetect a pre-installed jikes, and to autodetect the JVM's $CLASSPATH
105 .jikes:
106         @echo -e "\n\033[1mdetecting your jikes installation...\033[0m"
107         echo "#!/bin/sh" > .jikes
108         echo 'for A in `find build/class -name \*.class`; do mv $$A $$A.old; done;' >> .jikes
109         echo -n 'PATH=$$PATH:upstream/install/bin/ jikes -classpath lib/libgcj-minimal.jar $$@ -d build/class/ -sourcepath build/java/ ' >> .jikes
110         (type jikes && (jikes --version | grep "Version 1.18")) || make install_jikes-1.18
111         echo -n "$(jikes_flags) -bootclasspath " >> .jikes
112         echo "public class GetBootClassPath { public static void main(String[] s) { " > GetBootClassPath.java
113         echo "System.out.println(System.getProperty(\"sun.boot.class.path\")); } }"  >> GetBootClassPath.java
114         javac GetBootClassPath.java
115         java -cp . GetBootClassPath >> .jikes
116         rm GetBootClassPath.*
117         echo 'EXIT=$$?' >> .jikes
118         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
119         echo 'for A in `find build/class -name \*.class`; do test -e $$A.old && rm $$A.old; done' >> .jikes
120         echo 'exit $$EXIT' >> .jikes
121         chmod +x .jikes