SUMMARY="This is a compression library"
DESCRIPTION="Zopfli Compression Algorithm is a zlib (gzip, deflate) \
compatible compressor programmed in C"
HOMEPAGE="https://github.com/google/zopfli"
COPYRIGHT="2011-2018 Google Inc."
LICENSE="Apache v2"
REVISION="3"
SOURCE_URI="$HOMEPAGE/archive/zopfli-$portVersion.tar.gz"
CHECKSUM_SHA256="e955a7739f71af37ef3349c4fa141c648e8775bceb2195be07e86f8e638814bd"
SOURCE_DIR="zopfli-zopfli-$portVersion"

ARCHITECTURES="all !x86_gcc2 ?arm ?ppc"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

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

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

PROVIDES="
	zopfli$secondaryArchSuffix = $portVersion
	cmd:zopfli
	cmd:zopflipng
	lib:libzopfli$secondaryArchSuffix = $libVersionCompat
	lib:libzopflipng$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	zopfli${secondaryArchSuffix}_devel = $portVersion
	devel:libzopfli$secondaryArchSuffix = $libVersion
	devel:libzopflipng$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	zopfli$secondaryArchSuffix == $portVersion base
	"

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

BUILD()
{
	mkdir -p build && cd build
	cmake .. \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=$prefix \
		-DZOPFLI_BUILD_SHARED=ON \
		-DCMAKE_INSTALL_LIBDIR=$libDir \
		-DCMAKE_INSTALL_INCLUDEDIR=$includeDir
	make $jobArgs
}

INSTALL()
{
	cd build
	make install
}
