SUMMARY="STM32 discovery line programmer"
DESCRIPTION="stlink is a cheap adapter used to program and debug STM32 \
microcontrollers. This tool allows interfacing the stlink with GDB for easy \
programming and debugging of these chips.
"
HOMEPAGE="https://github.com/texane/stlink"
LICENSE="BSD (3-clause)"
COPYRIGHT="2011 The Capt'ns Missing Link Authors"
REVISION="1"

ARCHITECTURES=""
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"

SOURCE_URI="https://github.com/texane/stlink/archive/1.0.0.tar.gz"
CHECKSUM_SHA256="d80af441be2c2be8a8e431e4ff6608f7c5ae52017c590d1c04b28bf0af0a3ddb"

PROVIDES="
	stlink$secondaryArchSuffix = $portVersion
	cmd:st_flash$secondaryArchSuffix
	cmd:st_info$secondaryArchSuffix
	cmd:st_term$secondaryArchSuffix
	cmd:st_util$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libusb_1.0$secondaryArchSuffix
	"
BUILD_REQUIRES="
	devel:libusb_1.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:aclocal
	cmd:autoreconf
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	./autogen.sh
	runConfigure ./configure
	make $jobArgs LDFLAGS=-lnetwork
}

INSTALL()
{
	make install
}
