SUMMARY="DTX compression library"
DESCRIPTION="The libSquish library compresses images with the DXT standard \
(also known as S3TC). This standard is mainly used by OpenGL and DirectX for \
the lossy compression of RGBA textures."
HOMEPAGE="https://sourceforge.net/projects/libsquish/"
COPYRIGHT="2006 Simon Brown"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/libsquish/files/libsquish-$portVersion.tgz"
CHECKSUM_SHA256="628796eeba608866183a61d080d46967c9dda6723bc0a3ec52324c85d2147269"
SOURCE_DIR=""
PATCHES="libsquish-$portVersion.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	libsquish$secondaryArchSuffix = $portVersion
	lib:libsquish$secondaryArchSuffix = 0.0
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
if [ "$effectiveTargetArchitecture" != x86_gcc2 ]; then
	REQUIRES="$REQUIRES
		lib:libgomp$secondaryArchSuffix
		"
fi

PROVIDES_devel="
	libsquish${secondaryArchSuffix}_devel = $portVersion
	devel:libsquish$secondaryArchSuffix = 0.0
	"
REQUIRES_devel="
	libsquish$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	if [ $effectiveTargetArchitecture = x86_gcc2 ]; then
		SSE2="-DBUILD_SQUISH_WITH_SSE2=OFF"
	else
		SSE2="-DBUILD_SQUISH_WITH_SSE2=ON"
	fi

	mkdir -p build && cd build
	cmake -DCMAKE_BUILD_TYPE=Release \
		$cmakeDirArgs \
		$SSE2 \
		-DBUILD_SHARED_LIBS=ON ..
	make $jobArgs
}

INSTALL()
{
	make -C build install

	prepareInstalledDevelLib libsquish

	packageEntries devel \
		$developDir
}

TEST()
{
	cd build
	./squishtest
}
