#!/usr/bin/make -f

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

### Add here any variable or target overrides you need.
QTM_VERSION := $(shell grep QTM_VERSION_STR src/global/qmobilityglobal.h | cut -d'"' -f2)

# Find out how many parallel threads to run
comma := ,
TMP_BUILD_OPTS = $(subst $(comma), ,$(DEB_BUILD_OPTIONS))
ifneq (,$(filter parallel=%,$(TMP_BUILD_OPTS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(TMP_BUILD_OPTS)))
	PARALLEL_MAKEFLAGS += -j4
endif

# Add here any variable or target overrides you need.

DEB_MAKE_INVOKE := $(MAKE) $(PARALLEL_MAKEFLAGS)
DEB_MAKE_INSTALL_TARGET := INSTALL_ROOT=$(DEB_DESTDIR) install
DEB_DH_INSTALL_SOURCEDIR := debian/tmp
DEB_CLEAN_EXCLUDE := debian/tmp

DEB_CONFIGURE_NORMAL_ARGS := -maemo5  -prefix /usr -headerdir /usr/include \
	-plugindir /usr/lib/qt4/plugins \
	-examples


DEB_CONFIGURE_EXTRA_FLAGS := -debug -silent

clean::
	rm -Rf debian/config.tests debian/config.pri
	rm -Rf debian/tmp

# Automatically install lintian overrides, stolen from debian-qt-kde.mk
$(patsubst %,binary-install/%,$(DEB_PACKAGES)) :: binary-install/%:
	if test -e debian/$(cdbs_curpkg).lintian; then \
	install -p -D -m644 debian/$(cdbs_curpkg).lintian \
	debian/$(cdbs_curpkg)/usr/share/lintian/overrides/$(cdbs_curpkg); \
fi

common-binary-post-install-arch:: optify-libs

optify-libs:
	maemo-optify libqtm-bearer
	maemo-optify libqtm-contacts
	maemo-optify libqtm-location
	maemo-optify libqtm-messaging
	maemo-optify libqtm-multimedia
	maemo-optify libqtm-publishsubscribe
	maemo-optify libqtm-sensors
	maemo-optify libqtm-serviceframework
	maemo-optify libqtm-systeminfo
	maemo-optify libqtm-versit
	maemo-optify qt-mobility-examples
