# This file was generated by https://github.com/berberman/arch-hs, please check it manually.
# Maintainer: Ferdinand Bachmann <theferdi265@gmail.com>

pkgname=sv2v
pkgver=0.0.13
pkgrel=142
pkgdesc="SystemVerilog to Verilog conversion"
url="https://github.com/zachjs/sv2v"
license=("custom: BSD3")
arch=('x86_64')
depends=('ghc-libs' 'haskell-cmdargs' 'haskell-githash' 'haskell-hashable' 'haskell-vector')
makedepends=('ghc' 'alex' 'happy')
source=("https://github.com/zachjs/$pkgname/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('4ce7df8c6fa3857da6a2b69343c29e7c627a4283090f2b07221aa9ef956a88c8')

build() {
  cd $pkgname-$pkgver

  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
    --prefix=/usr --docdir=/usr/share/doc/$pkgname --enable-tests \
    --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \
    --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
    --ghc-option='-pie'

  runhaskell Setup build
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  if [[ -f register.sh ]]; then sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh; fi
  if [[ -f unregister.sh ]]; then sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh; fi
}

package() {
  cd $pkgname-$pkgver

  if [[ -f register.sh ]]; then install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh; fi
  if [[ -f unregister.sh ]]; then install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh; fi
  runhaskell Setup copy --destdir="$pkgdir"
  install -D -m644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
  rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
