scripts/addToolVersion.sh
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Mon Apr 16 15:25:36 2012 +0200 (2012-04-16)
changeset 2941 13e40098fffc
parent 2797 ce8ada0b1d41
child 3144 481658dd0e7f
permissions -rwxr-xr-x
cc/gcc: update Linaro GCC revisions to 2012.04

Update Linaro GCC with the latest available revisions.

The 4.7 revision is also released, but the infrastructure is not yet ready for
it in CT-NG.

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
yann@1173
     1
#!/bin/sh
yann@1174
     2
set -e
yann@1
     3
yann@1
     4
# Adds a new version to one of the toolchain component
yann@1
     5
myname="$0"
yann@1
     6
yann@1174
     7
# Parse the tools' paths configuration
yann@1623
     8
# It is expected that this script is only to be run from the
yann@1623
     9
# source directory of crosstool-NG, so it is trivial to find
yann@2838
    10
# paths.sh (we can't use  ". paths.sh", as POSIX states that
yann@1623
    11
# $PATH should be searched for, and $PATH most probably doe
yann@1623
    12
# not include "."), hence the "./".
yann@2838
    13
. "./paths.sh"
yann@1174
    14
yann@1
    15
doHelp() {
yann@1
    16
    cat <<-EOF
yann@1722
    17
		Usage: ${myname} <--tool> <[options] version [...]> ...
yann@1722
    18
		  'tool' in one of:
yann@1723
    19
		    gcc, binutils, glibc, eglibc, uClibc, newlib, linux, gdb, dmalloc,
yann@1723
    20
		    duma, strace, ltrace, libelf, gmp, mpfr, ppl, cloog, mpc
yann@1722
    21
		
yann@1722
    22
		  Valid options for all tools:
yann@1722
    23
		    --stable, -s, +x   (default)
yann@1722
    24
		      mark the version as being stable (as opposed to experimental, below)
yann@1722
    25
		
yann@1722
    26
		    --experimental, -x, +s
yann@1722
    27
		      mark the version as being experimental (as opposed to stable, above)
yann@1722
    28
		
yann@1722
    29
		    --current, -c, +o   (default)
yann@1722
    30
		      mark the version as being cuurent (as opposed to obsolete, below)
yann@1722
    31
		
yann@1722
    32
		    --obsolete, -o, +c
yann@1722
    33
		      mark the version as being obsolete (as opposed to current, above)
yann@1722
    34
		
yann@1722
    35
		  Note: setting a new tool resets to the defaults: 'stable' and 'current'.
yann@1722
    36
		
yann@1722
    37
		  'version' is a valid version for the specified tool.
yann@1722
    38
		
yann@1722
    39
		  Examples:
yann@1722
    40
		    add stable current version 2.6.19.2 to linux kernel:
yann@1722
    41
		      ${myname} --linux 2.6.19.2
yann@1722
    42
		
yann@1722
    43
		    add experimental obsolete version 2.3.5 and stable current versions 2.6.1
yann@1722
    44
		    and 2.6.2 to glibc, add stable obsolete version 3.3.3 to gcc:
yann@1722
    45
		      ${myname} --glibc -x -o 2.3.5 -s -c 2.6.1 2.6.2 --gcc -o 3.3.3
yann@1722
    46
		EOF
yann@1
    47
}
yann@1
    48
benoit@2485
    49
# Extract field $3 from version $1 with separator $2
benoit@2485
    50
getVersionField() {
benoit@2485
    51
    local version="$1"
benoit@2485
    52
    local sep="$2"
benoit@2485
    53
    local field="$3"
benoit@2485
    54
benoit@2485
    55
    echo "${version}${sep}${sep}${sep}${sep}" |cut -d ${sep} -f ${field}
benoit@2485
    56
}
benoit@2485
    57
yann@1173
    58
# Effectively add a version to the specified tool
yann@1173
    59
# $cat          : tool category
yann@1173
    60
# $tool         : tool name
yann@1173
    61
# $tool_prefix  : tool directory prefix
yann@1173
    62
# $EXP          : set to non empty if experimental, to empty otherwise
yann@1173
    63
# #OBS          : set to non empty if obsolete, to empty otherwise
yann@1173
    64
# $1            : version string to add
yann@1173
    65
