# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI="1"

DESCRIPTION="Command line tool read the content of dBASE III, IV, and 5.0 files, and output schema information, CSV files or SQL instruction sets"
HOMEPAGE="http://developer.berlios.de/projects/dbf/"
MY_PN="${PN}-core"
MY_P="${MY_PN}-${PV}"
SRC_URI="mirror://berlios/dbf/${MY_P}.src.zip"
LICENSE="LGPL-2"
SLOT="0"
KEYWORDS="~x86"
IUSE="doc"

RDEPEND="dev-libs/libdbf"
DEPEND="${RDEPEND}
	app-arch/unzip
	dev-perl/XML-Parser
	doc? ( app-text/docbook-sgml-utils )"

S="${WORKDIR}/${MY_PN}"

src_unpack() {
	unzip "${DISTDIR}/${MY_P}.src.zip" || die "unzip failed"
}

src_compile() {
	cd ${S}
	sed -i 's/docbook-to-man/$(DOC_TO_MAN)/' man/Makefile*
	chmod u+x configure
	if use doc; then
		export DOC_TO_MAN=docbook2man
	fi
	econf || die "econf failed"
        emake || die "emake failed"
	if use doc; then
		mv man/DBF.SECTION man/dbf.1 || die "Error moving man page"
	fi
}

src_install() {
	cd ${S}
	chmod u+x install-sh
        emake DESTDIR="${D}" install || die "make install failed"
}