2009-01-29 18:48:05 +00:00
|
|
|
#!/bin/sh
|
2009-01-29 18:53:32 +00:00
|
|
|
set -e
|
2007-02-24 11:00:05 +00:00
|
|
|
|
|
|
|
# Adds a new version to one of the toolchain component
|
|
|
|
myname="$0"
|
|
|
|
|
2009-01-29 18:53:32 +00:00
|
|
|
# Parse the tools' paths configuration
|
|
|
|
. "paths.mk"
|
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
doHelp() {
|
|
|
|
cat <<-EOF
|
2009-01-29 18:48:05 +00:00
|
|
|
Usage: ${myname} <tool> <[options] version [...]> ...
|
2007-02-24 11:00:05 +00:00
|
|
|
'tool' in one of:
|
2008-09-15 14:52:29 +00:00
|
|
|
--gcc, --binutils, --glibc, --eglibc, --uClibc, --linux,
|
2007-07-13 12:22:34 +00:00
|
|
|
--gdb, --dmalloc, --duma, --strace, --ltrace, --libelf
|
2008-04-30 10:43:41 +00:00
|
|
|
--gmp, --mpfr
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
Valid options for all tools:
|
2009-01-29 18:48:05 +00:00
|
|
|
--stable, -s, +x (default)
|
2009-03-04 17:59:35 +00:00
|
|
|
mark the version as being stable (as opposed to experimental, below)
|
2007-04-18 17:32:55 +00:00
|
|
|
|
2009-01-29 18:48:05 +00:00
|
|
|
--experimental, -x, +s
|
2009-03-04 17:59:35 +00:00
|
|
|
mark the version as being experimental (as opposed to stable, above)
|
2009-01-29 18:48:05 +00:00
|
|
|
|
|
|
|
--current, -c, +o (default)
|
2009-03-04 17:59:35 +00:00
|
|
|
mark the version as being cuurent (as opposed to obsolete, below)
|
2009-01-29 18:48:05 +00:00
|
|
|
|
|
|
|
--obsolete, -o, +c
|
2009-03-04 17:59:35 +00:00
|
|
|
mark the version as being obsolete (as opposed to current, above)
|
2009-01-29 18:48:05 +00:00
|
|
|
|
|
|
|
Note: setting a new tool resets to the defaults: 'stable' and 'current'.
|
2007-05-17 16:22:51 +00:00
|
|
|
|
2007-02-24 11:00:05 +00:00
|
|
|
'version' is a valid version for the specified tool.
|
|
|
|
|
|
|
|
Examples:
|
2009-01-29 18:48:05 +00:00
|
|
|
add stable current version 2.6.19.2 to linux kernel:
|
2008-09-15 14:52:29 +00:00
|
|
|
${myname} --linux 2.6.19.2
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2009-01-29 18:48:05 +00:00
|
|
|
add experimental obsolete version 2.3.5 and stable current versions 2.6.1
|
|
|
|
and 2.6.2 to glibc, add stable obsolete version 3.3.3 to gcc:
|
|
|
|
${myname} --glibc -x -o 2.3.5 -s -c 2.6.1 2.6.2 --gcc -o 3.3.3
|
2007-02-24 11:00:05 +00:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2009-01-29 18:48:05 +00:00
|
|
|
# Effectively add a version to the specified tool
|
|
|
|
# $cat : tool category
|
|
|
|
# $tool : tool name
|
|
|
|
# $tool_prefix : tool directory prefix
|
|
|
|
# $EXP : set to non empty if experimental, to empty otherwise
|
|
|
|
# #OBS : set to non empty if obsolete, to empty otherwise
|
|
|
|
# $1 : version string to add
|
|
|
|
addToolVersion() {
|
|
|
|
local version="$1"
|
|
|
|
local file
|
2009-02-02 21:56:30 +00:00
|
|
|
local config_ver_option
|
2009-01-29 18:48:05 +00:00
|
|
|
local exp_obs_prompt
|
|
|
|
local deps v ver_M ver_m
|
|
|
|
local SedExpr1 SedExpr2
|
|
|
|
|
|
|
|
file="config/${tool_prefix}/${tool}.in"
|
2009-01-29 18:53:32 +00:00
|
|
|
v=$(echo "${version}" |"${sed}" -r -e 's/-/_/g; s/\./_/g;')
|
2009-01-29 18:48:05 +00:00
|
|
|
|
2009-02-02 21:56:30 +00:00
|
|
|
config_ver_option="${cat}_V_${v}"
|
|
|
|
|
|
|
|
# Check for existing version: it can be legitimitate for an end-user
|
|
|
|
# to try adding a new version if the one he/she wants is not listed.
|
|
|
|
# But it can be the case where the version is hidden behind either one
|
|
|
|
# of EXPERIMENTAL or OBSOLETE, so warn if the version is already listed.
|
|
|
|
if (GREP_OPTIONS= grep -E "^config ${config_ver_option}$" "${file}" >/dev/null 2>&1); then
|
|
|
|
echo "'${tool}': version '${version}' already present:"
|
|
|
|
GREP_OPTIONS= grep -A3 -B0 -E "^config ${config_ver_option}$" "${file}"
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
SedExpr1="${SedExpr1}config ${config_ver_option}\n"
|
2009-01-29 18:48:05 +00:00
|
|
|
SedExpr1="${SedExpr1} bool\n"
|
|
|
|
SedExpr1="${SedExpr1} prompt \"${version}"
|
|
|
|
case "${EXP},${OBS}" in
|
|
|
|
,) ;;
|
|
|
|
,*) exp_obs_prompt=" (OBSOLETE)"
|
|
|
|
deps=" depends on OBSOLETE\n"
|
|
|
|
;;
|
|
|
|
*,) exp_obs_prompt=" (EXPERIMENTAL)"
|
|
|
|
deps=" depends on EXPERIMENTAL\n"
|
|
|
|
;;
|
|
|
|
*) exp_obs_prompt=" (EXPERIMENTAL, OBSOLETE)"
|
|
|
|
deps=" depends on EXPERIMENTAL && OBSOLETE\n"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
[ -n "${exp_obs_prompt}" ] && SedExpr1="${SedExpr1}${exp_obs_prompt}"
|
|
|
|
SedExpr1="${SedExpr1}\"\n"
|
|
|
|
[ -n "${deps}" ] && SedExpr1="${SedExpr1}${deps}"
|
|
|
|
if [ "${tool}" = "gcc" ]; then
|
|
|
|
# Extract 'M'ajor and 'm'inor from version string
|
|
|
|
ver_M=$(echo "${version}...." |cut -d . -f 1)
|
|
|
|
ver_m=$(echo "${version}...." |cut -d . -f 2)
|
|
|
|
if [ ${ver_M} -gt 4 \
|
|
|
|
-o \( ${ver_M} -eq 4 -a ${ver_m} -ge 3 \) ]; then
|
|
|
|
SedExpr1=" select CC_GCC_4_3_or_later\n"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
SedExpr2=" default \"${version}\" if ${cat}_V_${v}"
|
2009-01-29 18:53:32 +00:00
|
|
|
"${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_ABOVE)$/'"${SedExpr1}"'\n\1/;' "${file}"
|
|
|
|
"${sed}" -r -i -e 's/^(# CT_INSERT_VERSION_STRING_ABOVE)$/'"${SedExpr2}"'\n\1/;' "${file}"
|
2009-01-29 18:48:05 +00:00
|
|
|
}
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
cat=
|
2007-02-24 11:00:05 +00:00
|
|
|
tool=
|
|
|
|
tool_prefix=
|
|
|
|
VERSION=
|
2007-04-18 17:32:55 +00:00
|
|
|
EXP=
|
2007-05-17 16:22:51 +00:00
|
|
|
OBS=
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2009-01-29 18:48:05 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
doHelp
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
2007-05-17 16:22:51 +00:00
|
|
|
# Tools:
|
2009-01-29 18:48:05 +00:00
|
|
|
--gcc) EXP=; OBS=; cat=CC; tool=gcc; tool_prefix=cc;;
|
|
|
|
--binutils) EXP=; OBS=; cat=BINUTILS; tool=binutils; tool_prefix=;;
|
|
|
|
--glibc) EXP=; OBS=; cat=LIBC; tool=glibc; tool_prefix=libc;;
|
|
|
|
--eglibc) EXP=; OBS=; cat=LIBC; tool=eglibc; tool_prefix=libc;;
|
|
|
|
--uClibc) EXP=; OBS=; cat=LIBC; tool=uClibc; tool_prefix=libc;;
|
|
|
|
--linux) EXP=; OBS=; cat=KERNEL; tool=linux; tool_prefix=kernel;;
|
|
|
|
--gdb) EXP=; OBS=; cat=GDB; tool=gdb; tool_prefix=debug;;
|
|
|
|
--dmalloc) EXP=; OBS=; cat=DMALLOC; tool=dmalloc; tool_prefix=debug;;
|
|
|
|
--duma) EXP=; OBS=; cat=DUMA; tool=duma; tool_prefix=debug;;
|
|
|
|
--strace) EXP=; OBS=; cat=STRACE; tool=strace; tool_prefix=debug;;
|
|
|
|
--ltrace) EXP=; OBS=; cat=LTRACE; tool=ltrace; tool_prefix=debug;;
|
|
|
|
--libelf) EXP=; OBS=; cat=LIBELF; tool=libelf; tool_prefix=tools;;
|
|
|
|
--gmp) EXP=; OBS=; cat=GMP; tool=gmp; tool_prefix=gmp_mpfr;;
|
|
|
|
--mpfr) EXP=; OBS=; cat=MPFR; tool=mpfr; tool_prefix=gmp_mpfr;;
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# Tools options:
|
2009-01-29 18:48:05 +00:00
|
|
|
-x|--experimental|+s) EXP=1;;
|
|
|
|
-s|--stable|+x) EXP=;;
|
|
|
|
-o|--obsolete|+c) OBS=1;;
|
|
|
|
-c|--current|+o) OBS=;;
|
|
|
|
|
2007-05-17 16:22:51 +00:00
|
|
|
# Misc:
|
2009-01-29 18:48:05 +00:00
|
|
|
-h|--help) doHelp; exit 0;;
|
|
|
|
-*) echo "Unknown option: '$1' (use -h/--help for help)."; exit 1;;
|
2007-02-24 11:00:05 +00:00
|
|
|
|
2009-01-29 18:48:05 +00:00
|
|
|
# Version string:
|
|
|
|
*) [ -n "${tool}" ] || { doHelp; exit 1; }
|
|
|
|
addToolVersion "$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2007-02-24 11:00:05 +00:00
|
|
|
done
|