
--- distcc-2.18.3/distcc-default.csh	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/distcc-default.csh	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,9 @@
+#!/bin/csh
+
+if ( ! $?CCACHE_PATH ) then
+   setenv CCACHE_PATH $PATH
+endif
+
+setenv CCACHE_PATH "@FINKPREFIX@/var/lib/distcc/untranslated:"$CCACHE_PATH
+setenv PATH $PATH":@FINKPREFIX@/var/lib/distcc/untranslated"
+setenv CCACHE_PREFIX "@FINKPREFIX@/var/lib/distcc/gcc-translator.pl"
--- distcc-2.18.3/distcc-default.sh	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/distcc-default.sh	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -z "$CCACHE_PATH" ]; then
+   CCACHE_PATH="$PATH"
+fi
+
+export CCACHE_PATH="@FINKPREFIX@/var/lib/distcc/untranslated:$CCACHE_PATH"
+export PATH="$PATH:@FINKPREFIX@/var/lib/distcc/untranslated"
+export CCACHE_PREFIX="@FINKPREFIX@/var/lib/distcc/gcc-translator.pl"
--- distcc-2.18.3/distcc.conf	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/distcc.conf	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,30 @@
+# whether to translate compiler calls into e.g.
+#   powerpc-apple-darwin8-gcc -- don't set this
+#   unless you know what you're doing!
+#DISTCC_TRANS=false
+
+# the location of the distcc configuration files
+# the default is @FINKPREFIX@/var/cache/distcc/[uid]
+#DISTCC_DIR=@FINKPREFIX@/var/cache/distcc/foo
+
+# the hosts to use when compiling
+DISTCC_HOSTS='localhost'
+
+# whether to give more verbose output
+DISTCC_VERBOSE=0
+
+# the full path of a log file to log to
+# DISTCC_LOG=LOGFILE
+
+# disable tcp corks (see manual for details)
+DISTCC_TCP_CORK=1
+
+# whether to use MMAP
+DISTCC_MMAP=0
+
+# Enable building with multiple concurrent make
+# sessions by default -- this can cause problems
+# with building some packages.  If you have issues
+# building a package, comment this back out and
+# try again.
+#MAKEFLAGS=-j4
--- distcc-2.18.3/distcc.csh	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/distcc.csh	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,13 @@
+#!/bin/csh
+
+#### DO NOT EDIT BELOW HERE ####
+mkdir -p "@FINKPREFIX@/var/cache/distcc/`id -u`" && setenv DISTCC_DIR "@FINKPREFIX@/var/cache/distcc/`id -u`"
+
+grep -q -E '^ *DISTCC_TRANS' @FINKPREFIX@/etc/distcc.conf    && setenv DISTCC_TRANS `grep '^ *DISTCC_TRANS' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_DIR' @FINKPREFIX@/etc/distcc.conf      && setenv DISTCC_DIR `grep '^ *DISTCC_DIR' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_MMAP' @FINKPREFIX@/etc/distcc.conf     && setenv DISTCC_MMAP `grep '^ *DISTCC_MMAP' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_HOSTS' @FINKPREFIX@/etc/distcc.conf    && setenv DISTCC_HOSTS `grep '^ *DISTCC_HOSTS' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_VERBOSE' @FINKPREFIX@/etc/distcc.conf  && setenv DISTCC_VERBOSE `grep '^ *DISTCC_VERBOSE' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_LOG' @FINKPREFIX@/etc/distcc.conf      && setenv DISTCC_LOG `grep '^ *DISTCC_LOG' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_TCP_CORK' @FINKPREFIX@/etc/distcc.conf && setenv DISTCC_TCP_CORK `grep '^ *DISTCC_TCP_CORK' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *MAKEFLAGS' @FINKPREFIX@/etc/distcc.conf       && setenv MAKEFLAGS `grep '^ *MAKEFLAGS' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
--- distcc-2.18.3/distcc.sh	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/distcc.sh	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#### DO NOT EDIT BELOW HERE ####
+mkdir -p "@FINKPREFIX@/var/cache/distcc/`id -u`" && export DISTCC_DIR="@FINKPREFIX@/var/cache/distcc/`id -u `"
+
+grep -q -E '^ *DISTCC_TRANS' @FINKPREFIX@/etc/distcc.conf    && export DISTCC_TRANS=`grep '^ *DISTCC_TRANS' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_DIR' @FINKPREFIX@/etc/distcc.conf      && export DISTCC_DIR=`grep '^ *DISTCC_DIR' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_MMAP' @FINKPREFIX@/etc/distcc.conf     && export DISTCC_MMAP=`grep '^ *DISTCC_MMAP' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_HOSTS' @FINKPREFIX@/etc/distcc.conf    && export DISTCC_HOSTS=`grep '^ *DISTCC_HOSTS' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_VERBOSE' @FINKPREFIX@/etc/distcc.conf  && export DISTCC_VERBOSE=`grep '^ *DISTCC_VERBOSE' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_LOG' @FINKPREFIX@/etc/distcc.conf      && export DISTCC_LOG=`grep '^ *DISTCC_LOG' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *DISTCC_TCP_CORK' @FINKPREFIX@/etc/distcc.conf && export DISTCC_TCP_CORK=`grep '^ *DISTCC_TCP_CORK' @FINKPREFIX@/etc/distcc.conf  | head -1 | tr -d \'\" | cut -d= -f2` || :
+grep -q -E '^ *MAKEFLAGS' @FINKPREFIX@/etc/distcc.conf       && export MAKEFLAGS=`grep '^ *MAKEFLAGS' @FINKPREFIX@/etc/distcc.conf | head -1 | tr -d \'\" | cut -d= -f2` || :
--- distcc-2.18.3/distccd-fink.sh	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/distccd-fink.sh	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,31 @@
+#!/bin/sh -e
+
+source @FINKPREFIX@/etc/distccd.conf
+export DISTCC_MMAP
+
+export DISTCCD_PATH="@FINKPREFIX@/var/lib/distcc/translated:$PATH"
+export DISTCC_TRANS="true"
+
+DISTCCD_COMMAND="@FINKPREFIX@/bin/distccd --daemon --pid-file @FINKPREFIX@/var/run/distccd.pid"
+
+[ -n "$DISTCCD_NICENESS" ] && DISTCCD_COMMAND="$DISTCCD_COMMAND --nice $DISTCCD_NICENESS"
+[ -n "$DISTCCD_PORT"     ] && DISTCCD_COMMAND="$DISTCCD_COMMAND --port $DISTCCD_PORT"
+[ -n "$DISTCCD_LISTEN"   ] && DISTCCD_COMMAND="$DISTCCD_COMMAND --listen $DISTCCD_LISTEN"
+[ -n "$DISTCCD_USER"     ] && DISTCCD_COMMAND="$DISTCCD_COMMAND --user $DISTCCD_USER"
+[ -n "$DISTCCD_VERBOSE"  ] && DISTCCD_COMMAND="$DISTCCD_COMMAND --verbose"
+[ -n "$DISTCCD_LOGFILE"  ] && DISTCCD_COMMAND="$DISTCCD_COMMAND --log-file $DISTCCD_LOGFILE"
+
+[ "$DISTCCD_ZEROCONF" == 1 ] && DISTCCD_COMMAND="$DISTCCD_COMMAND --zeroconf"
+
+for allow in $DISTCCD_ALLOW; do
+   DISTCCD_COMMAND="$DISTCCD_COMMAND --allow $allow"
+done
+
+rm -f "@FINKPREFIX@/var/log/distccd.log"
+touch "@FINKPREFIX@/var/log/distccd.log"
+touch "@FINKPREFIX@/var/run/distccd.pid"
+chown distcc "@FINKPREFIX@/var/log/distccd.log"
+chown distcc "@FINKPREFIX@/var/run/distccd.pid"
+
+env -i DISTCC_MMAP="$DISTCC_MMAP" DISTCCD_PATH="$DISTCCD_PATH" DISTCC_TRANS="true" $DISTCCD_COMMAND
+
--- distcc-2.18.3/distccd.conf	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/distccd.conf	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,30 @@
+# whether to use MMAP
+DISTCC_MMAP=0
+
+# how nice should distccd be?
+DISTCCD_NICENESS=5
+
+# the port to listen on
+DISTCCD_PORT=3632
+
+# the IP address to listen on
+# 0.0.0.0 = all
+DISTCCD_LISTEN=0.0.0.0
+
+# the user to run as
+DISTCCD_USER=distcc
+
+# hosts to allow to connect to this distccd instance
+# format: 0.0.0.0[/CIDR_BITMASK] [0.0.0.0[/CIDR_BITMASK]] ...
+DISTCCD_ALLOW="0.0.0.0"
+
+# whether to be verbose in the logs
+# "" = no, anything else = yes
+DISTCCD_VERBOSE="true"
+
+# the log file to write to
+DISTCCD_LOGFILE="@FINKPREFIX@/var/log/distccd.log"
+
+# whether to use zeroconf
+# 0 = false, 1 = true
+DISTCCD_ZEROCONF=1
--- distcc-2.18.3/gcc-translator.pl	1969-12-31 19:00:00.000000000 -0500
+++ distcc-2.18.3-new/gcc-translator.pl	2007-02-24 12:10:14.000000000 -0500
@@ -0,0 +1,151 @@
+#!/usr/bin/perl -w
+
+# usage: put this file in $DATADIR, then make symlinks for each
+# of the compilers:
+# 
+#  cd $DATADIR
+#  for arch in powerpc i386; do
+#    for version in "" "-3.3" "-4.0"; do
+#      for gcc in cc c++ gcc g++; do
+#        if [ -f "/usr/bin/${gcc}${version}" ]; then
+#          ln -s "/usr/bin/${gcc}${version}" "${arch}-apple-darwin${DARWINVER}-${gcc}${version}"
+#        fi
+#      done
+#    done
+#  done
+# 
+# install distcc and ccache, then set:
+#
+# export CCACHE_PREFIX=$DATADIR/gcc-translator.pl
+#
+# assuming you've got ccache set up to do symlinks to take over gcc, the gcc-translator script
+# will automatically translate gcc calls into target-style gcc names (powerpc-apple-darwin8-gcc)
+
+use strict;
+
+my $DISTCCBIN = '@FINKPREFIX@/bin/distcc';
+my $DATADIR = '@FINKPREFIX@/var/lib/distcc';
+
+# shortcut if they're doing multiple architectures, the remote
+# compilers probably won't handle it right
+if (grep(/^-arch$/, @ARGV) >= 2) {
+	exit run_command($0, @ARGV);
+}
+
+if (not exists $ENV{'DISTCC_TRANS'} or $ENV{'DISTCC_TRANS'} !~ /^(true|1|yes|y)$/i) {
+	exit run_command($DISTCCBIN, @ARGV);
+}
+
+my $DEBUG = 0;
+
+my $arch_lookup = {
+	ppc   => 'powerpc',
+	ppc64 => 'powerpc',
+	i386  => 'i386',
+};
+
+my $reverse_arch_lookup = {
+	'powerpc' => 'ppc',
+	'i386'    => 'i386',
+};
+
+$ENV{'PATH'} = $DATADIR . '/translated:' . $ENV{'PATH'};
+
+if ($0 =~ /(powerpc|i386)-apple-([^\d]+)(\d+)-(.*)$/) {
+	my ($archname, $os, $version, $compiler) = ($1, $2, $3, $4);
+
+	my @command = ('/usr/bin/' . $compiler);
+	if (exists $reverse_arch_lookup->{$archname}) {
+		push(@command, '-arch', $reverse_arch_lookup->{$archname});
+	}
+	push(@command, @ARGV);
+	exit run_command(@command);
+}
+
+my $compiler = shift(@ARGV) || 'gcc';
+if ($compiler !~ m#/#) {
+	$compiler = which($compiler);
+}
+
+my $arch;
+my @args;
+
+$compiler = render_symlinks($compiler);
+
+my $lastarg;
+for my $arg (@ARGV) {
+	if ($arg eq "-arch") {
+		$lastarg = "arch";
+	} elsif (defined $lastarg and $lastarg eq "arch") {
+		$arch = $arch_lookup->{$arg} if (exists $arch_lookup->{$arg});
+		$lastarg = undef;
+	} else {
+		push(@args, $arg);
+	}
+}
+
+chomp(my $uname = lc(`uname -s -r -p`));
+my ($osname, $version, $archname) = split(/\s+/, $uname);
+$version =~ s/^(\d+).*$/$1/;
+
+if (not defined $arch) {
+	$arch = $archname;
+}
+
+$compiler = "${arch}-apple-${osname}${version}-" . basename($compiler);
+
+my @command = ($DISTCCBIN, $compiler, @args);
+exit run_command(@command);
+
+sub run_command {
+	print STDERR "@command\n" if ($DEBUG);
+
+	my $exit = system(@_);
+
+	if ($exit == -1) {
+		die "failed to execute $DISTCCBIN $compiler @args\n";
+	} elsif ($exit & 127) {
+		printf STDERR "child died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
+	} else {
+		return int($exit >> 8);
+	}
+}
+
+sub render_symlinks {
+	my $filename = shift;
+
+	if (defined $filename and -l $filename) {
+		my $linkname = readlink($filename);
+		if ($linkname !~ m#/#) {
+			$linkname = dirname($filename) . $linkname;
+		}
+		return render_symlinks($linkname);
+	}
+
+	return $filename;
+}
+
+sub which {
+	my $filename = shift;
+
+	for my $dir (split(/:/, $ENV{'PATH'})) {
+		my $fullname = $dir . '/' . $filename;
+		next if (-l $fullname and (readlink($fullname) =~ /distcc/ or readlink($fullname) =~ /ccache/));
+
+		if (-f $dir . '/' . $filename) {
+			return $dir . '/' . $filename;
+		}
+	}
+}
+
+sub basename {
+	my $filename = shift;
+
+	return @{[ $filename =~ m#^.*/([^/]+)$#]}[0];
+}
+
+sub dirname {
+	my $filename = shift;
+
+	return @{[ $filename =~ m#^(.*/)[^/]*$# ]}[0];
+}
--- distcc-2.18.3/src/zeroconf.c	2005-01-07 11:16:35.000000000 -0500
+++ distcc-2.18.3-new/src/zeroconf.c	2007-02-24 12:10:41.000000000 -0500
@@ -2,6 +2,7 @@
 
 #include "config.h"
 
+#include <sys/syslimits.h>
 #include <assert.h>
 #include <stdio.h>
 #include <sys/select.h>
