SUMMARY="Portable version of NetBSD make"
DESCRIPTION="Bmake is derived from NetBSD's make(1), its goal is to be a \
portable version of same, so new features are added via imports of NetBSD's \
make (I'm one of the contributors to NetBSD). Thus bmake is kept in sync with \
NetBSD's make.

This version of Make features several extensions that are not in GNU Make, and \
does not has all of GNU Make extensions. Some projects explicitly require one \
or the other."
HOMEPAGE="http://www.crufty.net/help/sjg/bmake.htm"
COPYRIGHT="1990-2018 NetBSD and sjg"
LICENSE="BSD (3-clause)"
REVISION="1"
SOURCE_URI="http://www.crufty.net/ftp/pub/sjg/bmake-$portVersion.tar.gz"
CHECKSUM_SHA256="fc0948b4eb0cf21fcec4f89660c0295150c55bf070d4b7445858947f84f7e67e"
SOURCE_DIR="bmake"

ARCHITECTURES="all"

PROVIDES="
	bmake = $portVersion
	cmd:bmake = $portVersion
	"
REQUIRES="
	haiku
	"

BUILD_REQUIRES="
	haiku_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:awk
	cmd:diff
	cmd:gcc
	cmd:libtoolize
	cmd:make
	cmd:sed
	"

PATCH()
{
	# This seems to be the only way to nicely workaround a "Force these"
	sed -i \
		-e "/^SHAREDIR=/ s|/share|/$relativeDataDir|;" \
		Makefile
}

BUILD()
{
	autoreconf -vfi
	runConfigure ./configure --with-default-sys-path="$dataDir"/mk
	make MANDIR="$manDir"
}

INSTALL()
{
	# The install process needs a root user, and there is no such thing in the
	# chroot.
	echo "root:x:0:" > /etc/group
	useradd root || true # Don't fail if user already exists

	make install MANDIR="$manDir"
}

TEST()
{
	# not sure if this is really needed, test are run in BUILD()
	make test
}
