SUMMARY="Library for Interfacing with HID-Class devices"
DESCRIPTION="HIDAPI is a multi-platform library which allows an \
application to interface with USB and Bluetooth HID-Class devices \
on Windows, Linux, FreeBSD, and macOS. HIDAPI can be either built \
as a shared library (.so, .dll or .dylib) or can be embedded directly \
into a target application by adding a single source file (per platform) \
and a single header.

The HIDAPI library was originally developed by Alan Ott (signal11)."
HOMEPAGE="https://github.com/libusb/hidapi"
COPYRIGHT="2010 Alan Ott
	2011 Signal 11 Software
	2019-2020 libusb/hidapi Team"
LICENSE="BSD (3-clause)
	GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/libusb/hidapi/archive/refs/tags/hidapi-$portVersion.tar.gz"
CHECKSUM_SHA256="f71dd8a1f46979c17ee521bc2117573872bbf040f8a4750e492271fc141f2644"
SOURCE_DIR="hidapi-hidapi-$portVersion"

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

PROVIDES="
	hidapi$secondaryArchSuffix = $portVersion
	lib:libhidapi$secondaryArchSuffix = 0.0.0 compat >= 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libusb_1.0$secondaryArchSuffix
	"

PROVIDES_devel="
	hidapi${secondaryArchSuffix}_devel = $portVersion
	devel:libhidapi$secondaryArchSuffix = 0.0.0 compat >= 0
	"
REQUIRES_devel="
	hidapi$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libusb_1.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	./bootstrap

	runConfigure ./configure \
		--disable-dependency-tracking \
		--with-gnu-ld

	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libhidapi.la

	prepareInstalledDevelLib libhidapi
	fixPkgconfig

	packageEntries devel \
		$developDir
}
