tools/addToolVersion.sh
changeset 1 eeea35fbf182
child 10 94a0eae9fe9f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/addToolVersion.sh	Sat Feb 24 11:00:05 2007 +0000
     1.3 @@ -0,0 +1,99 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +# Adds a new version to one of the toolchain component
     1.7 +myname="$0"
     1.8 +
     1.9 +doHelp() {
    1.10 +    cat <<-EOF
    1.11 +Usage: ${myname} <tool> [option] <version>
    1.12 +  'tool' in one of:
    1.13 +    --gcc, --tcc, --binutils, --glibc, --uClibc, --linux, --cygwin
    1.14 +
    1.15 +  Valid mandatory 'option' for tool==gcc is one of:
    1.16 +    --core, --final
    1.17 +
    1.18 +  Valid mandatory 'option' for tool==linux is one of:
    1.19 +    --install, --sanitised, --copy
    1.20 +
    1.21 +  'version' is a valid version for the specified tool.
    1.22 +
    1.23 +  Examples:
    1.24 +    add version 2.6.19.2 to linux kernel install method:
    1.25 +      ${myname} --linux --install 2.6.19.2
    1.26 +
    1.27 +    add versions 2.3.5 and 2.3.6 to glibc:
    1.28 +      ${myname} --glibc 2.3.5 2.3.6
    1.29 +EOF
    1.30 +}
    1.31 +
    1.32 +tool=
    1.33 +tool_prefix=
    1.34 +CORE=
    1.35 +FINAL=
    1.36 +VERSION=
    1.37 +
    1.38 +i=1
    1.39 +while [ $i -le $# ]; do
    1.40 +    case "${!i}" in
    1.41 +        --gcc)          cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
    1.42 +#        --tcc)          cat=CC;        tool=tcc;      tool_prefix=cc_;      tool_suffix=;;
    1.43 +        --binutils)     cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
    1.44 +        --glibc)        cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
    1.45 +        --uClibc)       cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
    1.46 +        --linux)        cat=KERNEL;    tool=linux;    tool_prefix=kernel_;;
    1.47 +#        --cygwin)       cat=KERNEL;    tool=cygwin;   tool_prefix=kernel_;;
    1.48 +        --core)         CORE=1;;
    1.49 +        --final)        FINAL=1;;
    1.50 +        --install)      tool_suffix=install;;
    1.51 +        --sanitised)    tool_suffix=sanitised;;
    1.52 +        --copy)         tool_suffix=copy;;
    1.53 +        -h|--help)      doHelp; exit 0;;
    1.54 +        -*)             echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
    1.55 +        *)              VERSION="${VERSION} ${!i}";;
    1.56 +    esac
    1.57 +    i=$((i+1))
    1.58 +done
    1.59 +
    1.60 +[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
    1.61 +
    1.62 +case "${cat}" in
    1.63 +    CC)     ;;
    1.64 +    KERNEL) FINAL=; CORE=;;
    1.65 +    *)      FINAL=1; CORE=;;
    1.66 +esac
    1.67 +
    1.68 +for ver in ${VERSION}; do
    1.69 +	v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
    1.70 +    if [ -n "${CORE}" ]; then
    1.71 +        L1="config ${cat}_CORE_V_${v}\n"
    1.72 +        L2="    bool\n"
    1.73 +        L3="    prompt \"${ver}\"\n"
    1.74 +        L4="    default \"${ver}\" if ${cat}_CORE_V_${v}"
    1.75 +        sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
    1.76 +                      s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}core_${tool}.in
    1.77 +    fi
    1.78 +    if [ -n "${FINAL}" ]; then
    1.79 +        L1="config ${cat}_V_${v}\n"
    1.80 +        L2="    bool\n"
    1.81 +        L3="    prompt \"${ver}\"\n"
    1.82 +        L4="    default \"${ver}\" if ${cat}_V_${v}"
    1.83 +        sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
    1.84 +                      s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}${tool}.in
    1.85 +    fi
    1.86 +    if [ "${cat}" = "KERNEL" ]; then
    1.87 +        TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
    1.88 +        L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
    1.89 +        L2="    bool\n"
    1.90 +        L3="    prompt \"${ver}\"\n"
    1.91 +        # Extra versions are not necessary visible:
    1.92 +        case "${ver}" in
    1.93 +            *.*.*.*) L4="    depends on KERNEL_VERSION_SEE_EXTRAVERSION\n";;
    1.94 +            *)       L4=;;
    1.95 +        esac
    1.96 +        # Sanitised headers always have an extra version:
    1.97 +        [ "${tool_suffix}" = "sanitised" ] && L4=
    1.98 +        L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
    1.99 +        sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
   1.100 +                      s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' config/${tool_prefix}${tool}_headers_${tool_suffix}.in
   1.101 +    fi
   1.102 +done