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... :-(
     1 #!/bin/sh
     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, --tcc, --binutils, --glibc, --uClibc, --linux, --cygwin
    11 
    12   Valid mandatory 'option' for tool==gcc is one of:
    13     --core, --final
    14 
    15   Valid mandatory 'option' for tool==linux is one of:
    16     --install, --sanitised, --copy
    17 
    18   'version' is a valid version for the specified tool.
    19 
    20   Examples:
    21     add version 2.6.19.2 to linux kernel install method:
    22       ${myname} --linux --install 2.6.19.2
    23 
    24     add versions 2.3.5 and 2.3.6 to glibc:
    25       ${myname} --glibc 2.3.5 2.3.6
    26 EOF
    27 }
    28 
    29 tool=
    30 tool_prefix=
    31 CORE=
    32 FINAL=
    33 VERSION=
    34 
    35 i=1
    36 while [ $i -le $# ]; do
    37     case "${!i}" in
    38         --gcc)          cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
    39 #        --tcc)          cat=CC;        tool=tcc;      tool_prefix=cc_;      tool_suffix=;;
    40         --binutils)     cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
    41         --glibc)        cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
    42         --uClibc)       cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
    43         --linux)        cat=KERNEL;    tool=linux;    tool_prefix=kernel_;;
    44 #        --cygwin)       cat=KERNEL;    tool=cygwin;   tool_prefix=kernel_;;
    45         --core)         CORE=1;;
    46         --final)        FINAL=1;;
    47         --install)      tool_suffix=install;;
    48         --sanitised)    tool_suffix=sanitised;;
    49         --copy)         tool_suffix=copy;;
    50         -h|--help)      doHelp; exit 0;;
    51         -*)             echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
    52         *)              VERSION="${VERSION} ${!i}";;
    53     esac
    54     i=$((i+1))
    55 done
    56 
    57 [ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
    58 
    59 case "${cat}" in
    60     CC)     ;;
    61     KERNEL) FINAL=; CORE=;;
    62     *)      FINAL=1; CORE=;;
    63 esac
    64 
    65 for ver in ${VERSION}; do
    66 	v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
    67     if [ -n "${CORE}" ]; then
    68         L1="config ${cat}_CORE_V_${v}\n"
    69         L2="    bool\n"
    70         L3="    prompt \"${ver}\"\n"
    71         L4="    default \"${ver}\" if ${cat}_CORE_V_${v}"
    72         sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
    73                       s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}core_${tool}.in
    74     fi
    75     if [ -n "${FINAL}" ]; then
    76         L1="config ${cat}_V_${v}\n"
    77         L2="    bool\n"
    78         L3="    prompt \"${ver}\"\n"
    79         L4="    default \"${ver}\" if ${cat}_V_${v}"
    80         sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
    81                       s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}${tool}.in
    82     fi
    83     if [ "${cat}" = "KERNEL" ]; then
    84         TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
    85         L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
    86         L2="    bool\n"
    87         L3="    prompt \"${ver}\"\n"
    88         # Extra versions are not necessary visible:
    89         case "${ver}" in
    90             *.*.*.*) L4="    depends on KERNEL_VERSION_SEE_EXTRAVERSION\n";;
    91             *)       L4=;;
    92         esac
    93         # Sanitised headers always have an extra version:
    94         [ "${tool_suffix}" = "sanitised" ] && L4=
    95         L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
    96         sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
    97                       s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' config/${tool_prefix}${tool}_headers_${tool_suffix}.in
    98     fi
    99 done