tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Sep 23 14:48:10 2008 +0000 (2008-09-23)
changeset 872 fd4bf138f08f
parent 548 3cd87bbfdf5a
permissions -rwxr-xr-x
Bart De VOS pointed out that removing absolute paths from the libc linker scripts is plainly wrong.
It dates from dawn ages of the original crosstool code, and is not well explained. At that time, binutils might not understand the sysroot stuff, and it was necessary to remove absolute paths in that case.

/trunk/scripts/build/libc/glibc.sh | 14 2 12 0 ++------------
1 file changed, 2 insertions(+), 12 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@858
    10
    --gcc, --binutils, --glibc, --eglibc, --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@1
    21
  'version' is a valid version for the specified tool.
yann@1
    22
yann@1
    23
  Examples:
yann@858
    24
    add version 2.6.19.2 to linux kernel:
yann@858
    25
      ${myname} --linux 2.6.19.2
yann@1
    26
yann@858
    27
    add experimental versions 2.3.5 and 2.3.6 to glibc:
yann@858
    28
      ${myname} --glibc -x 2.3.5 2.3.6
yann@1
    29
EOF
yann@1
    30
}
yann@1
    31
yann@96
    32
cat=
yann@1
    33
tool=
yann@1
    34
tool_prefix=
yann@1
    35
VERSION=
yann@43
    36
EXP=
yann@96
    37
OBS=
yann@322
    38
prompt_suffix=
yann@1
    39
yann@1
    40
i=1
yann@1
    41
while [ $i -le $# ]; do
yann@1
    42
    case "${!i}" in
yann@96
    43
        # Tools:
yann@858
    44
        --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc;;
yann@858
    45
        --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;;
yann@858
    46
        --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc;;
yann@858
    47
        --eglibc)           cat=LIBC;      tool=eglibc;   tool_prefix=libc;;
yann@858
    48
        --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc;;
yann@858
    49
        --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel;;
yann@858
    50
        --gdb)              cat=GDB;       tool=gdb;      tool_prefix=debug;;
yann@858
    51
        --dmalloc)          cat=DMALLOC;   tool=dmalloc;  tool_prefix=debug;;
yann@858
    52
        --duma)             cat=DUMA;      tool=duma;     tool_prefix=debug;;
yann@858
    53
        --strace)           cat=STRACE;    tool=strace;   tool_prefix=debug;;
yann@858
    54
        --ltrace)           cat=LTRACE;    tool=ltrace;   tool_prefix=debug;;
yann@858
    55
        --libelf)           cat=LIBELF;    tool=libelf;   tool_prefix=tools;;
yann@858
    56
        --gmp)              cat=GMP;       tool=gmp;      tool_prefix=gmp_mpfr;;
yann@858
    57
        --mpfr)             cat=MPFR;      tool=mpfr;     tool_prefix=gmp_mpfr;;
yann@96
    58
        # Tools options:
yann@322
    59
        -x|--experimental)  EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
yann@322
    60
        -o|--obsolete)      OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
yann@96
    61
        # Misc:
yann@43
    62
        -h|--help)          doHelp; exit 0;;
yann@523
    63
        -*)                 echo "Unknown option: '${!i}' (use -h/--help for help)."; exit 1;;
yann@96
    64
        *)                  VERSION="${VERSION} ${!i}";;
yann@1
    65
    esac
yann@1
    66
    i=$((i+1))
yann@1
    67
done
yann@1
    68
yann@1
    69
[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
yann@1
    70
yann@1
    71
for ver in ${VERSION}; do
yann@858
    72
    unset DEP L1 L2 L3 L4 L5 L6 FILE v ver_M ver_m
yann@858
    73
    FILE="config/${tool_prefix}/${tool}.in"
yann@523
    74
    v=$(echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;')
yann@858
    75
    L1="config ${cat}_V_${v}\n"
yann@858
    76
    L2="    bool\n"
yann@858
    77
    L3="    prompt \"${ver}${prompt_suffix}\"\n"
yann@43
    78
    [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
yann@96
    79
    [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
yann@858
    80
    [ -n "${DEP}" ] && L4="    depends on "$(echo "${DEP}" |sed -r -e 's/^ \&\& //; s/\&/\\&/g;')"\n"
yann@858
    81
    if [ "${tool}" = "gcc" ]; then
yann@858
    82
        # Extract 'M'ajor and 'm'inor from version string
yann@858
    83
        ver_M=$(echo "${ver}...." |cut -d . -f 1)
yann@858
    84
        ver_m=$(echo "${ver}...." |cut -d . -f 2)
yann@858
    85
        if [ ${ver_M} -gt 4 -o \( ${ver_M} -eq 4 -a ${ver_m} -ge 3 \) ]; then
yann@858
    86
            L5="    select CC_GCC_4_3_or_later\n"
yann@858
    87
        fi
yann@858
    88
    fi
yann@858
    89
    L6="    default \"${ver}\" if ${cat}_V_${v}"
yann@858
    90
    sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}${L5}"'\n\1/;'  \
yann@858
    91
              -e 's/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L6}"'\n\1/;'               \
yann@858
    92
              "${FILE}"
yann@1
    93
done