pkgname=asciidoc
pkgver=10.2.1
pkgdesc="A plain text human readable/writable document format"
homepage="https://asciidoc.org/ https://github.com/asciidoc-py/asciidoc-py/"
license=("GPL-2")
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/asciidoc-py/asciidoc-py/releases/download/${pkgver}/${sources[0]}")
sha512sums=("02d064aab8dfb05af4ae49a7c7bd1381156c6c90f95b2494218c80f01c39987cb971d68c533b5519abade77be9832b3fab653d8ae2ca7bb682c5bb720612839f")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  sed -i \
    -e '/^build: /a \\tpython3 -m build -wn' \
    -e '/pip install/{s#pip install --root#installer -d#;s#\.$#dist/*.whl#}' \
    Makefile.in
  # https://github.com/asciidoc-py/asciidoc-py/issues/234
  autoconf
}

src_build() {
  ./configure \
      --docdir /usr/share/$pkgname \
      --prefix /usr
  make build
}

src_install() {
  make DESTDIR="${pkgdir}" install
  make DESTDIR="${pkgdir}" docs
  install -Dm0644 -t "$pkgdir/usr/share/man/man1/" doc/*.1
  # ascidocapi is deprecated, but still included in 10.x on a "provisional" basis
  local _platlib="$(python -c 'import sysconfig; print(sysconfig.get_paths()["platlib"])')"
  install -Dm0644 -t "${pkgdir}/${_platlib}/${pkgname}/" asciidoc/api.py
}

# vim:ft=sh syn=sh et sw=2:
