tools/addToolVersion.sh
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue May 01 16:49:15 2007 +0000 (2007-05-01)
changeset 56 07a6a48962b7
parent 10 94a0eae9fe9f
child 96 aa1a9fbd6eb8
permissions -rwxr-xr-x
Merge patches sent by Robert P. J. Day <rpjday@mindspring.com>.
Warning: the buildroot folks purposedly removed the skip-comment patch but didn't really said why. Keeping it for the sake of having it in svn just in case (removing it will be easier thant not having it at all).
     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   Options:
    13     --experimental, -x
    14       mark the version as being experimental
    15 
    16   Valid mandatory 'option' for tool==gcc is one of:
    17     --core, --final
    18 
    19   Valid mandatory 'option' for tool==linux is one of:
    20     --install, --sanitised, --copy
    21 
    22   'version' is a valid version for the specified tool.
    23 
    24   Examples:
    25     add version 2.6.19.2 to linux kernel install method:
    26       ${myname} --linux --install 2.6.19.2
    27 
    28     add versions 2.3.5 and 2.3.6 to glibc:
    29       ${myname} --glibc 2.3.5 2.3.6
    30 EOF
    31 }
    32 
    33 tool=
    34 tool_prefix=
    35 CORE=
    36 FINAL=
    37 VERSION=
    38 EXP=
    39 
    40 i=1
    41 while [ $i -le $# ]; do
    42     case "${!i}" in
    43         --gcc)              cat=CC;        tool=gcc;      tool_prefix=cc_;      tool_suffix=;;
    44 #        --tcc)              cat=CC;        tool=tcc;      tool_prefix=cc_;      tool_suffix=;;
    45         --binutils)         cat=BINUTILS;  tool=binutils; tool_prefix=;         tool_suffix=;;
    46         --glibc)            cat=LIBC;      tool=glibc;    tool_prefix=libc_;    tool_suffix=;;
    47         --uClibc)           cat=LIBC;      tool=uClibc;   tool_prefix=libc_;    tool_suffix=;;
    48         --linux)            cat=KERNEL;    tool=linux;    tool_prefix=kernel_;;
    49 #        --cygwin)           cat=KERNEL;    tool=cygwin;   tool_prefix=kernel_;;
    50         --core)             CORE=1;;
    51         --final)            FINAL=1;;
    52         --install)          tool_suffix=install;;
    53         --sanitised)        tool_suffix=sanitised;;
    54         --copy)             tool_suffix=copy;;
    55         -x|--experimental)  EXP=1;;
    56         -h|--help)          doHelp; exit 0;;
    57         -*)             echo "Unknown option: \"${!i}\". (use -h/--help for help"; exit 1;;
    58         *)              VERSION="${VERSION} ${!i}";;
    59     esac
    60     i=$((i+1))
    61 done
    62 
    63 [ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
    64 
    65 case "${cat}" in
    66     CC)     [ -z "${CORE}" -a -z "${FINAL}" ] && { doHelp; exit 1; };;
    67     KERNEL) unset FINAL CORE
    68             [ -z "${tool_suffix}" ] && { doHelp; exit 1; }
    69             ;;
    70     *)      FINAL=1; CORE=;;
    71 esac
    72 
    73 for ver in ${VERSION}; do
    74     unset DEP L1 L2 L3 L4 L5 FILE
    75 	v=`echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;'`
    76     if [ -n "${CORE}" ]; then
    77         L1="config ${cat}_CORE_V_${v}\n"
    78         L2="    bool\n"
    79         L3="    prompt \"${ver}\"\n"
    80         L5="    default \"${ver}\" if ${cat}_CORE_V_${v}"
    81         FILE="config/${tool_prefix}core_${tool}.in"
    82     fi
    83     if [ -n "${FINAL}" ]; then
    84         L1="config ${cat}_V_${v}\n"
    85         L2="    bool\n"
    86         L3="    prompt \"${ver}\"\n"
    87         L5="    default \"${ver}\" if ${cat}_V_${v}"
    88         FILE="config/${tool_prefix}${tool}.in"
    89     fi
    90     if [ "${cat}" = "KERNEL" ]; then
    91         TOOL_SUFFIX="`echo \"${tool_suffix}\" |tr [[:lower:]] [[:upper:]]`"
    92         L1="config ${cat}_${TOOL_SUFFIX}_V_${v}\n"
    93         L2="    bool\n"
    94         L3="    prompt \"${ver}\"\n"
    95         # Extra versions are not necessary visible:
    96         case "${tool_suffix},${ver}" in
    97             sanitised,*)    ;; # Sanitised headers always have an extra version
    98             *,*.*.*.*)      DEP="${DEP} && KERNEL_VERSION_SEE_EXTRAVERSION";;
    99         esac
   100         L5="    default \"${ver}\" if ${cat}_${TOOL_SUFFIX}_V_${v}"
   101         FILE="config/${tool_prefix}${tool}_headers_${tool_suffix}.in"
   102     fi
   103     [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
   104     case "${DEP}" in
   105         "") ;;
   106         *)  L4="    depends on `echo \"${DEP}\" |sed -r -e 's/^ \\&\\& //; s/\\&/\\\\&/g;'`\n"
   107     esac
   108     sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}"'\n\1/;
   109                   s/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L5}"'\n\1/;' "${FILE}"
   110 done