import source from 1.3.40
[external/swig.git] / CCache / debian / update-ccache
1 #!/bin/sh
2 #
3 # Update compiler links to ccache (in /usr/local/bin)
4 #
5 # The idea is that /usr/local/bin is ahead of /usr/bin in your PATH, so adding
6 # the link /usr/local/bin/cc -> /usr/bin/ccache means that it is run instead of
7 # /usr/bin/cc
8 #
9 # Written by: Behan Webster <behanw@websterwood.com>
10 #
11
12 DIRECTORY=/usr/local/bin
13 CCACHE=/usr/bin/ccache
14 CCDIR=/usr/lib/ccache
15
16 usage() {
17     echo "Usage: `basename $0` [--directory <dir>] [--remove]"
18     exit 0
19 }
20
21 while [ $# -gt 0 ] ; do
22     case "$1" in
23         -d*|--d*|--directory) DIRECTORY=$2; shift; shift;;
24         -h*|--h*|--help) usage;;
25         -r*|--r*|--remove) REMOVE=1; shift;;
26         -t*|--t*|--test) TEST=echo; shift;;
27     esac
28 done
29
30 for FILE in `cd $CCDIR; ls` ; do
31     LINK=$DIRECTORY/$FILE
32     if [ -z "$REMOVE" ] ; then
33         # Add link
34         $TEST ln -fs $CCACHE $LINK
35     else
36         # Remove link
37         if [ -L "$LINK" ] ; then
38             $TEST rm -f $LINK
39         fi
40     fi
41 done
42
43 # vim: sw=4 ts=4