SUMMARY="StarOffice import library"
DESCRIPTION="Import filter(based on librevenge) to import all StarOffice \
documents."
HOMEPAGE="https://github.com/fosnola/libstaroffice"
COPYRIGHT="2015-2018 Laurent Alonso et al."
LICENSE="MPL v2.0"
REVISION="1"
SOURCE_URI="https://github.com/fosnola/libstaroffice/releases/download/$portVersion/libstaroffice-$portVersion.tar.bz2"
CHECKSUM_SHA256="2033fe841e1ec66fb7448e7aa813ee444e57bde9e10ad53800eb5c1e7f6f268f"

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%%.*}"
portVers="${portVersion%.*}"

PROVIDES="
	libstaroffice$secondaryArchSuffix = $portVersion
	cmd:sd2raw$commandSuffix = $portVersion
	cmd:sd2svg$commandSuffix = $portVersion
	cmd:sd2text$commandSuffix = $portVersion
	cmd:sdc2csv$commandSuffix = $portVersion
	cmd:sdw2html$commandSuffix = $portVersion
	lib:libstaroffice_0.0$secondaryArchSuffix = $portVersion compat >= 0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:librevenge_0.0$secondaryArchSuffix
	lib:librevenge_generators_0.0$secondaryArchSuffix
	lib:librevenge_stream_0.0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libstaroffice${secondaryArchSuffix}_devel = $portVersion
	devel:libstaroffice_0.0$secondaryArchSuffix = $portVersion compat >= 0
	"
REQUIRES_devel="
	libstaroffice$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:librevenge_0.0$secondaryArchSuffix
	#devel:librevenge_generators_0.0$secondaryArchSuffix
	#devel:librevenge_stream_0.0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:autoheader
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libstaroffice$secondaryArchSuffix \
	"$commandBinDir"/sd2raw \
	"$commandBinDir"/sd2svg \
	"$commandBinDir"/sd2text \
	"$commandBinDir"/sdc2csv \
	"$commandBinDir"/sdw2html \
	"$libDir"/libstaroffice-$portVers.so.$libVersion

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

INSTALL()
{
	make install

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

	prepareInstalledDevelLib libstaroffice-$portVers
	fixPkgconfig

	packageEntries devel $developDir
}

TEST()
{
	make check
}
