#!/usr/bin/make -f

PACKAGES=pentadactyl # teledactyl melodactyl
VERSION=$(shell dpkg-parsechangelog | \
	sed -n -e '/^Version:/ { s/^Version:\s*//; s/[^a-z0-9]/_/g; p }')
BUILD_DATE=$(shell date --date="$(shell dpkg-parsechangelog --show-field Date)" "+%Y/%m/%d %H:%M:%S")

%:
	dh $@ --with xul-ext

# this silliness is needed due to the binary/ directory in the project root
.PHONY: binary
binary:
	dh binary --with xul-ext

override_dh_auto_build:
	make DIRS=$(PACKAGES) MANGLE=chrome XPI_FILES='bootstrap.js NEWS' BUILD_DATE="$(BUILD_DATE)" xpi

override_dh_auto_install:
	for PACKAGE in $(PACKAGES); \
		do install-xpi -p xul-ext-$$PACKAGE downloads/$$PACKAGE-*.xpi; \
		done

override_dh_auto_clean:
	make DIRS=$(PACKAGES) clean
	for PACKAGE in $(PACKAGES); \
		do rm -f $$PACKAGE/chrome.zip; \
		done

override_dh_installchangelogs:
	for PACKAGE in $(PACKAGES); \
		do dh_installchangelogs -p xul-ext-$$PACKAGE $$PACKAGE/NEWS; \
		done
