SUMMARY="A full-featured cross-platform image library"
DESCRIPTION="
Developer's Image Library (DevIL) is a programmer's library to develop \
applications with very powerful image loading capabilities, yet is easy for a \
developer to learn and use. Ultimate control of images is left to the \
developer, so unnecessary conversions, etc. are not performed. DevIL utilizes \
a simple, yet powerful, syntax. DevIL can load, save, convert, manipulate, \
filter and display a wide variety of image formats."
HOMEPAGE="http://openil.sourceforge.net/"
COPYRIGHT="2017 Denton Woods"
LICENSE="GNU LGPL v2.1"
REVISION="4"
SOURCE_URI="http://sourceforge.net/projects/openil/files/DevIL/$portVersion/DevIL-$portVersion.tar.gz"
CHECKSUM_SHA256="0075973ee7dd89f0507873e2580ac78336452d29d34a07134b208f44e2feb709"
SOURCE_DIR="DevIL"

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

PROVIDES="
	devil$secondaryArchSuffix = $portVersion
	lib:libIL$secondaryArchSuffix
	lib:libILU$secondaryArchSuffix
	lib:libILUT$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libjasper$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	devil${secondaryArchSuffix}_devel = $portVersion
	devel:libIL$secondaryArchSuffix
	devel:libILU$secondaryArchSuffix
	devel:libILUT$secondaryArchSuffix
	"
REQUIRES_devel="
	devil$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libgl$secondaryArchSuffix
	devel:libilmimf$secondaryArchSuffix #openexr
	devel:libjasper$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblcms2$secondaryArchSuffix
	devel:libmng$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cd DevIL
	mkdir -p haiku-build
	cd haiku-build

	if [ $targetArchitecture = x86_gcc2 ]; then
	cmake .. \
		-DCMAKE_INSTALL_PREFIX:PATH=$libDir \
		-DCMAKE_CXX_FLAGS="-fpermissive"
	else
	cmake .. \
		-DCMAKE_INSTALL_PREFIX:PATH=$prefix \
		-DCMAKE_CXX_FLAGS="-fpermissive"
	fi

	make $jobArgs
}

INSTALL()
{
	cd DevIL/haiku-build
	make install

	if [ $targetArchitecture = x86_gcc2 ]; then
		mkdir -p $libDir
		mv $libDir/lib/* $libDir
		rmdir $libDir/lib
		mkdir -p $includeDir
		mv $libDir/include/* $includeDir
		rmdir $libDir/include
	fi

	if [ $targetArchitecture = x86_64 ]; then
	mkdir -p $includeDir
	mv $prefix/include/* $includeDir
	rmdir $prefix/include
	fi

	prepareInstalledDevelLibs libIL libILU libILUT
	fixPkgconfig

	packageEntries devel \
		$developDir
}

TEST()
{
	cd DevIL/haiku-build
	make check
}
