#!/usr/bin/make -f
#export DH_VERBOSE = 1
#export DH_OPTIONS = -v
# PROVE_OPTIONS: Set testing suite options (i.e. verbose output)
#export PROVE_OPTIONS = -v
export PREFIX=/usr
export INSTALL_LIB=$(DESTDIR)/usr/share/git-subrepo
export INSTALL_EXT=$(INSTALL_LIB)

%:
	dh $@ \
	  -Smakefile --with=bash-completion

override_dh_auto_clean:
	@if [ ! -d "test/repo_orig" ]; then \
		echo "MOVE ORIGINAL BIANRY REPOS"; \
		mv test/repo test/repo_orig; \
	else \
		echo "ORIGINAL BINARY REPOS ALREADY MOVED"; \
	fi
	make clean
	@if [ -d "test/repo_orig" ]; then \
		echo "RESTORE ORIGINAL BINARY REPOS"; \
		rm -rf test/repo; \
		mv test/repo_orig test/repo; \
	else \
		echo "NOTHING TO RESTORE - ORIGINAL BINARY REPOS NOT MOVED"; \
	fi

override_dh_auto_test:
	@if [ ! -d "test/repo_orig" ]; then \
		echo "MOVE ORIGINAL BIANRY REPOS"; \
		mv test/repo test/repo_orig; \
	else \
		echo "ORIGINAL BINARY REPOS ALREADY MOVED"; \
	fi
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	export prove=$(PROVE_OPTIONS); make test
endif

override_dh_installchangelogs:
	dh_installchangelogs Changes
