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

pkgname=groff
pkgver=1.23.0
pkgrel=2
pkgdesc="GNU troff text-formatting system"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/groff/groff.html"
msys2_references=(
  "cpe: cpe:/a:gnu:groff"
)
license=('spdx:GPL-3.0-or-later')
depends=('perl' 'gcc-libs')
makedepends=('autotools' 'gcc')
optdepends=()
source=(https://ftp.gnu.org/gnu/groff/groff-$pkgver.tar.gz{,.sig}
        site.tmac)
options=('!docs' '!emptydirs' '!makeflags')
sha256sums=('6b9757f592b7518b4902eb6af7e54570bdccba37a871fddb2d30ae3863511c13'
            'SKIP'
            'af59ecde597ce9f8189368a7739279a5f8a391139fe048ef6b4e493ed46e5f5f')
validpgpkeys=('2D0C08D2B0AD0D3D8626670272D23FBAC99D4E75')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  autoreconf -fvi -I m4
}

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

  ./configure \
    --build=${CHOST} \
    --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
}
