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

_hkgname=cpphs
pkgname=haskell-cpphs
pkgver=1.20.9.1
pkgrel=0
pkgdesc="A liberalised re-implementation of cpp, the C pre-processor."
url="https://projects.haskell.org/cpphs/"
license="LGPL"
arch='x86_64'
depends='ghc haskell-polyparse'
source="https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz"
builddir="$srcdir"/$_hkgname-$pkgver

build() {
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/\$pkgid --ghc-option=-fllvm
    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"
}
sha512sums="
bc5cd86c1e42061ae5c940612542dbea420344fb8596495d71ff2dc724bc1a3785f830e51c3ae99394488a122deabacd6433a5c919e3682c4129f3b296b7931f  cpphs-1.20.9.1.tar.gz
"
