# Contributor: Andy Postnikov <apostnikov@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>

pkgname=php82-pecl-igbinary
_extname=igbinary
pkgver=3.2.16
pkgrel=0
pkgdesc="Igbinary is a drop in replacement for the standard PHP 8.2 serializer - PECL"
url="https://pecl.php.net/package/igbinary"
arch="all"
license="BSD-3-Clause"
_phpv=82
_php=php$_phpv
depends="$_php-common"
makedepends="$_php-dev $_php-pecl-apcu"
checkdepends="$_php-session" # sessions needs work https://github.com/igbinary/igbinary/issues/116
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz"
builddir="$srcdir/$_extname-$pkgver"

install_if="php-$_extname php$_phpv"

build() {
	phpize$_phpv
	./configure --prefix=/usr --with-php-config=php-config$_phpv
	make
}

check() {
	local _modules="/usr/lib/$_php/modules"
	# Tests require extra extensions which are not bundled
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		TESTS=--show-diff \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/apcu.so \
		-d extension=$_modules/session.so \
		-d extension=modules/$_extname.so"
	$_php -d extension="$builddir"/modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/10_$_extname.ini
}

sha512sums="
ad806ad42398e2355b18d7f99da6ac176a8d5de829cc9d7c0c38a211f4092cafdde80f6fa989dbdc77ea912e054ce88825675c727afd3a6e0d3150b3796a7bcd  php-pecl-igbinary-3.2.16.tgz
"
