SUMMARY="A small C++ XML Parser"
DESCRIPTION="Tinyxml is a simple, OS independent XML parser for the C++ \
language.
Timyxml was first created to solve the common text I/O file problem. It \
parses the XML into a DOM-like tree and is able to read and write XML files.\
It allows you to create your own document mark-ups or even construct an XML \
document from scratch with C++ objects."
HOMEPAGE="http://www.grinninglizard.com/tinyxml2/"
COPYRIGHT="2011-2018 Lee Thomason"
LICENSE="Zlib"
REVISION="1"
SOURCE_URI="https://github.com/leethomason/tinyxml2/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="a381729e32b6c2916a23544c04f342682d38b3f6e6c0cad3c25e900c3a7ef1a6"

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

libVersion="$portVersion"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	tinyxml2$secondaryArchSuffix = $portVersion
	lib:libtinyxml2$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	tinyxml2${secondaryArchSuffix}_devel = $portVersion
	devel:libtinyxml2$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	tinyxml2$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	mkdir -p build && cd build
	cmake -DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
		-DCMAKE_INSTALL_LIBDIR=$libDir ..

	#this is needed to build xmltest on x86_64
	if [ $targetArchitecture != x86_gcc2 ]; then
		sed -i 's,-fPIE,-fPIC,g' CMakeFiles/xmltest.dir/flags.make
	fi

	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	# prepare development lib links
	prepareInstalledDevelLib libtinyxml2
	fixPkgconfig

	# devel package
	packageEntries devel $developDir
}

TEST()
{
	cd build
	./xmltest
}
