#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# QMF environment variables should be set
export QMF_INCLUDEDIR := /usr/include/qmfclient
export QMF_LIBDIR := /usr/lib

%:
	dh $@ --parallel --list-missing --dbg-package=qtmobility-dbg --with pkgkde_symbolshelper

override_dh_auto_configure:
	./configure \
	    -prefix "/usr" \
	    -headerdir "/usr/include" \
	    -libdir "/usr/lib" \
	    -bindir "/usr/bin" \
	    -plugindir "/usr/lib/qt4/plugins" \
	    -demosdir "/usr/lib/qtmobility/demos" \
	    -examplesdir "/usr/lib/qtmobility/examples" \
	    -examples \
	    -demos \
	    -modules "location contacts multimedia publishsubscribe versit messaging systeminfo serviceframework sensors gallery organizer feedback"

override_dh_auto_install:
	dh_auto_install
	# Fix wrong path in pkgconfig files
	find $(CURDIR)/debian/tmp/usr/lib/pkgconfig -type f -name '*.pc' \
		-exec perl -pi -e "s, -L$(CURDIR)/?\S+,,g" {} \;
	# Fix wrong path in prl files
	find $(CURDIR)/debian/tmp/usr/lib -type f -name '*.prl' \
		-exec sed -i -e "/^QMAKE_PRL_BUILD_DIR/d;s/\(QMAKE_PRL_LIBS =\).*/\1/" {} \;

override_dh_auto_clean:
	dh_auto_clean
	rm -f \
	    .qmake.cache \
	    config.tests/networkmanager/networkmanager \
	    config.tests/qmf/qmf \
	    tools/tools.pro.user
	find \( -false \
	    -o -type f -name Makefile \
	    -o -type f -name \*.o \
	    -o -type f -name config.\* \
	    -o -type f -name mobility\*.prf \
	\) -delete
	rm -rf include lib
