# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=asciidoc
pkgver=9.1.0
pkgrel=2
pkgdesc='Text document format for short documents, articles, books and UNIX man pages.'
arch=('any')
url='https://asciidoc.org/'
license=('GPL')
depends=('python' 'libxslt' 'docbook-xsl')
groups=('base-devel')
# optdepends=('lilypond: music-filter'
            # 'imagemagick: music-filter (used in conjunction with lilypond)'
            # 'source-highlight: source-highlight-filter'
            # 'dblatex: pdf generation'
            # 'fop: alternative pdf generation'
            # 'lynx: text generation'
            # 'w3m: text generation (alternative to lynx)')
source=("https://github.com/asciidoc/asciidoc-py3/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.gz"
        0001-W32-confdir.msys2.patch)
sha256sums=('fd499fcf51317b1aaf27336fb5e919c44c1f867f1ae6681ee197365d3065238b'
            '71f44b513f627b133afead38576fcb8a5460d0514174a4ce219c6ea761d8b40c')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-W32-confdir.msys2.patch
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  autoreconf -fi

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc

  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make install DESTDIR=${pkgdir}

  local _pyver=$(/usr/bin/python -c "import sys;sys.stdout.write('.'.join(map(str, sys.version_info[:2])))")

  install -Dm644 asciidocapi.py \
    ${pkgdir}/usr/lib/python${_pyver}/site-packages/asciidocapi.py
}
