File profile of Package distcc
1
#
2
# Try to find out the right distccd hosts
3
#
4
unset HOST_LIST
5
[ -e /etc/distccd.hosts ] && HOST_LIST=/etc/distccd.hosts
6
[ -e $HOME/.distccd.hosts ] && HOST_LIST=$HOME/.distccd.hosts
7
# sorry, SuSE special. Feel free to add your location here ;)
8
[ -e /work/users/adrian/distccd.hosts ] && HOST_LIST=/work/users/adrian/distccd.hosts
9
10
# do we not use the standard port ?
11
. /etc/sysconfig/distccd
12
PORT_EXT=""
13
[ "$DISTCCD_PORT" = 3632 ] || PORT_EXT=":$DISTCCD_PORT"
14
15
if [ -e $HOST_LIST ]; then
16
17
export LC_ALL=C
18
GCC_VER="`gcc -v 2>&1 | sed -n 's/gcc version \([^ ]*\).*/\1/p'`"
19
ARCH="`sed -n 's@.*(\([^)]*\)).*@\1@p' /etc/SuSE-release`"
20
DISTCC_HOSTS="`grep -v ^# $HOST_LIST | sed -n -e \"s/${GCC_VER}-${ARCH}:[ ]*\(.*\)/\1/p\" | head -1 | tr 'A-Z' 'a-z'`"
21
[ "$DISTCC_HOSTS" ] || { echo "unsupported compiler, please configure it in /etc/distccd.hosts"; }
22
23
localhost=`hostname | tr 'A-Z' 'a-z'`
24
new_hosts=
25
for HOST in $DISTCC_HOSTS; do
26
if test "$HOST" = "$localhost"; then
27
new_hosts="$new_hosts localhost$PORT_EXT"
28
else
29
if ping -c 1 $HOST >& /dev/null; then
30
new_hosts="$new_hosts $HOST$PORT_EXT"
31
else
32
echo "hostname $HOST can not be resolved"
33
fi
34
fi
35
done
36
DISTCC_HOSTS=$new_hosts
37
38
#
39
# randomize distccd host order
40
#
41
NR_OF_HOSTS="`echo $DISTCC_HOSTS|wc -w`"
42
i=$NR_OF_HOSTS
43
OUT=""
44
while [ $i -gt 0 ]; do
45
e=$(( $RANDOM * $i / 32767 ))
46
j=0
47
IN=""
48
for s in $DISTCC_HOSTS; do
49
[ $j -eq $e ] \
50
&& OUT="$OUT $s" \
51
|| IN="$IN $s"
52
j=$(( $j + 1 ))
53
done
54
DISTCC_HOSTS=$IN
55
i=$(( $i - 1 ))
56
done
57
DISTCC_HOSTS=$OUT
58
echo setup DISTCC_HOSTS for gcc ${GCC_VER}-${ARCH} \($NR_OF_HOSTS hosts \)
59
else
60
echo 'no host list found (/etc/distccd.hosts)'
61
fi
62
63
#
64
# setup enviroment for the configure/make stuff
65
#
66
export CC=distcc
67
export CXX=distcc++
68
export DISTCC_HOSTS
69
70