#!/usr/bin/make -f

XUL_SDK_DIR	:=	$(shell ls -d /usr/lib/thunderbird-devel-* | tail -n 1)
XPI_STAGE	:=	mozilla/dist/xpi-stage
XPI_FILES = \
	lightning \
	calendar-timezones \
	gdata-provider \
	$(NULL)

DEB_CONFIGURE_USER_FLAGS = 				\
	--enable-application=calendar			\
	--with-libxul-sdk=$(XUL_SDK_DIR)		\
	--with-system-libxul				\
	--disable-strip					\
	--disable-strip-libs				\
	--enable-optimize="-pipe -w $(OPTFLAGS)"	\
	--disable-debug 				\
	--enable-official-branding			\
	--disable-sunbird				\
	--disable-ogg					\
	--disable-wave					\
	--disable-dbus					\
	--disable-libnotify				\
	--disable-necko-wifi				\
	--disable-crashreporter				\
    	--disable-webm \
    	--disable-libjpeg-turbo \
    	--enable-chrome-format=jar \
    	--enable-libxul \
	$(NULL)

%:
	dh $@ --with xul-ext

debian/stamp-autotools-moz:
	if [ ! -e $(CURDIR)/configure ]; then \
		`which autoconf2.13`; \
	fi
	if [ ! -e $(CURDIR)/mozilla/configure ]; then \
		cd mozilla; `which autoconf2.13`; \
	fi
	touch $@

override_dh_auto_configure: debian/stamp-autotools-moz
	dh_auto_configure -- $(DEB_CONFIGURE_USER_FLAGS)

override_dh_auto_install:
	$(foreach xpi,$(XPI_FILES),install-xpi -p xul-ext-$(xpi) $(XPI_STAGE)/$(xpi).xpi;)

override_dh_auto_clean:
	rm -f debian/stamp-autotools-moz
	dh_auto_clean
	
