2006-05-15 13:26:59 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# this is where this script will store downloaded files and check for already
|
|
|
|
# downloaded files
|
2008-06-28 00:02:05 +00:00
|
|
|
dlwhere="/tmp/rbdev-dl"
|
2006-05-15 13:26:59 +00:00
|
|
|
|
|
|
|
# will append the target string to the prefix dir mentioned here
|
|
|
|
# Note that the user running this script must be able to do make install in
|
|
|
|
# this given prefix directory. Also make sure that this given root dir
|
|
|
|
# exists.
|
|
|
|
prefix="/usr/local"
|
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
# This directory is used to extract all files and to build everything in. It
|
|
|
|
# must not exist before this script is invoked (as a security measure).
|
2008-06-28 00:02:05 +00:00
|
|
|
builddir="/tmp/rbdev-build"
|
2006-05-15 13:26:59 +00:00
|
|
|
|
2006-11-22 09:07:45 +00:00
|
|
|
# This script needs to use GNU Make. On Linux systems, GNU Make is invoked
|
|
|
|
# by running the "make" command, on most BSD systems, GNU Make is invoked
|
|
|
|
# by running the "gmake" command. Set the "make" variable accordingly.
|
2007-08-13 00:43:01 +00:00
|
|
|
if [ -f "`which gmake`" ]; then
|
2006-11-22 09:07:45 +00:00
|
|
|
make="gmake"
|
|
|
|
else
|
|
|
|
make="make"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If detection fails, override the value of make manually:
|
|
|
|
# make="make"
|
|
|
|
|
2006-05-15 13:26:59 +00:00
|
|
|
##############################################################################
|
|
|
|
|
2007-05-24 19:58:17 +00:00
|
|
|
#
|
|
|
|
# These are the tools this script requires and depends upon.
|
|
|
|
reqtools="gcc bzip2 make patch"
|
|
|
|
|
2006-11-22 09:07:45 +00:00
|
|
|
|
2006-05-15 13:26:59 +00:00
|
|
|
findtool(){
|
|
|
|
file="$1"
|
|
|
|
|
|
|
|
IFS=":"
|
|
|
|
for path in $PATH
|
|
|
|
do
|
|
|
|
# echo "checks for $file in $path" >&2
|
|
|
|
if test -f "$path/$file"; then
|
|
|
|
echo "$path/$file"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
input() {
|
|
|
|
read response
|
|
|
|
echo $response
|
|
|
|
}
|
|
|
|
|
|
|
|
#$1 file
|
|
|
|
#$2 URL"root
|
|
|
|
getfile() {
|
|
|
|
tool=`findtool curl`
|
|
|
|
if test -z "$tool"; then
|
|
|
|
tool=`findtool wget`
|
|
|
|
if test -n "$tool"; then
|
|
|
|
# wget download
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: downloads $2/$1 using wget"
|
2006-05-15 13:26:59 +00:00
|
|
|
$tool -O $dlwhere/$1 $2/$1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# curl download
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: downloads $2/$1 using curl"
|
2006-05-15 13:26:59 +00:00
|
|
|
$tool -Lo $dlwhere/$1 $2/$1
|
|
|
|
fi
|
|
|
|
if test -z "$tool"; then
|
2006-10-10 12:20:41 +00:00
|
|
|
echo "ROCKBOXDEV: couldn't find any downloader tool to use!"
|
|
|
|
echo "ROCKBOXDEV: install curl or wget and re-run the script"
|
2006-05-15 13:26:59 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-05-24 19:58:17 +00:00
|
|
|
for t in $reqtools; do
|
|
|
|
tool=`findtool $t`
|
|
|
|
if test -z "$tool"; then
|
|
|
|
echo "ROCKBOXDEV: $t is required for this script to work. Please"
|
|
|
|
echo "ROCKBOXDEV: install and re-run the script."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2006-05-29 22:23:00 +00:00
|
|
|
###########################################################################
|
|
|
|
# Verify download directory or create it
|
|
|
|
if test -d "$dlwhere"; then
|
|
|
|
if ! test -w "$dlwhere"; then
|
|
|
|
echo "$dlwhere exists, but doesn't seem to be writable for you"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
mkdir $dlwhere
|
|
|
|
if test $? -ne 0; then
|
|
|
|
echo "$dlwhere is missing and we failed to create it!"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
echo "$dlwhere has been created to store downloads in"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Download directory: $dlwhere (edit script to change dir)"
|
|
|
|
echo "Install prefix: $prefix/[target] (edit script to change dir)"
|
2006-05-30 08:38:02 +00:00
|
|
|
echo "Build dir: $builddir (edit script to change dir)"
|
2006-05-29 22:23:00 +00:00
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# Verify that we can write in the prefix dir, as otherwise we will hardly
|
|
|
|
# be able to install there!
|
|
|
|
if test ! -w $prefix; then
|
|
|
|
echo "WARNING: this script is set to install in $prefix but has no"
|
2006-09-26 21:17:23 +00:00
|
|
|
echo "WARNING: write permission to do so! Please fix and re-run this script"
|
|
|
|
exit
|
2006-05-29 22:23:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# If there's already a build dir, we don't overwrite it
|
2006-05-30 08:38:02 +00:00
|
|
|
if test -d $builddir; then
|
|
|
|
echo "you have a $builddir dir already, please remove and rerun"
|
2006-05-29 22:23:00 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
cleardir () {
|
|
|
|
# $1 is the name of the build dir
|
|
|
|
# delete the build dirs and the source dirs
|
|
|
|
rm -rf $1/build-gcc $1/build-binu $1/gcc* $1/binutils*
|
|
|
|
}
|
2006-05-15 13:26:59 +00:00
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
buildone () {
|
2006-05-15 13:26:59 +00:00
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
gccpatch="" # default is no gcc patch
|
|
|
|
gccver="4.0.3" # default gcc version
|
|
|
|
binutils="2.16.1" # The binutils version to use
|
|
|
|
|
2006-08-13 18:27:31 +00:00
|
|
|
system=`uname -s`
|
2007-10-19 07:33:39 +00:00
|
|
|
gccurl="http://www.rockbox.org/gcc"
|
2006-08-13 18:27:31 +00:00
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
case $1 in
|
2006-05-15 13:26:59 +00:00
|
|
|
[Ss])
|
|
|
|
target="sh-elf"
|
2006-05-25 23:44:51 +00:00
|
|
|
gccpatch="gcc-4.0.3-rockbox-1.diff"
|
2006-05-15 13:26:59 +00:00
|
|
|
;;
|
|
|
|
[Mm])
|
|
|
|
target="m68k-elf"
|
|
|
|
gccver="3.4.6"
|
2006-08-13 18:27:31 +00:00
|
|
|
case $system in
|
2008-03-28 00:00:46 +00:00
|
|
|
CYGWIN* | Darwin | FreeBSD)
|
2006-08-13 18:27:31 +00:00
|
|
|
gccpatch="gcc-3.4.6.patch"
|
|
|
|
;;
|
|
|
|
Linux)
|
2007-06-29 11:35:35 +00:00
|
|
|
machine=`uname -m`
|
|
|
|
case $machine in
|
|
|
|
x86_64)
|
|
|
|
gccpatch="gcc-3.4.6-amd64.patch"
|
|
|
|
;;
|
|
|
|
esac
|
2006-08-13 18:27:31 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
2006-05-15 13:26:59 +00:00
|
|
|
;;
|
|
|
|
[Aa])
|
|
|
|
target="arm-elf"
|
2008-04-28 15:37:06 +00:00
|
|
|
gccpatch="rockbox-multilibs-arm-elf-gcc-4.0.3_2.diff"
|
2006-05-15 13:26:59 +00:00
|
|
|
;;
|
2008-07-08 07:13:05 +00:00
|
|
|
[Ii])
|
|
|
|
target="mipsel-elf"
|
|
|
|
;;
|
2006-05-15 13:26:59 +00:00
|
|
|
*)
|
|
|
|
echo "unsupported"
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
bindir="$prefix/$target/bin"
|
2006-05-30 08:38:02 +00:00
|
|
|
if test -n $pathadd; then
|
|
|
|
pathadd="$pathadd:$bindir"
|
|
|
|
else
|
|
|
|
pathadd="$bindir"
|
2006-05-25 23:44:51 +00:00
|
|
|
fi
|
2006-05-15 13:26:59 +00:00
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
mkdir $builddir
|
|
|
|
cd $builddir
|
2006-05-29 22:23:00 +00:00
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
summary="summary-$1"
|
|
|
|
|
|
|
|
echo "== Summary ==" > $summary
|
|
|
|
echo "Target: $target" >> $summary
|
|
|
|
echo "gcc $gccver" >> $summary
|
|
|
|
if test -n "$gccpatch"; then
|
|
|
|
echo "gcc patch $gccpatch" >> $summary
|
|
|
|
fi
|
|
|
|
echo "binutils $binutils" >> $summary
|
|
|
|
echo "install in $prefix/$target" >> $summary
|
|
|
|
echo "when complete, make your PATH include $bindir" >> $summary
|
|
|
|
|
|
|
|
cat $summary
|
2006-05-15 13:26:59 +00:00
|
|
|
|
|
|
|
if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then
|
|
|
|
echo "binutils $binutils already downloaded"
|
|
|
|
else
|
|
|
|
getfile binutils-$binutils.tar.bz2 ftp://ftp.gnu.org/pub/gnu/binutils
|
|
|
|
fi
|
|
|
|
|
2007-02-26 16:10:53 +00:00
|
|
|
if test -f "$dlwhere/gcc-core-$gccver.tar.bz2"; then
|
2006-05-15 13:26:59 +00:00
|
|
|
echo "gcc $gccver already downloaded"
|
|
|
|
else
|
2007-02-26 16:10:53 +00:00
|
|
|
getfile gcc-core-$gccver.tar.bz2 ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$gccver
|
2006-05-15 13:26:59 +00:00
|
|
|
fi
|
|
|
|
|
2006-05-25 23:44:51 +00:00
|
|
|
if test -n "$gccpatch"; then
|
|
|
|
if test -f "$dlwhere/$gccpatch"; then
|
|
|
|
echo "$gccpatch already downloaded"
|
|
|
|
else
|
|
|
|
getfile "$gccpatch" "$gccurl"
|
|
|
|
fi
|
|
|
|
fi
|
2006-05-15 13:26:59 +00:00
|
|
|
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir"
|
2006-05-15 13:26:59 +00:00
|
|
|
tar xjf $dlwhere/binutils-$binutils.tar.bz2
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir"
|
2007-02-26 16:10:53 +00:00
|
|
|
tar xjf $dlwhere/gcc-core-$gccver.tar.bz2
|
2006-05-15 13:26:59 +00:00
|
|
|
|
2006-05-25 23:44:51 +00:00
|
|
|
if test -n "$gccpatch"; then
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: applying gcc patch"
|
2006-05-25 23:44:51 +00:00
|
|
|
patch -p0 < "$dlwhere/$gccpatch"
|
|
|
|
fi
|
|
|
|
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: mkdir build-binu"
|
2006-05-15 13:26:59 +00:00
|
|
|
mkdir build-binu
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: cd build-binu"
|
2006-05-15 13:26:59 +00:00
|
|
|
cd build-binu
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: binutils/configure"
|
2006-05-15 13:26:59 +00:00
|
|
|
../binutils-$binutils/configure --target=$target --prefix=$prefix/$target
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: binutils/make"
|
2006-11-22 09:07:45 +00:00
|
|
|
$make
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: binutils/make install to $prefix/$target"
|
2006-11-22 09:07:45 +00:00
|
|
|
$make install
|
2006-05-30 08:38:02 +00:00
|
|
|
cd .. # get out of build-binu
|
2006-05-15 13:26:59 +00:00
|
|
|
PATH="${PATH}:$bindir"
|
|
|
|
SHELL=/bin/sh # seems to be needed by the gcc build in some cases
|
|
|
|
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: mkdir build-gcc"
|
2006-05-15 13:26:59 +00:00
|
|
|
mkdir build-gcc
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: cd build-gcc"
|
2006-05-15 13:26:59 +00:00
|
|
|
cd build-gcc
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: gcc/configure"
|
2006-05-15 13:26:59 +00:00
|
|
|
../gcc-$gccver/configure --target=$target --prefix=$prefix/$target --enable-languages=c
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: gcc/make"
|
2006-11-22 09:07:45 +00:00
|
|
|
$make
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "ROCKBOXDEV: gcc/make install to $prefix/$target"
|
2006-11-22 09:07:45 +00:00
|
|
|
$make install
|
2006-05-30 08:38:02 +00:00
|
|
|
cd .. # get out of build-gcc
|
|
|
|
cd .. # get out of $builddir
|
|
|
|
|
|
|
|
# end of buildone() function
|
|
|
|
}
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Select target arch:"
|
2006-08-10 06:46:56 +00:00
|
|
|
echo "s - sh (Archos models)"
|
|
|
|
echo "m - m68k (iriver h1x0/h3x0, ifp7x0 and iaudio)"
|
|
|
|
echo "a - arm (ipods, iriver H10, Sansa, etc)"
|
2008-07-08 07:13:05 +00:00
|
|
|
echo "i - mips (Jz4740 and ATJ-based players)"
|
2006-05-30 08:38:02 +00:00
|
|
|
echo "all - all three compilers"
|
|
|
|
|
|
|
|
arch=`input`
|
|
|
|
|
|
|
|
case $arch in
|
|
|
|
[Ss])
|
|
|
|
buildone $arch
|
|
|
|
;;
|
2008-07-08 07:13:05 +00:00
|
|
|
[Ii])
|
|
|
|
buildone $arch
|
|
|
|
;;
|
2006-05-30 08:38:02 +00:00
|
|
|
[Mm])
|
|
|
|
buildone $arch
|
|
|
|
;;
|
|
|
|
[Aa])
|
|
|
|
buildone $arch
|
|
|
|
;;
|
|
|
|
all)
|
|
|
|
echo "build ALL compilers!"
|
|
|
|
buildone s
|
|
|
|
cleardir $builddir
|
|
|
|
|
|
|
|
buildone m
|
|
|
|
cleardir $builddir
|
|
|
|
|
|
|
|
buildone a
|
|
|
|
|
2008-07-08 07:13:05 +00:00
|
|
|
# include this when we want MIPS added in the "build all"
|
|
|
|
#buildone i
|
|
|
|
|
2006-05-30 08:38:02 +00:00
|
|
|
# show the summaries:
|
|
|
|
cat $builddir/summary-*
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unsupported architecture option"
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
esac
|
2006-05-15 13:26:59 +00:00
|
|
|
|
|
|
|
echo "done"
|
2006-05-29 22:23:00 +00:00
|
|
|
echo ""
|
2006-05-30 08:38:02 +00:00
|
|
|
echo "Make your PATH include $pathadd"
|