# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=procps
pkgver=3.3.15
pkgrel=1
pkgdesc="Utilities for monitoring your system and processes on your system"
url="https://gitlab.com/procps-ng/procps"
arch="all"
license="GPL-2.0+ LGPL-2.0+"
makedepends_build="autoconf automake libtool gettext-tiny"
makedepends_host="ncurses-dev utmps-dev"
checkdepends="dejagnu"
subpackages="$pkgname-dev $pkgname-doc $pkgname-lang libproc"
source="$pkgname-$pkgver.tar.gz::https://gitlab.com/procps-ng/$pkgname/repository/archive.tar.gz?ref=v$pkgver
	0001-pt_BR-fix-translation-error.patch
	use-utmpx.patch"

prepare() {
	# NOTE: Name of the tarball's top-level directory contains SHA1.
	ln -fs $pkgname-v$pkgver-* "$builddir"

	default_prepare

	cd "$builddir"
	./autogen.sh
}

build() {
	cd "$builddir"

	export LIBS="$LIBS -lutmps -lskarnet"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/ \
		--bindir=/bin \
		--sbindir=/sbin \
		--libdir=/lib \
		--mandir=/usr/share/man \
		--sysconfdir=/etc \
		--docdir=/usr/share/doc \
		--datarootdir=/usr/share \
		--disable-static \
		--disable-rpath \
		--with-ncurses \
		ac_cv_func_malloc_0_nonnull=yes \
		ac_cv_func_realloc_0_nonnull=yes
	make
}

check() {
	cd "$builddir"
	# can't use `make check`; 'po' dir has no check target
	make check-TESTS
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" ldconfig=true install="install -D" \
		install

	# These binaries are identical.
	ln -sf pgrep "$pkgdir"/bin/pkill

	install -d "$pkgdir"/usr/lib
	mv "$pkgdir"/include "$pkgdir"/usr/ \
		&& mv "$pkgdir"/lib/pkgconfig "$pkgdir"/usr/lib/
}

libproc() {
	pkgdesc="Library for monitoring system and processes"
	license="LGPL-2.1+"

	install -d "$subpkgdir"/
	mv "$pkgdir"/lib "$subpkgdir"/
}

sha512sums="61017c98827cb9c325fe51f74e9e912cb6b130abdc69742678968a45f4a6f1f033bac4adaed19908197bc97a7426a7a27e04be361edb74ebff3dc0383b71fa53  procps-3.3.15.tar.gz
d63c8df42f74f08f19276a8f4d0260624313801b138aa2b430a105328c3230427d3e81bc016ddde9fc995575e97961a3be8e4f5ded34c874cc613c645605a976  0001-pt_BR-fix-translation-error.patch
6683b94f64848721ebce8254461fbd70a3efd048bf9579c5bbe298bd1ec00594c05640327f0e03475e583607f1f7405139b93fc9f06592d5593174cbf6d4119f  use-utmpx.patch"