# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Daniel Nagy <danielnagy at gmx de>
# Contributor: hauzer <hauzer@gmx.com>

_hkgname=cookie
pkgname=haskell-cookie
pkgver=0.5.0
pkgrel=2
pkgdesc="HTTP cookie parsing and rendering"
url="https://hackage.haskell.org/package/${_hkgname}"
license=('MIT')
arch=('x86_64' 'aarch64')
depends=('ghc-libs' 'haskell-data-default-class')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('f4a320280e01cf1a881f49b5ab037e1618983ce521585fcfe3837ec3292532f804717caa51db0fb42b84e149529cb4e665879af58edd974888b6ab129886d811')

build() {
    cd $_hkgname-$pkgver
    runhaskell Setup configure -O --enable-shared --enable-debug-info --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid -fnetwork-uri
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register   --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
