# SliTaz package receipt.

PACKAGE="ndiswrapper-driver64"
VERSION="1.63"
CATEGORY="system-tools"
TAGS="windows wireless network"
SHORT_DESC="Add Windows network drivers support to Linux kernel."
MAINTAINER="erjo@slitaz.org"
LICENSE="GPL"
WEB_SITE="https://sourceforge.net/projects/ndiswrapper/"

SOURCE="ndiswrapper"
TARBALL="$SOURCE-$VERSION.tar.gz"
WGET_URL="$SF_MIRROR/$SOURCE/stable/$TARBALL"

PROVIDE="ndiswrapper-driver:linux64"
DEPENDS="linux64"
BUILD_DEPENDS="linux64-module-headers uclibc-cross-compiler-x86_64 xz"

AUFS_NOT_RAMFS="uclibc-cross-compiler-x86_64 is not compatible with aufs+tmpfs 8("

# What is the latest version available today?
current_version()
{
	wget -O - https://sourceforge.net/projects/ndiswrapper/files/stable/ 2>/dev/null | \
	sed '/scope="row/!d;s|.*/ndiswrapper-||;s|.tar.*||;q'
}

# Rules to configure and make the package.
# Rules to configure and make the package.
compile_rules()
{
	sed -i 's|error Multiple|echo Multiple|' driver/Makefile

	make	KBUILD=/usr/src/linux	\
		KVER=linux-${kvers}-slitaz64

	xz driver/ndiswrapper.ko
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	EXTRAVERSION=_${kvers}
	mkdir -p $fs/sbin
	mkdir -p $fs/lib/modules/${kvers}-slitaz64/kernel/misc

	# Install utilities
	install -o root -m 0755 $src/utils/loadndisdriver \
		$fs/sbin/
	install -o root -m 0644 $src/driver/ndiswrapper.ko.xz \
		$fs/lib/modules/${kvers}-slitaz64/kernel/misc/ndiswrapper.ko.xz
}

# Post install/remove commands for Tazpkg.
post_install()
{
	chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz64
}

post_remove()
{
	chroot "$1/" depmod -a ${EXTRAVERSION#_}-slitaz64
}