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

EAPI="2"

inherit eutils autotools

DESCRIPTION="Library for working with MIME messages and Internet messaging services like IMAP, POP or SMTP"
HOMEPAGE="http://www.vmime.org"
SRC_URI="mirror://sourceforge/vmime/${P}.tar.bz2
	http://ftp.disconnected-by-peer.at/zarafa/${P}-zarafa-gentoo-4.tar.bz2"


LICENSE="GPL-2"
SLOT="0.7"
KEYWORDS="~amd64 ~arm ~x86"
IUSE="debug doc examples +imap +maildir +pop sasl sendmail +smtp ssl static"

RDEPEND="virtual/libiconv
	ssl? ( >=net-libs/gnutls-1.2.0 )
	sasl? ( virtual/gsasl )
	sendmail? ( virtual/mta )"
DEPEND="${RDEPEND}
	doc? ( app-doc/doxygen )"

src_prepare() {
	EPATCH_SOURCE="${WORKDIR}/patches" EPATCH_SUFFIX="patch" \
	EPATCH_FORCE="yes" epatch
	eautoreconf
#	die
}

src_configure() {
	econf $(use_enable debug) \
		$(use_enable static) \
		$(use_enable sasl) \
		$(use_enable ssl tls) \
		$(use_enable pop messaging-proto-pop3) \
		$(use_enable smtp messaging-proto-smtp) \
		$(use_enable imap messaging-proto-imap) \
		$(use_enable maildir messaging-proto-maildir) \
		$(use_enable sendmail messaging-proto-sendmail)
}

src_compile() {
	default
	if use doc ; then
		doxygen vmime.doxygen || die "doxygen failed"
	fi
}

src_install() {
	emake DESTDIR="${D}" install || die "emake install failed"
	dodoc AUTHORS ChangeLog || die "dodoc failed"
	if use doc ; then
		dohtml doc/html/* || die "dohtml failed"
	fi

	insinto /usr/share/doc/${PF}
	if use examples ; then
		doins -r examples || die "doins examples failed"
	fi
}