#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk

ifeq (,$(findstring noa11y,$(DEB_BUILD_OPTIONS)))
ENABLE_A11Y = --enable-a11y
else
ENABLE_A11Y =
endif

ifeq (,$(findstring nolauncher,$(DEB_BUILD_OPTIONS)))
ENABLE_LAUNCHER += --enable-maemo-launcher
endif

ifeq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CFLAGS += -DG_DEBUG_DISABLE
else
CFLAGS += -O0
endif

CFLAGS += -DG_DISABLE_CHECKS -Winline
CFLAGS += -Wno-enum-compare -Wno-unused-but-set-variable -Wno-error=inline
CFLAGS += -Wno-error=switch -Wno-error=strict-aliasing

ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS)))
        CFLAGS += -mthumb -mword-relocations -pie
endif

DEB_CONFIGURE_EXTRA_FLAGS += \
	$(ENABLE_A11Y) \
	$(ENABLE_LAUNCHER) \
	--enable-static-mb2=yes

DEB_DH_STRIP_ARGS := --dbg-package=hildon-desktop
DEB_DH_INSTALLINIT_ARGS := --no-start -- start 51 2 3 4 . stop 20 0 1 5 6 .

makebuilddir/hildon-desktop::
	[ -f configure ] || ./autogen.sh

binary-install/hildon-desktop::
	dh_maemolauncher
	cp src/hildon-desktop-keys.schemas debian/hildon-desktop/usr/share/gconf/schemas/
	dh_installxsession -u 'post 20'
	dh_installxsession --init-script='hildon-desktop-wait' -u 'post 21'

# Save SSU d/l volume.
ifeq ($(DEB_BUILD_ARCH),armel)
binary-post-install/hildon-desktop::
	rm -rf "debian/$(cdbs_curpkg)/usr/share/doc"
endif
