tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Mar 11 09:46:22 2007 +0000 (2007-03-11)
changeset 17 1cc9524bf15a
parent 1 eeea35fbf182
child 43 f3b4bb1e501b
permissions -rwxr-xr-x
Rename directory "licenses" to "licenses.d" for those filesystems unable to handle lower/upper case.
Update COPYING accordingly.
     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)     [ -z "${CORE}" -a -z "${FINAL}" ] && { doHelp; exit 1; };;
    61     KERNEL) unset FINAL CORE
    62             [ -z "${tool_suffix}" ] && { doHelp; exit 1; }
    63             ;;
    64     *)      FINAL=1; CORE=;;
    65 esac
    66 
    67 for ver in ${VERSION}; do
    68 	v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
    69     if [ -n "${CORE}" ]; then
    70         L1="config ${cat}_CORE_V_${v}\n"
    71         L2="    bool\n"
    72         L3="    prompt \"${ver}\"\n"
    73         L4="    default \"${ver}\" if ${cat}_CORE_V_${v}"
    74         sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
    75                       s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}core_${tool}.in
    76     fi
    77     if [ -n "${FINAL}" ]; then
    78         L1="config ${cat}_V_${v}\n"
    79         L2="    bool\n"
    80         L3="    prompt \"${ver}\"\n"
    81         L4="    default \"${ver}\" if ${cat}_V_${v}"
    82         sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}"'\n\1/;
    83                       s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L4}"'\n\1/;' config/${tool_prefix}${tool}.in
    84     fi
    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}\"\n"
    90         # Extra versions are not necessary visible:
    91         case "${ver}" in
    92             *.*.*.*) L4="    depends on KERNEL_VERSION_SEE_EXTRAVERSION\n";;
    93             *)       L4=;;
    94         esac
    95         # Sanitised headers always have an extra version:
    96         [ "${tool_suffix}" = "sanitised" ] && L4=
    97         L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
    98         sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
    99                       s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' config/${tool_prefix}${tool}_headers_${tool_suffix}.in
   100     fi
   101 done