tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Jul 19 12:25:46 2008 +0000 (2008-07-19)
changeset 688 b8d87af44232
parent 546 0bf5637e0afd
child 858 e815b1a5057c
permissions -rwxr-xr-x
It's been a long time that the gcc libraries are all installed in the sys-root.
Thus populate does not need to look above to find the libraries.

/trunk/tools/populate.in | 9 3 6 0 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
yann@375
     1
#!/bin/bash
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@103
    10
    --gcc, --binutils, --glibc, --uClibc, --linux,
yann@245
    11
    --gdb, --dmalloc, --duma, --strace, --ltrace, --libelf
yann@466
    12
    --gmp, --mpfr
yann@1
    13
yann@96
    14
  Valid options for all tools:
yann@43
    15
    --experimental, -x
yann@43
    16
      mark the version as being experimental
yann@43
    17
yann@96
    18
    --obsolete, -o
yann@96
    19
      mark the version as being obsolete
yann@96
    20
yann@96
    21
  Valid mandatory 'option' for tool==linux is one and only one of:
yann@1
    22
    --install, --sanitised, --copy
yann@1
    23
yann@1
    24
  'version' is a valid version for the specified tool.
yann@1
    25
yann@1
    26
  Examples:
yann@1
    27
    add version 2.6.19.2 to linux kernel install method:
yann@1
    28
      ${myname} --linux --install 2.6.19.2
yann@1
    29
yann@1
    30
    add versions 2.3.5 and 2.3.6 to glibc:
yann@1
    31
      ${myname} --glibc 2.3.5 2.3.6
yann@1
    32
EOF
yann@1
    33
}
yann@1
    34
yann@96
    35
cat=
yann@1
    36
tool=
yann@1
    37
tool_prefix=
yann@96
    38
tool_suffix=
yann@1
    39
VERSION=
yann@43
    40
EXP=
yann@96
    41
OBS=
yann@322
    42
prompt_suffix=
yann@1
    43
yann@1
    44
i=1
yann@1
    45
while [ $i -le $# ]; do
yann@1
    46
    case "${!i}" in
yann@96
    47
        # Tools:
yann@448
    48
        --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc;      tool_suffix=;;
yann@448
    49
        --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;        tool_suffix=;;
yann@448
    50
        --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc;    tool_suffix=;;
yann@448
    51
        --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc;    tool_suffix=;;
yann@448
    52
        --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel;  tool_suffix=;;
yann@448
    53
        --gdb)              cat=GDB;       tool=gdb;      tool_prefix=debug    tool_suffix=;;
yann@448
    54
        --dmalloc)          cat=DMALLOC;   tool=dmalloc;  tool_prefix=debug    tool_suffix=;;
yann@448
    55
        --duma)             cat=DUMA;      tool=duma;     tool_prefix=debug    tool_suffix=;;
yann@448
    56
        --strace)           cat=STRACE;    tool=strace;   tool_prefix=debug    tool_suffix=;;
yann@448
    57
        --ltrace)           cat=LTRACE;    tool=ltrace;   tool_prefix=debug    tool_suffix=;;
yann@448
    58
        --libelf)           cat=LIBELF;    tool=libelf;   tool_prefix=tools    tool_suffix=;;
yann@466
    59
        --gmp)              cat=GMP;       tool=gmp;      tool_prefix=cc;      tool_suffix=;;
yann@466
    60
        --mpfr)             cat=MPFR;      tool=mpfr;     tool_prefix=cc;      tool_suffix=;;
yann@96
    61
        # Tools options:
yann@322
    62
        -x|--experimental)  EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
yann@322
    63
        -o|--obsolete)      OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
yann@43
    64
        --install)          tool_suffix=install;;
yann@43
    65
        --sanitised)        tool_suffix=sanitised;;
yann@43
    66
        --copy)             tool_suffix=copy;;
yann@96
    67
        # Misc:
yann@43
    68
        -h|--help)          doHelp; exit 0;;
yann@523
    69
        -*)                 echo "Unknown option: '${!i}' (use -h/--help for help)."; exit 1;;
yann@96
    70
        *)                  VERSION="${VERSION} ${!i}";;
yann@1
    71
    esac
yann@1
    72
    i=$((i+1))
yann@1
    73
done
yann@1
    74
yann@1
    75
[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
yann@1
    76
yann@1
    77
case "${cat}" in
yann@422
    78
    KERNEL) [ -z "${tool_suffix}" ] && { doHelp; exit 1; } ;;
yann@422
    79
    *)      ;;
yann@1
    80
esac
yann@1
    81
yann@1
    82
for ver in ${VERSION}; do
yann@545
    83
    # Split VERSION into MAJOR MINOR PATCHLEVEL EXTRAVERSION 
yann@546
    84
    ver_M=$(echo "${ver}...." |cut -d . -f 1)
yann@546
    85
    ver_m=$(echo "${ver}...." |cut -d . -f 2)
yann@546
    86
    ver_P=$(echo "${ver}...." |cut -d . -f 3)
yann@546
    87
    ver_E=$(echo "${ver}...." |cut -d . -f 4)
yann@545
    88
    unset DEP L1 L2 L3 L4 L5 L6 FILE
yann@523
    89
    v=$(echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;')
yann@1
    90
    if [ "${cat}" = "KERNEL" ]; then
yann@523
    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@322
    94
        L3="    prompt \"${ver}${prompt_suffix}\"\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@546
   100
        L6="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
yann@448
   101
        FILE="config/${tool_prefix}/${tool}_headers_${tool_suffix}.in"
yann@96
   102
    else
yann@422
   103
        L1="config ${cat}_V_${v}\n"
yann@96
   104
        L2="    bool\n"
yann@322
   105
        L3="    prompt \"${ver}${prompt_suffix}\"\n"
yann@545
   106
        L6="    default \"${ver}\" if ${cat}_V_${v}"
yann@545
   107
        case "${tool}" in
yann@545
   108
            gcc)
yann@546
   109
                if [ ${ver_M} -gt 4 -o \( ${ver_M} -eq 4 -a ${ver_m} -ge 3 \) ]; then
yann@546
   110
                    L5="    select CC_GCC_4_3_or_later\n"
yann@545
   111
                fi
yann@545
   112
                ;;
yann@545
   113
        esac
yann@448
   114
        FILE="config/${tool_prefix}/${tool}.in"
yann@1
   115
    fi
yann@43
   116
    [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
yann@96
   117
    [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
yann@43
   118
    case "${DEP}" in
yann@43
   119
        "") ;;
yann@546
   120
        *)  L4="    depends on "$(echo "${DEP}" |sed -r -e 's/^ \&\& //; s/\&/\\&/g;')"\n"
yann@43
   121
    esac
yann@545
   122
    sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}${L5}"'\n\1/;
yann@545
   123
                  s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L6}"'\n\1/;' "${FILE}"
yann@1
   124
done