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"
149 gccurl
="http://www.rockbox.org/twiki/pub/Main/CrossCompiler"
150 gccpatch
="thumb-interwork-4.0.3.diff"
158 bindir
="$prefix/$target/bin"
159 if test -n $pathadd; then
160 pathadd
="$pathadd:$bindir"
170 echo "== Summary ==" > $summary
171 echo "Target: $target" >> $summary
172 echo "gcc $gccver" >> $summary
173 if test -n "$gccpatch"; then
174 echo "gcc patch $gccpatch" >> $summary
176 echo "binutils $binutils" >> $summary
177 echo "install in $prefix/$target" >> $summary
178 echo "when complete, make your PATH include $bindir" >> $summary
182 if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then
183 echo "binutils $binutils already downloaded"
185 getfile binutils-
$binutils.
tar.bz2
ftp://ftp.gnu.org
/pub
/gnu
/binutils
188 if test -f "$dlwhere/gcc-core-$gccver.tar.bz2"; then
189 echo "gcc $gccver already downloaded"
191 getfile gcc-core-
$gccver.
tar.bz2
ftp://ftp.gnu.org
/pub
/gnu
/gcc
/gcc-
$gccver
194 if test -n "$gccpatch"; then
195 if test -f "$dlwhere/$gccpatch"; then
196 echo "$gccpatch already downloaded"
198 getfile
"$gccpatch" "$gccurl"
202 echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir"
203 tar xjf
$dlwhere/binutils-
$binutils.
tar.bz2
204 echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir"
205 tar xjf
$dlwhere/gcc-core-
$gccver.
tar.bz2
207 if test -n "$gccpatch"; then
208 echo "ROCKBOXDEV: applying gcc patch"
209 patch -p0 < "$dlwhere/$gccpatch"
212 echo "ROCKBOXDEV: mkdir build-binu"
214 echo "ROCKBOXDEV: cd build-binu"
216 echo "ROCKBOXDEV: binutils/configure"
217 ..
/binutils-
$binutils/configure
--target=$target --prefix=$prefix/$target
218 echo "ROCKBOXDEV: binutils/make"
220 echo "ROCKBOXDEV: binutils/make install to $prefix/$target"
222 cd ..
# get out of build-binu
223 PATH
="${PATH}:$bindir"
224 SHELL
=/bin
/sh
# seems to be needed by the gcc build in some cases
226 echo "ROCKBOXDEV: mkdir build-gcc"
228 echo "ROCKBOXDEV: cd build-gcc"
230 echo "ROCKBOXDEV: gcc/configure"
231 ..
/gcc-
$gccver/configure
--target=$target --prefix=$prefix/$target --enable-languages=c
232 echo "ROCKBOXDEV: gcc/make"
234 echo "ROCKBOXDEV: gcc/make install to $prefix/$target"
236 cd ..
# get out of build-gcc
237 cd ..
# get out of $builddir
239 # end of buildone() function
243 echo "Select target arch:"
244 echo "s - sh (Archos models)"
245 echo "m - m68k (iriver h1x0/h3x0, ifp7x0 and iaudio)"
246 echo "a - arm (ipods, iriver H10, Sansa, etc)"
247 echo "all - all three compilers"
262 echo "build ALL compilers!"
271 # show the summaries:
272 cat $builddir/summary-
*
275 echo "unsupported architecture option"
282 echo "Make your PATH include $pathadd"