# Contributor: Alexander Edland <alpine@ocv.me>
# Maintainer: Alexander Edland <alpine@ocv.me>
pkgname=zimg
pkgver=3.0.1
pkgrel=0
pkgdesc="Scaling, colorspace conversion and dithering library"
url="https://github.com/sekrit-twc/zimg"
arch="all !s390x !mips !mips64" # Tests fail on big-endian
license="WTFPL-2.0"
makedepends="autoconf automake libtool"
subpackages="$pkgname-doc $pkgname-dev"
source="zimg-$pkgver.tar.gz::https://github.com/sekrit-twc/zimg/archive/release-$pkgver.tar.gz
	zimg-gtest-1.8.0.tar.gz::https://github.com/google/googletest/archive/release-1.8.0.tar.gz"
builddir="$srcdir/zimg-release-$pkgver"
options="!check" # we run tests in the build stage

prepare() {
	default_prepare
	mkdir -p "$pkgdir"
	# googletest is required in-tree
	ln -s "$srcdir"/googletest-*/* test/extra/googletest
	autoreconf -vfi
}

build() {
	# build and run test binaries here
#	./configure \
#		--build=$CBUILD \
#		--host=$CHOST \
#		--prefix=/usr \
#		--sysconfdir=/etc \
#		--mandir=/usr/share/man \
#		--localstatedir=/var \
#		--disable-static \
#		--enable-unit-test
#	make
#	make test/unit_test.log
	#test/unit_test

	# build release binaries here without enabling tests,
	# as they make zimg slower
#	make clean
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-static
	make
}

package() {
	make -j1 DESTDIR="$pkgdir" install
}

sha512sums="ae117399772d2c35ffa61b8cf5d156edf4ed65e9ffeb2e9e0688c88244fdd1a89c098bd842e3795b33fb0951da97f844fb6ffe27045e3234720f70f842356936  zimg-3.0.1.tar.gz
1dbece324473e53a83a60601b02c92c089f5d314761351974e097b2cf4d24af4296f9eb8653b6b03b1e363d9c5f793897acae1f0c7ac40149216035c4d395d9d  zimg-gtest-1.8.0.tar.gz"
