#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

override_dh_install:
	mkdir -p debian/enigmail/usr/share/xul-ext/enigmail
	unzip build-tb/*.xpi -d debian/enigmail/usr/share/xul-ext/enigmail

override_dh_auto_configure:
	ln -sf /usr/share/misc/config.guess /usr/share/misc/config.sub ./
	dh_auto_configure -- --with-tb-path=/usr/bin/thunderbird --with-tb-args='--headless --profile $(shell pwd)/test-profile'

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	debian/run-tests
endif

override_dh_auto_clean:
	# if config/autoconf.mk is not present, create stub of it, such that make distclean works
	if [ ! -f config/autoconf.mk ]; then \
		echo 'XPI_MODULE_VERS = $(DEB_VERSION_UPSTREAM)' > config/autoconf.mk; \
		echo 'DIST = $$(DEPTH)/build-tb/dist' >> config/autoconf.mk; \
		echo 'BUILD = $$(DEPTH)/build-tb' >> config/autoconf.mk; \
	fi

	dh_auto_clean
