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