#!/usr/bin/make -f

%:
	dh $@

override_dh_auto_build:
	phpabtpl \
	        --basedir . \
	        --require-file libs/PclZip/pclzip.lib.php \
	        composer.json \
	        > debian/autoload.php.tpl

	# Path at the install time does not have src/
	phpab --basedir src \
	        --output autoload.php \
	        --template debian/autoload.php.tpl src/

override_dh_auto_test:
	phpab --basedir . \
	        --output tests-autoload.php \
	        --template debian/autoload.php.tpl src/ tests/TestBase.php
	phpunit tests/ --no-coverage --do-not-cache-result --bootstrap ./tests-autoload.php
	# Restore the state (https://github.com/php/php-src/issues/8781)
	touch tests/Fixture/empty.zip
	chmod +x tests/Fixture/empty.zip


override_dh_install:
	dh_install
	chmod -x debian/php-matomo-component-decompress/usr/share/php/matomo/decompress/Gzip.php
	chmod -x debian/php-matomo-component-decompress/usr/share/php/matomo/decompress/Tar.php

override_dh_clean:
	dh_clean
	touch tests/Fixture/empty.zip
