SUMMARY="Apple Keynote import library"
DESCRIPTION="libetonyek is a library that parses the file format of Apple \
Keynote documents. It supports Keynote versions 2-5."
HOMEPAGE="https://wiki.documentfoundation.org/DLP/Libraries/libetonyek"
COPYRIGHT="Fridrich Strba, David Tardon"
LICENSE="MPL v2.0"
REVISION="3"
SOURCE_URI="https://dev-www.libreoffice.org/src/libetonyek/libetonyek-$portVersion.tar.xz"
CHECKSUM_SHA256="e61677e8799ce6e55b25afc11aa5339113f6a49cff031f336e32fa58635b1a4a"

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

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

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

PROVIDES="
	libetonyek$secondaryArchSuffix = $portVersion
	cmd:key2raw$commandSuffix = $portVersion
	cmd:key2text$commandSuffix = $portVersion
	cmd:key2xhtml$commandSuffix = $portVersion
	cmd:numbers2csv$commandSuffix = $portVersion
	cmd:numbers2raw$commandSuffix = $portVersion
	cmd:numbers2text$commandSuffix = $portVersion
	cmd:pages2html$commandSuffix = $portVersion
	cmd:pages2raw$commandSuffix = $portVersion
	cmd:pages2text$commandSuffix = $portVersion
	lib:libetonyek_$portVers$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:liblangtag$secondaryArchSuffix
	lib:librevenge_0.0$secondaryArchSuffix
	lib:librevenge_generators_0.0$secondaryArchSuffix
	lib:librevenge_stream_0.0$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libetonyek${secondaryArchSuffix}_devel = $portVersion
	devel:libetonyek_0.1$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libetonyek$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:glm
	devel:libboost_system$secondaryArchSuffix
	devel:libboost_container$secondaryArchSuffix
	devel:libcppunit$secondaryArchSuffix
	devel:liblangtag$secondaryArchSuffix
	devel:librevenge_0.0$secondaryArchSuffix
	devel:librevenge_generators_0.0$secondaryArchSuffix
	devel:librevenge_stream_0.0$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	devel:mdds >= 1.4
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:gperf
	"

defineDebugInfoPackage libetonyek$secondaryArchSuffix \
	"$commandBinDir"/key2raw \
	"$commandBinDir"/key2text \
	"$commandBinDir"/key2xhtml \
	"$commandBinDir"/numbers2csv \
	"$commandBinDir"/numbers2raw \
	"$commandBinDir"/numbers2text \
	"$commandBinDir"/pages2html \
	"$commandBinDir"/pages2raw \
	"$commandBinDir"/pages2text \
	"$libDir"/libetonyek-$portVers.so.$libVersion

BUILD()
{
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure --bindir="$commandBinDir" \
		--with-mdds=1.4
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool file
	rm -f "$libDir"/libetonyek-$portVers.la

	prepareInstalledDevelLib libetonyek-$portVers
	fixPkgconfig

	packageEntries devel $developDir
}

TEST()
{
	make check
}
