3 # this is where this script will store downloaded files and check for already
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
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
="$HOME/build-rbdev"
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 [ -n "`which gmake`" ]; then
26 # If detection fails, override the value of make manually:
29 ##############################################################################
38 # echo "checks for $file in $path" >&2
39 if test -f "$path/$file"; then
55 if test -z "$tool"; then
57 if test -n "$tool"; then
59 echo "ROCKBOXDEV: downloads $2/$1 using wget"
60 $tool -O $dlwhere/$1 $2/$1
64 echo "ROCKBOXDEV: downloads $2/$1 using curl"
65 $tool -Lo $dlwhere/$1 $2/$1
67 if test -z "$tool"; then
68 echo "ROCKBOXDEV: couldn't find any downloader tool to use!"
69 echo "ROCKBOXDEV: install curl or wget and re-run the script"
76 ###########################################################################
77 # Verify download directory or create it
78 if test -d "$dlwhere"; then
79 if ! test -w "$dlwhere"; then
80 echo "$dlwhere exists, but doesn't seem to be writable for you"
85 if test $?
-ne 0; then
86 echo "$dlwhere is missing and we failed to create it!"
89 echo "$dlwhere has been created to store downloads in"
92 echo "Download directory: $dlwhere (edit script to change dir)"
93 echo "Install prefix: $prefix/[target] (edit script to change dir)"
94 echo "Build dir: $builddir (edit script to change dir)"
96 ###########################################################################
97 # Verify that we can write in the prefix dir, as otherwise we will hardly
98 # be able to install there!
99 if test ! -w $prefix; then
100 echo "WARNING: this script is set to install in $prefix but has no"
101 echo "WARNING: write permission to do so! Please fix and re-run this script"
106 ###########################################################################
107 # If there's already a build dir, we don't overwrite it
108 if test -d $builddir; then
109 echo "you have a $builddir dir already, please remove and rerun"
114 # $1 is the name of the build dir
115 # delete the build dirs and the source dirs
116 rm -rf $1/build-gcc
$1/build-binu
$1/gcc
* $1/binutils
*
121 gccpatch
="" # default is no gcc patch
122 gccver
="4.0.3" # default gcc version
123 binutils
="2.16.1" # The binutils version to use
130 gccurl
="http://www.rockbox.org/twiki/pub/Main/CrossCompiler"
131 gccpatch
="gcc-4.0.3-rockbox-1.diff"
138 gccurl
="http://www.rockbox.org/twiki/pub/Main/CrossCompiler"
139 gccpatch
="gcc-3.4.6.patch"
156 bindir
="$prefix/$target/bin"
157 if test -n $pathadd; then
158 pathadd
="$pathadd:$bindir"
168 echo "== Summary ==" > $summary
169 echo "Target: $target" >> $summary
170 echo "gcc $gccver" >> $summary
171 if test -n "$gccpatch"; then
172 echo "gcc patch $gccpatch" >> $summary
174 echo "binutils $binutils" >> $summary
175 echo "install in $prefix/$target" >> $summary
176 echo "when complete, make your PATH include $bindir" >> $summary
180 if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then
181 echo "binutils $binutils already downloaded"
183 getfile binutils-
$binutils.
tar.bz2
ftp://ftp.gnu.org
/pub
/gnu
/binutils
186 if test -f "$dlwhere/gcc-$gccver.tar.bz2"; then
187 echo "gcc $gccver already downloaded"
189 getfile gcc-
$gccver.
tar.bz2
ftp://ftp.gnu.org
/pub
/gnu
/gcc
/gcc-
$gccver
192 if test -n "$gccpatch"; then
193 if test -f "$dlwhere/$gccpatch"; then
194 echo "$gccpatch already downloaded"
196 getfile
"$gccpatch" "$gccurl"
200 echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir"
201 tar xjf
$dlwhere/binutils-
$binutils.
tar.bz2
202 echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir"
203 tar xjf
$dlwhere/gcc-
$gccver.
tar.bz2
205 if test -n "$gccpatch"; then
206 echo "ROCKBOXDEV: applying gcc patch"
207 patch -p0 < "$dlwhere/$gccpatch"
210 echo "ROCKBOXDEV: mkdir build-binu"
212 echo "ROCKBOXDEV: cd build-binu"
214 echo "ROCKBOXDEV: binutils/configure"
215 ..
/binutils-
$binutils/configure
--target=$target --prefix=$prefix/$target
216 echo "ROCKBOXDEV: binutils/make"
218 echo "ROCKBOXDEV: binutils/make install to $prefix/$target"
220 cd ..
# get out of build-binu
221 PATH
="${PATH}:$bindir"
222 SHELL
=/bin
/sh
# seems to be needed by the gcc build in some cases
224 echo "ROCKBOXDEV: mkdir build-gcc"
226 echo "ROCKBOXDEV: cd build-gcc"
228 echo "ROCKBOXDEV: gcc/configure"
229 ..
/gcc-
$gccver/configure
--target=$target --prefix=$prefix/$target --enable-languages=c
230 echo "ROCKBOXDEV: gcc/make"
232 echo "ROCKBOXDEV: gcc/make install to $prefix/$target"
234 cd ..
# get out of build-gcc
235 cd ..
# get out of $builddir
237 # end of buildone() function
241 echo "Select target arch:"
242 echo "s - sh (Archos models)"
243 echo "m - m68k (iriver h1x0/h3x0, ifp7x0 and iaudio)"
244 echo "a - arm (ipods, iriver H10, Sansa, etc)"
245 echo "all - all three compilers"
260 echo "build ALL compilers!"
269 # show the summaries:
270 cat $builddir/summary-
*
273 echo "unsupported architecture option"
280 echo "Make your PATH include $pathadd"