+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+EAPI=4
+DESCRIPTION="Man pages for OpenGL"
+HOMEPAGE="http://www.opengl.org/sdk/docs/man/"
+SRC_URI="http://draconx.ca/${P}.tar.xz"
+
+LICENSE="SGI-B-2.0 OPL"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE=""
+
+DEPEND="dev-libs/libxslt
+ app-text/docbook-xsl-stylesheets
+ app-text/docbook-mathml-dtd
+ sys-apps/sed"
+
+manual_heading() {
+ case $1 in
+ man2) printf 'OpenGL 2 Reference Manual' ;;
+ man3) printf 'OpenGL 3 Reference Manual' ;;
+ man4) printf 'OpenGL 4 Reference Manual' ;;
+ glsl) printf 'OpenGL Shading Language Reference Manual' ;;
+ esac
+}
+
+src_compile() {
+ manxsl=/usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl
+
+ for dir in man2; do
+ cd "${S}/$dir" || die
+ cat >metainfo <<EOF
+<refmiscinfo class="manual">$(manual_heading $dir)</refmiscinfo>
+<refmiscinfo class="source">Khronos Group</refmiscinfo>
+EOF
+
+ for i in *.xml; do
+ sed -e '/<refmeta>/r metainfo' "$i" \
+ | xsltproc --nonet --noout "$manxsl" - || die
+ done
+ done
+}
+
+src_install() {
+ cd "${S}/man2"
+ doman *.3G || die
+}