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

EAPI="4"

DESCRIPTION="Irc bot to share files via dcc"
HOMEPAGE="http://iroffer.dinoex.de/projects/show/iroffer"
SRC_URI="http://iroffer.dinoex.net/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="chroot curl blowfish debug geoip http-admin http-server +memsave ruby +ssl static +telnet tls upnp"

RDEPEND="curl? ( net-misc/curl )
	geoip? ( dev-libs/geoip )
	ruby? ( dev-lang/ruby )
	ssl? ( dev-libs/openssl )
	tls? ( dev-tcltk/tls )"

DEPEND="${RDEPEND}"

src_configure() {
	my_config="PREFIX='/usr'
		LOCALBASE='/usr'"

	if use curl ; then
		my_config="${my_config} -curl"
	fi

	if use debug ; then
		my_config="${my_config} -debug"
	fi

	if use ruby ; then
		my_config="${my_config} -ruby"
	fi

	if use static ; then
		my_config="${my_config} -no-libs"
	fi

	if use tls ; then
		my_config="${my_config} -tls"
	fi

	if use upnp ; then
		my_config="${my_config} -upnp"
	fi

	if ! use admin ; then
		my_config="${my_config} -no-admin" # todo: make dep~ on http
	fi

	if ! use blowfish ; then
		my_config="${my_config} -no-blowfish"
	fi

	if ! use http ; then
		my_config="${my_config} -no-http"
	fi

	if ! use memsave ; then
		my_config="${my_config} -no-memsave"
	fi

	if ! use ssl ; then
		my_config="${my_config} -no-openssl"
	fi

	if ! use telnet ; then
		my_config="${my_config} -no-telnet"
	fi

	./Configure ${my_config}
}

src_install() {
	dobin iroffer

	if use chroot ; then
		dobin iroffer_chroot
	fi

	dodoc LICENSE README-iroffer.txt TODO sample.config dynip.sh iroffer.cron
}