Magellan Linux

Annotation of /trunk/ccache/ccache-config

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2532 - (hide annotations) (download)
Mon Jan 26 08:32:32 2015 UTC (9 years, 3 months ago) by niro
File size: 1813 byte(s)
-support icc and clang too
1 niro 144 #!/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 niro 1618 LIBDIR="lib"
14    
15 niro 144 # this should be getopt'd someday (override with CC_QUIET=1)
16     CC_VERBOSE=1
17    
18 niro 1618 cc_echo()
19     {
20 niro 144 [ -z "${CC_QUIET}" -a -n "${CC_VERBOSE}" ] && echo "$*"
21     }
22    
23     ###
24     # the following functions manage the ccache symlinks
25     # they allow the user or other scripts (namely gcc-config) to
26     # automatically update ccache's links when upgrading toolchains
27     #
28 niro 1618 cc_path()
29     {
30     echo ${MROOT%/}/usr/${LIBDIR}/ccache/bin/$1
31     }
32    
33     cc_remove_link()
34     {
35     local t=$(cc_path "$1")
36     if [ -L ${t} ]
37     then
38 niro 144 cc_echo "Removing ${t}..."
39     rm -f "${t}"
40     fi
41     }
42 niro 1618
43     cc_install_link()
44     {
45 niro 144 # Search the PATH for the specified compiler
46     # then create shadow link in /usr/lib/ccache/bin to ccache
47    
48 niro 1618 if [ -n "$(type -p ${1})" ]
49     then
50 niro 144 # first be sure any old link is removed
51     CC_QUIET=1 cc_remove_link "${1}"
52    
53     # then create the new link
54 niro 1618 local t=$(cc_path "$1")
55 niro 144 cc_echo "Creating ccache shadow link: ${t}..."
56 niro 1618 mkdir -p -m 0755 "${t%/*}" && ln -s /usr/bin/ccache "${t}"
57 niro 144 fi
58     }
59 niro 1618
60     cc_links()
61     {
62 niro 144 local a
63 niro 2532 for a in gcc cc c++ g++ icc icpc clang clang++
64 niro 1618 do
65     if [ -n "${2}" ]
66     then
67     # gcc-config doesn't install ${CHOST}-cc, so until
68     # it does, don't install a ccache symlink for it
69     [ "${a}" = "cc" ] && continue
70     a="${2}-${a}"
71     fi
72 niro 144 eval "cc_${1}_link" "${a}"
73     done
74     }
75    
76     ###
77     # main routine
78    
79     case "${1}" in
80     --install-links )
81     cc_links install "${2}"
82     ;;
83     --remove-links )
84     cc_links remove "${2}"
85     ;;
86     * )
87     echo "usage: ${0} {--install-links|--remove-links} [ CHOST ]"
88     ;;
89     esac