#!/usr/bin/make -f

UPSTREAM_VERSION = $(shell dpkg-parsechangelog | sed -n -e 's/^Version: \([^-]*\)-.*$$/\1/p')

%:
	dh $@ --with xul-ext --parallel

override_dh_auto_build:
	# Verify that we have the upstream Git commit id
	if [ "$$(sed -e 's/:.*//' debian/upstream-git-commit-id)" != '$(UPSTREAM_VERSION)' ]; then \
		echo "Git commit id has not been updated." >&2; \
		exit 1; \
	fi
	./makexpi.sh $(UPSTREAM_VERSION) --no-recurse

override_dh_auto_install:
	install-xpi pkg/https-everywhere-$(UPSTREAM_VERSION).xpi

override_dh_auto_test:
	@echo "No further tests are provided than what is during makexpi.sh."

override_dh_auto_clean:
	make clean
	# record upstream Git number if possible
	if type git > /dev/null && [ -d .git ]; then \
		echo -n $(UPSTREAM_VERSION): > debian/upstream-git-commit-id; \
		git rev-parse $(UPSTREAM_VERSION) >> debian/upstream-git-commit-id; \
	fi

override_dh_builddeb:
	dh_builddeb -- -z2 -Zxz

override_dh_install:
	rm -f debian/xul-ext-https-everywhere/usr/share/xul-ext/https-everywhere/LICENSE.txt

override_dh_installchangelogs:
	dh_installchangelogs src/Changelog
