tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sat Feb 24 11:00:05 2007 +0000 (2007-02-24)
changeset 1 eeea35fbf182
child 10 94a0eae9fe9f
permissions -rwxr-xr-x
Add the full crosstool-NG sources to the new repository of its own.
You might just say: 'Yeah! crosstool-NG's got its own repo!".
Unfortunately, that's because the previous repo got damaged beyond repair and I had no backup.
That means I'm putting backups in place in the afternoon.
That also means we've lost history... :-(
yann@1
     1
#!/bin/sh
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@1
    10
    --gcc, --tcc, --binutils, --glibc, --uClibc, --linux, --cygwin
yann@1
    11
yann@1
    12
  Valid mandatory 'option' for tool==gcc is one of:
yann@1
    13
    --core, --final
yann@1
    14
yann@1
    15
  Valid mandatory 'option' for tool==linux is one of:
yann@1
    16
    --install, --sanitised, --copy
yann@1
    17
yann@1
    18
  'version' is a valid version for the specified tool.
yann@1
    19
yann@1
    20
  Examples:
yann@1
    21
    add version 2.6.19.2 to linux kernel install method:
yann@1
    22
      ${myname} --linux --install 2.6.19.2
yann@1
    23
yann@1
    24
    add versions 2.3.5 and 2.3.6 to glibc:
yann@1
    25
      ${myname} --glibc 2.3.5 2.3.6
yann@1
    26
EOF
yann@1
    27
}
yann@1
    28
yann@1
    29
tool=
yann@1
    30
tool_prefix=
yann@1
    31
CORE=
yann@1
    32
FINAL=
yann@1
    33
VERSION=
yann@1
    34
yann@1
    35
i=1
yann@1
    36
while [ $i -le $# ]; do
yann@1
    37
    case "${!i}" in
yann@1
    38
        --gcc)          cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
yann@1
    39
#        --tcc)          cat=CC;        tool=tcc;      tool_prefix=cc_;      tool_suffix=;;
yann@1
    40
        --binutils)     cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
yann@1
    41
        --glibc)        cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
yann@1
    42
        --uClibc)       cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
yann@1
    43
        --linux)        cat=KERNEL;    tool=linux;    tool_prefix=kernel_;;
yann@1
    44
#        --cygwin)       cat=KERNEL;    tool=cygwin;   tool_prefix=kernel_;;
yann@1
    45
        --core)         CORE=1;;
yann@1
    46
        --final)        FINAL=1;;
yann@1
    47
        --install)      tool_suffix=install;;
yann@1
    48
        --sanitised)    tool_suffix=sanitised;;
yann@1
    49
        --copy)         tool_suffix=copy;;
yann@1
    50
        -h|--help)      doHelp; exit 0;;
yann@1
    51
        -*)             echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
yann@1
    52
        *)              VERSION="${VERSION} ${!i}";;
yann@1
    53
    esac
yann@1
    54
    i=$((i+1))
yann@1
    55
done
yann@1
    56
yann@1
    57
[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
yann@1
    58
yann@1
    59
case "${cat}" in
yann@1
    60
    CC)     ;;
yann@1
    61
    KERNEL) FINAL=; CORE=;;
yann@1
    62
    *)      FINAL=1; CORE=;;
yann@1
    63
esac
yann@1
    64
yann@1
    65
for ver in ${VERSION}; do
yann@1
    66
	v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
yann@1
    67
    if [ -n "${CORE}" ]; then
yann@1
    68
        L1="config ${cat}_CORE_V_${v}\n"
yann@1
    69
        L2="    bool\n"
yann@1
    70
        L3="    prompt \"${ver}\"\n"
yann@1
    71
        L4="    default \"${ver}\" if ${cat}_CORE_V_${v}"
yann@1
    72
        sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
yann@1
    73
                      s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}core_${tool}.in
yann@1
    74
    fi
yann@1
    75
    if [ -n "${FINAL}" ]; then
yann@1
    76
        L1="config ${cat}_V_${v}\n"
yann@1
    77
        L2="    bool\n"
yann@1
    78
        L3="    prompt \"${ver}\"\n"
yann@1
    79
        L4="    default \"${ver}\" if ${cat}_V_${v}"
yann@1
    80
        sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
yann@1
    81
                      s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}${tool}.in
yann@1
    82
    fi
yann@1
    83
    if [ "${cat}" = "KERNEL" ]; then
yann@1
    84
        TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
yann@1
    85
        L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
yann@1
    86
        L2="    bool\n"
yann@1
    87
        L3="    prompt \"${ver}\"\n"
yann@1
    88
        # Extra versions are not necessary visible:
yann@1
    89
        case "${ver}" in
yann@1
    90
            *.*.*.*) L4="    depends on KERNEL_VERSION_SEE_EXTRAVERSION\n";;
yann@1
    91
            *)       L4=;;
yann@1
    92
        esac
yann@1
    93
        # Sanitised headers always have an extra version:
yann@1
    94
        [ "${tool_suffix}" = "sanitised" ] && L4=
yann@1
    95
        L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
yann@1
    96
        sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
yann@1
    97
                      s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' config/${tool_prefix}${tool}_headers_${tool_suffix}.in
yann@1
    98
    fi
yann@1
    99
done