# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-im/climm/climm-0.6.4.ebuild,v 1.1 2009/02/23 19:36:59 jokey Exp $

DESCRIPTION="ICQ text-mode client with many features"
HOMEPAGE="http://www.climm.org/"
SRC_URI="http://www.climm.org/source/${P}.tgz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="xmpp gnutls otr tcl ssl"

DEPEND="xmpp? ( dev-libs/iksemel )
	gnutls? ( >=net-libs/gnutls-0.8.10 )
	ssl? (
		|| ( gnutls? ( >=net-libs/gnutls-0.8.10 )
		dev-libs/openssl ) )
	tcl? ( dev-lang/tcl )
	otr? ( >=net-libs/libotr-3.0.0 )"

pkg_setup() {
	if use xmpp && ! use gnutls ; then
	    eerror "You need to set the gnutls flag when you want to use"
	    eerror "the libiksemel Jabber library"
	    die "Set gnutls or unset xmpp for ${PN}"
	fi

	if use gnutls && ! use ssl ; then
		eerror "The gnutls flag can only be used with the ssl flag enabled"
		die "Set ssl or unset gnutls for ${PN}"
	fi
}


src_compile() {
	local myconf
	if use ssl ; then
		if ! use gnutls ; then
			elog "Using openSSL"
			myconf="--enable-ssl=openssl"
		else
			elog "Using gnutls"
			myconf="--enable-ssl=gnutls"
		fi
	else
		myconf="--disable-ssl"
	fi

	econf \
		$(use_enable xmpp) \
		$(use_enable otr) \
		$(use_enable ssl) \
		$(use_enable tcl) \
		${myconf} \
		|| die "econf failed"

	emake || die "emake failed"
}

src_install() {
	emake DESTDIR="${D}" install || die "emake install failed"
	dodoc AUTHORS ChangeLog FAQ INSTALL NEWS README TODO
}