# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

_prj=trellis
_pkgname=prj$_prj
pkgname=$_pkgname-git
_commit=%COMMIT%
pkgver=dummy
pkgrel=1
pkgdesc='Documentation and definitions for the Lattice ECP5 bit-stream format'
arch=('x86_64')
url='https://github.com/YosysHQ/prjtrellis'
license=('custom:ISC' 'MIT')
depends=('boost-libs' "$_pkgname-db")
makedepends=('git' 'cmake' 'boost' 'python-sphinx' 'python-sphinx_rtd_theme' 'python-recommonmark')
optdepends=('python: Python support')
provides=("$_pkgname")
conflicts=("$_pkgname")
source=("git+$url.git#commit=$_commit")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  printf "%s.r%s.%s" \
        $(git tag | tail -n1) \
        $(git rev-list --count HEAD) \
        $(git rev-parse --short HEAD)
}

build() {
  mkdir $_pkgname/libtrellis/build
  cd $_pkgname/libtrellis/build

  cmake .. \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib \
    -DCMAKE_BUILD_TYPE=Release

  make

#  cd ../../docs
#
#  make html
}

package() {
  cd $_pkgname

#  install -dm 755 "$pkgdir"/usr/share/doc/$pkgname
#  cp -r --no-preserve=ownership docs/_build/* "$pkgdir"/usr/share/doc/$pkgname/

  install -Dm 644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

  cd libtrellis/build

  make DESTDIR="$pkgdir" install

  # The database is provided in a separate package
  rmdir "$pkgdir"/usr/share/$_prj/database
}

