# Template file for 'devil'
pkgname=devil
version=1.7.8
revision=2
build_style=gnu-configure
configure_args="--enable-ILU --enable-ILUT --with-examples"
hostmakedepends="automake libtool pkg-config"
makedepends="lcms-devel libpng-devel libmng-devel jasper-devel
 glew-devel libfreeglut-devel SDL_image-devel"
short_desc="Developer's Image Library"
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
license="LGPL-2.1"
homepage="http://openil.sourceforge.net/"
distfiles="${SOURCEFORGE_SITE}/openil/DevIL-${version}.tar.gz"
checksum=682ffa3fc894686156337b8ce473c954bf3f4fb0f3ecac159c73db632d28a8fd

if [ -z "$CROSS_BUILD" ]; then
	makedepends+=" libopenexr-devel"
fi

pre_configure() {
	autoreconf -if
	# Replace obsolete libpng function names
	sed -e "s;png_set_gray_1_2_4_to_8;png_set_expand_gray_1_2_4_to_8;" \
		-i ${wrksrc}/src-IL/src/il_png.c
	sed -e "s;png_set_gray_1_2_4_to_8;png_set_expand_gray_1_2_4_to_8;" \
		-i ${wrksrc}/src-IL/src/il_icon.c
}

devil-devel_package() {
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmkdir usr/share/doc/devil
		cp -aR docs/html docs/images ${PKGDESTDIR}/usr/share/doc/devil
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.a"
		vmove "usr/lib/*.so"
	}
}
devil-examples_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" - examples"
	pkg_install() {
		vmove usr/share/devil/examples
		cp -aR ${wrksrc}/examples/* ${PKGDESTDIR}/usr/share/devil/examples
	}
}
