SUMMARY="A portable library for Microsoft compression formats"
DESCRIPTION="The following file formats are supported:
* SZDD files, which use LZSS compression
* KWAJ files, which use LZSS, LZSS+Huffman or deflate compression
* .HLP (MS Help) files, which use LZSS compression
* .CAB (MS Cabinet) files, which use deflate, LZX or Quantum compression
* .CHM (HTML Help) files, which use LZX compression
* .LIT (MS EBook) files, which use LZX compression and DES encryption
* .LZX (Exchange Offline Addressbook) files, which use LZX compression

To determine the capabilities of the library, and the binary compatibility \
version of any particular compressor or decompressor, use the \
mspack_version() function. The UNIX library interface version is defined as \
the highest-versioned library component."
HOMEPAGE="https://www.cabextract.org.uk/libmspack/"
COPYRIGHT="2000-2018 Stuart Caie"
LICENSE="GNU LGPL v2"
REVISION="1"
SOURCE_URI="${HOMEPAGE}libmspack-${portVersion/\~/}.tar.gz"
CHECKSUM_SHA256="bac862dee6e0fc10d92c70212441d9f8ad9b0222edc9a708c3ead4adb1b24a8e"
SOURCE_DIR="libmspack-${portVersion/\~/}"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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

PROVIDES="
	libmspack$secondaryArchSuffix = $portVersion
	lib:libmspack$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libmspack${secondaryArchSuffix}_devel = $portVersion
	devel:libmspack$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libmspack$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:autoheader
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

defineDebugInfoPackage libmspack$secondaryArchSuffix \
	"$libDir"/libmspack.so.$libVersion

BUILD()
{
	runConfigure ./configure
	if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then
		make $jobArgs AM_CFLAGS=-Wall
	else
		make $jobArgs
	fi
}

INSTALL()
{
	make install

	if [ -z "$secondaryArchSuffix" ]; then
		install -d $docDir $developDocDir
		install -t $docDir AUTHORS README
		cp -r doc/* "$developDocDir"
		rm "$developDocDir"/Doxyfile*
		rm "$developDocDir"/Makefile*
	else
		rm -rf "$binDir"
	fi

	rm -f "$libDir"/libmspack.la "$libDir"/libmspack.a

	prepareInstalledDevelLib libmspack
	fixPkgconfig

	packageEntries devel \
		"$developDir"
}

TEST()
{
	make check
	cd test
	./cabd_test
}
