# Contributor: Corey Oliver <coreyjonoliver@gmail.com>
# Maintainer: Corey Oliver <coreyjonoliver@gmail.com>
pkgname=argon2
_pkgname=phc-winner-argon2
pkgver=20161029
_soname=0.0.0
pkgrel=1
pkgdesc="The password hash Argon2, winner of PHC"
url="https://github.com/P-H-C/phc-winner-argon2"
arch="all !armhf"
license="Apache-2.0 CC0-1.0"
subpackages="$pkgname-dev libargon2"
source="$pkgname-$pkgver.tar.gz::https://github.com/P-H-C/$_pkgname/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
    cd "$builddir"
    make && make test
}

package() {
    cd "$builddir"
    make DESTDIR="$pkgdir" install || return 1

    # A version number is not appended to the shared library file by default, so we do it ourselves
    mv "$pkgdir"/usr/lib/libargon2.so "$pkgdir"/usr/lib/libargon2.so.$_soname || return 1
    ln -s libargon2.so.$_soname "$pkgdir"/usr/lib/libargon2.so || return 1
	ln -s libargon2.so.$_soname "$pkgdir"/usr/lib/libargon2.so.${_soname%%.*} || return 1
}

libargon2() {
    pkgdesc="The password hash Argon2 library, winner of PHC"
    mkdir -p "$subpkgdir"/usr
    mv "$pkgdir"/usr/lib "$subpkgdir"/usr
}
md5sums="bd3476cb8eac9d521a4e0e04d653f5a8  argon2-20161029.tar.gz"
sha256sums="fe0049728b946b58b94cc6db89b34e2d050c62325d16316a534d2bedd78cd5e7  argon2-20161029.tar.gz"
sha512sums="e1f947a97e8b5f292dd32a6f1ea0ef3f2e411629218653821886ec4e1d5f8289d5b8f4b8bf0a37e69c344a83b975c695947d6b49fd2001a0e4273bebd4792892  argon2-20161029.tar.gz"
