# Template file for 'tpm2-tss'
pkgname=tpm2-tss
version=4.1.3
revision=1
build_style=gnu-configure
configure_args="
 --disable-weakcrypto
 --with-crypto=ossl
 --with-runstatedir=/run
 --with-sysusersdir=/usr/lib/sysusers.d
 --with-tmpfilesdir=/usr/lib/tmpfiles.d
 --with-imameasurements=/sys/kernel/security/ima/binary_runtime_measurements
 --with-sysmeasurements=/sys/kernel/security/tpm0/binary_bios_measurements"
hostmakedepends="autoconf-archive automake libtool pkg-config doxygen libltdl-devel"
makedepends="libltdl-devel openssl-devel json-c-devel libuuid-devel libcurl-devel libtpms-devel"
checkdepends="cmocka-devel"
short_desc="OSS implementation of the TCG TPM2 Software Stack"
maintainer="Duncaen <duncaen@voidlinux.org>"
license="BSD-2-Clause"
homepage="https://github.com/tpm2-software/tpm2-tss"
distfiles="https://github.com/tpm2-software/tpm2-tss/archive/${version}.tar.gz"
checksum=8a389bda64690910e7af7deaf64703a3faed416dc538c9c3e4f893f24893524d

system_accounts="_tss"

if [ "$XBPS_CHECK_PKGS" ]; then
	configure_args+=" --enable-unit"
fi

post_extract() {
	vsed '/git describe/d' -i bootstrap
	echo "${version}" >VERSION
}

pre_configure() {
	./bootstrap
}

post_install() {
	vlicense LICENSE
}

tpm2-tss-fapi_package() {
	depends="${sourcepkg}>=${version}_${revison} acl-progs"
	short_desc+=" - FAPI"
	pkg_install() {
		vmove "usr/lib/libtss2-fapi.so.*"
		vmove etc/tpm2-tss/fapi-config.json
		vmove etc/tpm2-tss/fapi-profiles
		vmove usr/lib/tmpfiles.d/tpm2-tss-fapi.conf
		vmove usr/share/man/man5/fapi-config.5
		vmove usr/share/man/man5/fapi-profile.5
	}
}

tpm2-tss-devel_package() {
	depends="${sourcepkg}>=${version}_${revision} tpm2-tss-fapi>=${version}_${revision}
	 libcurl-devel openssl-devel json-c-devel libuuid-devel"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		vmove "usr/lib/*.a"
		vmove usr/share/man/man3
	}
}
