allow specifying the make command
[summon-arm-toolchain.git] / summon-arm-toolchain
index 9577702c3e5e41a91fd46c362282a3f859ac28e3..d4c1cef0306e54d94c7522303c85e2f6793a3d58 100755 (executable)
@@ -72,9 +72,9 @@ b2269d30ce7b93b7c714b90ef2f40221c2df0fcd  newlib-1.19.0.tar.gz"
 # Flags section
 ##############################################################################
 
-if which getconf > /dev/null && getconf _NPROCESSORS_ONLN > /dev/null; then
+if which getconf > /dev/null 2> /dev/null && getconf _NPROCESSORS_ONLN > /dev/null 2> /dev/null; then
        CPUS=$(getconf _NPROCESSORS_ONLN)
-elif which sysctl > /dev/null && sysctl hw.ncpu > /dev/null; then
+elif which sysctl > /dev/null 2> /dev/null && sysctl hw.ncpu 2> /dev/null > /dev/null; then
   CPUS=$(sysctl hw.ncpu | sed -E -e 's/^hw\.ncpu(: | = )//')
 else
        CPUS=1
@@ -141,13 +141,18 @@ else
     TAR=tar     # use the system tar
 fi
 
+if [ -z MAKE ]; then
+  MAKE=make
+  export make # make it known to the configure scripts
+fi
+
 ##############################################################################
 # Building section
 # You probably don't have to touch anything after this
 ##############################################################################
 
 # Fetch a versioned file from a URL
-fetch() {
+dofetch() {
     if [ ! -e ${STAMPS}/$1.fetch ]; then
         log "Downloading $1 sources..."
         ${FETCHCMD} $2
@@ -188,7 +193,7 @@ unpack() {
 # Install a build
 doinstall() {
     log $1
-    ${SUDO} make ${MAKESILENT} $2 $3 $4 $5 $6 $7 $8
+    ${SUDO} ${MAKE} ${MAKESILENT} $2 $3 $4 $5 $6 $7 $8
 }
 
 if [ ! -d $SUMMON_DIR ]; then
@@ -201,13 +206,13 @@ mkdir -p ${STAMPS} ${SOURCES}
 
 cd ${SOURCES}
 
-fetch ${BINUTILS} http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2
-fetch ${GCC} ${GCCURL}
-fetch ${NEWLIB} ftp://sources.redhat.com/pub/newlib/${NEWLIB}.tar.gz
-fetch ${GDB} http://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
-fetch ${GMP} ftp://ftp.gmplib.org/pub/${GMP}/${GMP}.tar.bz2
-fetch ${MPFR} http://www.mpfr.org/${MPFR}/${MPFR}.tar.bz2
-fetch ${MPC} http://www.multiprecision.org/mpc/download/${MPC}.tar.gz
+dofetch ${BINUTILS} http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2
+dofetch ${GCC} ${GCCURL}
+dofetch ${NEWLIB} ftp://sources.redhat.com/pub/newlib/${NEWLIB}.tar.gz
+dofetch ${GDB} http://ftp.gnu.org/gnu/gdb/${GDB}.tar.bz2
+dofetch ${GMP} ftp://ftp.gmplib.org/pub/${GMP}/${GMP}.tar.bz2
+dofetch ${MPFR} http://www.mpfr.org/${MPFR}/${MPFR}.tar.bz2
+dofetch ${MPC} http://www.multiprecision.org/mpc/download/${MPC}.tar.gz
 
 if which sha1sum > /dev/null; then
     for f in ${BINUTILS} ${GCC} ${NEWLIB} ${GDB} ${GMP} ${MPFR} ${MPC}; do
@@ -237,7 +242,7 @@ if [ ! -e ${STAMPS}/${BINUTILS}.build ]; then
                            --disable-werror \
                           ${BINUTILFLAGS}
     log "Building ${BINUTILS}"
-    make ${MAKEFLAGS}
+    ${MAKE} ${MAKEFLAGS}
     doinstall ${BINUTILS} install
     cd ..
     log "Cleaning up ${BINUTILS}"
@@ -270,7 +275,7 @@ if [ ! -e ${STAMPS}/${GCC}-boot.build ]; then
                      --with-system-zlib \
                      ${GCCFLAGS}
     log "Building ${GCC}-boot"
-    make ${MAKEFLAGS} all-gcc
+    ${MAKE} ${MAKEFLAGS} all-gcc
     doinstall ${GCC}-boot install-gcc
     cd ..
     log "Cleaning up ${GCC}-boot"
@@ -299,7 +304,7 @@ if [ ! -e ${STAMPS}/${NEWLIB}.build ]; then
                         --with-float=soft
     log "Building ${NEWLIB}"
     NEWLIB_FLAGS="-ffunction-sections -fdata-sections -DPREFER_SIZE_OVER_SPEED -D__OPTIMIZE_SIZE__ -Os -fomit-frame-pointer -fno-unroll-loops -D__BUFSIZ__=256 -mabi=aapcs"
-    make ${MAKEFLAGS} CFLAGS_FOR_TARGET="${NEWLIB_FLAGS}" CCASFLAGS="${NEWLIB_FLAGS}"
+    ${MAKE} ${MAKEFLAGS} CFLAGS_FOR_TARGET="${NEWLIB_FLAGS}" CCASFLAGS="${NEWLIB_FLAGS}"
     doinstall ${NEWLIB} install
     cd ..
     log "Cleaning up ${NEWLIB}"
@@ -332,7 +337,7 @@ if [ ! -e ${STAMPS}/${GCC}.build ]; then
                       --with-system-zlib \
                     ${GCCFLAGS}
     log "Building ${GCC}"
-    make ${MAKEFLAGS}
+    ${MAKE} ${MAKEFLAGS}
     doinstall ${GCC} install
     cd ..
     log "Cleaning up ${GCC}"
@@ -351,7 +356,7 @@ if [ ! -e ${STAMPS}/${GDB}.build ]; then
                       --disable-werror \
                      ${GDBFLAGS}
     log "Building ${GDB}"
-    make ${MAKEFLAGS}
+    ${MAKE} ${MAKEFLAGS}
     doinstall ${GDB} install
     cd ..
     log "Cleaning up ${GDB}"