# SliTaz package receipt.

PACKAGE="gpm"
VERSION="1.20.7"
CATEGORY="misc"
SHORT_DESC="Mouse server for console."
MAINTAINER="pascal.bellard@slitaz.org"
LICENSE="GPL2"
TARBALL="$PACKAGE-$VERSION.tar.bz2"
WEB_SITE="https://www.nico.schottelius.org/software/gpm/"
WGET_URL="https://www.nico.schottelius.org/software/gpm/archives/$TARBALL"
HOST_ARCH="i486 arm"

DEPENDS="ncurses"
BUILD_DEPENDS="gawk bison ncurses-dev automake autoconf libtool texinfo"

# When cross compiling gawk and bison build system are used.
case "$ARCH" in
	arm) BUILD_DEPENDS="" ;;
esac

# What is the latest version available today?
current_version()
{
	wget -O - ${WGET_URL%/*} 2>/dev/null | \
	sed "/latest/d;/$PACKAGE-[0-9]/!d;/tar/!d;s|.*$PACKAGE-\\(.*\\).tar.*|\\1|" | sort -Vr | sed q
}

# Rules to configure and make the package.
compile_rules()
{
	cd $src
	./autogen.sh
	ln -s headers/gpm.h src		# ???
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		$CONFIGURE_ARGS &&
	make && make install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/lib
	cp -a $install/usr/sbin $fs/usr
	cp -a $install/usr/lib/*.so* $fs/usr/lib
	chmod a+x $fs/usr/lib/*
	cp -a $stuff/* $fs
}

# Pre and post install commands for Tazpkg.
pre_remove()
{
	[ -n "$1" ] || /etc/init.d/gpm stop
}

post_install()
{
	[ -n "$1" -o -s /aufs-umount.sh ] || /etc/init.d/gpm start
}