SUMMARY="Distribute compilation of C code across several machines on a network"
DESCRIPTION="
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.

distcc does not require all machines to share a filesystem, have synchronized \
clocks, or to have the same libraries or header files installed. They can even \
have different processors or operating systems, if cross-compilers are \
installed.
"
HOMEPAGE="http://distcc.org/"
COPYRIGHT="2002-2004 by Martin Pool
    2005 Google Inc."
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/distcc/distcc/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="13a4b3ce49dfc853a3de550f6ccac583413946b3a2fa778ddf503a9edc8059b0"
SOURCE_DIR="distcc-$portVersion"
SOURCE_FILENAME="distcc-v$portVersion.tar.gz"
PATCHES="distcc-$portVersion.patchset"

ARCHITECTURES="all !x86_gcc2 ?x86"
SECONDARY_ARCHITECTURES="x86"

PYTHON_VERSION="3.7"

GLOBAL_WRITABLE_FILES="
	settings/default/distcc keep-old
	settings/distcc/hosts keep-old
	settings/distcc/clients.allow keep-old
	settings/distcc/commands.allow.sh keep-old
	"

PROVIDES="
	distcc = $portVersion
	cmd:distcc$secondaryArchSuffix = $portVersion
	cmd:distccd$secondaryArchSuffix = $portVersion
	cmd:distccmon_text$secondaryArchSuffix = $portVersion
	cmd:lsdistcc$secondaryArchSuffix = $portVersion
	cmd:pump$secondaryArchSuffix =$portVersion
	cmd:update_distcc_symlinks$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libpopt$secondaryArchSuffix
	lib:libpython${PYTHON_VERSION}m$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpopt$secondaryArchSuffix
	devel:libpython${PYTHON_VERSION}m$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:g++$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	#cmd:gdb # for testing
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:which
	"

BUILD()
{
	libtoolize --copy --force --install
	./autogen.sh
	export CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE"
	export LDFLAGS="-lbsd -lposix_error_mapper -L`python${PYTHON_VERSION}-config --prefix`/lib/python${PYTHON_VERSION}/config"
	runConfigure ./configure \
		--disable-Werror \
		--without-libiberty
	make $jobArgs
}

INSTALL()
{
	make install
}

TEST()
{
	make check RESTRICTED_PATH=/sources/distcc-${portVersion}:/bin
}
