SUMMARY="Yubico universal 2nd factor (U2F) host C library"
DESCRIPTION="libu2fhost provides a C library and command-line tool \
that implements the host-side of the U2F protocol.
There are APIs to talk to a U2F device and perform the \
U2F Register and U2F Authenticate operations."
HOMEPAGE="https://developers.yubico.com/libu2f-host/
	https://github.com/Yubico/libu2f-host"
COPYRIGHT="2013-2014 Yubico AB"
LICENSE="GNU GPL v3
	GNU LGPL v2"
REVISION="3"
SOURCE_URI="https://github.com/Yubico/libu2f-host/archive/libu2f-host-$portVersion.tar.gz"
CHECKSUM_SHA256="45937c6c04349f865d9f047d3a68cc50ea24e9085d18ac2c7d31fa38eb749303"
SOURCE_DIR="libu2f-host-libu2f-host-$portVersion"
PATCHES="libu2f_host-$portVersion.patchset"

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

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

libVersion="0.1.10"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	libu2f_host$secondaryArchSuffix = $portVersion
	cmd:u2f_host$commandSuffix = $portVersion
	lib:libu2f_host$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libjson_c$secondaryArchSuffix
	lib:libhidapi$secondaryArchSuffix
	"

PROVIDES_devel="
	libu2f_host_devel$secondaryArchSuffix = $portVersion
	devel:libu2f_host$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libu2f_host$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libjson_c$secondaryArchSuffix
	devel:libhidapi$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:gengetopt
	cmd:help2man
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	autoreconf -vfi
	runConfigure --omit-dirs "binDir" ./configure \
		--bindir="$commandBinDir"
	make $jobArgs
}

INSTALL()
{
	make install
	rm -f "$libDir"/*.la

	prepareInstalledDevelLib libu2f-host
	fixPkgconfig

	packageEntries devel \
		$developDir
}
