--- trunk/ccache/ccache-config 2012/01/13 16:13:51 1617 +++ trunk/ccache/ccache-config 2012/01/14 01:07:08 1618 @@ -10,10 +10,13 @@ # # Additional features to come; this provides a starting point +LIBDIR="lib" + # this should be getopt'd someday (override with CC_QUIET=1) CC_VERBOSE=1 -cc_echo() { +cc_echo() +{ [ -z "${CC_QUIET}" -a -n "${CC_VERBOSE}" ] && echo "$*" } @@ -22,31 +25,50 @@ # they allow the user or other scripts (namely gcc-config) to # automatically update ccache's links when upgrading toolchains # -cc_remove_link() { - local t="/usr/lib/ccache/bin/${1}" - if [ -L ${t} ]; then +cc_path() +{ + echo ${MROOT%/}/usr/${LIBDIR}/ccache/bin/$1 +} + +cc_remove_link() +{ + local t=$(cc_path "$1") + if [ -L ${t} ] + then cc_echo "Removing ${t}..." rm -f "${t}" fi } -cc_install_link() { + +cc_install_link() +{ # Search the PATH for the specified compiler # then create shadow link in /usr/lib/ccache/bin to ccache - if [ -n "$(type -p ${1})" ]; then + if [ -n "$(type -p ${1})" ] + then # first be sure any old link is removed CC_QUIET=1 cc_remove_link "${1}" # then create the new link - local t="/usr/lib/ccache/bin/${1}" + local t=$(cc_path "$1") cc_echo "Creating ccache shadow link: ${t}..." - ln -s /usr/bin/ccache "${t}" + mkdir -p -m 0755 "${t%/*}" && ln -s /usr/bin/ccache "${t}" fi } -cc_links() { + +cc_links() +{ local a - for a in gcc cc c++ g++ ; do - [ -n "${2}" ] && a="${2}-${a}" + for a in gcc cc c++ g++ + do + if [ -n "${2}" ] + then + # gcc-config doesn't install ${CHOST}-cc, so until + # it does, don't install a ccache symlink for it + [ "${a}" = "cc" ] && continue + a="${2}-${a}" + fi eval "cc_${1}_link" "${a}" done } @@ -65,4 +87,3 @@ echo "usage: ${0} {--install-links|--remove-links} [ CHOST ]" ;; esac -