541a547f47d2c00f78a029fa634d36c893b51577
[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
9 # where to get stuff
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
19 # building gcc requires binutils
20 configure_gcc-3.3: install_binutils-2.13.2.1
21
22 # how to configure it
23 configure_gcc-3.3                       := --enable-languages=c,c++,java --enable-gc-type=boehm --disable-shared --disable-jvmpi
24 configure_gcc-3.3                       += --disable-java-awt --disable-interpreter --enable-static
25 configure_gcc-3.3                       += --with-gnu-ld --with-gnu-as --enable-libgcj
26 configure_gcc-3.3-powerpc-apple         := --enable-threads=posix --disable-hash-synchronization
27 configure_gcc-3.3-i686-pc-mingw32       := --enable-threads=win32 --enable-hash-synchronization
28 configure_gcc-3.3-i686-pc-linux-gnu     := --enable-threads=posix --enable-hash-synchronization
29 configure_gcc-3.3-sparc-sun-solaris2.7  := --enable-threads=posix --disable-multilib
30 configure_gcc-3.3-mips                  := --enable-languages=c --nfp --with-newlib=yes --enable-multilib --disable-threads
31
32 .PRECIOUS: .vendor .download_%_$(target) .configure_%_$(target) .install_%_$(target)
33
34 # vendor-supplied binaries and headers; this is stuff that comes with various OSes
35 vendor: .vendor; @true
36 .vendor:
37         @echo -e "\n\033[1mdownloading vendor-supplied headers and libraries...\033[0m"
38         curl http://www.megacz.com/vendor.tgz | tar xzf - -C upstream/install
39         mkdir -p upstream/install/i686-pc-mingw32
40         curl $(url_w32api-2.3) | tar xzf - -C upstream/install/i686-pc-mingw32
41         curl $(url_mingw-runtime-3.0) | tar xzf - -C upstream/install/i686-pc-mingw32
42         touch .vendor
43
44 .download_%:
45         @echo -e "\n\033[1mdownloading $*...\033[0m"
46         mkdir -p upstream/$*
47         curl $(url_$*) | tar xzf - -C upstream/$*
48         mv upstream/$*/$* upstream/$*/src; true
49         (test -e upstream/$*/patches && cd upstream/$*/src && for A in ../patches/*.patch; do patch -p0 < $$A; done); true
50         touch $@
51
52 .configure_%_$(target): .download_% 
53         @echo -e "\n\033[1mconfiguring $*...\033[0m"
54         mkdir -p upstream/$*/build-$(target)
55         cd upstream/$*/build-$(target); \
56                 $(setcc) ../src/configure \
57                 --target=$(target) \
58                 --prefix=`pwd`/../../install \
59                 $(configure_$*) \
60                 $(configure_$*-$(target))
61         touch $@
62
63 .install_%_$(target): .configure_%_$(target)
64         @echo -e "\n\033[1mbuilding $*...\033[0m"
65         cd upstream/$*/build-$(target); $(setcc) PATH=$$PATH:`pwd`/../../install/bin make
66         @echo -e "\n\033[1minstalling $*...\033[0m"
67         cd upstream/$*/build-$(target); $(setcc) PATH=$$PATH:`pwd`/../../install/bin make install
68         touch $@
69
70 .install_freetype-2.1.4_$(target): download_freetype-2.1.4 install_binutils-2.13.2.1 install_gcc-3.3
71         @echo -e "\n\033[1mbuilding freetype $*...\033[0m"
72         cd upstream/freetype-2.1.4/src; make setup ansi; PATH=$$PATH:`pwd`/../install/bin make CC=mips-gcc AR=mips-ar
73         ../install/bin/mips-ranlib freetype-2.1.4/objs/libfreetype.a
74         touch $@
75
76 # jikes has a special target to autodetect a pre-installed jikes, and to autodetect the JVM's $CLASSPATH
77 .jikes:
78         @echo -e "\n\033[1mdetecting your jikes installation...\033[0m"
79         echo "#!/bin/sh" > .jikes
80         echo 'for A in `find build/class -name \*.class`; do mv $$A $$A.old; done;' >> .jikes
81         echo -n 'PATH=$$PATH:upstream/install/bin/ jikes -classpath lib/libgcj-minimal.jar $$@ -d build/class/ -sourcepath build/java/ ' >> .jikes
82         (type jikes && (jikes --version | grep "Version 1.18")) || make install_jikes-1.18
83         echo -n "$(jikes_flags) -bootclasspath " >> .jikes
84         echo "public class GetBootClassPath { public static void main(String[] s) { " > GetBootClassPath.java
85         echo "System.out.println(System.getProperty(\"sun.boot.class.path\")); } }"  >> GetBootClassPath.java
86         javac GetBootClassPath.java
87         java -cp . GetBootClassPath >> .jikes
88         rm GetBootClassPath.*
89         echo 'EXIT=$$?' >> .jikes
90         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
91         echo 'for A in `find build/class -name \*.class`; do test -e $$A.old && rm $$A.old; done' >> .jikes
92         echo 'exit $$EXIT' >> .jikes
93         chmod +x .jikes