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

inherit eutils

P="${PN}src-${PV/_rc/-RC}"

DESCRIPTION="A portable coherent-noise-generating library for C++ compilers"
SRC_URI="mirror://sourceforge/libnoise/${P}"
HOMEPAGE="http://sourceforge.net/projects/libnoise/"

LICENSE="LGPL-2"

KEYWORDS="~x86"
IUSE="doc"

S=${WORKDIR}/noise

DEPEND="doc? ( app-doc/doxygen )"
RDEPEND=""

src_unpack() {
	unpack ${A}
	cd "${S}"
	epatch "${FILESDIR}/libnoise-1.0.0_rc1-makefile.patch"
}

src_compile() {
	emake -j1 || die "compilation error"

	if use doc; then
		emake -j1 doc || die "compilation error"
	fi
}

src_install() {
	emake DESTDIR="${D}" install || die "install failed"
	dolib.a  lib/libnoise.a
	dolib    lib/libnoise.la
	dolib.so lib/libnoise.so.0.3

	if use doc; then
		dohtml -r doc/html/*
	fi
}

pkg_postinst() {
	elog "You should read the documentation and also see the examples."
	elog "Tutorials can be found here:"
	elog "  http://libnoise.sourceforge.net/tutorials/index.html"
	elog "Documentation can be found here:"
	elog "  http://libnoise.sourceforge.net/docs/index.html"
	if use doc; then
		elog "Don't forget to read the local doxygen API documentation!"
		elog "Generated API docs are located in ${ROOT}usr/share/doc/${PF}/html"
	fi
}
