SUMMARY="The Device Tree Compiler"
DESCRIPTION="The Device Tree Compiler (DTC) is the toolchain for building \
device tree source files (*.dts) into the binary format (*.dtb)."
HOMEPAGE="https://git.kernel.org/cgit/utils/dtc/dtc.git"
SOURCE_URI="git://git.kernel.org/pub/scm/utils/dtc/dtc.git#v1.4.1"
LICENSE="GNU GPL v2"
COPYRIGHT="2005 David Gibson, IBM Corporation"
REVISION="1"

ARCHITECTURES="x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	dtc$secondaryArchSuffix = $portVersion
	cmd:convert_dtsv0 = $portVersion
	cmd:dtc = $portVersion
	cmd:dtdiff = $portVersion
	cmd:fdtdump = $portVersion
	cmd:fdtget = $portVersion
	cmd:fdtput = $portVersion
	lib:libfdt$secondaryArchSuffix = $portVersion
	lib:libfdt_$portVersion$secondaryArchSuffix = $portVersion
	devel:libfdt$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:bison >= 2.5
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

PATCHES="dtc-${portVersion}.patch"

BUILD()
{
	make PREFIX=$prefix $jobArgs
}

INSTALL()
{
	make install PREFIX=$prefix INCLUDEDIR=$includeDir LIBDIR=$libDir

	prepareInstalledDevelLibs libfdt
}

TEST()
{
	make tests
}
