# Template file for 'procps-ng'
pkgname=procps-ng
version=3.3.8
revision=1
short_desc="Utilities for monitoring your system and its processes"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2, LGPL-2.1"
homepage="http://gitorious.org/procps"

nofetch=yes
noextract=yes

hostmakedepends="libtool automake gettext-devel pkg-config"
makedepends="ncurses-devel"

do_fetch() {
	git clone git://gitorious.org/procps/procps.git \
		-b v${version} ${pkgname}-${version}
}

do_configure() {
	echo ${version} > .tarball-version
	./autogen.sh

	./configure ${configure_args} --exec-prefix=/ \
		--prefix=/usr --libdir=/usr/lib --disable-static \
		ac_cv_func_malloc_0_nonnull=yes \
		ac_cv_func_realloc_0_nonnull=yes \
		ac_cv_func_strtod=yes ac_cv_func_mmap_fixed_mapped=yes
}

do_build() {
	make ${makejobs}
}

do_install() {
	make DESTDIR=${DESTDIR} install

	vinstall ${FILESDIR}/sysctl.conf 644 etc

	# provided by util-linux
	rm ${DESTDIR}/bin/kill
	rm ${DESTDIR}/usr/share/man/man1/kill.1

	vmkdir usr/bin
	vmkdir usr/sbin
	mv ${DESTDIR}/bin/* ${DESTDIR}/usr/bin
	mv ${DESTDIR}/sbin/* ${DESTDIR}/usr/sbin

	# Create pidof symlink.
	ln -sfr ${DESTDIR}/usr/bin/pgrep ${DESTDIR}/usr/bin/pidof

	# Remove devel and docs.
	rm -rf ${DESTDIR}/usr/share/doc \
		${DESTDIR}/usr/include ${DESTDIR}/usr/lib/pkgconfig

}

procps-ng_package() {
	conf_files="/etc/sysctl.conf"
	replaces="procps>=0"
	provides="procps-${version}"
	conflicts="coreutils<8.21_3"
	pkg_install() {
		vmove all
	}
}
