SUMMARY="Program Silicon Labs 8051 microcontrollers"
DESCRIPTION="Tools for SiLabs C8051 series of microcontrollers and the matching
EC2, EC3, EC5, EC6 debug adapters."
HOMEPAGE="https://github.com/paragonRobotics/ec2-new"
COPYRIGHT="2006 Ricky White"
LICENSE="GNU GPL v2"
REVISION="2"
srcGitRev="e8848813272fb8c85cc497c57d8fb643a6dd169e"
SOURCE_URI="https://github.com/paragonRobotics/ec2-new/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="9c5552a3140a43159de3ce4cf3abfe119cc58e3eafcfacd1564a496b1cf2ffb8"
SOURCE_FILENAME="ec2-new-$portVersion-$srcGitRev.tar.gz"
SOURCE_DIR="ec2-new-$srcGitRev"
PATCHES="ec2drv-$portVersion.patchset"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	ec2drv$secondaryArchSuffix = $portVersion
	cmd:ec2_update_fw$commandSuffix
	cmd:ec2adapters$commandSuffix
	cmd:ec2device$commandSuffix
	cmd:ec2readflash$commandSuffix
	cmd:ec2readfw$commandSuffix
	cmd:ec2test_any$commandSuffix
	cmd:ec2writeflash$commandSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libusb$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libusb$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ninja
	cmd:python
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. -GNinja $cmakeDirArgs
	ninja
}

INSTALL()
{
	mkdir -p "$commandBinDir"
	cp build/bin/* "$commandBinDir"
}
