# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=polyparse
pkgname=haskell-polyparse
pkgver=1.13
pkgrel=3
pkgdesc="A variety of alternative parser combinator libraries."
url="http://code.haskell.org/~malcolm/polyparse/"
license="LGPL"
arch='x86_64'
makedepends='ghc'
source="https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz"
builddir=$srcdir/$_hkgname-$pkgver

prepare() {
    sed -i 's/< *4.14/<5/' $_hkgname.cabal
}

build() {
    runhaskell Setup configure -O --disable-shared --disable-profiling --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib  --libsubdir=\$compiler/\$pkgid
    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() {
    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 "COPYRIGHT" "${pkgdir}/usr/share/licenses/${pkgname}/COPYRIGHT"
    rm -f "${pkgdir}/usr/share/doc/${pkgname}/COPYRIGHT"
}
sha512sums="3b66a73f97d6b5b6628193f87cae1ae1a68d63df0058532b2ac9a62af82dabe28e15fe1464075a2f436e70a7d20b57e72fdd7831f8b11035ff8117becb08d18e  polyparse-1.13.tar.gz"
