@@ -20,6 +20,7 @@ ARG_WGET_LINARO_GCC_SRC=
ARG_BZR_LINARO_GCC_SRC=
ARG_WITH_GCC=
+ARG_WITH_GDB=
ARG_WITH_SYSROOT=
ARG_APPLY_PATCH=no
@@ -54,72 +55,91 @@ usage() {
echo " --prefix=<path> Specify installation path
[/tmp/android-toolchain-eabi]"
echo " --toolchain-src=<path> Toolchain source directory [`dirname
$PWD`]"
echo " --with-gcc=<path> Specify GCC source (support:
directory, bzr, url)"
+ echo " --with-gdb=<path> Specify gdb source (support:
directory, bzr, url)"
echo " --with-sysroot=<path> Specify SYSROOT directory"
echo " --apply-gcc-patch=<yes|no> Apply Linaro's extra gcc-patches
[no]"
echo " --help Print this 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} fails."
+# $1 - package name (gcc, gdb, etc)
+# $2 - value of ARG_WITH_package (lp:*, http://*)
+downloadFromBZR() {
+ local package=$1
+ local MY_LP_LINARO_PKG=$2
+ local src_dir=${MY_LP_LINARO_PKG#*:}
+
+ local PACKAGE_NAME=`echo $package | tr "[:lower:]" "[:upper:]"`
+ eval "ARG_LINARO_${PACKAGE_NAME}_SRC_DIR=${src_dir}"
+
+ [ ! -d ${ARG_TOOLCHAIN_SRC_DIR}/$package ] && mkdir -p
"${ARG_TOOLCHAIN_SRC_DIR}/$package"
+ if [ ! -d "${ARG_TOOLCHAIN_SRC_DIR}/$package/${src_dir}" ]; then
+ info "Use bzr to clone ${MY_LP_LINARO_PKG}"
+ RUN=`bzr clone ${MY_LP_LINARO_PKG}
${ARG_TOOLCHAIN_SRC_DIR}/$package/${src_dir}`
+ [ $? -ne 0 ] && error "bzr ${MY_LP_LINARO_PKG} fails."
else
- info "${ARG_TOOLCHAIN_SRC_DIR}/gcc/${ARG_LINARO_GCC_SRC_DIR} already
exists, skip bzr clone"
+ info "${ARG_TOOLCHAIN_SRC_DIR}/$package/${src_dir} already exists, 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
+# $1 - package name (gcc, gdb, etc)
+# $2 - arg (lp:*, http://*)
+downloadFromHTTP() {
+ local package=$1
+ local url=$2
+ local file=`basename $url`
+
+ local PACKAGE_NAME=`echo $package | tr "[:lower:]" "[:upper:]"`
+
+ info "Use wget to get $file"
+ if [ -f "${ARG_TOOLCHAIN_SRC_DIR}/${file}" ] || [ -f
"${ARG_TOOLCHAIN_SRC_DIR}/$package/${file}" ]; then
#TODO: Add md5 check
- info "${MY_LINARO_GCC_FILE} is already exist, skip download"
+ info "${file} is already exist, skip download"
else
- RUN=`wget $1`
- [ $? -ne 0 ] && error "wget $1 error"
+ wget "$url" || error "wget $1 error"
+ mv "$file" "${ARG_TOOLCHAIN_SRC_DIR}/$package" || error "fail to move
$file"
#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
+ local src_dir=$(basename $file)
+ src_dir=$(echo $src_dir | sed
"s/\(\.tar\.bz2\|\.tar\.gz\|\.tgz\|\.tbz\)//")
+ eval "ARG_LINARO_${PACKAGE_NAME}_SRC_DIR=${src_dir}"
}
-getGCCFrom() {
- # set empty to detect error
- ARG_LINARO_GCC_SRC_DIR=
- ARG_LINARO_GCC_VER=
+# $1 - value of ARG_WITH_package
+getPackage() {
+ local package=$(basename $1)
+ local version=${package#*-}
+ version=$(echo $version | sed
"s/\(\.tar\.bz2\|\.tar\.gz\|\.tgz\|\.tbz\)//")
+ package=${package%%-*}
+
+ local PACKAGE_NAME=`echo $package | tr "[:lower:]" "[:upper:]"`
case $1 in
lp:*) # bzr clone lp:gcc-linaro
- downloadFormBZR $1
+ downloadFromBZR $package $1
;;
http://*) # snapshot URL:
http://launchpad.net/gcc-linaro/4.5/4.5-2011.03-0/+download/gcc-linaro-4.5-2011.03-0.tar.bz2
- downloadFormHTTP $1
+ downloadFromHTTP $package $1
;;
*) # local directory