# Maintainer: Jonas Witschel <diabonas@archlinux.org>
pkgname=libtpms
pkgver=0.9.6
_tag=fccd9f0ec5febf75ccec2742e75889cdfa329e53 # git rev-parse "v$pkgver"
pkgrel=1.1
pkgdesc='Library providing a software emulation of a Trusted Platform Module (TPM 1.2 and TPM 2.0)'
url='https://github.com/stefanberger/libtpms'
license=('BSD')
ncxfat_makedepends=('openssl' 'gcc' 'binutils')
ncxfab_makedepends=('git' 'autoconf' 'automake' 'perl' 'libtool' 'pkgconfig')
source=("git+$url.git?signed#tag=$_tag")
sha512sums=('SKIP')
#options=(!lto)
validpgpkeys=('B818B9CADF9089C2D5CEC66B75AD65802A0B4211') # Stefan Berger <stefanb@linux.vnet.ibm.com>

pkgver() {
	cd libtpms
	git describe | sed 's/^v//;s/\([^-]*-\)g/r\1/;s/-/./g'
}

prepare() {
	cd libtpms
	autoreconf --install --force
}

build() {
	cd libtpms

	./configure \
		--host=$MPKG_TARGETMACHINE \
		--prefix=$MPKG_USRPATH \
		--with-openssl
	make V=1 # LIBTOOLFLAGS="-Xcompiler -Wno-error=stringop-overflow"
}

check() {
	cd libtpms
	make check
}

package() {
	ncxfat_depends=('openssl')
	cd libtpms
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
