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

EAPI=2

inherit distutils eutils

DESCRIPTION="Powerful IMAP/Maildir synchronization and reader support"
SRC_URI="mirror://debian/pool/main/o/offlineimap/${P/-/_}.orig.tar.gz"
HOMEPAGE="http://software.complete.org/offlineimap"
LICENSE="GPL-2"
KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
SLOT="0"
IUSE="doc ssl"

DEPEND="doc? ( app-text/docbook-sgml-utils )"
RDEPEND="dev-lang/python[threads,ssl?]"

DOCS="offlineimap.conf offlineimap.conf.minimal offlineimap.sgml"

src_prepare() {
	epatch \
		"${FILESDIR}"/${PN}-6.2.0-darwin10.patch
}

src_compile() {
	distutils_src_compile

	# the provided Makefile does other broken stuff, doing it manually
	if use doc ; then
		docbook2man offlineimap.sgml || die "docbook2man failed"
		docbook2man offlineimap.sgml || die "docbook2man failed"
		docbook2html -u offlineimap.sgml || die "docbook2html failed"
	fi
}

src_install() {
	distutils_src_install

	if use doc ; then
		dohtml *.html
		doman offlineimap.1
	fi
}

pkg_postinst() {
	elog ""
	elog "You will need to configure offlineimap by creating ~/.offlineimaprc"
	elog "Sample configurations are in /usr/share/doc/${PF}/"
	elog ""
}