#!/usr/bin/make -f

TWIG_RELEASE_VERSION := $(shell dpkg-parsechangelog | grep -E -e '^Version:' | sed -r 's/^[^:]+: (.*)-[^-]+$$/\1/')
TWIG_VERSION := $(shell echo $(TWIG_RELEASE_VERSION) | sed -r 's/^([0-9]+\.[0-9]+).*/\1/')

%:
	dh $@ --with phpcomposer,sphinxdoc

override_dh_auto_build:
	sphinx-build -C \
	 -b html \
	 -D source_suffix='.rst' \
	 -D master_doc='index' \
	 -D project='php-twig-doc' \
	 -D copyright='by the Twig Team' \
	 -D version='${TWIG_VERSION}' \
	 -D release='${TWIG_RELEASE_VERSION}' \
	 -D pygments_style='sphinx' \
	 -D html_theme='default' \
	 doc debian/build-tmp/php-twig-doc
	cp -a src lib/Twig/psr-4
	phpab --output lib/Twig/autoload.php lib/Twig
	mkdir --parents vendor
	phpab 	--output vendor/autoload.php \
		--template debian/autoload.tests.php.tpl \
		test

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	phpunit
endif