addToolVersion() {
yann@1173
    66
    local version="$1"
yann@2412
    67
    local file="$2"
yann@1200
    68
    local config_ver_option
yann@1173
    69
    local exp_obs_prompt
yann@1734
    70
    local deps v ver_M ver_m ver_p
yann@1173
    71
    local SedExpr1 SedExpr2
yann@1173
    72
yann@2412
    73
    [ -f "${file}" ] || return 0
yann@2412
    74
yann@1174
    75
    v=$(echo "${version}" |"${sed}" -r -e 's/-/_/g; s/\./_/g;')
yann@1173
    76
yann@1200
    77
    config_ver_option="${cat}_V_${v}"
yann@1200
    78
yann@1200
    79
    # Check for existing version: it can be legitimitate for an end-user
yann@1200
    80
    # to try adding a new version if the one he/she wants is not listed.
yann@1200
    81
    # But it can be the case where the version is hidden behind either one
yann@1200
    82
    # of EXPERIMENTAL or OBSOLETE, so warn if the version is already listed.
yann@2412
    83
    if grep -E "^config ${config_ver_option}$" "${file}" >/dev/null 2>&1; then
yann@1200
    84
        echo "'${tool}': version '${version}' already present:"
yann@2412
    85
        grep -A1 -B0 -n                                                     \
yann@2412
    86
             -E "^(config ${config_ver_option}| {4}prompt \"${version}\")$" \
yann@2412
    87
             "${file}" /dev/null
yann@1200
    88
        return 0
yann@1200
    89
    fi
yann@1200
    90
yann@1200
    91
    SedExpr1="${SedExpr1}config ${config_ver_option}\n"
yann@1173
    92
    SedExpr1="${SedExpr1}    bool\n"
yann@1173
    93
    SedExpr1="${SedExpr1}    prompt \"${version}"
yann@1173
    94
    case "${EXP},${OBS}" in
yann@1173
    95
        ,)  ;;
yann@1536
    96
        ,*) exp_obs_prompt=" (OBSOLETE)"
yann@1535
    97
            deps="    depends on OBSOLETE"
yann@1173
    98
            ;;
yann@1536
    99
        *,) exp_obs_prompt=" (EXPERIMENTAL)"
yann@1535
   100
            deps="    depends on EXPERIMENTAL"
yann@1173
   101
            ;;
yann@1536
   102
        *)  exp_obs_prompt=" (EXPERIMENTAL, OBSOLETE)"
yann@1535
   103
            deps="    depends on EXPERIMENTAL \\&\\& OBSOLETE"
yann@1173
   104
            ;;
yann@1173
   105
    esac
yann@1173
   106
    [ -n "${exp_obs_prompt}" ] && SedExpr1="${SedExpr1}${exp_obs_prompt}"
yann@1535
   107
    SedExpr1="${SedExpr1}\""
yann@1535
   108
    [ -n "${deps}" ] && SedExpr1="${SedExpr1}\n${deps}"
yann@1692
   109
    case "${tool}" in
yann@1692
   110
        gcc)
yann@1692
   111
            # Extract 'M'ajor and 'm'inor from version string
benoit@2485
   112
            ver_M=$(getVersionField "${version}" . 1)
benoit@2485
   113
            ver_m=$(getVersionField "${version}" . 2)
yann@2441
   114
            if [   \( ${ver_M} -eq 4 -a ${ver_m} -eq 6 \)  ]; then
yann@2441
   115
                SedExpr1="${SedExpr1}\n    select CC_GCC_4_6"
yann@2441
   116
            elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 5 \)  ]; then
yann@2441
   117
                SedExpr1="${SedExpr1}\n    select CC_GCC_4_5"
yann@2441
   118
            elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 4 \)  ]; then
yann@2441
   119
                SedExpr1="${SedExpr1}\n    select CC_GCC_4_4"
yann@2441
   120
            elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 3 \)  ]; then
yann@2441
   121
                SedExpr1="${SedExpr1}\n    select CC_GCC_4_3"
yann@2441
   122
            elif [ \( ${ver_M} -eq 4 -a ${ver_m} -eq 2 \)  ]; then
yann@2441
   123
                SedExpr1="${SedExpr1}\n    select CC_GCC_4_2"
yann@1692
   124
            fi
yann@1692
   125
            ;;
benoit@2488
   126
        binutils)
benoit@2488
   127
            # Extract 'M'ajor and 'm'inor from version string
benoit@2488
   128
            ver_M=$(getVersionField "${version}" . 1)
