# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Alessio 'mOLOk' Bolognino <themolok@gmail.com>

pkgname=docbook2x
pkgver=0.8.8
pkgrel=19
pkgdesc="A software package that converts DocBook documents into the traditional Unix man page format and the GNU Texinfo format."
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="http://docbook2x.sourceforge.net"
license=("MIT")
depends=('glibc' 'perl-sgmls' 'perl-xml-parser' 'perl-xml-sax' 'libxslt'
	 'jade' 'perl-xml-sax-expat')
makedepends=('texinfo')
source=(https://downloads.sourceforge.net/$pkgname/docbook2X-$pkgver.tar.gz
        datadir.diff)
sha256sums=('4077757d367a9d1b1427e8d5dfc3c49d993e90deabc6df23d05cfe9cd2fcdc45'
            'ffb3fe7052ee0fb0422493e00f97b640f58fcade4ca9d5ac8c0c224e71666569')

prepare() {
  cd "$srcdir"/docbook2X-$pkgver
  patch -p1 <"$srcdir"/datadir.diff
  sed -e 's/AM_CONFIG_HEADER(/AC_CONFIG_HEADERS(/' -i configure.ac
  autoreconf -vfi
}

build()  {
  cd docbook2X-$pkgver
  # to avoid file conflicts with docbook2* from docbook-utils
  ./configure \
    --prefix=/usr \
    --mandir=/usr/share/man \
    --program-transform-name 's,docbook2,db2x_docbook2,'
  make
}

package() {
  cd docbook2X-$pkgver
  make DESTDIR="$pkgdir" install
  install -D -m0644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/license
  sed -i 's|http://docbook2x.sf.net/latest|/usr/share/docbook2X|g' \
    "$pkgdir"/usr/bin/db2x_xsltproc
}
