SUMMARY="Create documentation from DocBook"
DESCRIPTION="Provides tools to generate documentation in various format from \
DocBook files."
HOMEPAGE="https://github.com/KDE/kdoctools/"
COPYRIGHT="2010-2022 KDE Organisation"
LICENSE="GNU LGPL v2"
REVISION="2"
SOURCE_URI="https://github.com/KDE/kdoctools/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="8d6af1a614785d2bf9bf90b95dd2cfcb7d35fd3947d2a4cd31e6d88f62f93f5f"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	kdoctools$secondaryArchSuffix = $portVersion
	cmd:checkxml5$secondaryArchSuffix = $portVersion
	cmd:meinproc5$secondaryArchSuffix = $portVersion
	lib:libKF5DocTools$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libexslt$secondaryArchSuffix
	lib:libKF5Archive$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libxslt$secondaryArchSuffix
	"

PROVIDES_devel="
	kdoctools${secondaryArchSuffix}_devel = $portVersion
	devel:libKF5DocTools$secondaryArchSuffix = $portVersion compat >= 5
	"
REQUIRES_devel="
	kdoctools$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	docbook_xml_dtd
	docbook_xsl_stylesheets >= 1.79.2
	extra_cmake_modules$secondaryArchSuffix >= $portVersion
	uri
	devel:libKF5archive$secondaryArchSuffix == $portVersion
#	devel:libKF5i18n$secondaryArchSuffix == $portVersion # breaks the build
	devel:libQt5Core$secondaryArchSuffix >= 5.7
	devel:libxml2$secondaryArchSuffix
	devel:libxslt$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:python2
	"

BUILD()
{
	# disable docs generation until libxml package is fixed
 	sed -i s/add/#add/g docs/CMakeLists.txt

	mkdir -p build
	cd build

	cmake .. $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DECM_MKSPECS_INSTALL_DIR=$dataDir/Qt5/mkspecs \
		-DECM_DIR=/system/data/cmake/Modules/ECM/cmake \
		-DCMAKE_INSTALL_DATAROOTDIR=data \
		-DDocBookXSL_DIR=/system/data/xml/docbook/xsl-stylesheets-1.79.2
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs \
		libKF5DocTools

	packageEntries devel \
		$libDir/cmake \
		$developDir
}

TEST()
{
	cd build
	make test
}
