tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed May 21 22:00:52 2008 +0000 (2008-05-21)
changeset 527 4ac12179ef23
parent 473 731718e6ffdc
child 545 a7782f2c0926
permissions -rwxr-xr-x
Introduce target-specific LDFLAGS, the same way we have CFLAGS for the target.
It seems to be helping gcc somewhat into telling the correct endianness to ld that sticks with little endian even when the target is big (eg armeb-unknown-linux-uclibcgnueabi).
There's still work to do, especially finish the gcc part that is not in this commit.

/trunk/scripts/functions | 9 7 2 0 +++++++--
1 file changed, 7 insertions(+), 2 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, --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   Valid mandatory 'option' for tool==linux is one and only one of:
    22     --install, --sanitised, --copy
    23 
    24   'version' is a valid version for the specified tool.
    25 
    26   Examples:
    27     add version 2.6.19.2 to linux kernel install method:
    28       ${myname} --linux --install 2.6.19.2
    29 
    30     add versions 2.3.5 and 2.3.6 to glibc:
    31       ${myname} --glibc 2.3.5 2.3.6
    32 EOF
    33 }
    34 
    35 cat=
    36 tool=
    37 tool_prefix=
    38 tool_suffix=
    39 VERSION=
    40 EXP=
    41 OBS=
    42 prompt_suffix=
    43 
    44 i=1
    45 while [ $i -le $# ]; do
    46     case "${!i}" in
    47         # Tools:
    48         --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc;      tool_suffix=;;
    49         --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;        tool_suffix=;;
    50         --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc;    tool_suffix=;;
    51         --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc;    tool_suffix=;;
    52         --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel;  tool_suffix=;;
    53         --gdb)              cat=GDB;       tool=gdb;      tool_prefix=debug    tool_suffix=;;
    54         --dmalloc)          cat=DMALLOC;   tool=dmalloc;  tool_prefix=debug    tool_suffix=;;
    55         --duma)             cat=DUMA;      tool=duma;     tool_prefix=debug    tool_suffix=;;
    56         --strace)           cat=STRACE;    tool=strace;   tool_prefix=debug    tool_suffix=;;
    57         --ltrace)           cat=LTRACE;    tool=ltrace;   tool_prefix=debug    tool_suffix=;;
    58         --libelf)           cat=LIBELF;    tool=libelf;   tool_prefix=tools    tool_suffix=;;
    59         --gmp)              cat=GMP;       tool=gmp;      tool_prefix=cc;      tool_suffix=;;
    60         --mpfr)             cat=MPFR;      tool=mpfr;     tool_prefix=cc;      tool_suffix=;;
    61         # Tools options:
    62         -x|--experimental)  EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
    63         -o|--obsolete)      OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
    64         --install)          tool_suffix=install;;
    65         --sanitised)        tool_suffix=sanitised;;
    66         --copy)             tool_suffix=copy;;
    67         # Misc:
    68         -h|--help)          doHelp; exit 0;;
    69         -*)                 echo "Unknown option: '${!i}' (use -h/--help for help)."; exit 1;;
    70         *)                  VERSION="${VERSION} ${!i}";;
    71     esac
    72     i=$((i+1))
    73 done
    74 
    75 [ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
    76 
    77 case "${cat}" in
    78     KERNEL) [ -z "${tool_suffix}" ] && { doHelp; exit 1; } ;;
    79     *)      ;;
    80 esac
    81 
    82 for ver in ${VERSION}; do
    83     unset DEP L1 L2 L3 L4 L5 FILE
    84     v=$(echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;')
    85     if [ "${cat}" = "KERNEL" ]; then
    86         TOOL_SUFFIX=$(echo "${tool_suffix}" |tr [[:lower:]] [[:upper:]])
    87         L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
    88         L2="    bool\n"
    89         L3="    prompt \"${ver}${prompt_suffix}\"\n"
    90         # Extra versions are not necessary visible:
    91         case "${tool_suffix},${ver}" in
    92             sanitised,*)    ;; # Sanitised headers always have an extra version
    93             *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
    94         esac
    95         L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
    96         FILE="config/${tool_prefix}/${tool}_headers_${tool_suffix}.in"
    97     else
    98         L1="config ${cat}_V_${v}\n"
    99         L2="    bool\n"
   100         L3="    prompt \"${ver}${prompt_suffix}\"\n"
   101         L5="    default \"${ver}\" if ${cat}_V_${v}"
   102         FILE="config/${tool_prefix}/${tool}.in"
   103     fi
   104     [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
   105     [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
   106     case "${DEP}" in
   107         "") ;;
   108         *)  L4="    depends on "$(echo "${DEP}" |sed -r -e 's/^ \\&\\& //; s/\\&/\\\\&/g;')"\n"
   109     esac
   110     sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
   111                   s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' "${FILE}"
   112 done