# Contributor: Andy Postnikov <apostnikov@gmail.com>
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php81-pecl-xdebug
_extname=xdebug
pkgver=3.4.3
_pkgver=${pkgver/_/}
pkgrel=0
pkgdesc="PHP 8.1 extension that provides functions for function traces and profiling - PECL"
url="https://pecl.php.net/package/xdebug"
arch="all"
license="PHP-3.0"
_phpv=81
_php=php$_phpv
depends="$_php-common"
makedepends="$_php-dev linux-headers"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz"
builddir="$srcdir/$_extname-$pkgver"
provides="$_php-xdebug=$pkgver-r$pkgrel" # for backward compatibility
replaces="$_php-xdebug" # for backward compatibility

install_if="php-$_extname php$_phpv"

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

check() {
	# PECL package has no test suite.
	$_php -d zend_extension="$builddir"/modules/xdebug.so -r 'xdebug_info();'
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	local _confdir="$pkgdir"/etc/$_php/conf.d
	mkdir -p $_confdir
	# should go after opcache
	cat > $_confdir/50_$_extname.ini <<-EOF
		; Uncomment and configure mode https://xdebug.org/docs/all_settings#xdebug.mode
		;zend_extension=$_extname.so
		;xdebug.mode=off
	EOF

	install -D -m644 -t "$pkgdir"/usr/share/$_php/xdebug/ contrib/tracefile-analyser.php
	install -D -m644 -t "$pkgdir"/usr/share/vim/vimfiles/syntax/ contrib/xt.vim
}

sha512sums="
0b4d2b6cd2fe42a9f208f7c0ac89082d72ceb6ca767d95f132df611490f7a4832e5c5be857a7ea774477325b374a5477439243e73e8f1e01655f553a1214b77c  php-pecl-xdebug-3.4.3.tgz
"
