blob: 901fe7c0430d2632de32dd64bea2b3239553cb0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/bash
# Copyright 2007 Timothy Redaelli <drizzt@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
function einfo() {
echo -e " \e[32;01m*\e[0m $*"
}
function ewarn() {
echo -e " \e[33;01m*\e[0m $*" >&2
}
CHOST=$(gcc -v 2>&1 | awk '/^Target: /{print $2}')
export AS="/usr/${CHOST}/bin/as"
export LD="/usr/${CHOST}/bin/ld"
if type ccache &>/dev/null; then
einfo "ccache detected"
export PATH="/usr/lib/ccache/bin/:$PATH"
export CC="/usr/lib/ccache/bin/${CHOST}-gcc"
export CXX="/usr/lib/ccache/bin/${CHOST}-g++"
fi
if type distcc &>/dev/null; then
einfo "distcc detected"
if [[ -z "$DISTCC_HOSTS" ]]; then
for i in $(</etc/distcc/hosts); do
ip=${i%/*}
port=${ip#*:}
[[ "${port}" = "${ip}" ]] && port=3632 || ip=${ip%:*}
if ( > "/dev/tcp/${ip}/${port}" ) 2>/dev/null || [[ ${ip} = localhost ]]; then
DISTCC_HOSTS="${DISTCC_HOSTS} ${i}"
else
ewarn "${ip}:${port} is not available."
fi
done
fi
if [[ "${DISTCC_HOSTS}" ]]; then
export DISTCC_HOSTS=${DISTCC_HOSTS}
MAKEOPTS="-j$(($(for i in ${DISTCC_HOSTS}; do echo -n ${i#*/}+; done ; echo 0)))"
if type ccache &>/dev/null; then
export CCACHE_PREFIX="distcc"
else
export PATH="/usr/lib/distcc/bin/:$PATH"
export CC="/usr/lib/distcc/bin/${CHOST}-gcc"
export CXX="/usr/lib/distcc/bin/${CHOST}-g++"
fi
einfo "I'm using distcc with \"${DISTCC_HOSTS}\""
fi
fi
make -e ${MAKEOPTS} "$@"
|