# Contributor: Andy Postnikov <apostnikov@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php82-pecl-event
_php=82
_extname=event
pkgver=3.1.4
_pkgver=${pkgver/_rc/RC}
pkgrel=0
pkgdesc="PHP 8.2 extension that provides interface to libevent library - PECL"
url="https://pecl.php.net/package/event"
arch="all"
license="PHP-3.01"
depends="php$_php-sockets"
makedepends="php$_php-dev libevent-dev openssl-dev>3"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$_pkgver.tgz"
builddir="$srcdir/$_extname-$_pkgver"

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

check() {
	local _ext="-d extension=modules/$_extname.so"
	php$_php $_ext --ri $_extname
	# Tests require sockets extension which is not bundled
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 SKIP_ONLINE_TESTS=1 test \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=/usr/lib/php$_php/modules/sockets.so \
		$_ext" \
		TESTS="--show-diff tests"
}

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

sha512sums="
d9f9431f3ee1092b421d75fd5a065feea65014a38c45d6087f6d4754458e286a3bbb23ce0aefe1771a960a2b531987d19f96b156ae38f5336631d9e3381e4067  php-pecl-event-3.1.4.tgz
"
