diff --git a/tools/rockboxdev.sh b/tools/rockboxdev.sh index 9b7878f..595a26a 100755 --- a/tools/rockboxdev.sh +++ b/tools/rockboxdev.sh @@ -39,6 +39,84 @@ fi ############################################################################## # +# change rockboxdev.sh status. +status_file="$builddir/run.status" +selarch= +arch= +status=0 + +STATUS_BINUTILS_DOWNLOAD=1 +STATUS_GCC_DOWNLOAD=2 +STATUS_PATCH_DOWNLOAD=3 +STATUS_BINUTILS_EXPANDED=4 +STATUS_GCC_EXPANDED=5 +STATUS_PATCH_APPLIED=6 +STATUS_BINUTILS_CONFIGURE=7 +STATUS_BINUTILS_BUILD=8 +STATUS_GCC_CONFIGURE=9 +STATUS_GCC_BUILD=10 + +create_status_file() { + if test -f "$status_file"; then + rm "$status_file" + fi + touch "$status_file" + selarch= + arch= + status=0 +} + +read_status_file() { + if test -f "$status_file"; then + line=0 + selarch= + arch= + status=0 + while read data + do + case $line in + 0) + selarch=$data + ;; + 1) + arch=$data + ;; + 2) + status=$data + ;; + *) + ;; + esac + line=`expr $line + 1` + done < $status_file + fi +} + +set_targets() { + selarch=$1 + arch= + status=0 + echo "$selarch" > $status_file +} + +update_build_target() { + arch=$1 + status=0 + echo "$selarch" > $status_file + echo "$arch" >> $status_file + echo "$status" >> $status_file +} + +update_status() { + status=$1 + echo "$selarch" > $status_file + echo "$arch" >> $status_file + echo "$status" >> $status_file +} + +############################################################################## + +# # These are the tools this script requires and depends upon. reqtools="gcc bzip2 make patch" @@ -123,7 +201,7 @@ echo "Build dir: $builddir (set RBDEV_BUILD to change dir)" ########################################################################### # Verify that the prefix dir exists and that we can write to it, -# as otherwise we will hardly be able to install there! +# as otherwise we will hardly be able to install there! if test ! -d $prefix; then echo "WARNING: The installation destination does not exist." echo "Please create it and re-run this script" @@ -221,16 +299,20 @@ echo "Example:" echo "$ GNU_MIRROR=http://mirrors.kernel.org/gnu ./rockboxdev.sh" echo "" +cd $builddir + if test -f "$dlwhere/binutils-$binutils.tar.bz2"; then echo "binutils $binutils already downloaded" else getfile binutils-$binutils.tar.bz2 $GNU_MIRROR/binutils + update_status $STATUS_BINUTILS_DOWNLOAD fi if test -f "$dlwhere/gcc-core-$gccver.tar.bz2"; then echo "gcc $gccver already downloaded" else getfile gcc-core-$gccver.tar.bz2 $GNU_MIRROR/gcc/gcc-$gccver + update_status $STATUS_GCC_DOWNLOAD fi if test -n "$gccpatch"; then @@ -238,21 +320,11 @@ if test -n "$gccpatch"; then echo "$gccpatch already downloaded" else getfile "$gccpatch" "$gccurl" + update_status $STATUS_PATCH_DOWNLOAD fi fi ########################################################################### -# If there's already a build dir, we don't overwrite or delete it -if test -d $builddir; then - echo "You already have a $builddir directory!" - echo "Please remove it and re-run the script" - exit -else - mkdir -p $builddir - cd $builddir -fi - -########################################################################### # Create a summary file for each toolchain, containing info about the version # and a remainder to append the compiler path to PATH @@ -272,50 +344,129 @@ echo "=================================================================" >> $sum cat $summary -echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir" -tar xjf $dlwhere/binutils-$binutils.tar.bz2 -echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir" -tar xjf $dlwhere/gcc-core-$gccver.tar.bz2 +if test $status -lt $STATUS_BINUTILS_EXPANDED; then + echo "ROCKBOXDEV: extracting binutils-$binutils in $builddir" + tar xjf $dlwhere/binutils-$binutils.tar.bz2 + update_status $STATUS_BINUTILS_EXPANDED +fi +if test $status -lt $STATUS_GCC_EXPANDED; then + echo "ROCKBOXDEV: extracting gcc-$gccver in $builddir" + tar xjf $dlwhere/gcc-core-$gccver.tar.bz2 + update_status $STATUS_GCC_EXPANDED +fi -if test -n "$gccpatch"; then - echo "ROCKBOXDEV: applying gcc patch" - patch -p0 < "$dlwhere/$gccpatch" +if test $status -lt $STATUS_PATCH_APPLIED; then + if test -n "$gccpatch"; then + echo "ROCKBOXDEV: applying gcc patch" + patch -p0 < "$dlwhere/$gccpatch" + update_status $STATUS_PATCH_APPLIED + fi +fi + +if test ! -d "$builddir/build-binu"; then + echo "ROCKBOXDEV: mkdir $builddir/build-binu" + mkdir "$builddir/build-binu" +fi +if test $status -lt $STATUS_BINUTILS_BUILD; then + echo "ROCKBOXDEV: cd build-binu" + cd build-binu + if test $status -lt $STATUS_BINUTILS_CONFIGURE; then + echo "ROCKBOXDEV: binutils/configure" + # we undefine _FORTIFY_SOURCE to make the binutils built run fine on recent + # Ubuntu installations + CFLAGS=-U_FORTIFY_SOURCE ../binutils-$binutils/configure --target=$target --prefix=$prefix/$target $binutilsconf + update_status $STATUS_BINUTILS_CONFIGURE + fi + echo "ROCKBOXDEV: binutils/make" + $make + echo "ROCKBOXDEV: binutils/make install to $prefix/$target" + $make install + cd .. # get out of build-binu + update_status $STATUS_BINUTILS_BUILD fi +if test $status -lt $STATUS_GCC_BUILD; then + PATH="${PATH}:$bindir" + SHELL=/bin/sh # seems to be needed by the gcc build in some cases + cd $builddir + if test ! -d build-gcc; then + echo "ROCKBOXDEV: mkdir build-gcc" + mkdir build-gcc + fi + echo "ROCKBOXDEV: cd build-gcc" + cd build-gcc + if test $status -lt $STATUS_GCC_CONFIGURE; then + echo "ROCKBOXDEV: gcc/configure" + # we undefine _FORTIFY_SOURCE to make the gcc build go through fine on + # recent Ubuntu installations + CFLAGS=-U_FORTIFY_SOURCE ../gcc-$gccver/configure --target=$target --prefix=$prefix/$target --enable-languages=c $gccconfigure + update_status $STATUS_GCC_CONFIGURE + fi + echo "ROCKBOXDEV: gcc/make" + $make + echo "ROCKBOXDEV: gcc/make install to $prefix/$target" + $make install + cd .. # get out of build-gcc + update_status $STATUS_GCC_BUILD + cd .. # get out of $builddir +fi + +echo "Cleaning up build folder" +cleardir $builddir +echo "" +echo "Done!" +echo "" +echo "Make your PATH include $pathadd" -echo "ROCKBOXDEV: mkdir build-binu" -mkdir build-binu -echo "ROCKBOXDEV: cd build-binu" -cd build-binu -echo "ROCKBOXDEV: binutils/configure" -# we undefine _FORTIFY_SOURCE to make the binutils built run fine on recent -# Ubuntu installations -CFLAGS=-U_FORTIFY_SOURCE ../binutils-$binutils/configure --target=$target --prefix=$prefix/$target $binutilsconf -echo "ROCKBOXDEV: binutils/make" -$make -echo "ROCKBOXDEV: binutils/make install to $prefix/$target" -$make install -cd .. # get out of build-binu -PATH="${PATH}:$bindir" -SHELL=/bin/sh # seems to be needed by the gcc build in some cases - -echo "ROCKBOXDEV: mkdir build-gcc" -mkdir build-gcc -echo "ROCKBOXDEV: cd build-gcc" -cd build-gcc -echo "ROCKBOXDEV: gcc/configure" -# we undefine _FORTIFY_SOURCE to make the gcc build go through fine on -# recent Ubuntu installations -CFLAGS=-U_FORTIFY_SOURCE ../gcc-$gccver/configure --target=$target --prefix=$prefix/$target --enable-languages=c $gccconfigure -echo "ROCKBOXDEV: gcc/make" -$make -echo "ROCKBOXDEV: gcc/make install to $prefix/$target" -$make install -cd .. # get out of build-gcc -cd .. # get out of $builddir - - # end of buildone() function +# end of buildone() function } +read_status_file +if test "$selarch" != "" -o "$arch" != ""; then + echo "" + echo "Because the processing of rockboxdev.sh ended on the way, " + echo "processing is restarted." + echo "" + echo "Select:" + echo "c - Continue" + echo "s - Starts from the beginning" + echo "" + + mode=`input` + case $mode in + [cC]) + bflg=0 + sa=$arch + for ac in $selarch + do + if test "$ac" = "$sa"; then + bflg=1 + buildone $ac + elif test $bflg -ne 0; then + update_build_target $ac + buildone $ac + fi + done + rm $status_file + exit + ;; + [sS]) + ;; + *) + echo "An unsupported selection." + exit + ;; + esac +fi + +if test -d $builddir; then + echo "deleting files..." + cleardir $builddir +else + mkdir -p $builddir +fi + +create_status_file + echo "" echo "Select target arch:" echo "s - sh (Archos models)" @@ -327,36 +478,29 @@ echo "(i.e. \"s m a\" will build sh, m86k and arm)" echo "" selarch=`input` +set_targets "$selarch" for arch in $selarch do -echo "" -case $arch in - [Ss]) - buildone $arch - ;; - [Ii]) - buildone $arch - ;; - [Mm]) - buildone $arch - ;; - [Aa]) - buildone $arch - ;; - *) - echo "An unsupported architecture option: $arch" - exit - ;; -esac - -echo "Cleaning up build folder" -cleardir $builddir -echo "" -echo "Done!" -echo "" -echo "Make your PATH include $pathadd" - + echo "" + case $arch in + [Ss]) + buildone $arch + ;; + [Ii]) + buildone $arch + ;; + [Mm]) + buildone $arch + ;; + [Aa]) + buildone $arch + ;; + *) + echo "An unsupported architecture option: $arch" + exit + ;; + esac done # show the summaries: