#!/usr/bin/make -f

USRDIR   := $(CURDIR)/debian/composer/usr
UPSTREAM := $(shell dpkg-parsechangelog -S version | sed 's/-.?*//')

%:
	dh $@ --with phpcomposer -XCompiler.php

override_dh_auto_build:
	phpab \
		--output src/Composer/autoload.php \
		--template debian/autoload.php.tpl \
		src/Composer

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	phpunit --include-path src --verbose
else
	@echo "** tests disabled"
endif

override_dh_installdocs:
	dh_installdocs -Xdoc/composer

override_dh_installman:
	mkdir --parent $(CURDIR)/debian/tmp
	cd $(USRDIR)/share/php && help2man \
		--help-option=\  \
		--include=$(CURDIR)/debian/composer.1.in \
		--version-string=$(UPSTREAM) \
		--no-info \
		--no-discard-stderr \
		"echo -n 'Usage: composer' && $(CURDIR)/bin/composer --no-ansi | tail -n+10" \
		> $(CURDIR)/debian/tmp/composer.1
	dh_installman

get-orig-source:
	uscan --verbose --force --rename
