SUMMARY="Tools and library for the Better Prortable Graphics format"
DESCRIPTION="BPG is an image format based on the HEVC standard that aims to \
provide a replacement for the JPEG format with better quality and smaller file\
 size."

HOMEPAGE="http://bellard.org/bpg/"
LICENSE="
	MIT
	GNU LGPL v2.1
	"
COPYRIGHT="2014 Fabrice Bellard"


SOURCE_URI="http://bellard.org/bpg/libbpg-0.9.4.tar.gz"
CHECKSUM_SHA256="9986d66408f36fb678014bfcbb693c0f8358767719bc05797e4af54fa4237c2a"
SOURCE_DIR="libbpg-$portVersion"

REVISION="1"
ARCHITECTURES="x86 ?x86_64"
# libbpg requires gcc4, so we can only do x86_gcc2 if it's a hybrid
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
else
	ARCHITECTURES="$ARCHITECTURES !x86_gcc2"
fi

SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	bpg = $portVersion
	cmd:bpgenc$secondaryArchSuffix
	cmd:bpgdec$secondaryArchSuffix
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	lib:libpng$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	"

PROVIDES_devel="
	libbpg${secondaryArchSuffix}_devel = $portVersion
	devel:libbpg$secondaryArchSuffix = $portVersion
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpng$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	"

BUILD_PREREQUIRES="
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	"

BUILD()
{
	sed -i 's/-lpthread//g' Makefile
	sed -i 's/-lm//g' Makefile
	sed -i 's/-lrt//g' Makefile
	make
}

INSTALL()
{
	mkdir -p $binDir

	sed -i "s,\$(prefix)/bin,$binDir,g" Makefile
	make install

	mkdir -p $libDir
	cp libbpg.a $libDir
	prepareInstalledDevelLib libbpg
	packageEntries devel $developLibDir
}
