When considering a project involving a large number of source files, compilation time is always an issue. DistCC is in these cases a very good solution. From DistCC site:
distcc is a program to distribute builds of C, C++, Objective C or Objective C++ code across several machines on a network. distcc should always generate the same results as a local build, is simple to install and use, and is usually much faster than a local compile
My problem was how to keep the $DISTCC_HOSTS variable updated, since computers in my lab never seam to be left alone (after all... this is a lab :) ).
My idea was therefore to use AVAHI and to come up with a simple unix pipe that would feed the $DISTCC_DIR/hosts file.
Here is my hack:
- created /etc/avahi/services/distcc.service:
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">Distcc on %h</name> <service> <type>_distcc._tcp</type> </service> </service-group> - Install distcc and avahi-utils
apt-get install distcc avahi-utils - edit /etc/defaultdistcc accordingly
- add the following command to crontab:
avahi-browse _distcc._tcp -t -r | grep address | egrep -v : | cut -d [ -f 2 | cut -d ] -f 1 | paste -s -d' ' > ~/.distcc/hosts
That's it!
There is also a patch available for distcc to integrate avahi functionality in a more robust manner (for instance by hack will cause problems when compiling during the update of the file), but I didn't want to patch my Ubuntu distcc version. Best of all it is much easier to distribute the distcc.service file then a patched version of distcc ;).
This article was authored by