SUMMARY="A validating XML parser written in a portable subset of C++"
DESCRIPTION="This library makes it easy to give your application the ability \
to read and write XML data. A shared library is provided for parsing, \
generating, manipulating, and validating XML documents using the DOM, SAX, \
and SAX2 APIs."
HOMEPAGE="https://xerces.apache.org/xerces-c/"
COPYRIGHT="1999-2018 The Apache Software Foundation"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="http://apache.mirrors.tds.net/xerces/c/3/sources/xerces-c-$portVersion.tar.bz2"
CHECKSUM_SHA256="45c2329e684405f2b8854ecbddfb8d5b055cdf0fe4d35736cc352c504989bbb6"
SOURCE_DIR="xerces-c-$portVersion"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	xerces_c$secondaryArchSuffix = $portVersion
	lib:libxerces_c_3.2$secondaryArchSuffix
	cmd:CreateDOMDocument$commandSuffix
	cmd:DOMCount$commandSuffix
	cmd:DOMPrint$commandSuffix
	cmd:EnumVal$commandSuffix
	cmd:MemParse$commandSuffix
	cmd:PParse$commandSuffix
	cmd:PSVIWriter$commandSuffix
	cmd:Redirect$commandSuffix
	cmd:SAX2Count$commandSuffix
	cmd:SAX2Print$commandSuffix
	cmd:SAXCount$commandSuffix
	cmd:SAXPrint$commandSuffix
	cmd:SCMPrint$commandSuffix
	cmd:SEnumVal$commandSuffix
	cmd:StdInParse$commandSuffix
	cmd:XInclude$commandSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	xerces_c${secondaryArchSuffix}_devel = $portVersion
	devel:libxerces_c_3.2$secondaryArchSuffix
	devel:libxerces_c$secondaryArchSuffix
	"
REQUIRES_devel="
	xerces_c$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcrypto$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:cmp
	cmd:g++$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	export LDFLAGS="-lnetwork -lbsd"
	export CPPFLAGS="-D_BSD_SOURCE"
	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install-strip

	rm "$libDir"/libxerces-c.*a

	prepareInstalledDevelLibs libxerces-c
	fixPkgconfig

	ln -s --relative $libDir/libxerces-c-3.2.so $developLibDir

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
