drizztbsd Retired Dev
Joined: 21 Nov 2004 Posts: 278 Location: Cesano Maderno
|
Posted: Fri Jan 26, 2007 2:51 pm Post subject: [SCRIPT] dmake -- distcc make |
|
|
Oggi mi sono fatto uno script per gestire comodamente la compilazione con distcc
Le features sono le seguenti:
- Utilizza di ccache e/o distcc automaticamente se rilevati
- Supporto cross-distcc
- Supporto porte diverse da quelle standard e numero jobs
L'unico problema per ora è che devi usare la sintassi col numero jobs (host/num o host:port/num)
Code: | #!/bin/bash
# Copyright 2007 Timothy Redaelli <drizzt@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
einfo() {
echo -e " \e[32;01m*\e[0m $*"
}
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} $* |
Per gli host usare distcc-config _________________ Gentoo/Alt lead
Gentoo/*BSD and Gentoo/FreeBSD deputy lead
Paludis contributor |
|