SUMMARY="Generate documentation from C sources"
DESCRIPTION="GTK-Doc is a project which was started to generate API \
documentation from comments added to C code. It is typically used to \
document the public API of GTK+ and GNOME libraries, but it can also \
be used to document application code."
HOMEPAGE="https://www.gtk.org/gtk-doc/"
COPYRIGHT="2002-2018 Damon Chaplin and Owen Taylor"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://download.gnome.org/sources/gtk-doc/${portVersion%.*}/gtk-doc-$portVersion.tar.xz"
CHECKSUM_SHA256="cc1b709a20eb030a278a1f9842a362e00402b7f834ae1df4c1998a723152bf43"
SOURCE_DIR="gtk-doc-$portVersion"

ARCHITECTURES="any"

PROVIDES="
	gtk_doc = $portVersion
	cmd:gtkdoc_check
	cmd:gtkdoc_depscan
	cmd:gtkdoc_fixxref
	cmd:gtkdoc_mkdb
	cmd:gtkdoc_mkhtml
	cmd:gtkdoc_mkhtml2
	cmd:gtkdoc_mkman
	cmd:gtkdoc_mkpdf
	cmd:gtkdoc_rebase
	cmd:gtkdoc_scan
	cmd:gtkdoc_scangobj
	cmd:gtkdocize
	"
REQUIRES="
	haiku
	pygments_python3
	six_python3
	cmd:perl
	cmd:pkg_config
	cmd:python3
	cmd:xsltproc
	devel:libglib_2.0
	docbook_xsl_stylesheets
	"

BUILD_REQUIRES="
	haiku_devel
	devel:libglib_2.0
	docbook_xml_dtd
	docbook_xsl_stylesheets
	pygments_python3
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:cmake
	cmd:gcc
	cmd:itstool
	cmd:meson
	cmd:msgfmt
	cmd:perl
	cmd:pkg_config
	cmd:python3
	cmd:xsltproc
	"

TEST_REQUIRES="
	lxml_python3
	parameterized_python3
	six_python3
	devel:libglib_2.0
	cmd:bc
	cmd:xmllint
	"

BUILD()
{
	# Generate an XML catalog that includes both the Docbook-XML and Docbook-XSL
	# ones. Linux distros populate a global catalog file using post-install
	# scripts in the docbook packages, but we don't have that yet.
	echo "<!DOCTYPE catalog
	PUBLIC \"-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN\"
	\"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd\">
	<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\"
		prefer=\"public\">
	" > xmlcat

	for i in /system/data/xml/catalog/*
	do
		echo "	<nextCatalog catalog=\"file://$i\"/>" >> xmlcat
	done

	echo "</catalog>" >> xmlcat

	unset meson
	meson build --buildtype=release \
		--prefix="$prefix" --libdir="$libDir" --includedir="$includeDir" \
		--datadir=$dataDir --bindir=$binDir
	meson compile -C build
}

INSTALL()
{
	unset meson
	meson install -C build
}

TEST()
{
	unset meson
	PATH="$sourceDir:$PATH" meson test -C build
}
