3 # this is where this script will store downloaded files and check for already
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
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
26 # If detection fails, override the value of make manually:
29 ##############################################################################
32 # These are the tools this script requires and depends upon.
33 reqtools
="gcc bzip2 make patch"
42 # echo "checks for $file in $path" >&2
43 if test -f "$path/$file"; then
59 if test -z "$tool"; then
61 if test -n "$tool"; then
63 echo "ROCKBOXDEV: downloads $2/$1 using wget"
64 $tool -O $dlwhere/$1 $2/$1
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"
80 for t
in $reqtools; do
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."
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"
98 if test $?
-ne 0; then
99 echo "$dlwhere is missing and we failed to create it!"
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"
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"
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
*
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
143 gccurl
="http://www.rockbox.org/twiki/pub/Main/CrossCompiler"
144 gccpatch
="gcc-4.0.3-rockbox-1.diff"
151 gccurl
="http://www.rockbox.org/twiki/pub/Main/CrossCompiler"
152 gccpatch
="gcc-3.4.6.patch"
158 gccurl
="http://www.rockbox.org/twiki/pub/Main/CrossCompiler"
159 gccpatch
="gcc-3.4.6-amd64.patch"
169 gccurl
="http://www.rockbox.org/twiki/pub/Main/CrossCompiler"
170 gccpatch
="thumb-interwork-4.0.3.diff"
178 bindir
="$prefix/$target/bin"
179 if test -n $pathadd; then
180 pathadd
="$pathadd:$bindir"
190 echo "== Summary ==" > $summary
191 echo "Target: $target" >> $summary
192 echo "gcc $gccver" >> $summary
193 if test -n "$gccpatch"; then
194 echo "gcc patch $gccpatch" >> $summary
196 echo "binutils $binutils" >> $summary
197 echo "install in $prefix/$target" >> $summary
198 echo "when complete, make your PATH include $bindir" >> $summary
202 if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then
203 echo "binutils $binutils already downloaded"
205 getfile binutils-
$binutils.
tar.bz2
ftp://ftp.gnu.org
/pub
/gnu
/binutils
208 if test -f "$dlwhere/gcc-core-$gccver.tar.bz2"; then
209 echo "gcc $gccver already downloaded"
211 getfile gcc-core-
$gccver.
tar.bz2
ftp://ftp.gnu.org
/pub
/gnu
/gcc
/gcc-
$gccver
214 if test -n "$gccpatch"; then
215 if test -f "$dlwhere/$gccpatch"; then
216 echo "$gccpatch already downloaded"
218 getfile
"$gccpatch" "$gccurl"
222 echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir"
223 tar xjf
$dlwhere/binutils-
$binutils.
tar.bz2
224 echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir"
225 tar xjf
$dlwhere/gcc-core-
$gccver.
tar.bz2
227 if test -n "$gccpatch"; then
228 echo "ROCKBOXDEV: applying gcc patch"
229 patch -p0 < "$dlwhere/$gccpatch"
232 echo "ROCKBOXDEV: mkdir build-binu"
234 echo "ROCKBOXDEV: cd build-binu"
236 echo "ROCKBOXDEV: binutils/configure"
237 ..
/binutils-
$binutils/configure
--target=$target --prefix=$prefix/$target
238 echo "ROCKBOXDEV: binutils/make"
240 echo "ROCKBOXDEV: binutils/make install to $prefix/$target"
242 cd ..
# get out of build-binu
243 PATH
="${PATH}:$bindir"
244 SHELL
=/bin
/sh
# seems to be needed by the gcc build in some cases
246 echo "ROCKBOXDEV: mkdir build-gcc"
248 echo "ROCKBOXDEV: cd build-gcc"
250 echo "ROCKBOXDEV: gcc/configure"
251 ..
/gcc-
$gccver/configure
--target=$target --prefix=$prefix/$target --enable-languages=c
252 echo "ROCKBOXDEV: gcc/make"
254 echo "ROCKBOXDEV: gcc/make install to $prefix/$target"
256 cd ..
# get out of build-gcc
257 cd ..
# get out of $builddir
259 # end of buildone() function
263 echo "Select target arch:"
264 echo "s - sh (Archos models)"
265 echo "m - m68k (iriver h1x0/h3x0, ifp7x0 and iaudio)"
266 echo "a - arm (ipods, iriver H10, Sansa, etc)"
267 echo "all - all three compilers"
282 echo "build ALL compilers!"
291 # show the summaries:
292 cat $builddir/summary-
*
295 echo "unsupported architecture option"
302 echo "Make your PATH include $pathadd"