description="Provides a way to load and enumerate PKCS 11 modules."
url="http://p11-glue.freedesktop.org/p11-kit.html"

packager="tnut <tnut@nutyx.org>"
contributors="Pierre B"

makedepends=(libffi libtasn1 gtk-doc libxslt)

name=p11-kit
version=0.23.20

source=(https://github.com/p11-glue/p11-kit/releases/download/$version/$name-$version.tar.xz)

build() {
cd $name-$version
sed '20,$ d' -i trust/trust-extract-compat.in &&
cat >> trust/trust-extract-compat.in << "EOF"
# Copy existing anchor modifications to /etc/ssl/local
/usr/libexec/make-ca/copy-trust-modifications

# Generate a new trust store
/usr/sbin/make-ca -f -g
EOF

./configure --prefix=/usr \
            --sysconfdir=/etc \
            --with-trust-paths=/etc/pki/anchors \
            --enable-doc
make
make DESTDIR=$PKG install

ln -s /usr/libexec/p11-kit/trust-extract-compat \
      $PKG/usr/bin/update-ca-certificates

if [ -f $PKG/etc/pkcs11/pkcs11.conf.example ]; then
	mv $PKG/etc/pkcs11/pkcs11.conf{.example,}
fi

# Obsolets libs
rm $PKG/usr/lib/libp11-kit.la
rm $PKG/usr/lib/pkcs11/p11-kit-{client,trust}.la
}
