#!/usr/bin/make -f

include /usr/share/dpkg/default.mk
UPSTREAM := $(DEB_VERSION_UPSTREAM)

%:
	dh $@

execute_before_dh_auto_build:
	phpabtpl composer.json > debian/autoload.php.tpl
	phpab \
		--tolerant \
		--output lib/Doctrine/ORM/autoload.php \
		--template debian/autoload.php.tpl \
		lib/Doctrine/ORM
	mkdir --parents vendor lib/data/Doctrine
	ln -s ../../../doctrine-mapping.xsd lib/data/Doctrine/
	phpab \
		--tolerant \
		--exclude tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php \
		--exclude tests/Doctrine/Tests/ORM/Mapping/MappingDriverTestCase.php \
		--exclude tests/Doctrine/Tests/Models/Enums/Product.php \
		--output vendor/autoload.php \
		--template debian/autoload.tests.php.tpl \
		tests

override_dh_auto_test:
	phpunit --include-path lib

execute_after_dh_install:
	sed -i "s/@VERSION@/$(UPSTREAM)/;s/\+dfsg//" \
		$(CURDIR)/debian/php-doctrine-orm/usr/share/php/Doctrine/ORM/Version.php

override_dh_installchangelogs:
	dh_installchangelogs debian/upstream/changelog
