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

_hkgname=skylighting
pkgname=haskell-skylighting
pkgver=0.14.3
pkgrel=13
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=('223e228eae72e9edbeec757c6c26eb9729671d7a39243e13efa1898941e7761bbc12757a73004534b231ad40837ebb8a38603b11b8ea1b535518af406cabd6c4')

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
}
