APP=mandoc
VERSION=1.14.5
BUILD=1sml
HOMEPAGE='https://mandoc.bsd.lv/'
DOWNLOAD='https://mandoc.bsd.lv/snapshots/mandoc-1.14.5.tar.gz'
DESC="UNIX manpage compiler suite"
REQUIRES="less zlib"

build() {
  mkandenterbuilddir
  rm -rf $APP-$VERSION

  tar xf $SRCDIR/$APP-$VERSION.tar.?z*
  cd $APP-$VERSION
  fixbuilddirpermissions

  patch -p1 < $SRCDIR/main.c.patch
  patch -p1 < $SRCDIR/fix-tbl-segfault.patch
  patch -p1 < $SRCDIR/shared-libmandoc.patch
  patch -p1 < $SRCDIR/simplify-compat.patch
  patch -p1 < $SRCDIR/outdated-warn-disable.patch

  cp $SRCDIR/configure.local configure.local

  ./configure
  #make CFLAGS="-static"
  make
  make DESTDIR=$PKG PREFIX="" LIBDIR=/lib base-install lib-install

  cp LICENSE $PKGDOCS/
  
  (
    cd $PKG/bin
    for i in apropos makewhatis man whatis ; do
      rm "$PKG"/bin/"$i"
      ln -sf mandoc "$PKG"/bin/"$i"
    done
  )

  mkfinalpkg
}

SHA512SUMS="
cba0c95ebb290cdc33767f8ffe338171c8494924a8bd919ca5626cc0bddbcece5bddf0399136652fbbedcfc96d8276cbf4597af56e37263a22eee756d2dca456  mandoc-1.14.5.tar.lz
0861027ece94c23395df3a235e8320a7353976df79d623a2fdbdd1673c5b745394726600a494d7403d52d18cefbdf9b3b9456b7f3813f8d9fe452a4c384f30e3  fix-tbl-segfault.patch
59eed3d6f6bba6a03cea86dac0cfae085b22aa42304be9671edd4f6e6751a939392977b64271bcfbd5e12052219df6b6be396f7ffdba3c450e16050213792654  main.c.patch
ced05e8b57fb9705c6d8d8570cd6b06ad187511a4c243ac2dbc34064aa164ca49e0c877160134161dcb98ebd5e61a5c23d5741f03ef95903ff56193dd07f36a1  outdated-warn-disable.patch
b1bd2c197584948cc8bab2310e759b8942b9f9479254ffb5a8223cfa6ba03c9e1a4d402c5440b8d9f962be9a020287d3dd8556592c17f2b46f15f405d9d373cb  shared-libmandoc.patch
0979e8ee20d6163669f7ab3ace1f959ba9d831c208785c3522261c72ddc2f60ce8420ed36ea963c46a72b9ffdbcb9199da436b13e14c0ca4d938351d170adfa7  simplify-compat.patch
"
