SUMMARY="An advanced replacement library for libraries like libXpm"
DESCRIPTION="A library that does image file loading and saving as well as \
rendering, manipulation, arbitrary polygon support, etc.

It does ALL of these operations FAST. Imlib2 also tries to be highly \
intelligent about doing them, so writing naive programs can be done easily, \
without sacrificing speed.

This is a complete rewrite over the Imlib 1.x series. The architecture is more \
modular, simple, and flexible. See index.html in the doc/ directory for more \
information."
HOMEPAGE="https://www.enlightenment.org/"
COPYRIGHT="2002-2018 Project Enlightenment"
LICENSE="IMLIB2"
REVISION="3"
SOURCE_URI="https://downloads.sourceforge.net/enlightenment/imlib2-$portVersion.tar.bz2"
CHECKSUM_SHA256="fa4e57452b8843f4a70f70fd435c746ae2ace813250f8c65f977db5d7914baae"

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

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

PROVIDES="
	imlib2$secondaryArchSuffix = $portVersion
	lib:libimlib2$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgif$secondaryArchSuffix
	lib:libid3tag$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix >= 5
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	imlib2${secondaryArchSuffix}_devel = $portVersion
	cmd:imlib2_config$secondaryArchSuffix = $portVersion
	cmd:imlib2_conv$secondaryArchSuffix = $portVersion
	devel:libimlib2$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	haiku$secondaryArchSuffix
	haiku${secondaryArchSuffix}_devel
	imlib2$secondaryArchSuffix == $portVersion base
	devel:libbz2$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libgif$secondaryArchSuffix
	devel:libid3tag$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix >= 5
	devel:libz$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libgif$secondaryArchSuffix
	devel:libid3tag$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix >= 5
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:ranlib$secondaryArchSuffix
	"

debugList=(
	"$libDir"/libImlib2.so.$libVersion
	"$libDir"/imlib2/filters/bumpmap.so
	"$libDir"/imlib2/filters/colormod.so
	"$libDir"/imlib2/filters/testfilter.so
	)
for i in argb bmp bz2 ff gif id3 jpeg lbm png pnm tga tiff xpm zlib; do
	debugList+=("$libDir"/imlib2/loaders/$i.so)
done
defineDebugInfoPackage imlib2$secondaryArchSuffix "${debugList[@]}"

BUILD()
{
	libtoolize --force --copy --install
	aclocal
	autoconf
	automake --add-missing
	runConfigure ./configure --without-x
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool files
	rm $libDir/*.la
	rm $libDir/imlib2/filters/*.la
	rm $libDir/imlib2/loaders/*.la

	prepareInstalledDevelLib libImlib2
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$binDir" \
		"$developDir"
}

TEST()
{
	make check
}
