#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

SRC_TMP=$(CURDIR)/SRC_TMP
debtmp := $(CURDIR)/debian/tmp

include /usr/share/dpkg/default.mk
BUILD_DATE := $(shell dpkg-parsechangelog | grep Date: | cut -d' ' -f2-7)

export TZ=UTC
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with python2

override_dh_auto_clean:
	dh_auto_clean
	rm -rf solvers

override_dh_auto_build:
	mkdir solvers
	dh_auto_build

override_dh_install-indep:
	dh_install
	rm -rf debian/$(DEB_SOURCE)/usr/share/cain/help/* debian/$(DEB_SOURCE)/usr/share/cain/gui/help.htm*
	find help -type d | xargs chmod 755
	find help -type f | xargs chmod 644
	find help | xargs touch --no-dereference --date='$(BUILD_DATE)'
	cd help && (find . -type f -not \( -name "*.htb" -or -name "*.htd" \) -print0 | \
          LC_ALL=C sort -z | \
          xargs -0 zip ../debian/$(DEB_SOURCE)/usr/share/cain/help/cain.htb -X -r -q)
	touch --no-dereference --date='$(BUILD_DATE)' debian/$(DEB_SOURCE)/usr/share/cain/help/cain.htb
	if [ -d debian/$(DEB_SOURCE)/usr/share/cain/ ] ; then \
	    find debian/$(DEB_SOURCE)/usr/share/cain/ -type f -executable -exec chmod 644 {} + ; \
	fi

override_dh_auto_test:
	echo "no tests implemented"
