From 2a8768d10c5127dbb03cff3a0951d0b910867582 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Fri, 28 Feb 2014 08:03:56 +0100 Subject: [PATCH] don't setup cross-compiler if COMPILE=false or ARCH is ARM --- TODO.org | 2 +- build.sh | 50 +++++++++++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/TODO.org b/TODO.org index 5aabe67..7040b4d 100644 --- a/TODO.org +++ b/TODO.org @@ -3,7 +3,7 @@ * TODO [#A] offer pre-built binaries * TODO [#A] configure by passing --parameters * TODO [#A] reinstall mpfr and/or aaa_elflids to fix missing libmpfr...so -* TODO [#B] allow for running on ARM host +* DONE [#B] UNTESTED allow for running on ARM host * TODO [#B] build rootfs from slackwarearm-current ftp://ftp.arm.slackware.com/slackwarearm/slackwarearm-devtools/minirootfs/scripts/ * TODO [#B] compile out-of-tree diff --git a/build.sh b/build.sh index e52c26f..50dfa12 100755 --- a/build.sh +++ b/build.sh @@ -2,8 +2,12 @@ set -e +# Requires root .. +if [ "$UID" -ne 0 ]; then + echo "Please run as root" +fi + # --- Configuration ------------------------------------------------------------- -#change to your needs IMG_NAME=${IMG_NAME:-"SlackwareARM_cubitruck"} VERSION=${VERSION:-0.2} COMPILE=${COMPILE:-"true"} @@ -20,31 +24,31 @@ CWD=$(pwd) mkdir -p $DEST -#Requires root .. -if [ "$UID" -ne 0 ]; then - echo "Please run as root" -fi - echo "Building Cubietruck-Slackware in $DEST from $CWD" -echo "--------------------------------------------------------------------------------" -echo "Downloading necessary files for building - aka Toolchain" -echo "--------------------------------------------------------------------------------" -#Read this for further information if you run into problems with gcc compiler -#http://linux-sunxi.org/Toolchain -if [ ! -e $PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/ ]; then - [ ! -e $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz ] && wget -c https://launchpadlibrarian.net/$TOOLCHAIN_URL_RANDOM_NUMBER/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz -O $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz - tar xf $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz -fi - -CROSS_COMPILE=$PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/bin/arm-linux-gnueabihf- - -echo "--------------------------------------------------------------------------------" -echo "Clone / Pull sources and patch" -echo "--------------------------------------------------------------------------------" -mkdir -p $DEST/output - if [ "$COMPILE" = "true" ]; then + + echo "--------------------------------------------------------------------------------" + echo "Downloading necessary files for building - aka Toolchain" + echo "--------------------------------------------------------------------------------" + if $(uname -m | grep -q arm); then + CROSS_COMPILE='' + else + #Read this for further information if you run into problems with gcc compiler + #http://linux-sunxi.org/Toolchain + if [ ! -e $PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/ ]; then + [ ! -e $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz ] && wget -c https://launchpadlibrarian.net/$TOOLCHAIN_URL_RANDOM_NUMBER/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz -O $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz + tar xf $CWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux.tar.xz + fi + + CROSS_COMPILE=$PWD/gcc-linaro-arm-linux-gnueabihf-${TOOLCHAIN_VERSION}_linux/bin/arm-linux-gnueabihf- + fi + + echo "--------------------------------------------------------------------------------" + echo "Clone / Pull sources and patch" + echo "--------------------------------------------------------------------------------" + mkdir -p $DEST/output + # Boot loader if [ -d "$DEST/u-boot-sunxi" ]; then ( cd $DEST/u-boot-sunxi;