# Maintainer: Tobias Powalowski <tpowa@archlinux.org>

pkgname=groff
pkgver=1.23.0
pkgrel=5
pkgdesc='GNU troff text-formatting system'
arch=('x86_64' 'aarch64')
url='https://www.gnu.org/software/groff/groff.html'
license=('GPL')
depends=('perl' 'gcc-libs')
makedepends=('netpbm' 'psutils'  'libxaw' 'perl-file-homedir')
optdepends=('netpbm: for use together with man -H command interaction in browsers'
            'psutils: for use together with man -H command interaction in browsers'
            'libxaw: for gxditview'
            'perl-file-homedir: for use with glilypond')
options=('!docs' '!emptydirs' '!makeflags')
validpgpkeys=('2D0C08D2B0AD0D3D8626670272D23FBAC99D4E75') # Bertrand Garrigues <bertrand.garrigues@laposte.net>
source=("https://ftpmirror.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz"{,.sig}
        display-utc-times.patch
	site.tmac)
sha256sums=('6b9757f592b7518b4902eb6af7e54570bdccba37a871fddb2d30ae3863511c13'
            'SKIP'
            '489bb32bbd1c7bced33bf187611219527914ae46ce05238fe80dc11c4b1bb909'
            'cbcfe19bc1271b91e2c3bb8864813118863a3d8d10e6ca341f82c0ca5dc37dff')

prepare() {
  cd $pkgname-$pkgver
  # always use UTC times for display - using localtime is problematic for reproducible builds
  # fixes FS#69123 - patch taken from Debian
  patch -Np1 -i ../display-utc-times.patch
}  

build() {
  cd $pkgname-$pkgver

  ./configure \
    --prefix=/usr \
    --with-x \
    --with-appresdir=/usr/share/X11/app-defaults
  make
}

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

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  
  # add compatibility symlinks
  ln -s eqn "$pkgdir"/usr/bin/geqn
  ln -s tbl "$pkgdir"/usr/bin/gtbl
  ln -s soelim "$pkgdir"/usr/bin/zsoelim

  cat "$srcdir"/site.tmac >> \
  "$pkgdir"/usr/share/groff/site-tmac/man.local
  cat "$srcdir"/site.tmac >> \
  "$pkgdir"/usr/share/groff/site-tmac/mdoc.local
}
sha256sums=('6b9757f592b7518b4902eb6af7e54570bdccba37a871fddb2d30ae3863511c13'
            'SKIP'
            '489bb32bbd1c7bced33bf187611219527914ae46ce05238fe80dc11c4b1bb909'
            '94f28b32775bcfebf1a50231a2df9791a194d571c1651b465d4875bdea181f96')
