#!/usr/bin/make -f

# HACK: disable checks, i.e. unit tests
DEB_BUILD_OPTIONS += nocheck
export WITHOUT_NOSETESTS := 1

EXAMPLE_SCRIPTS=\
    gbp-add-patch          \
    gbp-cowbuilder-sid     \
    gbp-posttag-push       \
    gbp-configure-unpatched-source \
    wrap_cl.py

DEB_COMPRESS_EXCLUDE=$(EXAMPLE_SCRIPTS)

ZSH_COMPDIR = /usr/share/zsh/vendor-completions/

PYCHECKER_ARGS=-boptparse --no-override --no-shadowbuiltin

%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	dh_auto_test
	export GIT_AUTHOR_NAME="Gbp Tests";		\
	export GIT_AUTHOR_EMAIL=tests@example.com;	\
	export GIT_COMMITTER_NAME=$$GIT_AUTHOR_NAME;	\
	export GIT_COMMITTER_EMAIL=$$GIT_AUTHOR_EMAIL;	\
	PYTHONPATH=.					\
	python3 setup.py nosetests

else
	@echo "Checks disabled via DEB_BUILD_OPTIONS"
endif

override_dh_auto_build:
	dh_auto_build
	make -C docs

override_dh_auto_install:
	python3 setup.py install --root=debian/tmp --prefix=/usr/local
	dh_bash-completion
	mkdir -p debian/git-buildpackage/$(ZSH_COMPDIR)
	install -m644 debian/git-buildpackage.zsh-completion \
		debian/git-buildpackage/$(ZSH_COMPDIR)/_gbp

override_dh_auto_clean:
	dh_auto_clean
	# Remove renamed files - renames are not correctly expressed in debian.diff
	rm -f debian/doc-base
	rm -f debian/docs
	rm -f debian/examples
	rm -f debian/manpages
	rm -rf build/
	make -C docs/ clean
	-rm gbp/version.py

override_dh_compress:
	dh_compress --exclude=usr/share/doc/git-buildpackage/examples/

override_dh_usrlocal:

