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 [ -z $GNU_MIRROR ] ; then
27 GNU_MIRROR
=ftp://ftp.gnu.org
/pub
/gnu
30 # If detection fails, override the value of make manually:
33 ##############################################################################
36 # These are the tools this script requires and depends upon.
37 reqtools
="gcc bzip2 make patch"
46 # echo "Checks for $file in $path" >&2
47 if test -f "$path/$file"; then
63 if test -z "$tool"; then
65 if test -n "$tool"; then
67 echo "ROCKBOXDEV: Downloading $2/$1 using wget"
68 $tool -O $dlwhere/$1 $2/$1
72 echo "ROCKBOXDEV: Downloading $2/$1 using curl"
73 $tool -Lo $dlwhere/$1 $2/$1
76 if [ $?
-ne 0 ] ; then
77 echo "ROCKBOXDEV: couldn't download the file!"
78 echo "ROCKBOXDEV: check your internet connection"
82 if test -z "$tool"; then
83 echo "ROCKBOXDEV: No downloader tool found!"
84 echo "ROCKBOXDEV: Please install curl or wget and re-run the script"
89 for t
in $reqtools; do
91 if test -z "$tool"; then
92 echo "ROCKBOXDEV: $t is required for this script to work."
93 echo "ROCKBOXDEV: Please install $t and re-run the script."
98 ###########################################################################
99 # Verify download directory or create it
100 if test -d "$dlwhere"; then
101 if ! test -w "$dlwhere"; then
102 echo "$dlwhere exists, but doesn't seem to be writable for you"
107 if test $?
-ne 0; then
108 echo "$dlwhere is missing and we failed to create it!"
111 echo "$dlwhere has been created to store downloads in"
114 echo "Download directory: $dlwhere (edit script to change dir)"
115 echo "Install prefix: $prefix/[target] (edit script to change dir)"
116 echo "Build dir: $builddir (edit script to change dir)"
118 ###########################################################################
119 # Verify that we can write in the prefix dir, as otherwise we will hardly
120 # be able to install there!
121 if test ! -w $prefix; then
122 echo "WARNING: This script is set to install in $prefix but has no write permissions for it"
123 echo "Please fix this and re-run this script"
128 ###########################################################################
129 # If there's already a build dir, we don't overwrite it
130 if test -d $builddir; then
131 echo "You already have a $builddir directory!"
132 echo "Please remove it and re-run the script"
137 # $1 is the name of the build dir
138 # delete the build dirs and the source dirs
139 rm -rf $1/build-gcc
$1/build-binu
$1/gcc
* $1/binutils
*
145 gccpatch
="" # default is no gcc patch
146 gccver
="4.0.3" # default gcc version
147 binutils
="2.16.1" # The binutils version to use
148 gccconfigure
="" #default is nothing added to configure
151 gccurl
="http://www.rockbox.org/gcc"
156 gccpatch
="gcc-4.0.3-rockbox-1.diff"
162 CYGWIN
* | Darwin | FreeBSD | Interix
)
163 gccpatch
="gcc-3.4.6.patch"
169 gccpatch
="gcc-3.4.6-amd64.patch"
179 gccpatch
="rockbox-multilibs-arm-elf-gcc-4.0.3_2.diff"
185 gccconfigure
="--disable-libssp"
188 gccpatch
="gcc-4.1.2-interix.diff"
195 echo "An unsupported architecture option: $arch"
200 bindir
="$prefix/$target/bin"
201 if test -n $pathadd; then
202 pathadd
="$pathadd:$bindir"
212 echo "============================ Summary ============================" > $summary
213 echo "target: $target" >> $summary
214 echo "gcc version: $gccver" >> $summary
215 if test -n "$gccpatch"; then
216 echo "gcc patch: $gccpatch" >> $summary
218 echo "binutils: $binutils" >> $summary
219 echo "installation target: $prefix/$target" >> $summary
221 echo "When done, append $bindir to PATH" >> $summary
222 echo "=================================================================" >> $summary
227 echo "In case you encounter a slow internet connection, you can use an alternative mirror."
228 echo "A list of other GNU mirrors is available here: http://www.gnu.org/prep/ftp.html"
230 echo "Usage: GNU_MIRROR=[URL] ./rockboxdev.sh"
233 echo "$ GNU_MIRROR=http://mirrors.kernel.org/gnu ./rockboxdev.sh"
236 if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then
237 echo "binutils $binutils already downloaded"
239 getfile binutils-
$binutils.
tar.bz2
$GNU_MIRROR/binutils
242 if test -f "$dlwhere/gcc-core-$gccver.tar.bz2"; then
243 echo "gcc $gccver already downloaded"
245 getfile gcc-core-
$gccver.
tar.bz2
$GNU_MIRROR/gcc
/gcc-
$gccver
248 if test -n "$gccpatch"; then
249 if test -f "$dlwhere/$gccpatch"; then
250 echo "$gccpatch already downloaded"
252 getfile
"$gccpatch" "$gccurl"
256 echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir"
257 tar xjf
$dlwhere/binutils-
$binutils.
tar.bz2
258 echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir"
259 tar xjf
$dlwhere/gcc-core-
$gccver.
tar.bz2
261 if test -n "$gccpatch"; then
262 echo "ROCKBOXDEV: applying gcc patch"
263 patch -p0 < "$dlwhere/$gccpatch"
266 echo "ROCKBOXDEV: mkdir build-binu"
268 echo "ROCKBOXDEV: cd build-binu"
270 echo "ROCKBOXDEV: binutils/configure"
271 ..
/binutils-
$binutils/configure
--target=$target --prefix=$prefix/$target
272 echo "ROCKBOXDEV: binutils/make"
274 echo "ROCKBOXDEV: binutils/make install to $prefix/$target"
276 cd ..
# get out of build-binu
277 PATH
="${PATH}:$bindir"
278 SHELL
=/bin
/sh
# seems to be needed by the gcc build in some cases
280 echo "ROCKBOXDEV: mkdir build-gcc"
282 echo "ROCKBOXDEV: cd build-gcc"
284 echo "ROCKBOXDEV: gcc/configure"
285 ..
/gcc-
$gccver/configure
--target=$target --prefix=$prefix/$target --enable-languages=c
$gccconfigure
286 echo "ROCKBOXDEV: gcc/make"
288 echo "ROCKBOXDEV: gcc/make install to $prefix/$target"
290 cd ..
# get out of build-gcc
291 cd ..
# get out of $builddir
293 # end of buildone() function
297 echo "Select target arch:"
298 echo "s - sh (Archos models)"
299 echo "m - m68k (iriver h1x0/h3x0, ifp7x0 and iaudio)"
300 echo "a - arm (ipods, iriver H10, Sansa, etc)"
301 echo "i - mips (Jz4740 and ATJ-based players)"
302 echo "separate multiple targets with spaces"
303 echo "(i.e. \"s m a\" will build sh, m86k and arm)"
325 echo "An unsupported architecture option: $arch"
330 echo "Cleaning up build folder"
335 echo "Make your PATH include $pathadd"
339 # show the summaries:
340 cat $builddir/summary-
*