# Template file for 'kmod'
pkgname=kmod
version=15
revision=1
build_style=gnu-configure
configure_args="--with-zlib --with-xz"
hostmakedepends="pkg-config libxslt"
makedepends="zlib-devel liblzma-devel"
short_desc="Linux kernel module handling"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2"
homepage="http://git.profusion.mobi/cgit.cgi/kmod.git"
distfiles="${KERNEL_SITE}/utils/kernel/kmod/kmod-${version}.tar.xz"
checksum=e8ef0ea7e1929b46aa681fe6ce58c5e62d0026289026ebfc63abae3b8fd5ca9e
long_desc="
 kmod is a set of tools to handle common tasks with Linux kernel modules like
 insert, remove, list, check properties, resolve dependencies and aliases."

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" libtool automake"
	pre_configure() {
		autoreconf -fi
	}
fi

post_install() {
	vinstall ${FILESDIR}/depmod-search.conf 644 usr/lib/depmod.d search.conf
	# Add compatibility symlinks.
	vmkdir usr/sbin
	for tool in {ls,ins,rm,dep}mod mod{info,probe}; do
		cd ${DESTDIR}/usr/sbin
		ln -sf ../bin/kmod $tool
	done
}

libkmod_package() {
	short_desc+=" - runtime shared library"
	pkg_install() {
		vmove "usr/lib/*.so.*"
	}
}

libkmod-devel_package() {
	depends="zlib-devel liblzma-devel libkmod>=${version}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
	}
}

kmod_package() {
	make_dirs="
		/etc/depmod.d 0755 root root
		/etc/modprobe.d 0755 root root
		/usr/lib/depmod.d 0755 root root
		/usr/lib/modprobe.d 0755 root root"
	provides="module-init-tools-3.17"
	replaces="module-init-tools>=0"
	pkg_install() {
		vmove all
	}
}