#!/bin/bash

# by TeknoHog at iki d0t fi,
# after http://www.gentoo.org/doc/en/cross-compiling-distcc.xml

# edit this to match your local machine
# where distcc is called, not the servers
#CHOST=powerpc-unknown-linux-gnu
#CHOST="i686-pc-linux-gnu"
CHOST=$MACHTYPE

###########

LINKS="c++ g++ gcc cc"

WRAPPER=$CHOST-wrapper.sh

cd /usr/lib/distcc/bin

# note to self: escapes are needed for those $s that are not
# immediately substituted
cat << EOF > $WRAPPER
#!/bin/bash
exec /usr/lib/distcc/bin/$CHOST-g\${0:\$[-2]} "\$@"
EOF

chmod a+x $WRAPPER

for i in $LINKS; do
        rm $i
        ln -s $WRAPPER $i
done


