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

EAPI="2"

DESCRIPTION="Fast, multi-threaded malloc() and nifty performance analysis tools"
HOMEPAGE="http://code.google.com/p/google-perftools/"
SRC_URI="http://google-perftools.googlecode.com/files/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+omitfp static-libs"

DEPEND="omitfp? ( >=sys-libs/libunwind-0.99 )
	!omitfp? ( >=sys-libs/glibc-2.9[-glibc-omitfp] )"
RDEPEND="${DEPEND}"

src_configure() {
	econf \
		$(use_enable static-libs static) \
		$(use_enable !omitfp frame-pointers)
}

src_install() {
	emake DESTDIR="${D}" install || die "emake install failed"

	rm -rf "${D}/usr/share/doc"

	# see below why we install INSTALL
	dodoc README* AUTHORS ChangeLog TODO INSTALL
	dohtml -r doc/*

	if ! use static-libs ; then
		rm "${D}"/usr/lib*/*.la
	fi
}

pkg_postinst() {
	if use amd64 ; then
		elog "Make sure you read the INSTALL file in case"
		elog "you experience lockups."
	fi
}