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
)
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 echo "An unsupported architecture option: $arch"
193 bindir
="$prefix/$target/bin"
194 if test -n $pathadd; then
195 pathadd
="$pathadd:$bindir"
205 echo "============================ Summary ============================" > $summary
206 echo "target: $target" >> $summary
207 echo "gcc version: $gccver" >> $summary
208 if test -n "$gccpatch"; then
209 echo "gcc patch: $gccpatch" >> $summary
211 echo "binutils: $binutils" >> $summary
212 echo "installation target: $prefix/$target" >> $summary
214 echo "When done, append $bindir to PATH" >> $summary
215 echo "=================================================================" >> $summary
220 echo "In case you encounter a slow internet connection, you can use an alternative mirror."
221 echo "A list of other GNU mirrors is available here: http://www.gnu.org/prep/ftp.html"
223 echo "Usage: GNU_MIRROR=[URL] ./rockboxdev.sh"
226 echo "$ GNU_MIRROR=http://mirrors.kernel.org/gnu ./rockboxdev.sh"
229 if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then
230 echo "binutils $binutils already downloaded"
232 getfile binutils-
$binutils.
tar.bz2
$GNU_MIRROR/binutils
235 if test -f "$dlwhere/gcc-core-$gccver.tar.bz2"; then
236 echo "gcc $gccver already downloaded"
238 getfile gcc-core-
$gccver.
tar.bz2
$GNU_MIRROR/gcc
/gcc-
$gccver
241 if test -n "$gccpatch"; then
242 if test -f "$dlwhere/$gccpatch"; then
243 echo "$gccpatch already downloaded"
245 getfile
"$gccpatch" "$gccurl"
249 echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir"
250 tar xjf
$dlwhere/binutils-
$binutils.
tar.bz2
251 echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir"
252 tar xjf
$dlwhere/gcc-core-
$gccver.
tar.bz2
254 if test -n "$gccpatch"; then
255 echo "ROCKBOXDEV: applying gcc patch"
256 patch -p0 < "$dlwhere/$gccpatch"
259 echo "ROCKBOXDEV: mkdir build-binu"
261 echo "ROCKBOXDEV: cd build-binu"
263 echo "ROCKBOXDEV: binutils/configure"
264 ..
/binutils-
$binutils/configure
--target=$target --prefix=$prefix/$target
265 echo "ROCKBOXDEV: binutils/make"
267 echo "ROCKBOXDEV: binutils/make install to $prefix/$target"
269 cd ..
# get out of build-binu
270 PATH
="${PATH}:$bindir"
271 SHELL
=/bin
/sh
# seems to be needed by the gcc build in some cases
273 echo "ROCKBOXDEV: mkdir build-gcc"
275 echo "ROCKBOXDEV: cd build-gcc"
277 echo "ROCKBOXDEV: gcc/configure"
278 ..
/gcc-
$gccver/configure
--target=$target --prefix=$prefix/$target --enable-languages=c
$gccconfigure
279 echo "ROCKBOXDEV: gcc/make"
281 echo "ROCKBOXDEV: gcc/make install to $prefix/$target"
283 cd ..
# get out of build-gcc
284 cd ..
# get out of $builddir
286 # end of buildone() function
290 echo "Select target arch:"
291 echo "s - sh (Archos models)"
292 echo "m - m68k (iriver h1x0/h3x0, ifp7x0 and iaudio)"
293 echo "a - arm (ipods, iriver H10, Sansa, etc)"
294 echo "all - all three compilers above"
295 echo "i - mips (Jz4740 and ATJ-based players)"
315 echo "Building all compilers..."
325 # include this when we want MIPS added in the "build all"
328 # show the summaries:
329 cat $builddir/summary-
*
332 echo "An unsupported architecture option: $arch"
340 echo "Make your PATH include $pathadd"