[PATCH] toolchain/build: Support linaro android toolchain
Meng-Hsuan Cheng
luse at 0xlab.org
Wed Mar 9 07:35:12 UTC 2011
Add linaro-build.sh to support linaro android toolchain.
--prefix= Specify where to install (default:
/tmp/android-toolchain-eabi)
--toolchain-src= Specify Android toolchain source dir (default:
<toolchain/build>/../)
--with-gcc= Specify GCC source (support: directory, bzr, url)
--apply-gcc-patch=(yes|no) Apply gcc-patches (default: no)
--help Print help message
Change-Id: I15478ba3b3dd4f49be3767724028e4e4dcade1ca
---
linaro-build.sh | 195
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 195 insertions(+), 0 deletions(-)
create mode 100755 linaro-build.sh
diff --git a/linaro-build.sh b/linaro-build.sh
new file mode 100755
index 0000000..57266dd
--- /dev/null
+++ b/linaro-build.sh
@@ -0,0 +1,195 @@
+#!/bin/bash
+
+# Copyright (C) 2011 Linaro
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+
+ARG_PREFIX_DIR=/tmp/android-toolchain-eabi
+ARG_TOOLCHAIN_SRC_DIR=${PWD%/build}
+
+ARG_LINARO_GCC_SRC_DIR=
+ARG_WGET_LINARO_GCC_SRC=
+ARG_BZR_LINARO_GCC_SRC=
+
+ARG_WITH_GCC=
+
+ARG_APPLY_PATCH=no
+
+abort() {
+ echo $@
+ exec false
+}
+
+error() {
+ abort "[ERROR] $@"
+}
+
+warn() {
+ echo "[WARNING] $@"
+}
+
+info() {
+ echo "[INFO] $@"
+}
+
+note() {
+ echo "[NOTE] $@"
+}
+
+usage() {
+ echo
"--------------------------------------------------------------------"
+ echo "--prefix= Specify where to install (default:
/tmp/android-toolchain-eabi)"
+ echo "--toolchain-src= Specify Android toolchain source dir (default:
<toolchain/build>/../)"
+ echo "--with-gcc= Specify GCC source (support: directory, bzr,
url)"
+ echo "--apply-gcc-patch=(yes|no) Apply gcc-patches (default: no)"
+ echo "--help Print help message"
+ echo
"--------------------------------------------------------------------"
+}
+
+ARG_LINARO_GCC_SRC_DIR=
+
+
+downloadFormBZR() {
+ local MY_LP_LINARO_GCC=$1
+ ARG_LINARO_GCC_SRC_DIR=${MY_LP_LINARO_GCC#*:}
+
+ [ ! -d ${ARG_TOOLCHAIN_SRC_DIR}/gcc ] && mkdir -p
"${ARG_TOOLCHAIN_SRC_DIR}/gcc"
+ if [ ! -d "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR}" ];
then
+ info "Use bzr to clone ${MY_LP_LINARO_GCC}"
+ RUN=`bzr clone ${MY_LP_LINARO_GCC}
${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR}`
+ [ $? -ne 0 ] && error "bzr ${MY_LP_LINARO_GCC} error"
+ else
+ info "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR} is already
exist, skip bzr clone"
+ fi
+}
+
+downloadFormHTTP() {
+ info "Use wget to get $1"
+ local MY_LINARO_GCC_FILE=`basename $1`
+ if [ -f "${MY_LINARO_GCC_FILE}" ]; then
+ #TODO: Add md5 check
+ info "${MY_LINARO_GCC_FILE} is already exist, skip download"
+ else
+ RUN=`wget $1`
+ [ $? -ne 0 ] && error "wget $1 error"
+ #TODO: Add md5 check
+ fi
+
+ ARG_LINARO_GCC_SRC_DIR=`basename ${MY_LINARO_GCC_FILE} .tar.bz2`
+ [ ! -d ${ARG_TOOLCHAIN_SRC_DIR}/gcc ] && mkdir -p
"${ARG_TOOLCHAIN_SRC_DIR}/gcc"
+ if [ ! -d "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR}" ];
then
+ info "untar ${MY_LINARO_GCC_FILE} to ${ARG_TOOLCHAIN_SRC_DIR}/gcc"
+ tar jxf ${MY_LINARO_GCC_FILE} -C ${ARG_TOOLCHAIN_SRC_DIR}/gcc
+ else
+ info "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR} is already
exist, skip untar"
+ fi
+}
+
+getGCCFrom() {
+ # set empty to detect error
+ ARG_LINARO_GCC_SRC_DIR=
+ ARG_LINARO_GCC_VER=
+
+ case $1 in
+ lp:*) # bzr clone lp:gcc-linaro
+ downloadFormBZR $1
+ ;;
+ http://*) # snapshot url
http://launchpad.net/gcc-linaro/4.5/4.5-2011.02-0/+download/gcc-linaro-4.5-2011.02-0.tar.bz2
+ downloadFormHTTP $1
+ ;;
+ *) # local directory
+ [ ! -d "${ARG_TOOLCHAIN_SRC_DIR}/gcc/$1" ] && error
"$ARG_TOOLCHAIN_SRC_DIR/gcc/$ARG_LINARO_GCC_SRC_DIR not exist"
+ ARG_LINARO_GCC_SRC_DIR=$1
+ esac
+
+ ARG_LINARO_GCC_VER=`echo ${ARG_LINARO_GCC_SRC_DIR} | grep -o "4\.[5-9]"`
+ if [ ${ARG_LINARO_GCC_VER} = "" ]; then
+ warn "Cannot detect version for ${ARG_LINARO_GCC_VER}, 4.5 is used"
+ ARG_LINARO_GCC_VER=4.5
+ fi
+}
+
+while [ $# -gt 0 ]; do
+ ARG=$1
+ ARG_PARMS="$ARG_PARMS '$ARG'"
+ shift
+ case "$ARG" in
+ --prefix=*)
+ ARG_PREFIX_DIR="${ARG#*=}"
+ ;;
+ --toolchain-src=*)
+ ARG_TOOLCHAIN_SRC_DIR="${ARG#*=}"
+ ;;
+ --with-gcc=*)
+ ARG_WITH_GCC="${ARG#*=}"
+ ;;
+ --apply-gcc-patch=yes | --apply-gcc-patch=no)
+ ARG_APPLY_PATCH="${ARG#*=}"
+ ;;
+ --help)
+ usage && abort
+ ;;
+ *)
+ error "Unrecognized parameter $ARG"
+ ;;
+ esac
+done
+
+BUILD_ARCH=`uname -m`
+BUILD_WITH_LOCAL=
+BUILD_HOST=
+
+if [ "${ARG_TOOLCHAIN_SRC_DIR}" = "" ] || [ ! -f
"${ARG_TOOLCHAIN_SRC_DIR}/build/configure" ] ; then
+ error "--toolchain-src-dir is not set or ${ARG_TOOLCHAIN_SRC_DIR} is not
ANDROID_TOOLCHAIN_ROOT"
+fi
+
+if [ "${ARG_WITH_GCC}" = "" ]; then
+ error "Must specify --with-gcc to build toolchain"
+fi
+
+getGCCFrom $ARG_WITH_GCC
+
+if [ "x${ARG_APPLY_PATCH}" = "xyes" ]; then
+ note "Will apply patches in toolchain/gcc-patches/${ARG_LINARO_GCC_VER}"
+ cd ${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR}
+ for FILE in `ls
${ARG_TOOLCHAIN_SRC_DIR}/gcc-patches/${ARG_LINARO_GCC_VER}` ; do
+ if [ ! -f ${FILE}-patch.log ]; then
+ note "Applying patch ${FILE}"
+ git apply
${ARG_TOOLCHAIN_SRC_DIR}/gcc-patches/${ARG_LINARO_GCC_VER}/${FILE} 2>&1 |
tee "${FILE}-patch.log"
+ fi
+ done
+ cd -
+fi
+
+ARG_LINARO_GCC_SRC_DIR=${ARG_LINARO_GCC_SRC_DIR#gcc-*}
+
+if echo "$BUILD_ARCH" | grep -q '64' ; then
+ info "Use 64-bit Build Enviorment"
+ BUILD_HOST=x86_64-linux-gnu
+ CC="gcc -m32"
+ CXX="g++ -m32"
+else
+ info "Use 32-bit Build Enviorment"
+ BUILD_HOST=i686-unknown-linux-gnu
+fi
+
+${ARG_TOOLCHAIN_SRC_DIR}/build/configure \
+ --prefix=${ARG_PREFIX_DIR} --target=arm-eabi \
+ --disable-docs --disable-nls \
+ --host=${BUILD_HOST} --build=${BUILD_HOST} \
+ --with-gcc-version=${ARG_LINARO_GCC_SRC_DIR} \
+ --with-binutils-version=2.20.1 \
+ --with-gmp-version=4.2.4 \
+ --with-mpfr-version=2.4.1 \
+ --with-gdb-version=7.1.x
+
+make
+make install
--
1.7.0.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linaro.org/pipermail/linaro-dev/attachments/20110309/d640dcf4/attachment-0001.html>
More information about the linaro-dev
mailing list