benoit@2488
   129
            ver_m=$(getVersionField "${version}" . 2)
titus@2797
   130
            if [   \( ${ver_M} -eq 2 -a ${ver_m} -eq 22 \)  ]; then
titus@2797
   131
                SedExpr1="${SedExpr1}\n    select BINUTILS_2_22_or_later"
titus@2797
   132
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 21 \)  ]; then
benoit@2488
   133
                SedExpr1="${SedExpr1}\n    select BINUTILS_2_21_or_later"
benoit@2488
   134
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 20 \)  ]; then
benoit@2488
   135
                SedExpr1="${SedExpr1}\n    select BINUTILS_2_20_or_later"
benoit@2488
   136
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 19 \)  ]; then
benoit@2488
   137
                SedExpr1="${SedExpr1}\n    select BINUTILS_2_19_or_later"
benoit@2488
   138
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 18 \)  ]; then
benoit@2488
   139
                SedExpr1="${SedExpr1}\n    select BINUTILS_2_18_or_later"
benoit@2488
   140
            fi
benoit@2488
   141
            ;;
benoit@2489
   142
        eglibc)
benoit@2489
   143
            # Extract 'M'ajor and 'm'inor from version string
benoit@2489
   144
            ver_M=$(getVersionField "${version}" . 1)
benoit@2489
   145
            ver_m=$(getVersionField "${version}" . 2)
benoit@2489
   146
            if [   \( ${ver_M} -eq 2 -a ${ver_m} -eq 13 \)  ]; then
benoit@2489
   147
                SedExpr1="${SedExpr1}\n    select LIBC_EGLIBC_2_13_or_later"
benoit@2489
   148
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 12 \)  ]; then
benoit@2489
   149
                SedExpr1="${SedExpr1}\n    select LIBC_EGLIBC_2_12_or_later"
benoit@2489
   150
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 11 \)  ]; then
benoit@2489
   151
                SedExpr1="${SedExpr1}\n    select LIBC_EGLIBC_2_11_or_later"
benoit@2489
   152
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 10 \)  ]; then
benoit@2489
   153
                SedExpr1="${SedExpr1}\n    select LIBC_EGLIBC_2_10_or_later"
benoit@2489
   154
            elif [ \( ${ver_M} -eq 2 -a ${ver_m} -eq 9 \)  ]; then
benoit@2489
   155
                SedExpr1="${SedExpr1}\n    select LIBC_EGLIBC_2_9_or_later"
benoit@2489
   156
            fi
benoit@2489
   157
            ;;
yann@1734
   158
        uClibc)
yann@1734
   159
            # uClibc-0.9.30 and above need some love
benoit@2485
   160
            ver_M=$(getVersionField "${version}" . 1)
benoit@2485
   161
            ver_m=$(getVersionField "${version}" . 2)
benoit@2485
   162
            ver_p=$(getVersionField "${version}" . 3)
yann@2666
   163
            if [    ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 30 \
yann@2666
   164
                 -o ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 31 ]; then
yann@1734
   165
                SedExpr1="${SedExpr1}\n    select LIBC_UCLIBC_0_9_30_or_later"
yann@2666
   166
            elif [  ${ver_M} -eq 0 -a ${ver_m} -eq 9 -a ${ver_p} -eq 32 ]; then
yann@2666
   167
                SedExpr1="${SedExpr1}\n    select LIBC_UCLIBC_0_9_32_or_later"
yann@1734
   168
            fi
yann@1734
   169
            ;;
yann@1852
   170
        gdb)
yann@1852
   171
            # gdb-7.0 and above have special handling
benoit@2485
   172
            ver_M=$(getVersionField "${version}" . 1)
yann@1852
   173
            if [ ${ver_M} -ge 7 ]; then
yann@1852
   174
                SedExpr1="${SedExpr1}\n    select GDB_7_0_or_later"
yann@1852
   175
            fi
yann@1852
   176
            ;;
yann@1692
   177
    esac
yann@1721
   178
    SedExpr2="    default \"${version}\" if ${config_ver_option}"
yann@1542
   179
    "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_BELOW)$/\1\n\n'"${SedExpr1}"'/;' "${file}"
yann@1535
   180
    "${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_STRING_BELOW)$/\1\n'"${SedExpr2}"'/;' "${file}"
yann@1173
   181
}
yann@1173
   182
yann@96
   183
cat=
yann@1
   184
