It's unknown to me if the archive accepts packages built using this method, but it can be useful when building "local" packages for low-performance semi-embedded devices, where you have access to multiple identical machines.

First on one machine, lets call it master, we install the usual build tools. Then install the packages distcc and ccache. On all the slaves, you should install distcc and g++ (if you will ever only compile c code, you can install only gcc instead). On all slaves, edit their /etc/default/distcc and set STARTDISTCC to true, ALLOWEDNETS to your sub-network (i.e. "192.168.37.0/24"), and LISTENER to the LAN interface (i.e. "192.168.37.27"). If you want to use avahi, let ZEROCONF be true. You don't need to do this modification on the master, as we don't want to use that server for actual remote building. After modification don't forget to start the daemons.

If you dont want to use avahi, then on the master, add all the IP:s to $HOME/.distcc/hosts.

Even though you can use distcc without ccache I recommend this combination, as you can easly hook distcc to the call of ccache.

Now we create two scripts in /usr/local/bin:

First /usr/local/bin/distbuild:

export MAKE="/usr/local/bin/distmake"
export DISTCC_HOSTS="+zeroconf"
export CCACHE_PREFIX="distcc"
export DISTCC_JOBS=`distcc -j`
export CC="ccache gcc"
export CXX="ccache g++"

echo "Building with $DISTCC_JOBS parallel jobs on following servers:"
for server in `distcc --show-hosts`; do
                server=$(echo $server | sed 's/:.*//')
                echo -e "\t$server"
done

BCMD="debuild -rfakeroot"
EXTRA_FLAGS="-eCC -eCXX -eCCACHE_PREFIX -eMAKE -eDISTCC_HOSTS -eDISTCC_JOBS"
if [ -d .svn ]; then
                BCMD="svn-buildpackage --svn-builder $BCMD"
fi
echo $BCMD $EXTRA_FLAGS $@
$BCMD $EXTRA_FLAGS $@

And again, if you don't want to use zeroconf, don't export DISTCC_HOSTS with "+zeroconf". The SVN check I added to easily use same command on both normal builds as subversion builds.

Second we need a make (/usr/local/bin/makebuild) wrapper, as debhelper might choke otherwise:

make --jobs=${DISTCC_JOBS:-1} "$@"

Now we can build package as following:

$ bbuild -uc -us -tc
Building with 16 parallel jobs on following servers:
        192.168.37.42
        192.168.37.30
        192.168.37.25
        192.168.37.27
debuild -rfakeroot -eCC -eCXX -eCCACHE_PREFIX -eMAKE -eDISTCC_HOSTS -eDISTCC_JOBS -uc -us

Debian Bookworm

export CCACHE_PREFIX="distcc"
export DISTCC_HOSTS="192.168.37.42 192.168.37.30"
export DISTCC_VERBOSE="1"
debuild --prepend-path=/usr/lib/ccache --preserve-envvars=CCACHE_* --preserve-envvars=DISTCC_* -uc -us

Or without ccache:

export DISTCC_HOSTS="10.0.5.51"
debuild --prepend-path=/usr/lib/distcc --preserve-envvars=DISTCC_* -uc -us

Simple make:

export PATH="/usr/lib/distcc/:$PATH"
export DISTCC_HOSTS="10.0.5.51"
make

Cross Compilation

Cross compilation with distcc is supported but sometimes may not work. If host machine calling 'gcc' instead of it full name like 'arm-linux-gnueabi-g++' remote distcc will produce wrong arch output file. To fix that remove /usr/lib/distcc/ links and replace them with proper full name calling gcc.

cd /usr/lib/distcc

rm c++ cc g++ gcc

cat << EOF > cc
ccache arm-linux-gnueabi-gcc "$@"
EOF
chmod +x cc

cat << EOF > gcc
ccache arm-linux-gnueabi-gcc "$@"
EOF
chmod +x gcc

cat << EOF > c++
ccache arm-linux-gnueabi-g++ "$@"
EOF
chmod +x c++

cat << EOF > g++
ccache arm-linux-gnueabi-g++ "$@"
EOF
chmod +x g++


CategorySoftware | CategoryProgramming | CategoryPackaging