#!/usr/bin/make -f
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

TYPELIB := python /usr/lib/icedove-devel/sdk/bin/typelib.py \
 -I"/usr/lib/icedove-devel/idl" \
 -I"interfaces/exchangeAddressBook/exchangeAbCard" \
 -I"interfaces/exchangeBaseItem" \
 -I"interfaces/exchangeTimeZones"

TOPDIRS := $(shell ls -d */)

%:
	dh $@ --with xul-ext --buildsystem=xul_ext

override_dh_auto_build:
	for idlfile in $$(find $(TOPDIRS) -type f -name *.idl); do \
		$(TYPELIB) -o $$(dirname $$idlfile)/$$(basename $$idlfile .idl).xpt $$idlfile; \
	done
	dh_auto_build

override_dh_auto_install:
	install-xpi -x 'chrome/skins/fugue/Fugue Icons README.txt' \
		$$(find $(TOPDIRS) -name *.idl -printf '-x %p ') \
		-x history.en_US.txt \
		-x license.txt \
		-x defaults/preferences/debug.js \
		calendar-exchange-provider.xpi

override_dh_installdocs:
	cp history.en_US.txt Changelog
	dh_installdocs

override_dh_auto_clean:
	dh_auto_clean
	find -type f -name *.xpt -delete
	find -type f -name Changelog -delete

