tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Apr 18 17:32:55 2007 +0000 (2007-04-18)
changeset 43 f3b4bb1e501b
parent 10 94a0eae9fe9f
child 96 aa1a9fbd6eb8
permissions -rwxr-xr-x
When adding a new tool version, allow it to be EXPERIMENTAL.
yann@1
     1
#!/bin/sh
yann@1
     2
yann@1
     3
# Adds a new version to one of the toolchain component
yann@1
     4
myname="$0"
yann@1
     5
yann@1
     6
doHelp() {
yann@1
     7
    cat <<-EOF
yann@1
     8
Usage: ${myname} <tool> [option] <version>
yann@1
     9
  'tool' in one of:
yann@1
    10
    --gcc, --tcc, --binutils, --glibc, --uClibc, --linux, --cygwin
yann@1
    11
yann@43
    12
  Options:
yann@43
    13
    --experimental, -x
yann@43
    14
      mark the version as being experimental
yann@43
    15
yann@1
    16
  Valid mandatory 'option' for tool==gcc is one of:
yann@1
    17
    --core, --final
yann@1
    18
yann@1
    19
  Valid mandatory 'option' for tool==linux is one of:
yann@1
    20
    --install, --sanitised, --copy
yann@1
    21
yann@1
    22
  'version' is a valid version for the specified tool.
yann@1
    23
yann@1
    24
  Examples:
yann@1
    25
    add version 2.6.19.2 to linux kernel install method:
yann@1
    26
      ${myname} --linux --install 2.6.19.2
yann@1
    27
yann@1
    28
    add versions 2.3.5 and 2.3.6 to glibc:
yann@1
    29
      ${myname} --glibc 2.3.5 2.3.6
yann@1
    30
EOF
yann@1
    31
}
yann@1
    32
yann@1
    33
tool=
yann@1
    34
tool_prefix=
yann@1
    35
CORE=
yann@1
    36
FINAL=
yann@1
    37
VERSION=
yann@43
    38
EXP=
yann@1
    39
yann@1
    40
i=1
yann@1
    41
while [ $i -le $# ]; do
yann@1
    42
    case "${!i}" in
yann@43
    43
        --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
yann@43
    44
#        --tcc)              cat=CC;        tool=tcc;      tool_prefix=cc_;      tool_suffix=;;
yann@43
    45
        --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
yann@43
    46
        --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
yann@43
    47
        --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
yann@43
    48
        --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel_;;
yann@43
    49
#        --cygwin)           cat=KERNEL;    tool=cygwin;   tool_prefix=kernel_;;
yann@43
    50
        --core)             CORE=1;;
yann@43
    51
        --final)            FINAL=1;;
yann@43
    52
        --install)          tool_suffix=install;;
yann@43
    53
        --sanitised)        tool_suffix=sanitised;;
yann@43
    54
        --copy)             tool_suffix=copy;;
yann@43
    55
        -x|--experimental)  EXP=1;;
yann@43
    56
        -h|--help)          doHelp; exit 0;;
yann@1
    57
        -*)             echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
yann@1
    58
        *)              VERSION="${VERSION} ${!i}";;
yann@1
    59
    esac
yann@1
    60
    i=$((i+1))
yann@1
    61
done
yann@1
    62
yann@1
    63
[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
yann@1
    64
yann@1
    65
case "${cat}" in
yann@10
    66
    CC)     [ -z "${CORE}" -a -z "${FINAL}" ] && { doHelp; exit 1; };;
yann@10
    67
    KERNEL) unset FINAL CORE
yann@10
    68
            [ -z "${tool_suffix}" ] && { doHelp; exit 1; }
yann@10
    69
            ;;
yann@1
    70
    *)      FINAL=1; CORE=;;
yann@1
    71
esac
yann@1
    72
yann@1
    73
for ver in ${VERSION}; do
yann@43
    74
    unset DEP L1 L2 L3 L4 L5 FILE
yann@1
    75
	v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
yann@1
    76
    if [ -n "${CORE}" ]; then
yann@1
    77
        L1="config ${cat}_CORE_V_${v}\n"
yann@1
    78
        L2="    bool\n"
yann@1
    79
        L3="    prompt \"${ver}\"\n"
yann@43
    80
        L5="    default \"${ver}\" if ${cat}_CORE_V_${v}"
yann@43
    81
        FILE="config/${tool_prefix}core_${tool}.in"
yann@1
    82
    fi
yann@1
    83
    if [ -n "${FINAL}" ]; then
yann@1
    84
        L1="config ${cat}_V_${v}\n"
yann@1
    85
        L2="    bool\n"
yann@1
    86
        L3="    prompt \"${ver}\"\n"
yann@43
    87
        L5="    default \"${ver}\" if ${cat}_V_${v}"
yann@43
    88
        FILE="config/${tool_prefix}${tool}.in"
yann@1
    89
    fi
yann@1
    90
    if [ "${cat}" = "KERNEL" ]; then
yann@1
    91
        TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
yann@1
    92
        L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
yann@1
    93
        L2="    bool\n"
yann@1
    94
        L3="    prompt \"${ver}\"\n"
yann@1
    95
        # Extra versions are not necessary visible:
yann@43
    96
        case "${tool_suffix},${ver}" in
yann@43
    97
            sanitised,*)    ;; # Sanitised headers always have an extra version
yann@43
    98
            *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
yann@1
    99
        esac
yann@1
   100
        L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
yann@43
   101
        FILE="config/${tool_prefix}${tool}_headers_${tool_suffix}.in"
yann@1
   102
    fi
yann@43
   103
    [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
yann@43
   104
    case "${DEP}" in
yann@43
   105
        "") ;;
yann@43
   106
        *)  L4="    depends on `echo \"${DEP}\" |sed -r -e 's/^ \\&\\& //; s/\\&/\\\\&/g;'`\n"
yann@43
   107
    esac
yann@43
   108
    sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
yann@43
   109
                  s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' "${FILE}"
yann@1
   110
done