SUMMARY="An ASCII art rendering library"
DESCRIPTION="libcaca is a software library which allows applications to \
automatically convert still and moving images into colored ASCII art."
HOMEPAGE="http://caca.zoy.org/wiki/libcaca"
COPYRIGHT="1998, 1999, 2001 Jan Hubicka
	2003-2008 Sam Hocevar
	2003-2008 Jean-Yves Lamoureux
	2004-2005 John Beppu
	2006-2007 Ben Wiley Sittler
	2007-2008 Pascal Terjan"
LICENSE="WTFPL
	GNU GPL v2"
REVISION="6"
SOURCE_URI="http://caca.zoy.org/raw-attachment/wiki/libcaca/libcaca-$portVersion.tar.gz"
CHECKSUM_SHA256="128b467c4ed03264c187405172a4e83049342cc8cc2f655f53a2d0ee9d3772f4"
SOURCE_DIR="libcaca-$portVersion"
PATCHES="libcaca-${portVersion}.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

PROVIDES="
	libcaca$secondaryArchSuffix = $portVersion compat >= 0
	lib:libcaca$secondaryArchSuffix = 0.99.19 compat >= 0
	lib:libcaca++$secondaryArchSuffix = 0.99.19 compat >= 0
	"
if [ -z "$secondaryArchSuffix" ]; then
	PROVIDES="$PROVIDES
		cmd:cacaclock = $portVersion compat >= 0
		cmd:cacademo = $portVersion compat >= 0
		cmd:cacafire = $portVersion compat >= 0
		cmd:cacaserver = $portVersion compat >= 0
		cmd:cacaview = $portVersion compat >= 0
		cmd:cacaplay = $portVersion compat >= 0
		cmd:img2txt = $portVersion compat >= 0
		"
fi
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libncursesw$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libcaca${secondaryArchSuffix}_devel = $portVersion compat >= 0
	devel:libcaca$secondaryArchSuffix = $portVersion compat >= 0
	devel:libcaca++$secondaryArchSuffix = $portVersion compat >= 0
	cmd:caca_config$secondaryArchSuffix = $portVersion compat >= 0
	"
REQUIRES_devel="
	haiku$secondaryArchSuffix
	libcaca$secondaryArchSuffix == $portVersion base
	lib:libncursesw$secondaryArchSuffix
	devel:libncursesw$secondaryArchSuffix
	"

if [ -z "$secondaryArchSuffix" ]; then
	ARCHITECTURES_doc="any"
	PROVIDES_doc="
		libcaca_doc = $portVersion
		"
	REQUIRES_doc=""
fi

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libncursesw$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:doxygen
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config
	cmd:ranlib
	"

PATCH()
{
	sed -i -e 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' configure.ac
}

BUILD()
{
	autoreconf -fi
	runConfigure ./configure \
		--enable-ncurses \
		--enable-cxx \
		--disable-python \
		--htmldir=${developDocDir}
	make $jobArgs
}

INSTALL()
{
	make install

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $dataDir/libcaca $developDocDir $documentationDir
		rmdir $developDir/documentation
	else
		packageEntries doc \
			$developDocDir \
			$documentationDir/man/man3
	fi

	prepareInstalledDevelLibs libcaca libcaca++
	rm $developLibDir/*.la
	fixPkgconfig

	# devel package
	packageEntries devel \
		$binDir/caca-config \
		$developDir

	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $binDir
	fi
}

TEST()
{
	make check
}
