SUMMARY="YubiKey Personalization package"
DESCRIPTION="A library and command line tool used to personalize \
(i.e., set a AES key) YubiKeys."
HOMEPAGE="https://developers.yubico.com/yubico-c-client/"
COPYRIGHT="2008-2019 Yubico AB"
LICENSE="BSD (2-clause)"
REVISION="2"
SOURCE_URI="https://developers.yubico.com/yubikey-personalization/Releases/ykpers-$portVersion.tar.gz"
CHECKSUM_SHA256="0ec84d0ea862f45a7d85a1a3afe5e60b8da42df211bb7d27a50f486e31a79b93"
# patch taken from Arch Linux
PATCHES="0001-fix-boolean-value-with-json-c-0.14.patch"

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

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

PROVIDES="
	ykpers$secondaryArchSuffix = $portVersion
	cmd:ykchalresp$secondaryArchSuffix = $portVersion
	cmd:ykinfo$secondaryArchSuffix = $portVersion
	cmd:ykpersonalize$secondaryArchSuffix = $portVersion
	lib:libykpers_1$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libjson_c$secondaryArchSuffix
	lib:libusb_1.0$secondaryArchSuffix
	lib:libyubikey$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcurl$secondaryArchSuffix
	devel:libjson_c$secondaryArchSuffix
	devel:libusb_1.0$secondaryArchSuffix
	devel:libyubikey$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:autoheader
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

BUILD()
{
	autoreconf -vfi
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libykpers-1.la

	prepareInstalledDevelLib libykpers-1
	fixPkgconfig

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $manDir
	fi

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
