tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed Sep 12 17:35:07 2007 +0000 (2007-09-12)
changeset 375 4beb099d5aa4
parent 322 3f14c769a4dc
child 422 dcc13bf07ba6
permissions -rwxr-xr-x
Don't use /bin/sh for crosstool-NG build scripts, we want /bin/bash!
Don't hardcode ncurses include and link flags.
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@1
    12
yann@96
    13
  Valid options for all tools:
yann@43
    14
    --experimental, -x
yann@43
    15
      mark the version as being experimental
yann@43
    16
yann@96
    17
    --obsolete, -o
yann@96
    18
      mark the version as being obsolete
yann@96
    19
yann@96
    20
  Valid mandatory 'option' for tool==gcc is one and only one of:
yann@1
    21
    --core, --final
yann@1
    22
yann@96
    23
  Valid mandatory 'option' for tool==linux is one and only one of:
yann@1
    24
    --install, --sanitised, --copy
yann@1
    25
yann@1
    26
  'version' is a valid version for the specified tool.
yann@1
    27
yann@1
    28
  Examples:
yann@1
    29
    add version 2.6.19.2 to linux kernel install method:
yann@1
    30
      ${myname} --linux --install 2.6.19.2
yann@1
    31
yann@1
    32
    add versions 2.3.5 and 2.3.6 to glibc:
yann@1
    33
      ${myname} --glibc 2.3.5 2.3.6
yann@1
    34
EOF
yann@1
    35
}
yann@1
    36
yann@96
    37
cat=
yann@1
    38
tool=
yann@1
    39
tool_prefix=
yann@96
    40
tool_suffix=
yann@1
    41
CORE=
yann@1
    42
FINAL=
yann@1
    43
VERSION=
yann@43
    44
EXP=
yann@96
    45
OBS=
yann@322
    46
prompt_suffix=
yann@1
    47
yann@1
    48
i=1
yann@1
    49
while [ $i -le $# ]; do
yann@1
    50
    case "${!i}" in
yann@96
    51
        # Tools:
yann@43
    52
        --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
yann@43
    53
        --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
yann@43
    54
        --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
yann@43
    55
        --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
yann@96
    56
        --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel_;  tool_suffix=;;
yann@96
    57
        --gdb)              cat=GDB;       tool=gdb;      tool_prefix=debug/    tool_suffix=;;
yann@103
    58
        --dmalloc)          cat=DMALLOC;   tool=dmalloc;  tool_prefix=debug/    tool_suffix=;;
yann@236
    59
        --duma)             cat=DUMA;      tool=duma;     tool_prefix=debug/    tool_suffix=;;
yann@239
    60
        --strace)           cat=STRACE;    tool=strace;   tool_prefix=debug/    tool_suffix=;;
yann@245
    61
        --ltrace)           cat=LTRACE;    tool=ltrace;   tool_prefix=debug/    tool_suffix=;;
yann@245
    62
        --libelf)           cat=LIBELF;    tool=libelf;   tool_prefix=tools/    tool_suffix=;;
yann@96
    63
        # Tools options:
yann@322
    64
        -x|--experimental)  EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
yann@322
    65
        -o|--obsolete)      OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
yann@96
    66
        --core)             CORE=1; FINAL=;;
yann@96
    67
        --final)            FINAL=1; CORE=;;
yann@43
    68
        --install)          tool_suffix=install;;
yann@43
    69
        --sanitised)        tool_suffix=sanitised;;
yann@43
    70
        --copy)             tool_suffix=copy;;
yann@96
    71
        # Misc:
yann@43
    72
        -h|--help)          doHelp; exit 0;;
yann@96
    73
        -*)                 echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
yann@96
    74
        *)                  VERSION="${VERSION} ${!i}";;
yann@1
    75
    esac
yann@1
    76
    i=$((i+1))
yann@1
    77
done
yann@1
    78
yann@1
    79
[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
yann@1
    80
yann@1
    81
case "${cat}" in
yann@96
    82
    CC)     [    -z "${CORE}" -a -z "${FINAL}" ] && { doHelp; exit 1; };;
yann@10
    83
    KERNEL) unset FINAL CORE
yann@10
    84
            [ -z "${tool_suffix}" ] && { doHelp; exit 1; }
yann@10
    85
            ;;
yann@96
    86
    *)      CORE=; FINAL=;;
yann@1
    87
esac
yann@1
    88
yann@96
    89
MIDDLE_V=; MIDDLE_F=
yann@96
    90
[ -n "${CORE}" ] && MIDDLE_V="_CORE" && MIDDLE_F="core_"
yann@1
    91
for ver in ${VERSION}; do
yann@43
    92
    unset DEP L1 L2 L3 L4 L5 FILE
yann@96
    93
    v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
yann@1
    94
    if [ "${cat}" = "KERNEL" ]; then
yann@1
    95
        TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
yann@1
    96
        L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
yann@1
    97
        L2="    bool\n"
yann@322
    98
        L3="    prompt \"${ver}${prompt_suffix}\"\n"
yann@1
    99
        # Extra versions are not necessary visible:
yann@43
   100
        case "${tool_suffix},${ver}" in
yann@43
   101
            sanitised,*)    ;; # Sanitised headers always have an extra version
yann@43
   102
            *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
yann@1
   103
        esac
yann@1
   104
        L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
yann@43
   105
        FILE="config/${tool_prefix}${tool}_headers_${tool_suffix}.in"
yann@96
   106
    else
yann@109
   107
        L1="config ${cat}${MIDDLE_V}_V_${v}\n"
yann@96
   108
        L2="    bool\n"
yann@322
   109
        L3="    prompt \"${ver}${prompt_suffix}\"\n"
yann@109
   110
        L5="    default \"${ver}\" if ${cat}${MIDDLE_V}_V_${v}"
yann@96
   111
        FILE="config/${tool_prefix}${MIDDLE_F}${tool}.in"
yann@1
   112
    fi
yann@43
   113
    [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
yann@96
   114
    [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
yann@43
   115
    case "${DEP}" in
yann@43
   116
        "") ;;
yann@43
   117
        *)  L4="    depends on `echo \"${DEP}\" |sed -r -e 's/^ \\&\\& //; s/\\&/\\\\&/g;'`\n"
yann@43
   118
    esac
yann@43
   119
    sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
yann@43
   120
                  s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' "${FILE}"
yann@1
   121
done