SUMMARY="Library to read Adobe PageMaker files"
DESCRIPTION="Libpagemaker is a library that parses the file format of \
Aldus/Adobe PageMaker documents. Currently it only understands documents \
created by PageMaker version 6.x and 7."
HOMEPAGE="https://wiki.documentfoundation.org/DLP/Libraries/libpagemaker"
COPYRIGHT="2013-2014, 2017 Fridrich Štrba
	2014 Anurag Kanungo
	2014 Brennan Vincent
	2014-2018 David Tardon"
LICENSE="MPL v2.0"
REVISION="2"
SOURCE_URI="https://dev-www.libreoffice.org/src/libpagemaker/libpagemaker-$portVersion.tar.xz"
CHECKSUM_SHA256="66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d"
PATCHES="libpagemaker-$portVersion.patchset"

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

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

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

portVersionCompat="$portVersion compat >= ${portVersion%%.*}"
portVers="${portVersion%.*}"
PROVIDES="
	libpagemaker$secondaryArchSuffix = $portVersion compat >= 0
	cmd:pmd2raw$commandSuffix = $portVersion compat >= 0
	cmd:pmd2svg$commandSuffix = $portVersion compat >= 0
	cmd:pmd2text$commandSuffix = $portVersion compat >= 0
	lib:libpagemaker_$portVers$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:librevenge_0.0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libpagemaker${secondaryArchSuffix}_devel = $portVersion compat >= 0
	devel:libpagemaker_$portVers$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libpagemaker${secondaryArchSuffix} == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix >= 1.69.0
	devel:librevenge_0.0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:autoheader
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libpagemaker$secondaryArchSuffix \
	"$commandBinDir"/pmd2raw \
	"$commandBinDir"/pmd2svg \
	"$commandBinDir"/pmd2text \
	"$libDir"/libpagemaker-$portVers.so.$libVersion

BUILD()
{
	libtoolize --force --copy
	aclocal -I m4
	autoheader
	automake -a -c --foreign
	autoconf
	runConfigure --omit-dirs binDir ./configure --bindir="$commandBinDir"
	make $jobArgs
}

INSTALL()
{
	make install

	rm $libDir/libpagemaker*.la

	# set up the develop directory correctly
	prepareInstalledDevelLib libpagemaker-$portVers
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
