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

_hkgname=skylighting
pkgname=haskell-skylighting
pkgver=0.14.4
pkgrel=34
pkgdesc="Syntax highlighting library"
url="https://github.com/jgm/skylighting"
license=('GPL-2.0-only')
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=('6f1709b32cc156030a024548a0b421bda7b625c8db5306c1003e05d2172556128493bcef0f4825590febf5ec56e09ee2531b4e9eefbe4893853140f852c89708')

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
}
