# 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=php82-pecl-xdebug
_extname=xdebug
pkgver=3.3.2
pkgrel=2
pkgdesc="PHP 8.2 extension that provides functions for function traces and profiling - PECL"
url="https://pecl.php.net/package/xdebug"
arch="all"
license="PHP-3.0"
_phpv=82
_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="
06096e7a8899e586af8a9a763889546274ef0b520c1b84a1153c704cfdd2f6ff5491c30510da34c0b41169c94fe1f08f27b81535f98162edbb14f1569bd55846  php-pecl-xdebug-3.3.2.tgz
"
