scripts: fix double slash in paths

Computed paths may contain double slashes.
This is not an issue but it is just ugly to look at.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
This commit is contained in:
Yann E. MORIN" 2011-01-25 21:59:03 +01:00
parent 94be1f470c
commit 8efc6dae8a
2 changed files with 20 additions and 0 deletions

View File

@ -295,6 +295,7 @@ if [ -z "${CT_RESTART}" ]; then
CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}" CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/${CT_SYSROOT_NAME}"
CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root" CT_DEBUGROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/${CT_SYSROOT_DIR_PREFIX}/debug-root"
CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include" CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
CT_SanitiseVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR
BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
@ -308,6 +309,7 @@ if [ -z "${CT_RESTART}" ]; then
CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}" CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
CT_DEBUGROOT_DIR="${CT_SYSROOT_DIR}" CT_DEBUGROOT_DIR="${CT_SYSROOT_DIR}"
CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include" CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
CT_SanitiseVarDir CT_SYSROOT_DIR CT_DEBUGROOT_DIR CT_HEADERS_DIR
# hack! Always use --with-sysroot for binutils. # hack! Always use --with-sysroot for binutils.
# binutils 2.14 and later obey it, older binutils ignore it. # binutils 2.14 and later obey it, older binutils ignore it.
# Lets you build a working 32->64 bit cross gcc # Lets you build a working 32->64 bit cross gcc

View File

@ -159,6 +159,24 @@ CT_SanitizePath() {
PATH="${new}" PATH="${new}"
} }
# Sanitise the directory name contained in the variable passed as argument:
# - remove duplicate /
# Usage: CT_SanitiseVarDir CT_PREFIX_DIR
CT_SanitiseVarDir() {
local var
local old_dir
local new_dir
for var in "$@"; do
eval "old_dir=\"\${${var}}\""
new_dir="$( printf "${old_dir}" \
|sed -r -e 's:/+:/:g;' \
)"
eval "${var}=\"${new_dir}\""
CT_DoLog DEBUG "Sanitised '${var}': '${old_dir}' -> '${new_dir}'"
done
}
# Abort the execution with an error message # Abort the execution with an error message
# Usage: CT_Abort <message> # Usage: CT_Abort <message>
CT_Abort() { CT_Abort() {