# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DESCRIPTION="Use a laserpointer as Mouse with a camera and gStreamer"
HOMEPAGE="http://wiki.hobbyist.de/?LaserTraq"
SRC_URI="http://www.hobbyist.de/lasertraq/${P}.tar.bz2"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~x86"

IUSE="sdl gtk"
DEPEND="media-libs/gstreamer
	gnome-base/libglade
	media-libs/libsdl
	media-libs/sdl-image"

src_compile() {
	echo "Compiling lasertraqd..."
	cd ${S}/lasertraqd
	econf || die
	emake || die

	if use gtk ; then
	 echo "Compiling traqConfig (gtk configuration program)"
	 cd ${S}/traqConfig
	 econf || die
	 emake || die
	fi

	if use sdl ; then
	 echo "Compiling traqDemo (small SDL demo to visualize mouse-clicks)"
	 cd ${S}/traqDemo
	 econf || die
	 emake || die
	fi
}

src_install() {
	echo "Installing lasertraqd..."
	cd ${S}/lasertraqd
	einstall || die

	if use gtk ; then
	 echo "Installing traqConfig (gtk configuration program)"
	 cd ${S}/traqConfig
	 einstall || die
	else
	 elog "Set gtk USE-Flag to compile configurator GUI"
	fi
	if use sdl ; then
	 echo "Installing traqDemo (small SDL demo to visualize mouse-clicks)"
	 cd ${S}/traqDemo
	 einstall || die
	else
	 elog "Set 'sdl' USE-Flag to compile demo"
	fi

}

pkg_postinst() {
	elog "Copy /usr/share/traqConfig/config.xml and /usr/share/traqConfig/lt.dtd to \$HOME/.lasertraq/"
	elog "For further information see Homepage:"
	elog "http://wiki.hobbyist.de/?LaserTraq"
}