# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=skylighting
pkgname=haskell-skylighting
pkgver=0.10.5.1
pkgrel=22
pkgdesc="Syntax highlighting library"
url="https://github.com/jgm/skylighting"
license=('GPL2')
arch=('x86_64')
depends=('ghc-libs' 'haskell-skylighting-core')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('03d157469c73e18d262e6eda771aceba12663e1144d754fce959550db9f0cbf3e9f762fa6e05924f0a24b3e25b14c533e17b69265aa00f7bd24bc425e8ce34c7')

build() {
    cd $_hkgname-$pkgver

    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --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
}

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
}
