1.1 --- a/scripts/addToolVersion.sh Wed Jan 28 22:36:44 2009 +0000
1.2 +++ b/scripts/addToolVersion.sh Thu Jan 29 18:48:05 2009 +0000
1.3 @@ -1,93 +1,136 @@
1.4 -#!/bin/bash
1.5 +#!/bin/sh
1.6
1.7 # Adds a new version to one of the toolchain component
1.8 myname="$0"
1.9
1.10 doHelp() {
1.11 cat <<-EOF
1.12 -Usage: ${myname} <tool> [option] <version>
1.13 +Usage: ${myname} <tool> <[options] version [...]> ...
1.14 'tool' in one of:
1.15 --gcc, --binutils, --glibc, --eglibc, --uClibc, --linux,
1.16 --gdb, --dmalloc, --duma, --strace, --ltrace, --libelf
1.17 --gmp, --mpfr
1.18
1.19 Valid options for all tools:
1.20 - --experimental, -x
1.21 - mark the version as being experimental
1.22 + --stable, -s, +x (default)
1.23 + mark the version as being stable (as opposed to experimental)
1.24
1.25 - --obsolete, -o
1.26 - mark the version as being obsolete
1.27 + --experimental, -x, +s
1.28 + mark the version as being experimental (as opposed to stable)
1.29 +
1.30 + --current, -c, +o (default)
1.31 + mark the version as being cuurent (as opposed to obsolete)
1.32 +
1.33 + --obsolete, -o, +c
1.34 + mark the version as being obsolete (as opposed to current)
1.35 +
1.36 + Note: setting a new tool resets to the defaults: 'stable' and 'current'.
1.37
1.38 'version' is a valid version for the specified tool.
1.39
1.40 Examples:
1.41 - add version 2.6.19.2 to linux kernel:
1.42 + add stable current version 2.6.19.2 to linux kernel:
1.43 ${myname} --linux 2.6.19.2
1.44
1.45 - add experimental versions 2.3.5 and 2.3.6 to glibc:
1.46 - ${myname} --glibc -x 2.3.5 2.3.6
1.47 + add experimental obsolete version 2.3.5 and stable current versions 2.6.1
1.48 + and 2.6.2 to glibc, add stable obsolete version 3.3.3 to gcc:
1.49 + ${myname} --glibc -x -o 2.3.5 -s -c 2.6.1 2.6.2 --gcc -o 3.3.3
1.50 EOF
1.51 }
1.52
1.53 +# Effectively add a version to the specified tool
1.54 +# $cat : tool category
1.55 +# $tool : tool name
1.56 +# $tool_prefix : tool directory prefix
1.57 +# $EXP : set to non empty if experimental, to empty otherwise
1.58 +# #OBS : set to non empty if obsolete, to empty otherwise
1.59 +# $1 : version string to add
1.60 +addToolVersion() {
1.61 + local version="$1"
1.62 + local file
1.63 + local exp_obs_prompt
1.64 + local deps v ver_M ver_m
1.65 + local SedExpr1 SedExpr2
1.66 +
1.67 + file="config/${tool_prefix}/${tool}.in"
1.68 + v=$(echo "${version}" |sed -r -e 's/-/_/g; s/\./_/g;')
1.69 +
1.70 + SedExpr1="${SedExpr1}config ${cat}_V_${v}\n"
1.71 + SedExpr1="${SedExpr1} bool\n"
1.72 + SedExpr1="${SedExpr1} prompt \"${version}"
1.73 + case "${EXP},${OBS}" in
1.74 + ,) ;;
1.75 + ,*) exp_obs_prompt=" (OBSOLETE)"
1.76 + deps=" depends on OBSOLETE\n"
1.77 + ;;
1.78 + *,) exp_obs_prompt=" (EXPERIMENTAL)"
1.79 + deps=" depends on EXPERIMENTAL\n"
1.80 + ;;
1.81 + *) exp_obs_prompt=" (EXPERIMENTAL, OBSOLETE)"
1.82 + deps=" depends on EXPERIMENTAL && OBSOLETE\n"
1.83 + ;;
1.84 + esac
1.85 + [ -n "${exp_obs_prompt}" ] && SedExpr1="${SedExpr1}${exp_obs_prompt}"
1.86 + SedExpr1="${SedExpr1}\"\n"
1.87 + [ -n "${deps}" ] && SedExpr1="${SedExpr1}${deps}"
1.88 + if [ "${tool}" = "gcc" ]; then
1.89 + # Extract 'M'ajor and 'm'inor from version string
1.90 + ver_M=$(echo "${version}...." |cut -d . -f 1)
1.91 + ver_m=$(echo "${version}...." |cut -d . -f 2)
1.92 + if [ ${ver_M} -gt 4 \
1.93 + -o \( ${ver_M} -eq 4 -a ${ver_m} -ge 3 \) ]; then
1.94 + SedExpr1=" select CC_GCC_4_3_or_later\n"
1.95 + fi
1.96 + fi
1.97 + SedExpr2=" default \"${version}\" if ${cat}_V_${v}"
1.98 + sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${SedExpr1}"'\n\1/;' "${file}"
1.99 + sed -r -i -e 's/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${SedExpr2}"'\n\1/;' "${file}"
1.100 +}
1.101 +
1.102 cat=
1.103 tool=
1.104 tool_prefix=
1.105 VERSION=
1.106 EXP=
1.107 OBS=
1.108 -prompt_suffix=
1.109
1.110 -i=1
1.111 -while [ $i -le $# ]; do
1.112 - case "${!i}" in
1.113 +if [ $# -eq 0 ]; then
1.114 + doHelp
1.115 + exit 1
1.116 +fi
1.117 +
1.118 +while [ $# -gt 0 ]; do
1.119 + case "$1" in
1.120 # Tools:
1.121 - --gcc) cat=CC; tool=gcc; tool_prefix=cc;;
1.122 - --binutils) cat=BINUTILS; tool=binutils; tool_prefix=;;
1.123 - --glibc) cat=LIBC; tool=glibc; tool_prefix=libc;;
1.124 - --eglibc) cat=LIBC; tool=eglibc; tool_prefix=libc;;
1.125 - --uClibc) cat=LIBC; tool=uClibc; tool_prefix=libc;;
1.126 - --linux) cat=KERNEL; tool=linux; tool_prefix=kernel;;
1.127 - --gdb) cat=GDB; tool=gdb; tool_prefix=debug;;
1.128 - --dmalloc) cat=DMALLOC; tool=dmalloc; tool_prefix=debug;;
1.129 - --duma) cat=DUMA; tool=duma; tool_prefix=debug;;
1.130 - --strace) cat=STRACE; tool=strace; tool_prefix=debug;;
1.131 - --ltrace) cat=LTRACE; tool=ltrace; tool_prefix=debug;;
1.132 - --libelf) cat=LIBELF; tool=libelf; tool_prefix=tools;;
1.133 - --gmp) cat=GMP; tool=gmp; tool_prefix=gmp_mpfr;;
1.134 - --mpfr) cat=MPFR; tool=mpfr; tool_prefix=gmp_mpfr;;
1.135 + --gcc) EXP=; OBS=; cat=CC; tool=gcc; tool_prefix=cc;;
1.136 + --binutils) EXP=; OBS=; cat=BINUTILS; tool=binutils; tool_prefix=;;
1.137 + --glibc) EXP=; OBS=; cat=LIBC; tool=glibc; tool_prefix=libc;;
1.138 + --eglibc) EXP=; OBS=; cat=LIBC; tool=eglibc; tool_prefix=libc;;
1.139 + --uClibc) EXP=; OBS=; cat=LIBC; tool=uClibc; tool_prefix=libc;;
1.140 + --linux) EXP=; OBS=; cat=KERNEL; tool=linux; tool_prefix=kernel;;
1.141 + --gdb) EXP=; OBS=; cat=GDB; tool=gdb; tool_prefix=debug;;
1.142 + --dmalloc) EXP=; OBS=; cat=DMALLOC; tool=dmalloc; tool_prefix=debug;;
1.143 + --duma) EXP=; OBS=; cat=DUMA; tool=duma; tool_prefix=debug;;
1.144 + --strace) EXP=; OBS=; cat=STRACE; tool=strace; tool_prefix=debug;;
1.145 + --ltrace) EXP=; OBS=; cat=LTRACE; tool=ltrace; tool_prefix=debug;;
1.146 + --libelf) EXP=; OBS=; cat=LIBELF; tool=libelf; tool_prefix=tools;;
1.147 + --gmp) EXP=; OBS=; cat=GMP; tool=gmp; tool_prefix=gmp_mpfr;;
1.148 + --mpfr) EXP=; OBS=; cat=MPFR; tool=mpfr; tool_prefix=gmp_mpfr;;
1.149 +
1.150 # Tools options:
1.151 - -x|--experimental) EXP=1; OBS=; prompt_suffix=" (EXPERIMENTAL)";;
1.152 - -o|--obsolete) OBS=1; EXP=; prompt_suffix=" (OBSOLETE)";;
1.153 + -x|--experimental|+s) EXP=1;;
1.154 + -s|--stable|+x) EXP=;;
1.155 + -o|--obsolete|+c) OBS=1;;
1.156 + -c|--current|+o) OBS=;;
1.157 +
1.158 # Misc:
1.159 - -h|--help) doHelp; exit 0;;
1.160 - -*) echo "Unknown option: '${!i}' (use -h/--help for help)."; exit 1;;
1.161 - *) VERSION="${VERSION} ${!i}";;
1.162 + -h|--help) doHelp; exit 0;;
1.163 + -*) echo "Unknown option: '$1' (use -h/--help for help)."; exit 1;;
1.164 +
1.165 + # Version string:
1.166 + *) [ -n "${tool}" ] || { doHelp; exit 1; }
1.167 + addToolVersion "$1"
1.168 + ;;
1.169 esac
1.170 - i=$((i+1))
1.171 + shift
1.172 done
1.173 -
1.174 -[ -n "${tool}" -o -n "${VERSION}" ] || { doHelp; exit 1; }
1.175 -
1.176 -for ver in ${VERSION}; do
1.177 - unset DEP L1 L2 L3 L4 L5 L6 FILE v ver_M ver_m
1.178 - FILE="config/${tool_prefix}/${tool}.in"
1.179 - v=$(echo "${ver}" |sed -r -e 's/-/_/g; s/\./_/g;')
1.180 - L1="config ${cat}_V_${v}\n"
1.181 - L2=" bool\n"
1.182 - L3=" prompt \"${ver}${prompt_suffix}\"\n"
1.183 - [ -n "${EXP}" ] && DEP="${DEP} && EXPERIMENTAL"
1.184 - [ -n "${OBS}" ] && DEP="${DEP} && OBSOLETE"
1.185 - [ -n "${DEP}" ] && L4=" depends on "$(echo "${DEP}" |sed -r -e 's/^ \&\& //; s/\&/\\&/g;')"\n"
1.186 - if [ "${tool}" = "gcc" ]; then
1.187 - # Extract 'M'ajor and 'm'inor from version string
1.188 - ver_M=$(echo "${ver}...." |cut -d . -f 1)
1.189 - ver_m=$(echo "${ver}...." |cut -d . -f 2)
1.190 - if [ ${ver_M} -gt 4 -o \( ${ver_M} -eq 4 -a ${ver_m} -ge 3 \) ]; then
1.191 - L5=" select CC_GCC_4_3_or_later\n"
1.192 - fi
1.193 - fi
1.194 - L6=" default \"${ver}\" if ${cat}_V_${v}"
1.195 - sed -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${L1}${L2}${L3}${L4}${L5}"'\n\1/;' \
1.196 - -e 's/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${L6}"'\n\1/;' \
1.197 - "${FILE}"
1.198 -done