Magellan Linux

Contents of /trunk/ccache/ccache-config

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (show annotations) (download)
Tue May 8 20:06:05 2007 UTC (17 years ago) by niro
File size: 1554 byte(s)
-import

1 #!/bin/bash
2 #
3 # ccache-config - helper script for ccache and its ebuild
4 #
5 # Copyright 2003 Superlucidity Services, LLC
6 # This program licensed under the GNU GPL version 2.
7 #
8 # This script developed by Zachary T Welch at Superlucidity Services, LLC
9 # it was cloned from the distcc-config script
10 #
11 # Additional features to come; this provides a starting point
12
13 # this should be getopt'd someday (override with CC_QUIET=1)
14 CC_VERBOSE=1
15
16 cc_echo() {
17 [ -z "${CC_QUIET}" -a -n "${CC_VERBOSE}" ] && echo "$*"
18 }
19
20 ###
21 # the following functions manage the ccache symlinks
22 # they allow the user or other scripts (namely gcc-config) to
23 # automatically update ccache's links when upgrading toolchains
24 #
25 cc_remove_link() {
26 local t="/usr/lib/ccache/bin/${1}"
27 if [ -L ${t} ]; then
28 cc_echo "Removing ${t}..."
29 rm -f "${t}"
30 fi
31 }
32 cc_install_link() {
33 # Search the PATH for the specified compiler
34 # then create shadow link in /usr/lib/ccache/bin to ccache
35
36 if [ -n "$(type -p ${1})" ]; then
37 # first be sure any old link is removed
38 CC_QUIET=1 cc_remove_link "${1}"
39
40 # then create the new link
41 local t="/usr/lib/ccache/bin/${1}"
42 cc_echo "Creating ccache shadow link: ${t}..."
43 ln -s /usr/bin/ccache "${t}"
44 fi
45 }
46 cc_links() {
47 local a
48 for a in gcc cc c++ g++ ; do
49 [ -n "${2}" ] && a="${2}-${a}"
50 eval "cc_${1}_link" "${a}"
51 done
52 }
53
54 ###
55 # main routine
56
57 case "${1}" in
58 --install-links )
59 cc_links install "${2}"
60 ;;
61 --remove-links )
62 cc_links remove "${2}"
63 ;;
64 * )
65 echo "usage: ${0} {--install-links|--remove-links} [ CHOST ]"
66 ;;
67 esac
68