summaryrefslogtreecommitdiffstats
path: root/doc/distcc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/distcc')
-rw-r--r--doc/distcc161
1 files changed, 161 insertions, 0 deletions
diff --git a/doc/distcc b/doc/distcc
new file mode 100644
index 0000000..1afdfbe
--- /dev/null
+++ b/doc/distcc
@@ -0,0 +1,161 @@
+Online documentation:
+
+Using distcc and crosstool-ng for distributed cross-compilations:
+- http://archlinuxarm.org/developers/distcc-cross-compiling
+
+Setting up a distcc environment:
+- http://archlinuxarm.org/developers/distributed-compiling
+
+# ===========================================================================
+
+Setting up distcc on the host (the ARM computer):
+
+Add the following to /etc/profile.d/distcc.sh :
+
+#-----8<------------------------------------------
+# Explicitly set the ARCH since we are not natively compiling:
+export ARCH=armv7hl
+
+# Automatically determine the ARCH we are running distcc on:
+MARCH=$( uname -m )
+if [ -z "$ARCH" ]; then
+ case "$MARCH" in
+ i?86) export ARCH=i486 ;;
+ armv7hl) export ARCH=$MARCH ;;
+ arm*) export ARCH=arm ;;
+ # Unless $ARCH is already set, use uname -m for all other archs:
+ *) export ARCH=$MARCH ;;
+ esac
+fi
+
+case "$ARCH" in
+ arm*) TARGET=$ARCH-slackware-linux-gnueabi ;;
+ *) TARGET=$ARCH-slackware-linux ;;
+esac
+
+# Define the compilers with their full name, not just "gcc" - or else
+# we can not distribute the compilation to a distcc cross-compiler:
+export CC=${TARGET}-gcc
+export CXX=${TARGET}-g++
+export AS=${TARGET}-as
+
+# We need a private directory where we will create distcc symlinks:
+DISTCC_CPATH="/var/tmp/${UID}/distcc"
+
+# Create distcc compiler and assembler symlinks, for our host architecture:
+( mkdir -p $DISTCC_CPATH
+ cd $DISTCC_CPATH
+ ln -svf /usr/bin/distcc ${TARGET}-gcc
+ ln -svf /usr/bin/distcc ${TARGET}-g++
+ ln -svf /usr/bin/distcc ${TARGET}-c++
+ ln -svf /usr/bin/distcc ${TARGET}-as
+)
+# So that every compiler call will actually trigger distcc:
+export PATH="$DISTCC_CPATH:$PATH"
+
+# First priority is the localhost (the arm computer), note that this must
+# be the literal string "localhost" which is interpreted as "run a compilation
+# locally if only a single job must be run":
+export DISTCC_HOSTS="localhost 192.168.0.1"
+#-----8<------------------------------------------
+
+Setting up my own distcc server:
+
+In /etc/hosts.allow, define distccd hosts or network, otherwise the master
+won't be able to connect (distcc runs on port 3632):
+
+#-----8<------------------------------------------
+distccd: 192.168.0.0/24
+#-----8<------------------------------------------
+
+Create a file with defaults for the rc.distccd script which comes next:
+
+#-----8<------------------------------------------
+# Example /etc/default/distccd
+DISTCCD_USER=nobody
+DISTCCD_NUMJOBS=5
+DISTCCD_ALLOW="192.168.0.0/24"
+DISTCCD_PID="/var/run/distcc/distccd.pid"
+#-----8<------------------------------------------
+
+Create /etc/rc.d/rc.distccd as follows:
+
+#-----8<------------------------------------------
+# /etc/rc.d/rc.distccd
+#
+# Start/stop/restart the distcc daemon.
+#
+
+# Load defaults:
+if [ -f /etc/default/distccd ] ; then
+ . /etc/default/distccd
+fi
+
+DISTCCD_USER=${DISTCCD_USER:-nobody}
+DISTCCD_NUMJOBS=${DISTCCD_NUMJOBS:-5}
+DISTCCD_ALLOW=${DISTCCD_ALLOW:-"192.168.0.0/24"}
+DISTCCD_PID=${DISTCCD_PID:-/var/run/distcc/distccd.pid}
+
+# If we allow cross-compiling, then define the architecture(s) space-separated:
+DISTCCD_TARGET=${DISTCCD_TARGET:-"armv7hl"}
+
+# Determine the ARCH we are running the distcc daemon on:
+case "$( uname -m )" in
+ i?86) DISTCCARCH=i486 ;;
+ *) DISTCCARCH=$( uname -m ) ;;
+esac
+
+if [ -n "$DISTCCD_TARGET" ]; then
+ # Where will distcc find the crosscompiler:
+ DISTCC_BASEDIR=/tftpboot/crossdev/${DISTCCARCH}
+ for CARCH in $DISTCCD_TARGET ; do
+ DISTCC_PATH="${DISTCC_BASEDIR}/${CARCH}/bin:${DISTCC_PATH}"
+ done
+ echo "Distcc will look for crosscompilers in '$DISTCC_PATH'"
+fi
+
+distccd_start() {
+ echo "Starting distcc daemon: /usr/bin/distccd start"
+ mkdir -p /var/run/distcc
+ chown $DISTCCD_USER /var/run/distcc
+ touch /var/log/distccd.log
+ chown $DISTCCD_USER /var/log/distccd.log
+
+ DISTCCD_PATH=$DISTCC_PATH/bin \
+ /usr/bin/distccd --daemon -N 5 --user $DISTCCD_USER --allow $DISTCCD_ALLOW --jobs $DISTCCD_NUMJOBS --pid-file $DISTCCD_PID --log-file /var/log/distccd.log
+}
+
+distccd_stop() {
+ killall distccd
+}
+
+distccd_status() {
+ PIDS=$(cat $DISTCCD_PID 2>/dev/null)
+ if [ "$PIDS" == "" ]; then
+ echo "distccd is not running!"
+ else
+ echo "distccd is running at pid(s) ${PIDS}."
+ fi
+}
+
+case "$1" in
+ 'start')
+ distccd_start
+ ;;
+ 'stop')
+ distccd_stop
+ ;;
+ 'restart')
+ distccd_stop
+ sleep 1
+ distccd_start
+ ;;
+ 'status')
+ distccd_status
+ ;;
+ *)
+ echo "usage $0 start|stop|restart|status" ;;
+esac
+#-----8<------------------------------------------
+
+