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

inherit eutils

DESCRIPTION="Viking is a free/open source program to manage GPS data."
HOMEPAGE="http://viking.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
IUSE="google old-google terraserver expedia openstreetmap geocaches"
KEYWORDS="~x86"

RDEPEND=""
DEPEND=">=x11-libs/gtk+-2.8 \
	net-misc/curl"

pkg_preinst(){
	if use geocaches; then
		einfo "The geocaches use flag is selected. This feature is actually
		broken and will be disabled."
	fi
}

src_unpack(){
	unpack "${A}"
	cd "${S}"
}

src_compile() {
	local myconf="";

	if use google ; then
		myconf="${myconf} --enable-google"
	else
		myconf="${myconf} --disable-google"
	fi
	
	if use old-google ; then
		myconf="${myconf} --enable-old-google"
	else
		myconf="${myconf} --disable-old-google"
	fi

	if use terraserver ; then
		myconf="${myconf} --enable-terraserver"
	else
		myconf="${myconf} --disable-terraserver"
	fi

	if use expedia ; then
		myconf="${myconf} --enable-expedia"
	else
		myconf="${myconf} --disable-expedia"
	fi

	if use openstreetmap ; then
		myconf="${myconf} --enable-openstreetmap"
	else
		myconf="${myconf} --disable-openstreetmap"
	fi

	if use geocaches ; then
		#broken feature
		myconf="${myconf}"
		#myconf="${myconf} --enable-geocaches"
	else
		myconf="${myconf} --disable-geocaches"
	fi

	econf ${myconf} || die "configure failed"

	emake -j1 || die "emake failed"
}

src_install() {
	cd "${S}"
	make DESTDIR="${D}" install || die "Install failed"
	dodoc README* || die "Unable to install viking doc"
}


