SUMMARY="Yubico universal 2nd factor (U2F) server C library"
DESCRIPTION="libu2f-server is a server-side implementation
of the U2F protocol, as well as relevant APIs."
HOMEPAGE="https://developers.yubico.com/libu2f-server/
	https://github.com/Yubico/libu2f-server"
COPYRIGHT="2014 Yubico AB"
LICENSE="BSD (2-clause)"
REVISION="4"
SOURCE_URI="https://github.com/Yubico/libu2f-server/archive/libu2f-server-$portVersion.tar.gz"
CHECKSUM_SHA256="6551109e692c9c4fea61e99f1cd8377e8e54e3033e421cc191da6d673311c860"
SOURCE_DIR="libu2f-server-libu2f-server-$portVersion"

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

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

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

PROVIDES="
	libu2f_server$secondaryArchSuffix = $portVersion
	cmd:u2f_server$commandSuffix = $portVersion
	lib:libu2f_server$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libjson_c$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	"

PROVIDES_devel="
	libu2f_server${secondaryArchSuffix}_devel = $portVersion
	devel:libu2f_server$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libu2f_server$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libjson_c$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:gengetopt
	cmd:help2man
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:which
	"

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

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

	prepareInstalledDevelLib libu2f-server
	fixPkgconfig

	packageEntries devel \
		$developDir
}

