pkgname=gawk
pkgver=5.3.2
pkgdesc="GNU version of awk"
arch=('x86_64')
homepage="https://www.gnu.org/software/gawk/"
license=('GPL-3.0-or-later')
sources=("${pkgname}-${pkgver}.tar.xz")
urls=("https://ftp.gnu.org/gnu/${pkgname}/${sources[0]}")
md5sums=("b7014650c5f45e5d4837c31209dc0037")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  sed -i 's/extras//' Makefile.in
}

src_build() {
  ./configure --prefix=/usr
  make
}

src_check() {
  chown -R leaf .
  su leaf -c "PATH=$PATH make check"
}

src_install() {
  make DESTDIR="${pkgdir}" install
  ln -sv gawk.1 "${pkgdir}"/usr/share/man/man1/awk.1
  install -vDm644 doc/{awkforai.txt,*.{eps,pdf,jpg}} -t "${pkgdir}"/usr/share/doc/gawk-${pkgver}
}
