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

EAPI=5

inherit eutils

DESCRIPTION="Documentation system for many programming languages"
HOMEPAGE="http://developer.apple.com/opensource/tools/headerdoc.html"
SRC_URI="http://www.opensource.apple.com/tarballs/${PN}/${P}.tar.gz"
LICENSE="APSL-2"
SLOT="0"
KEYWORDS="~amd64 ~mips"
IUSE="doc"

DEPEND="dev-libs/libxml2
		dev-lang/perl
		dev-perl/FreezeThaw
		dev-perl/HTML-Parser"
RDEPEND="${DEPEND}"

src_prepare() {
	sed -i \
		-e "s:install -s:install:g" \
		-e 's:make :$(MAKE) :g' \
		Makefile || die "sed failed in Makefile"
}

src_compile() {
	use doc && { emake apidoc || die "emake apidoc failed" ; }
	emake -j1 all_internal || die "emake all_internal failed"
}

src_install() {
	emake DSTROOT="${D}" installsub || die "emake installsub failed"
	use doc && { dodoc -r Documentation/hdapi || \
		die "API documentation installation failed" ; }
}