Asap codec: put outputbuffer into iram. Improves performance.
[kugel-rb.git] / tools / rockboxdev.sh
blob9bbe56c25bc8a1754eda657e5d64dc5af137bc42
1 #!/bin/sh
3 # this is where this script will store downloaded files and check for already
4 # downloaded files
5 dlwhere="/tmp/rbdev-dl"
7 # will append the target string to the prefix dir mentioned here
8 # Note that the user running this script must be able to do make install in
9 # this given prefix directory. Also make sure that this given root dir
10 # exists.
11 prefix="/usr/local"
13 # This directory is used to extract all files and to build everything in. It
14 # must not exist before this script is invoked (as a security measure).
15 builddir="/tmp/rbdev-build"
17 # This script needs to use GNU Make. On Linux systems, GNU Make is invoked
18 # by running the "make" command, on most BSD systems, GNU Make is invoked
19 # by running the "gmake" command. Set the "make" variable accordingly.
20 if [ -f "`which gmake`" ]; then
21 make="gmake"
22 else
23 make="make"
26 # If detection fails, override the value of make manually:
27 # make="make"
29 ##############################################################################
32 # These are the tools this script requires and depends upon.
33 reqtools="gcc bzip2 make patch"
36 findtool(){
37 file="$1"
39 IFS=":"
40 for path in $PATH
42 # echo "checks for $file in $path" >&2
43 if test -f "$path/$file"; then
44 echo "$path/$file"
45 return
47 done
50 input() {
51 read response
52 echo $response
55 #$1 file
56 #$2 URL"root
57 getfile() {
58 tool=`findtool curl`
59 if test -z "$tool"; then
60 tool=`findtool wget`
61 if test -n "$tool"; then
62 # wget download
63 echo "ROCKBOXDEV: downloads $2/$1 using wget"
64 $tool -O $dlwhere/$1 $2/$1
66 else
67 # curl download
68 echo "ROCKBOXDEV: downloads $2/$1 using curl"
69 $tool -Lo $dlwhere/$1 $2/$1
71 if test -z "$tool"; then
72 echo "ROCKBOXDEV: couldn't find any downloader tool to use!"
73 echo "ROCKBOXDEV: install curl or wget and re-run the script"
74 exit
80 for t in $reqtools; do
81 tool=`findtool $t`
82 if test -z "$tool"; then
83 echo "ROCKBOXDEV: $t is required for this script to work. Please"
84 echo "ROCKBOXDEV: install and re-run the script."
85 exit
87 done
89 ###########################################################################
90 # Verify download directory or create it
91 if test -d "$dlwhere"; then
92 if ! test -w "$dlwhere"; then
93 echo "$dlwhere exists, but doesn't seem to be writable for you"
94 exit
96 else
97 mkdir $dlwhere
98 if test $? -ne 0; then
99 echo "$dlwhere is missing and we failed to create it!"
100 exit
102 echo "$dlwhere has been created to store downloads in"
105 echo "Download directory: $dlwhere (edit script to change dir)"
106 echo "Install prefix: $prefix/[target] (edit script to change dir)"
107 echo "Build dir: $builddir (edit script to change dir)"
109 ###########################################################################
110 # Verify that we can write in the prefix dir, as otherwise we will hardly
111 # be able to install there!
112 if test ! -w $prefix; then
113 echo "WARNING: this script is set to install in $prefix but has no"
114 echo "WARNING: write permission to do so! Please fix and re-run this script"
115 exit
119 ###########################################################################
120 # If there's already a build dir, we don't overwrite it
121 if test -d $builddir; then
122 echo "you have a $builddir dir already, please remove and rerun"
123 exit
126 cleardir () {
127 # $1 is the name of the build dir
128 # delete the build dirs and the source dirs
129 rm -rf $1/build-gcc $1/build-binu $1/gcc* $1/binutils*
132 buildone () {
134 gccpatch="" # default is no gcc patch
135 gccver="4.0.3" # default gcc version
136 binutils="2.16.1" # The binutils version to use
137 gccconfigure="" #default is nothing added to configure
139 system=`uname -s`
140 gccurl="http://www.rockbox.org/gcc"
142 case $1 in
143 [Ss])
144 target="sh-elf"
145 gccpatch="gcc-4.0.3-rockbox-1.diff"
147 [Mm])
148 target="m68k-elf"
149 gccver="3.4.6"
150 case $system in
151 CYGWIN* | Darwin | FreeBSD)
152 gccpatch="gcc-3.4.6.patch"
154 Linux)
155 machine=`uname -m`
156 case $machine in
157 x86_64)
158 gccpatch="gcc-3.4.6-amd64.patch"
160 esac
164 esac
166 [Aa])
167 target="arm-elf"
168 gccpatch="rockbox-multilibs-arm-elf-gcc-4.0.3_2.diff"
170 [Ii])
171 target="mipsel-elf"
172 gccver="4.1.2"
173 binutils="2.17"
174 gccconfigure="--disable-libssp"
177 echo "unsupported"
178 exit
180 esac
182 bindir="$prefix/$target/bin"
183 if test -n $pathadd; then
184 pathadd="$pathadd:$bindir"
185 else
186 pathadd="$bindir"
189 mkdir $builddir
190 cd $builddir
192 summary="summary-$1"
194 echo "== Summary ==" > $summary
195 echo "Target: $target" >> $summary
196 echo "gcc $gccver" >> $summary
197 if test -n "$gccpatch"; then
198 echo "gcc patch $gccpatch" >> $summary
200 echo "binutils $binutils" >> $summary
201 echo "install in $prefix/$target" >> $summary
202 echo "when complete, make your PATH include $bindir" >> $summary
204 cat $summary
206 if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then
207 echo "binutils $binutils already downloaded"
208 else
209 getfile binutils-$binutils.tar.bz2 ftp://ftp.gnu.org/pub/gnu/binutils
212 if test -f "$dlwhere/gcc-core-$gccver.tar.bz2"; then
213 echo "gcc $gccver already downloaded"
214 else
215 getfile gcc-core-$gccver.tar.bz2 ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$gccver
218 if test -n "$gccpatch"; then
219 if test -f "$dlwhere/$gccpatch"; then
220 echo "$gccpatch already downloaded"
221 else
222 getfile "$gccpatch" "$gccurl"
226 echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir"
227 tar xjf $dlwhere/binutils-$binutils.tar.bz2
228 echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir"
229 tar xjf $dlwhere/gcc-core-$gccver.tar.bz2
231 if test -n "$gccpatch"; then
232 echo "ROCKBOXDEV: applying gcc patch"
233 patch -p0 < "$dlwhere/$gccpatch"
236 echo "ROCKBOXDEV: mkdir build-binu"
237 mkdir build-binu
238 echo "ROCKBOXDEV: cd build-binu"
239 cd build-binu
240 echo "ROCKBOXDEV: binutils/configure"
241 ../binutils-$binutils/configure --target=$target --prefix=$prefix/$target
242 echo "ROCKBOXDEV: binutils/make"
243 $make
244 echo "ROCKBOXDEV: binutils/make install to $prefix/$target"
245 $make install
246 cd .. # get out of build-binu
247 PATH="${PATH}:$bindir"
248 SHELL=/bin/sh # seems to be needed by the gcc build in some cases
250 echo "ROCKBOXDEV: mkdir build-gcc"
251 mkdir build-gcc
252 echo "ROCKBOXDEV: cd build-gcc"
253 cd build-gcc
254 echo "ROCKBOXDEV: gcc/configure"
255 ../gcc-$gccver/configure --target=$target --prefix=$prefix/$target --enable-languages=c $gccconfigure
256 echo "ROCKBOXDEV: gcc/make"
257 $make
258 echo "ROCKBOXDEV: gcc/make install to $prefix/$target"
259 $make install
260 cd .. # get out of build-gcc
261 cd .. # get out of $builddir
263 # end of buildone() function
266 echo ""
267 echo "Select target arch:"
268 echo "s - sh (Archos models)"
269 echo "m - m68k (iriver h1x0/h3x0, ifp7x0 and iaudio)"
270 echo "a - arm (ipods, iriver H10, Sansa, etc)"
271 echo "i - mips (Jz4740 and ATJ-based players)"
272 echo "all - all three compilers"
274 arch=`input`
276 case $arch in
277 [Ss])
278 buildone $arch
280 [Ii])
281 buildone $arch
283 [Mm])
284 buildone $arch
286 [Aa])
287 buildone $arch
289 all)
290 echo "build ALL compilers!"
291 buildone s
292 cleardir $builddir
294 buildone m
295 cleardir $builddir
297 buildone a
299 # include this when we want MIPS added in the "build all"
300 #buildone i
302 # show the summaries:
303 cat $builddir/summary-*
306 echo "unsupported architecture option"
307 exit
309 esac
311 echo "done"
312 echo ""
313 echo "Make your PATH include $pathadd"