#!/usr/bin/make -f

# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_BUILD_ARCH  ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
        OPTFLAGS = --disable-optimize
else
        OPTFLAGS = --enable-optimize
endif

BRANDING_DIR = calendar/sunbird/branding/nightly/

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

#export BUILD_OFFICIAL=1
#export MOZILLA_OFFICIAL=1

ifneq (,$(findstring s390,$(DEB_HOST_GNU_TYPE)))
        export FORCE_USE_HOST_OS=1
endif

DEB_MOZ_NAME=iceowl

DEB_CONFIGURE_USER_FLAGS= \
        --host=$(DEB_HOST_GNU_TYPE) \
	--enable-application=calendar \
	--enable-calendar \
	--disable-strip \
	--disable-strip-libs \
	--disable-install-strip \
	--disable-crashreporter \
	--disable-tests \
	--disable-mochitest \
        --enable-default-toolkit=cairo-gtk2-x11 \
	--with-default-mozilla-five-home=/usr/lib/iceowl \
	--with-system-mng=/usr \
	--with-system-jpeg=/usr \
	--with-system-zlib=/usr \
        --with-system-bz2 \
	$(OPTFLAGS) \
	--with-system-nspr \
	--with-system-nss \
	--enable-gnomevfs \
	--enable-system-sqlite \
	--disable-necko-wifi \
	--enable-static \
	--enable-static-mail \
	--disable-shared \
	--disable-debug \
        --build=$(DEB_BUILD_GNU_TYPE) \
        --host=$(DEB_HOST_GNU_TYPE) \
	--with-distribution-id=org.debian


common-install-arch::
	make -C calendar/installer install DESTDIR=$(CURDIR)/debian/tmp


clean::
	rm -f debian/stamp-iceowl-branding


post-patches:: debian/stamp-iceowl-branding
debian/stamp-iceowl-branding:
	cp -af debian/iceowl-branding/* $(BRANDING_DIR)
	touch $@

CFLAGS=-g
CXXFLAGS=-g

export CFLAGS CXXFLAGS
