summaryrefslogtreecommitdiffstats
path: root/tools/rockboxdev.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/rockboxdev.sh')
-rwxr-xr-xtools/rockboxdev.sh166
1 files changed, 73 insertions, 93 deletions
diff --git a/tools/rockboxdev.sh b/tools/rockboxdev.sh
index d0d623be1b..63b1a1f5a1 100755
--- a/tools/rockboxdev.sh
+++ b/tools/rockboxdev.sh
@@ -29,8 +29,12 @@ else
make="make"
fi
+# record version
+makever=`$make -v |sed -n '1p' | sed -e 's/.* \([0-9]*\)\.\([0-9]*\).*/\1\2/'`
+
# This is the absolute path to where the script resides.
rockboxdevdir="$( readlink -f "$( dirname "${BASH_SOURCE[0]}" )" )"
+patch_dir="$rockboxdevdir/toolchain-patches"
if [ `uname -s` = "Darwin" ]; then
parallel=`sysctl -n hw.physicalcpu`
@@ -51,7 +55,7 @@ if [ -z $LINUX_MIRROR ] ; then
fi
# These are the tools this script requires and depends upon.
-reqtools="gcc g++ bzip2 gzip make patch makeinfo automake libtool autoconf flex bison"
+reqtools="gcc g++ xz bzip2 gzip $make patch makeinfo automake libtool autoconf flex bison"
##############################################################################
# Functions:
@@ -179,18 +183,23 @@ gettool() {
srv_file="gcc-core-$version"
fi
url="$GNU_MIRROR/gcc/gcc-$version"
+ if ! version_lt "$version" "7.2"; then
+ ext="tar.xz"
+ fi
;;
binutils)
url="$GNU_MIRROR/binutils"
+ if ! version_lt "$version" "2.28.1"; then
+ ext="tar.xz"
+ fi
;;
glibc)
url="$GNU_MIRROR/glibc"
- ;;
-
- crosstool-ng)
- url="http://crosstool-ng.org/download/crosstool-ng"
+ if ! version_lt "$version" "2.11"; then
+ ext="tar.xz"
+ fi
;;
alsa-lib)
@@ -208,7 +217,7 @@ gettool() {
;;
zlib)
- url="https://zlib.net"
+ url="https://www.zlib.net/fossils"
ext="tar.gz"
;;
@@ -285,7 +294,7 @@ run_cmd() {
echo "Running '$@'" >>$logfile
if ! $@ >> "$logfile" 2>&1; then
echo "ROCKBOXDEV: an error occured, please see $logfile"
- exit
+ exit 1
fi
}
@@ -336,8 +345,7 @@ buildtool() {
echo "ROCKBOXDEV: mkdir build-$toolname"
mkdir "build-$toolname"
- echo "ROCKBOXDEV: cd build-$toolname"
- cd "build-$toolname"
+ cd build-$toolname
# in-tree/out-of-tree build
case "$tool" in
@@ -387,9 +395,14 @@ buildtool() {
echo "ROCKBOXDEV: $toolname/make (install)"
run_cmd "$logfile" $make $install_opts
- echo "ROCKBOXDEV: rm -rf build-$toolname $toolname"
cd ..
+
+ echo "ROCKBOXDEV: rm -rf build-$toolname $toolname"
rm -rf build-$toolname
+ if [ "$stepname" != "gcc-stage1" ] ; then
+ echo "ROCKBOXDEV: rm -rf $toolname"
+ rm -rf $toolname
+ fi
}
build() {
@@ -399,6 +412,14 @@ build() {
patch="$4"
configure_params="$5"
needs_libs="$6"
+ logfile="$builddir/build-$toolname.log"
+
+ stepname=${RESTART_STEP:-$toolname}
+ if ! check_restart "$stepname"; then
+ echo "ROCKBOXDEV: Skipping step '$stepname' as requested per RBDEV_RESTART"
+ return
+ fi
+ echo "ROCKBOXDEV: Starting step '$stepname'"
# create build directory
if test -d $builddir; then
@@ -410,8 +431,6 @@ build() {
mkdir -p $builddir
fi
- patch_dir="$rockboxdevdir/toolchain-patches"
-
# download source tarball
gettool "$toolname" "$version"
file="$toolname-$version"
@@ -467,95 +486,32 @@ build() {
cd $builddir
fi
+ # GCC is special
+ if [ "$toolname" == "gcc" ] ; then
+ configure_params="--enable-languages=c --disable-libssp $configure_params"
+ fi
+
+ echo "ROCKBOXDEV: logging to $logfile"
+ rm -f "$logfile"
+
echo "ROCKBOXDEV: mkdir build-$toolname"
mkdir build-$toolname
- echo "ROCKBOXDEV: cd build-$toolname"
cd build-$toolname
echo "ROCKBOXDEV: $toolname/configure"
- case $toolname in
- crosstool-ng) # ct-ng doesnt support out-of-tree build and the src folder is named differently
- toolname="crosstool-ng"
- cp -r ../$toolname-$version/* ../$toolname-$version/.version .
- ./configure --prefix=$prefix $configure_params
- ;;
- *)
- CFLAGS='-U_FORTIFY_SOURCE -fgnu89-inline -fcommon' CXXFLAGS='-std=gnu++03' ../$toolname-$version/configure --target=$target --prefix=$prefix --enable-languages=c --disable-libssp --disable-docs $configure_params
- ;;
- esac
+ CFLAGS='-U_FORTIFY_SOURCE -fgnu89-inline -fcommon -O2' CXXFLAGS='-std=gnu++03' run_cmd "$logfile" ../$toolname-$version/configure --target=$target --prefix=$prefix --disable-docs $configure_params
echo "ROCKBOXDEV: $toolname/make"
- $make $make_parallel
+ run_cmd "$logfile" $make $make_parallel
echo "ROCKBOXDEV: $toolname/make install"
- $make install
+ run_cmd "$logfile" $make install
- echo "ROCKBOXDEV: rm -rf build-$toolname $toolname-$version"
cd ..
- rm -rf build-$toolname $toolname-$version
-}
-
-make_ctng() {
- if test -f "`which ct-ng 2>/dev/null`"; then
- ctng="ct-ng"
- else
- ctng=""
- fi
-
- if test ! -n "$ctng"; then
- if test ! -f "$prefix/bin/ct-ng"; then # look if we build it already
- build "crosstool-ng" "" "1.13.2" "crosstool-ng-1.13.2.diff"
- fi
- fi
- ctng=`PATH=$prefix/bin:$PATH which ct-ng`
-}
-build_ctng() {
- ctng_target="$1"
- extra="$2"
- tc_arch="$3"
- tc_host="$4"
-
- make_ctng
-
- dlurl="http://www.rockbox.org/gcc/$ctng_target"
-
- # download
- getfile "ct-ng-config" "$dlurl"
-
- test -n "$extra" && getfile "$extra" "$dlurl"
-
- # create build directory
- if test -d $builddir; then
- if test ! -w $builddir; then
- echo "ROCKBOXDEV: No write permission for $builddir"
- exit
- fi
- else
- mkdir -p $builddir
- fi
-
- # copy config and cd to $builddir
- mkdir $builddir/build-$ctng_target
- ctng_config="$builddir/build-$ctng_target/.config"
- cat "$dlwhere/ct-ng-config" | sed -e "s,\(CT_PREFIX_DIR=\).*,\1$prefix," > $ctng_config
- cd $builddir/build-$ctng_target
-
- $ctng "build"
-
- # install extras
- if test -e "$dlwhere/$extra"; then
- # verify the toolchain has sysroot support
- if test -n `cat $ctng_config | grep CT_USE_SYSROOT\=y`; then
- sysroot=`cat $ctng_config | grep CT_SYSROOT_NAME | sed -e 's,CT_SYSROOT_NAME\=\"\([a-zA-Z0-9]*\)\",\1,'`
- tar xf "$dlwhere/$extra" -C "$prefix/$tc_arch-$ctng_target-$tc_host/$sysroot"
- fi
- fi
-
- # cleanup
- cd $builddir
- rm -rf $builddir/build-$ctng_target
+ echo "ROCKBOXDEV: rm -rf build-$toolname $toolname-$version"
+ rm -rf build-$toolname $toolname-$version
}
# build a cross compiler toolchain for linux
@@ -576,6 +532,8 @@ build_linux_toolchain () {
linux_ver="$6"
glibc_ver="$7"
glibc_opts="$8"
+ glibc_patches="$9"
+
# where to put the sysroot
sysroot="$prefix/$target/sysroot"
# extract arch from target
@@ -599,6 +557,11 @@ build_linux_toolchain () {
mkdir -p $builddir
fi
+ if [ "$makever" -gt 43 ] ; then
+ glibc_make_opts="--jobserver-style=pipe --shuffle=none"
+# MAKEFLAGS="--jobserver-style=pipe --shuffle=none"
+ fi
+
# download all tools
gettool "binutils" "$binutils_ver"
gettool "gcc" "$gcc_ver"
@@ -612,6 +575,18 @@ build_linux_toolchain () {
extract "linux-$linux_ver"
extract "glibc-$glibc_ver"
+ # do we have a patch?
+ for p in $glibc_patches; do
+ echo "ROCKBOXDEV: applying patch $p"
+ (cd $builddir/glibc-$glibc_ver ; patch -p1 < "$patch_dir/$p")
+
+ # check if the patch applied cleanly
+ if [ $? -gt 0 ]; then
+ echo "ROCKBOXDEV: failed to apply patch $p"
+ exit
+ fi
+ done
+
# we make it possible to restart a build on error by using the RBDEV_RESTART
# variable, the format is RBDEV_RESTART="tool" where tool is the toolname at which
# to restart (binutils, gcc)
@@ -646,7 +621,7 @@ build_linux_toolchain () {
prefix="/usr" \
buildtool "glibc" "$glibc_ver" "--target=$target --host=$target --build=$MACHTYPE \
--with-__thread --with-headers=$sysroot/usr/include $glibc_opts" \
- "" "install install_root=$sysroot"
+ "$glibc_make_opts" "install install_root=$sysroot"
# build stage 2 compiler
RESTART_STEP="gcc-stage2" \
buildtool "gcc" "$gcc_ver" "$gcc_opts --enable-languages=c,c++ --target=$target \
@@ -720,6 +695,11 @@ if [ -n "$missingtools" ]; then
exit 1
fi
+if ! $make -v | grep -q GNU ; then
+ echo "ROCKBOXDEV: Building the rockbox toolchains requires GNU Make."
+ exit 1
+fi
+
dlwhere=$(readlink -f "$dlwhere")
prefix=$(readlink -f "$prefix")
builddir=$(readlink -f "$builddir")
@@ -762,7 +742,7 @@ fi
if [ -z "$RBDEV_TARGET" ]; then
echo "Select target arch:"
echo "m - m68k (iriver h1x0/h3x0, iaudio m3/m5/x5 and mpio hd200)"
- echo "a - arm (ipods, iriver H10, Sansa, D2, Gigabeat, etc)"
+ echo "a - arm (ipods, iriver H10, Sansa, D2, Gigabeat, older Sony NWZ, etc)"
echo "i - mips (Jz47xx and ATJ-based players)"
echo "x - arm-linux (Generic Linux ARM: Samsung ypr0, Linux-based Sony NWZ)"
echo "y - mips-linux (Generic Linux MIPS: eg the many HiBy-OS targets)"
@@ -835,7 +815,7 @@ do
# avoid patches/bugs.
glibcopts="--enable-kernel=2.6.23 --enable-oldest-abi=2.4"
build_linux_toolchain "arm-rockbox-linux-gnueabi" "2.26.1" "" "4.9.4" \
- "$gccopts" "2.6.32.68" "2.19" "$glibcopts"
+ "$gccopts" "2.6.32.68" "2.19" "$glibcopts" "glibc-220-make44.patch"
# build alsa-lib
# we need to set the prefix to how it is on device (/usr) and then
# tweak install dir at make install step
@@ -871,7 +851,7 @@ do
glibcopts="--enable-kernel=3.2 --enable-oldest-abi=2.16"
# FIXME: maybe add -mhard-float
build_linux_toolchain "mipsel-rockbox-linux-gnu" "2.26.1" "" "4.9.4" \
- "$gccopts" "3.2.85" "2.25" "$glibcopts"
+ "$gccopts" "3.2.85" "2.25" "$glibcopts" "glibc-225-make44.patch"
# build alsa-lib
# we need to set the prefix to how it is on device (/usr) and then
# tweak install dir at make install step
@@ -889,7 +869,7 @@ do
(cd $prefix/$target/sysroot/usr/include ; ln -sf ../lib/libffi-$libffi_ver/include/ffi.h . ; ln -sf ../lib/libffi-$libffi_ver/include/ffitarget.h . )
# build zlib
- zlib_ver="1.2.11"
+ zlib_ver="1.2.13" # Target uses 1.2.8!
gettool "zlib" "$zlib_ver"
extract "zlib-$zlib_ver"
CHOST=$target prefix="/usr" buildtool "zlib" "$zlib_ver" \