SUMMARY="Versatile and fast Unicode/ASCII/ANSI graphics renderer"
DESCRIPTION="Chafa is a command-line utility that converts all kinds of \
images, including animated GIFs, into sixel or ANSI/Unicode character output \
that can be displayed in a terminal.

It is highly configurable, with support for alpha transparency and multiple \
color modes and color spaces, combining selectable ranges of Unicode \
characters to produce the desired output."
HOMEPAGE="https://hpjansson.org/chafa/"
COPYRIGHT="2018-2021 Hans Petter Jansson et al
	2004 Richard Wilson
	2008 Sean Fox"
LICENSE="GNU LGPL v3"
REVISION="1"
SOURCE_URI="https://github.com/hpjansson/chafa/archive/refs/tags/$portVersion.tar.gz"
CHECKSUM_SHA256="1d9ef79955ef8d5e86ebf1eb641b9629d732b7a44ccc9d44e1ee939a4a7e63e3"

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

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	chafa$secondaryArchSuffix = $portVersion
	cmd:chafa$commandSuffix = $portVersion
	lib:libchafa$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libMagickWand_7.Q16HDRI$secondaryArchSuffix
	"

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

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreetype$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libMagickWand_7.Q16HDRI$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoreconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:gtkdocize
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:which
	"

BUILD()
{
	mkdir -p m4
	NOCONFIGURE=1 ./autogen.sh
	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir
	make $jobArgs OBJ_DIR=objects
}

INSTALL()
{
	make install

	# remove libtool file
	rm $libDir/libchafa.la

	prepareInstalledDevelLib libchafa
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
