# Maintainer: 
pkgname=jasper
pkgver=2.0.16
pkgrel=0
pkgdesc="Library implementing JPEG-2000"
url="http://www.ece.uvic.ca/~mdadams/jasper/"
arch="all"
license="custom:JasPer2.0"
depends=  #"libjpeg>=8 freeglut libxi libxmu mesa"
makedepends="libjpeg-turbo-dev cmake"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/mdadams/jasper/archive/version-$pkgver.tar.gz"
builddir="$srcdir/$pkgname-version-$pkgver"

# secfixes:
#   2.0.12-r1:
#     - CVE-2017-1000050

build() {
	mkdir "$builddir"/obj
	cd "$builddir"/obj
	# default of 16 causes stack overflow
	export CFLAGS="${CFLAGS} -DJPC_QMFB_COLGRPSIZE=6"
	cmake ..  \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib

	make
}

check() {
	cd "$builddir"/obj
	make test
}

package() {
	cd "$builddir"/obj
	make DESTDIR="$pkgdir" install
}

libs() {
	pkgdesc="JPEG-2000 library"
	install -d "$subpkgdir"/usr/
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr
}

sha512sums="b3bca227f833567c9061c4a29c0599784ed6a131b5cceddfd1696542d19add821eda445ce6d83782b454b266723b24d0f028cbc644a25c0e3a75304e615b34ee  jasper-2.0.16.tar.gz"