# Description: A tool to distribute compilations.
# URL: https://github.com/distcc/distcc
# Maintainer: Danny Rawlins, crux at romster dot me
# Optional: avahi gtk3

name=distcc
version=3.4
release=3
source=(https://github.com/distcc/distcc/releases/download/v$version/$name-$version.tar.gz
	distccd distccd.conf)

build() {
	cd $name-$version

	prt-get isinst gtk3 || PKGMK_DISTCC+=' --without-gtk'
	prt-get isinst popt || PKGMK_DISTCC+=' --with-included-popt'

	./autogen.sh

	sed -i 's/ install-gnome-data//g' Makefile.in

	./configure ${PKGMK_DISTCC} \
		--prefix=/usr \
		--sysconfdir=/etc \
		--runstatedir=/run \
		--enable-rfc2553

	make WERROR_CFLAGS= INCLUDESERVER_PYTHON=/usr/bin/python3
	make DESTDIR=$PKG INCLUDESERVER_PYTHON=/usr/bin/python3 install

	# distccd should be in sbin
	mv $PKG/usr/bin/distccd $PKG/usr/sbin/distccd

	# install service
	install -m 0755 -D $SRC/distccd $PKG/etc/rc.d/distccd

	# create the masquerade directory
	install -d $PKG/usr/lib/distcc
	cd $PKG/usr/lib/distcc
	for c in cc c++ gcc g++ cpp; do
		ln -s ../../bin/distcc $c
	done
	cd -

	# install config file
	install -D -m 0644 $SRC/distccd.conf $PKG/etc/distccd.conf

	# cleanup
	rm -r $PKG/usr/share/doc $PKG/etc/distcc $PKG/etc/default
	rm $PKG/usr/sbin/update-distcc-symlinks
}
