# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>

_hkgname=skylighting
pkgname=haskell-skylighting
pkgver=0.14.1.1
pkgrel=30
pkgdesc="Syntax highlighting library"
url="https://github.com/jgm/skylighting"
license=('GPL2')
arch=('x86_64' 'aarch64')
depends=('ghc-libs' 'haskell-skylighting-core' 'haskell-skylighting-format-ansi'
         'haskell-skylighting-format-blaze-html' 'haskell-skylighting-format-context'
         'haskell-skylighting-format-latex')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('76b4ad20908e0b7e6eee04184e20728bfbcd87c6f68bf540fb4c867fba80ce321f7639aa8171f9c4e33810c379ea04c3d78a5a7b1328187b329d8152ce78c845')

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 --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \
            -f-executable
    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
}

check() {
    cd $_hkgname-$pkgver
    runhaskell Setup test --show-details=direct
}

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"
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
