pkgname=procps-ng
pkgver=3.3.16
pkgrel=1
pkgdesc='Utilities for monitoring your system and its processes'
arch=('i686' 'x86_64')
url='https://gitlab.com/procps-ng/procps'
license=('GPL' 'LGPL')
groups=('sys-utils')
depends=('ncurses')
makedepends=('ncurses-devel')
options=('!emptydirs' 'strip')
conflicts=('procps')
provides=('procps')
#replaces=('procps')
source=("https://downloads.sourceforge.net/project/${pkgname}/Production/${pkgname}-${pkgver}.tar.xz"
         procps-ng-3.3.12-msys2.patch)
sha256sums=('925eacd65dedcf9c98eb94e8978bbfb63f5de37294cc1047d81462ed477a20af'
            'e2d692b45dd2ba9840ec5cd6a25a9106bd0ac3ca36d1b4a120288be6575c6977')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}
  patch -p1 -i ${srcdir}/procps-ng-3.3.12-msys2.patch
  autoreconf -fi
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure \
    --build=${CHOST} \
    --prefix=/usr \
    --bindir=/usr/bin \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib \
    --libdir=/usr/lib \
    --without-libiconv-prefix \
    --without-libintl-prefix \
    CFLAGS="${CFLAGS} -I/usr/include/ncursesw" \
    --enable-watch8bit \
    --disable-kill
    # kill is provided by util-linux

  # Workaround.
  # See https://github.com/msys2/MSYS2-packages/pull/1908#issuecomment-605453647
  make -j proc/libprocps.la

  make -j1
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
}
