bcel fix
[nestedvm.git] / upstream / Makefile
1 # Inspired by XWT's Makefile.upstream
2
3 version_gcc = 3.3.3
4 url_gcc-core = http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(version_gcc)/gcc-core-$(version_gcc).tar.gz
5 url_gcc-c++ = http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(version_gcc)/gcc-g++-$(version_gcc).tar.gz
6 patches_gcc = gcc-fixes.patch gcc-fdata-sections-bss.patch
7 configure_gcc = --target=mips-unknown-elf --disable-threads --with-gnu-ld --with-gnu-as --with-newlib=yes --enable-sjlj-exceptions --enable-languages="c"
8 configure_gcc_step2 = $(configure_gcc) --enable-languages="c,c++"
9
10 version_binutils = 2.14
11 url_binutils = ftp://ftp.gnu.org/gnu/binutils/binutils-$(version_binutils).tar.gz
12 patches_binutils = binutils-no64.patch
13 configure_binutils = --target=mips-unknown-elf
14
15 version_newlib = 1.11.0
16 url_newlib = http://mirrors.rcn.net/pub/sourceware/newlib/newlib-$(version_newlib).tar.gz
17 patches_newlib = newlib-mips.patch newlib-tzset.patch newlib-malloc.patch
18 configure_newlib = --enable-multilib --target=mips-unknown-elf
19
20 url_openbsdglob = http://www.brianweb.net/xwt/openbsdglob.tar.gz
21 url_regex = ftp://ftp.zoo.toronto.edu/pub/regex.shar
22
23 version_bcel = 5.1
24 url_bcel = http://mirrors.mix5.com/apache/jakarta/bcel/binaries/bcel-$(version_bcel).tar.gz
25
26 .SECONDARY: # This is broken in gmake < 3.79.1
27
28 upstream = $(shell pwd)
29 root = $(shell dirname "`pwd`")
30 prefix = $(upstream)/install
31
32 PATH := $(prefix)/bin:$(PATH)
33 export PATH
34
35 # Solaris' patch doesn't work, use gnu patch on solaris
36 PATCH = $(shell test `uname` = SunOS && echo gpatch || echo patch)
37
38 tasks/full_toolchain: tasks/build_binutils tasks/build_gcc_step2 tasks/build_libc
39         touch $@
40
41 tasks/build_gcc: tasks/build_binutils
42 tasks/build_newlib: tasks/build_gcc
43
44 tasks/build_libc: tasks/build_newlib tasks/build_regex tasks/build_openbsdglob
45         rm -f install/mips-unknown-elf/lib/crt0.o
46         ln -s $(root)/build/org/xwt/mips/crt0.o install/mips-unknown-elf/lib/crt0.o 
47         echo '#include <unistd.h>' > install/mips-unknown-elf/include/getopt.h
48         touch $@
49
50 clean_%:
51         rm -rf "build/$(*)"*
52         rm -f "tasks/build_$*" "tasks/patch_$*" "tasks/extract_$*"
53
54 tasks/download_%:
55         if [ -z "$(url_$*)" ]; then echo "No url for $*" >&2; false; fi
56         mkdir -p download
57         cd download && wget --passive-ftp -N $(url_$*)
58         touch $@
59
60 tasks/download_gcc: tasks/download_gcc-core tasks/download_gcc-c++
61         touch $@
62
63 tasks/extract_%: tasks/download_%
64         mkdir -p build
65         cd build && \
66                 gzip -dc  ../download/$*-$(version_$*).tar.gz | tar xf - && \
67                 rm -f $* && \
68                 ln -s $*-$(version_$*) $*
69         touch $@
70
71 tasks/extract_gcc: tasks/download_gcc
72         mkdir -p build
73         cd build && gzip -dc ../download/gcc-core-$(version_gcc).tar.gz | tar xf -
74         cd build && gzip -dc ../download/gcc-g++-$(version_gcc).tar.gz | tar xf -
75         touch $@
76
77 tasks/patch_%: tasks/extract_%
78         cd build/$*-$(version_$*) &&  \
79         for p in $(patches_$*) end; do \
80                 [ "$$p" = "end" ] || $(PATCH) -p0 < ../../patches/$$p || exit 1; \
81         done
82         touch $@
83
84 tasks/build_%: tasks/patch_%
85         mkdir -p install
86         @[ "$*" = "newlib" ] && rm -f install/mips-unknown-elf/lib/crt0.o || true
87         mkdir -p build/$*-obj && cd build/$*-obj && \
88                 ../$*-$(version_$*)/configure --prefix=$(prefix) $(configure_$*) && \
89                 $(MAKE) TARGET_CFLAGS="$(MIPS_CFLAGS)" && \
90                 $(MAKE) install
91         touch $@
92
93 tasks/build_gcc_step2: tasks/patch_gcc tasks/build_libc
94         mkdir -p install
95         mkdir -p build/gcc-obj && cd build/gcc-obj && \
96                 ../gcc-$(version_gcc)/configure --prefix=$(prefix) $(configure_gcc_step2) && \
97                 $(MAKE) TARGET_CFLAGS="$(MIPS_CFLAGS)" && \
98                 $(MAKE) install
99         touch $@
100
101 tasks/build_openbsdglob: tasks/download_openbsdglob tasks/build_newlib
102         @mkdir -p install/mips-unknown-elf/{include,lib}
103         cd build && gzip -dc ../download/openbsdglob.tar.gz | tar xf -
104         cd build/openbsdglob && \
105                 mips-unknown-elf-gcc '-Dissetugid()=0' -DARG_MAX=65536 $(MIPS_CFLAGS) -I. -c -o glob.o glob.c && \
106                 mips-unknown-elf-gcc -O2 -Wall -Werror -I. -c -o fnmatch.o fnmatch.c && \
107                 mips-unknown-elf-ar cr libglob.a *.o && \
108                 mips-unknown-elf-ranlib libglob.a && \
109                 cp *.h ../../install/mips-unknown-elf/include && \
110                 cp *.a ../../install/mips-unknown-elf/lib
111         touch $@
112
113 tasks/build_regex: tasks/download_regex tasks/build_newlib
114         @mkdir -p install/mips-unknown-elf/{include,lib}
115         mkdir -p build/regex build/regex/fake
116         cd build/regex && \
117                 sh ../../download/regex.shar && \
118                 make CC=mips-unknown-elf-gcc CFLAGS="-I. $(MIPS_CFLAGS)" regcomp.o regexec.o regerror.o regfree.o && \
119                 mips-unknown-elf-ar cr libregex.a regcomp.o regexec.o regerror.o regfree.o && \
120                 mips-unknown-elf-ranlib libregex.a && \
121                 cp regex.h ../../install/mips-unknown-elf/include && \
122                 cp libregex.a ../../install/mips-unknown-elf/lib 
123         touch $@
124
125
126 #
127 # Tests
128 # These are simply here for convenience. They aren't required 
129 # to build or run mips2java
130 #
131
132 tasks/build_freetype: tasks/full_toolchain
133 tasks/build_libjpeg: tasks/full_toolchain
134 tasks/build_boehmgc: tasks/full_toolchain
135 tasks/build_libmspack: tasks/full_toolchain
136 tasks/build_freetype: tasks/full_toolchain
137
138 version_libjpeg = 6b
139 url_libjpeg = http://www.ijg.org/files/jpegsrc.v$(version_libjpeg).tar.gz
140
141 version_libmspack = 20030726
142 url_libmspack = http://www.kyz.uklinux.net/downloads/libmspack-$(version_libmspack).tar.gz
143 patches_libmspack = libmspack.patch
144
145 version_freetype = 2.1.4
146 url_freetype = http://umn.dl.sourceforge.net/sourceforge/freetype/freetype-$(version_freetype).tar.gz
147 patches_freetype = freetype.patch ft-nostdio.patch
148
149 version_boehmgc = 6.3alpha2
150 url_boehmgc = http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc$(version_boehmgc).tar.gz
151 patches_boehmgc = boehm-gc.patch
152
153 version_busybox = 0.60.5
154 url_busybox = http://busybox.net/downloads/busybox-$(version_busybox).tar.gz
155 patches_busybox = busybox.patch
156
157
158 tasks/extract_libjpeg: tasks/download_libjpeg
159         mkdir -p build
160         cd build && \
161                 gzip -dc ../download/jpegsrc.v$(version_libjpeg).tar.gz | tar xf - && \
162                 mv jpeg-$(version_libjpeg) libjpeg-$(version_libjpeg) && \
163                 rm -f libjpeg && \
164                 ln -s libjpeg-$(version_libjpeg)  libjpeg
165         touch $@    
166
167 tasks/build_libjpeg: tasks/patch_libjpeg
168         cd build/libjpeg-$(version_libjpeg) && \
169                 ./configure && \
170                 make CC="mips-unknown-elf-gcc" \
171                         AR="mips-unknown-elf-ar rc" \
172                         AR2="mips-unknown-elf-ranlib" \
173                         CFLAGS="$(MIPS_CFLAGS)" \
174                         LDFLAGS="$(MIPS_LDFLAGS)"
175         touch $@    
176
177 tasks/extract_libmspack: tasks/download_libmspack
178         mkdir -p build
179         cd build && \
180                 gzip -dc ../download/libmspack-$(version_libmspack).tar.gz | tar xf - && \
181                 mv libmspack libmspack-$(version_libmspack) && \
182                 rm -f libmspack && \
183                 ln -s libmspack-$(version_libmspack)  libmspack
184         touch $@    
185
186 tasks/build_libmspack: tasks/patch_libmspack tasks/full_toolchain
187         cd build/libmspack-$(version_libmspack)/mspack && \
188                 make CC="mips-unknown-elf-gcc" \
189                         AR="mips-unknown-elf-ar" \
190                         RANLIB="mips-unknown-elf-ranlib" \
191                         OPTIM="$(MIPS_CFLAGS)"
192         touch $@    
193
194 tasks/build_freetype: tasks/patch_freetype tasks/full_toolchain
195         cd build/freetype-$(version_freetype) && \
196                 $(MAKE) setup ansi && \
197                 $(MAKE) CC="mips-unknown-elf-gcc" \
198                     CFLAGS="-c $(MIPS_CFLAGS)" \
199                         AR="mips-unknown-elf-ar" \
200                         RANLIB="mips-unknown-elf-ranlib" && \
201                 mips-unknown-elf-ranlib objs/libfreetype.a
202         touch $@    
203
204 tasks/extract_boehmgc: tasks/download_boehmgc
205         mkdir -p build
206         cd build && \
207                 rm -rf gc$(version_boehmgc) && \
208                 gzip -dc ../download/gc$(version_boehmgc).tar.gz | tar xf - && \
209                 rm -f boehmgc boehmgc-$(version_boehmgc) && \
210                 ln -s gc$(version_boehmgc)  boehmgc && \
211                 ln -s gc$(version_boehmgc)  boehmgc-$(version_boehmgc)
212         touch $@
213
214 tasks/build_boehmgc: tasks/patch_boehmgc tasks/full_toolchain
215         cd build/gc$(version_boehmgc) && \
216                 CC="mips-unknown-elf-gcc" CFLAGS="$(MIPS_CFLAGS)" LDFLAGS="$(MIPS_LDFLAGS)" \
217                 ./configure --host=mips-unknown-elf --disable-shared --disable-threads && \
218                 make && \
219                 make gctest 
220         touch $@
221
222 tasks/build_busybox: tasks/patch_busybox tasks/full_toolchain
223         cd build && \
224                 rm -f busybox && \
225                 ln -s busybox-$(version_busybox) busybox
226         cd build/busybox && $(MAKE) SHELL=/bin/bash LDFLAGS="$(MIPS_LDFLAGS)" CFLAGS_EXTRA="$(MIPS_CFLAGS) -g"
227         touch $@