rename install() to not mask the standard command
[summon-arm-toolchain.git] / summon-arm-toolchain
index 4b901249e49cd735c74cc2a7768c62a1e190babd..31c7991b350d21f9f822eaa73307473c35ba5209 100755 (executable)
@@ -100,43 +100,33 @@ SOURCES=${SUMMON_DIR}/sources
 STAMPS=${SUMMON_DIR}/stamps
 
 
-##############################################################################
-# Tool section
-##############################################################################
-TAR=tar
-
 ##############################################################################
 # OS and Tooldetection section
 # Detects which tools and flags to use
 ##############################################################################
 
-case "$(uname)" in
-       Linux)
-       echo "Found Linux OS."
-       ;;
-       Darwin)
-       echo "Found Darwin OS."
-
-       # darwin dependencies
-       DARWINDEPS="wget"
-
-  echo "Installing dependencies ..."
-  if ! which brew > /dev/null; then
-    echo "Homebrew not installed."
-  else
-      brew install ${DARWINDEPS} | (grep -v '^Warning: Formula already installed: ' || true)
-  fi
+# normalized fetching with whatever we can find
+if which fetch > /dev/null; then
+    FETCHCMD="fetch -p"
+elif which wget > /dev/null; then
+    FETCHCMD=wget
+elif which curl > /dev/null; then
+    FETCHCMD="curl -O"
+else
+    FETCHCMD=ftp    # the only HTTP client on some BSD
+fi
 
+if [ USE_LINARO = 1 ]; then
+    if which gnutar > /dev/null; then
         TAR=gnutar
-       ;;
-       CYGWIN*)
-       echo "Found CygWin that means Windows most likely."
-       ;;
-       *)
-       echo "Found unknown OS. Aborting!"
-       exit 1
-       ;;
-esac
+    elif which gtar > /dev/null; then
+        TAR=gtar
+    else    # hopefully it understands the GNU format
+        TAR=tar
+    fi
+else
+    TAR=tar     # use the system tar
+fi
 
 ##############################################################################
 # Building section
@@ -147,7 +137,7 @@ esac
 fetch() {
     if [ ! -e ${STAMPS}/$1.fetch ]; then
         log "Downloading $1 sources..."
-        wget -c $2
+        ${FETCHCMD} $2
         touch ${STAMPS}/$1.fetch
     fi
 }
@@ -183,7 +173,7 @@ unpack() {
 }
 
 # Install a build
-install() {
+doinstall() {
     log $1
     ${SUDO} make ${MAKEFLAGS} $2 $3 $4 $5 $6 $7 $8
 }
@@ -227,7 +217,7 @@ if [ ! -e ${STAMPS}/${BINUTILS}.build ]; then
                           ${BINUTILFLAGS}
     log "Building ${BINUTILS}"
     make ${MAKEFLAGS}
-    install ${BINUTILS} install
+    doinstall ${BINUTILS} install
     cd ..
     log "Cleaning up ${BINUTILS}"
     touch ${STAMPS}/${BINUTILS}.build
@@ -260,7 +250,7 @@ if [ ! -e ${STAMPS}/${GCC}-boot.build ]; then
                      ${GCCFLAGS}
     log "Building ${GCC}-boot"
     make ${MAKEFLAGS} all-gcc
-    install ${GCC}-boot install-gcc
+    doinstall ${GCC}-boot install-gcc
     cd ..
     log "Cleaning up ${GCC}-boot"
     touch ${STAMPS}/${GCC}-boot.build
@@ -289,7 +279,7 @@ if [ ! -e ${STAMPS}/${NEWLIB}.build ]; then
     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}"
-    install ${NEWLIB} install
+    doinstall ${NEWLIB} install
     cd ..
     log "Cleaning up ${NEWLIB}"
     touch ${STAMPS}/${NEWLIB}.build
@@ -322,7 +312,7 @@ if [ ! -e ${STAMPS}/${GCC}.build ]; then
                     ${GCCFLAGS}
     log "Building ${GCC}"
     make ${MAKEFLAGS}
-    install ${GCC} install
+    doinstall ${GCC} install
     cd ..
     log "Cleaning up ${GCC}"
     touch ${STAMPS}/${GCC}.build
@@ -341,7 +331,7 @@ if [ ! -e ${STAMPS}/${GDB}.build ]; then
                      ${GDBFLAGS}
     log "Building ${GDB}"
     make ${MAKEFLAGS}
-    install ${GDB} install
+    doinstall ${GDB} install
     cd ..
     log "Cleaning up ${GDB}"
     touch ${STAMPS}/${GDB}.build