SUMMARY="libcaca 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"

# FIXME: the offical website is down right now. Using mirror provided by the
#        MXE project.
SOURCE_URI="
	http://caca.zoy.org/raw-attachment/wiki/libcaca/libcaca-$portVersion.tar.gz
	http://s3.amazonaws.com/mxe-pkg/libcaca-$portVersion.tar.gz
	"
CHECKSUM_SHA256="128b467c4ed03264c187405172a4e83049342cc8cc2f655f53a2d0ee9d3772f4"
SOURCE_DIR="libcaca-$portVersion"
REVISION="1"
LICENSE="
	WTFPL
	GNU GPL v2
	"
COPYRIGHT="
	1998, 1999, 2001 Jan Hubicka <hubicka@freesoft.cz>
	2003-2008 Sam Hocevar <sam@zoy.org>
	2003-2008 Jean-Yves Lamoureux <jylam@lnxscene.org>
	2004-2005 John Beppu <beppu@lbox.org>
	2006-2007 Ben Wiley Sittler <bsittler@gmail.com>
	2007-2008 Pascal Terjan <pterjan@linuxfr.org>
	"

ARCHITECTURES="x86_gcc2 x86 x86_64"
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
	cmd:cacaclock$secondaryArchSuffix = $portVersion compat >= 0
	cmd:cacademo$secondaryArchSuffix = $portVersion compat >= 0
	cmd:cacafire$secondaryArchSuffix = $portVersion compat >= 0
	cmd:cacaserver$secondaryArchSuffix = $portVersion compat >= 0
	cmd:cacaview$secondaryArchSuffix = $portVersion compat >= 0
	cmd:cacaplay$secondaryArchSuffix = $portVersion compat >= 0
	cmd:img2txt$secondaryArchSuffix = $portVersion compat >= 0
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libncursesw$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
if [ "$effectiveTargetArchitecture" != 'x86_gcc2' ]; then
	REQUIRES="
		$REQUIRES
		lib:libgcc_s$secondaryArchSuffix
		lib:libstdc++$secondaryArchSuffix
		"
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
	cmd:make
	cmd:pkg_config
	cmd:ranlib
	"

PATCHES="libcaca-${portVersion}.patchset"

PATCH()
{
        sed -i '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
	prepareInstalledDevelLibs libcaca libcaca++
	fixPkgconfig

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

# ----- devel package -------------------------------------------------------

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
	"