tool=
yann@1
   185
tool_prefix=
yann@1
   186
VERSION=
yann@43
   187
EXP=
yann@96
   188
OBS=
yann@1
   189
yann@1173
   190
if [ $# -eq 0 ]; then
yann@1173
   191
    doHelp
yann@1173
   192
    exit 1
yann@1173
   193
fi
yann@1173
   194
yann@1173
   195
while [ $# -gt 0 ]; do
yann@1173
   196
    case "$1" in
yann@96
   197
        # Tools:
yann@1722
   198
        --gcc)      EXP=; OBS=; cat=CC;             tool=gcc;       tool_prefix=cc;;
yann@1722
   199
        --binutils) EXP=; OBS=; cat=BINUTILS;       tool=binutils;  tool_prefix=binutils;;
yann@1722
   200
        --glibc)    EXP=; OBS=; cat=LIBC_GLIBC;     tool=glibc;     tool_prefix=libc;;
yann@1722
   201
        --eglibc)   EXP=; OBS=; cat=LIBC_EGLIBC;    tool=eglibc;    tool_prefix=libc;;
yann@1722
   202
        --uClibc)   EXP=; OBS=; cat=LIBC_UCLIBC;    tool=uClibc;    tool_prefix=libc;;
yann@1723
   203
        --newlib)   EXP=; OBS=; cat=LIBC_NEWLIB;    tool=newlib;    tool_prefix=libc;;
yann@1722
   204
        --linux)    EXP=; OBS=; cat=KERNEL;         tool=linux;     tool_prefix=kernel;;
yann@1722
   205
        --gdb)      EXP=; OBS=; cat=GDB;            tool=gdb;       tool_prefix=debug;;
yann@1722
   206
        --dmalloc)  EXP=; OBS=; cat=DMALLOC;        tool=dmalloc;   tool_prefix=debug;;
yann@1722
   207
        --duma)     EXP=; OBS=; cat=DUMA;           tool=duma;      tool_prefix=debug;;
yann@1722
   208
        --strace)   EXP=; OBS=; cat=STRACE;         tool=strace;    tool_prefix=debug;;
yann@1722
   209
        --ltrace)   EXP=; OBS=; cat=LTRACE;         tool=ltrace;    tool_prefix=debug;;
yann@1722
   210
        --gmp)      EXP=; OBS=; cat=GMP;            tool=gmp;       tool_prefix=companion_libs;;
yann@1722
   211
        --mpfr)     EXP=; OBS=; cat=MPFR;           tool=mpfr;      tool_prefix=companion_libs;;
yann@1722
   212
        --ppl)      EXP=; OBS=; cat=PPL;            tool=ppl;       tool_prefix=companion_libs;;
yann@1722
   213
        --cloog)    EXP=; OBS=; cat=CLOOG;          tool=cloog;     tool_prefix=companion_libs;;
yann@1722
   214
        --mpc)      EXP=; OBS=; cat=MPC;            tool=mpc;       tool_prefix=companion_libs;;
yann@1872
   215
        --libelf)   EXP=; OBS=; cat=LIBELF;         tool=libelf;    tool_prefix=companion_libs;;
yann@1173
   216
yann@96
   217
        # Tools options:
yann@1173
   218
        -x|--experimental|+s)   EXP=1;;
yann@1173
   219
        -s|--stable|+x)         EXP=;;
yann@1173
   220
        -o|--obsolete|+c)       OBS=1;;
yann@1173
   221
        -c|--current|+o)        OBS=;;
yann@1173
   222
yann@96
   223
        # Misc:
yann@1173
   224
        -h|--help)  doHelp; exit 0;;
yann@1173
   225
        -*)         echo "Unknown option: '$1' (use -h/--help for help)."; exit 1;;
yann@1173
   226
yann@1173
   227
        # Version string:
yann@1173
   228
        *)  [ -n "${tool}" ] || { doHelp; exit 1; }
yann@2412
   229
            file_base="config/${tool_prefix}/${tool}.in"
yann@2412
   230
            # Components have their version selection either
yann@2412
   231
            # in the .in or the .in.2 file. Handle both.
yann@2412
   232
            addToolVersion "$1" "${file_base}"
yann@2412
   233
            addToolVersion "$1" "${file_base}.2"
yann@1173
   234
            ;;
yann@1
   235
    esac
yann@1173
   236
    shift
yann@1
   237
done