#!/usr/bin/make -f

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

ifneq (,$(filter $(DEB_HOST_ARCH),armhf))
    export GCC47 := "QMAKE_CXX=g++-4.7"
else
    export GCC47 := 
endif

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# Upstream changelog
upstream_changes := $(wildcard dist/changes-*)

%:
	dh $@ --parallel --list-missing --dbg-package=qtcreator-dbg --buildsystem=qmake --builddirectory=builddir

override_dh_auto_configure:
	mkdir -p builddir
	dh_auto_configure -- $(CURDIR) $(GCC47) IDE_LIBRARY_BASENAME=lib/$(DEB_HOST_MULTIARCH) IDE_PACKAGE_MODE=1 USE_SYSTEM_BOTAN=1 $(extra_configure_opts)

override_dh_auto_install:
ifneq (,$(filter qtcreator-doc,qtcreator-dev, $(shell dh_listpackages)))
	dh_auto_build -- qch_docs
endif
	dh_auto_install --destdir=debian/tmp/usr
	dh_auto_build -- install_docs INSTALL_ROOT=$(CURDIR)/debian/tmp/usr
	mkdir -p debian/tmp/usr/src/qtcreator/
	find | egrep -v '^\.\/doc|^\.\/share|^\.\/\.pc|^\.\/debian|^\.\/tests|^\.\/share' | grep "\.pri\$$\|\.h\$$\|\.xsl\$$" | xargs -I{} cp --parents -r "{}" debian/tmp/usr/src/qtcreator
	cd debian/tmp/usr/src/qtcreator; cp -r builddir/* .; rm -R builddir

override_dh_auto_clean:
	dh_auto_clean
	# make sure the bundles botan lib isn't used during the build
	rm -f src/libs/3rdparty/botan/botan.cpp src/libs/3rdparty/botan/botan.h

override_dh_installdocs:
	dh_installdocs -pqtcreator $(upstream_changes)
	dh_installdocs --remaining-packages

override_dh_makeshlibs:
	# qtcreator doesn't provide any public libraries

override_dh_shlibdeps:
	dh_shlibdeps -XlibUbuntu.so -XlibCordovaUbuntuProjectManager.so


override_dh_builddeb:
	dh_builddeb -- -Zxz
