# Template file for 'freeimage'
pkgname=freeimage
version=3.17.0
revision=1
wrksrc=FreeImage
build_style=gnu-makefile
hostmakedepends="unzip"
short_desc="Support library for popular graphics image formats"
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
license="GPL-2 FIPL"
homepage="http://freeimage.sourceforge.net/"
distfiles="${SOURCEFORGE_SITE}/freeimage/Source%20Distribution/FreeImage${version//./}.zip"
checksum=fbfc65e39b3d4e2cb108c4ffa8c41fd02c07d4d436c594fff8dab1a6d5297f89

CFLAGS="-fPIC -DPIC -fexceptions -fvisibility=hidden"
CXXFLAGS="${CFLAGS} -Wno-ctor-dtor-privacy"
subpackages="freeimage freeimage-plus freeimage-devel freeimage-plus-devel"

post_extract() {
	mkdir /tmp/fi
	mv ${wrksrc}/* /tmp/fi
	cp -a /tmp/fi ${wrksrc}/fip
	mv /tmp/fi ${wrksrc}
}

do_build() {
	cd ${wrksrc}/fi
	make ${makejobs}
	cd ${wrksrc}/fip
	make -f Makefile.fip ${makejobs}
}

do_install() {
	cd ${wrksrc}/fi
	make DESTDIR="${DESTDIR}" install
	vlicense license-fi.txt LICENSE
}

freeimage-plus_package() {
	short_desc+=" (plus)"
	pkg_install() {
		cd ${wrksrc}/fip
		make -f Makefile.fip DESTDIR="${PKGDESTDIR}" install
		vlicense license-fi.txt LICENSE
	}
}

freeimage-devel_package() {
	short_desc+=" - development files"
	depends="freeimage>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/libfreeimage.a
		vmove usr/lib/libfreeimage.so
	}
}

freeimage-plus-devel_package() {
	short_desc+=" (plus) - development files"
	depends="freeimage-plus>=${version}_${revision}"
	pkg_install() {
		DESTDIR="${DESTDIR/freeimage-/freeimage-plus-}"
		vmove usr/include
		vmove usr/lib/libfreeimageplus.a
		vmove usr/lib/libfreeimageplus.so
#		vmkdir usr/lib
#		mv ${_destdir}/usr/include ${PKGDESTDIR}/usr
#		mv ${_destdir}/usr/lib/libfreeimageplus.{a,so} ${PKGDESTDIR}/usr/lib
	}
}

