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="https://bellard.org/bpg/"
COPYRIGHT="2014-2018 Fabrice Bellard"
LICENSE="MIT
	GNU LGPL v2.1"
REVISION="3"
SOURCE_URI="http://bellard.org/bpg/libbpg-$portVersion.tar.gz"
CHECKSUM_SHA256="c0788e23bdf1a7d36cb4424ccb2fae4c7789ac94949563c4ad0e2569d3bf0095"

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

PROVIDES="
	libbpg$secondaryArchSuffix = $portVersion
	cmd:bpgdec$secondaryArchSuffix
	cmd:bpgenc$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	"
REPLACES="
	bpg$secondaryArchSuffix
	"

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

SUMMARY_tools="A small utility to view image files"
PROVIDES_tools="
	libbpg${secondaryArchSuffix}_tools = $portVersion
	cmd:bpgview$secondaryArchSuffix
	"
REQUIRES_tools="
	haiku$secondaryArchSuffix
	lib:libSDL$secondaryArchSuffix
	lib:libSDL_image$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL$secondaryArchSuffix
	devel:libSDL_image$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	"
PATCH()
{
	sed -i 's/USE_X265=y/#USE_X265=y/g' Makefile
	sed -i 's/-lrt//g' Makefile
	sed -i "s,\$(prefix)/bin,$binDir,g" Makefile
}

BUILD()
{
	make $jobArgs
}

INSTALL()
{
	mkdir -p $binDir $developLibDir $documentationDir $includeDir
	cp {bpgenc,bpgdec,bpgview} $binDir
	cp libbpg.a $developLibDir
	cp doc/bpg_spec.txt $documentationDir
	cp {libbpg.h,bpgenc.h} $includeDir

	packageEntries devel \
		$developDir
	packageEntries tools \
		$binDir/bpgview
}
