SUMMARY="Microsoft Works import library"
DESCRIPTION="libwps is a Microsoft Works file format import filter based on \
top of the librevenge."
HOMEPAGE="https://sourceforge.net/projects/libwps/"
COPYRIGHT="2011-2018 Laurent Alonso
	2006-2014 Fridrich Strba
	2015-2016 Sean Young
	2006-2007 Andrew Ziehm
	2012-2016 David Tardon"
LICENSE="MPL v2.0
	GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://downloads.sourceforge.net/libwps/libwps-$portVersion.tar.xz"
CHECKSUM_SHA256="e21afb52a06d03b774c5a8c72679687ab64891b91ce0c3bdf2d3e97231534edb"

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

portVers="0.4"
libVersion="4.0.${portVersion#$portVers.}"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	libwps$secondaryArchSuffix = $portVersion
	cmd:wks2csv$secondaryArchSuffix
	cmd:wks2raw$secondaryArchSuffix
	cmd:wks2text$secondaryArchSuffix
	cmd:wps2html$secondaryArchSuffix
	cmd:wps2raw$secondaryArchSuffix
	cmd:wps2text$secondaryArchSuffix
	lib:libwps_$portVers$secondaryArchSuffix = $libVersionCompat
	"
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="
	libwps${secondaryArchSuffix}_devel = $portVersion
	devel:libwps_$portVers$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libwps$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 libwps$secondaryArchSuffix \
	"$binDir"/wks2csv \
	"$binDir"/wks2raw \
	"$binDir"/wks2text \
	"$binDir"/wps2html \
	"$binDir"/wps2raw \
	"$binDir"/wps2text \
	"$libDir"/libwps-$portVers.so.$libVersion

BUILD()
{
	libtoolize --force --copy --install
	aclocal
	autoheader
	automake -a -c --foreign
	autoconf
	runConfigure ./configure --with-sharedptr=c++11
	make $jobArgs
}

INSTALL()
{
	make install

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

	prepareInstalledDevelLib libwps-$portVers
	fixPkgconfig

	packageEntries devel $developDir
}

TEST()
{
	make check
}
