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

pkgname=groff
pkgver=1.22.4
pkgrel=1
pkgdesc="GNU troff text-formatting system"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/groff/groff.html"
license=('GPL')
groups=('base-devel')
depends=('perl' 'gcc-libs')
makedepends=()
optdepends=()
source=(https://ftp.gnu.org/gnu/groff/groff-$pkgver.tar.gz{,.sig}
        site.tmac
        groff-1.22.4-msys2.patch)
options=('!docs' '!emptydirs' '!makeflags')
install=groff.install
sha256sums=('e78e7b4cb7dec310849004fa88847c44701e8d133b5d4c13057d876c1bad0293'
            'SKIP'
            'af59ecde597ce9f8189368a7739279a5f8a391139fe048ef6b4e493ed46e5f5f'
            '07743afae5521c41119307642f6c44913cda09c1a82cda95b88ce4d582d74884')
validpgpkeys=('2D0C08D2B0AD0D3D8626670272D23FBAC99D4E75')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/groff-1.22.4-msys2.patch

  autoreconf -fvi -I m4
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure --prefix=/usr
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install

  rm -f ${pkgdir}/usr/lib/charset.alias

  # FS33760 - TERMCAP variables not followed
  # TODO: everyone is doing this - find out why upstream does not...
  cat ${srcdir}/site.tmac >> \
    ${pkgdir}/usr/share/groff/site-tmac/man.local
  cat ${srcdir}/site.tmac >> \
    ${pkgdir}/usr/share/groff/site-tmac/mdoc.local
}
