# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=groff
pkgver=1.23.0
pkgrel=6
pkgdesc='GNU troff text-formatting system'
arch=('x86_64')
url='https://www.gnu.org/software/groff/groff.html'
license=('GPL-3.0-or-later')
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')
source=("https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz"{,.sig}
        display-utc-times.patch
	site.tmac)
sha256sums=('6b9757f592b7518b4902eb6af7e54570bdccba37a871fddb2d30ae3863511c13'
            'SKIP'
            '489bb32bbd1c7bced33bf187611219527914ae46ce05238fe80dc11c4b1bb909'
            'fa6ad35f27caaf285a26b1ee87607643552e4c02a641b58a6034b0d153eb920f')

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
}
