SUMMARY="AbiWord import library"
DESCRIPTION="libabw is a library that parses the file format of AbiWord \
documents."
HOMEPAGE="https://wiki.documentfoundation.org/DLP/Libraries/libabw"
COPYRIGHT="Fridrich Strba, David Tardon"
LICENSE="MPL v2.0"
REVISION="1"
SOURCE_URI="https://dev-www.libreoffice.org/src/libabw/libabw-$portVersion.tar.xz"
CHECKSUM_SHA256="e763a9dc21c3d2667402d66e202e3f8ef4db51b34b79ef41f56cacb86dcd6eed"

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

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

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

PROVIDES="
	libabw$secondaryArchSuffix = $portVersion
	cmd:abw2html$commandSuffix = $portVersion
	cmd:abw2raw$commandSuffix = $portVersion
	cmd:abw2text$commandSuffix = $portVersion
	lib:libabw_$portVers$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$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="
	libabw${secondaryArchSuffix}_devel = $portVersion
	devel:libabw_$portVers$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libabw$secondaryArchSuffix == $portVersion base
	"

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

defineDebugInfoPackage libabw$secondaryArchSuffix \
	"$commandBinDir"/abw2html \
	"$commandBinDir"/abw2raw \
	"$commandBinDir"/abw2text \
	"$libDir"/libabw-$portVers.so.$libVersion

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

INSTALL()
{
	make install

	rm -f "$libDir"/libabw-$portVers.la

	prepareInstalledDevelLib libabw-$portVers
	fixPkgconfig

	packageEntries devel $developDir
}

TEST()
{
	make check
}
