#!/usr/bin/make -f

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

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

export CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
export CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) -Wl,--as-needed
export QT_SELECT := qt5

%:
	dh $@ --with pkgkde_symbolshelper

override_dh_auto_configure:
	qmake CONFIG-=use_gold_linker

override_dh_auto_build-indep:
	dh_auto_build -- docs

override_dh_auto_install-indep:
	dh_auto_build -- INSTALL_ROOT=$(CURDIR)/debian/tmp install_docs

override_dh_auto_install-arch:
	dh_auto_install

	# Remove libtool-like file
	rm -vf debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libQt5WaylandCompositor.la
	rm -fv debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libQt5WaylandClient.la

	# Remove private elements.
	rm -rvf debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/qt5/QtWaylandCompositor/*/QtWaylandCompositor/private
	rm -rvf debian/tmp/usr/include/$(DEB_HOST_MULTIARCH)/qt5/QtWaylandClient/*/QtWaylandClient/private/
	rm -fv debian/tmp/usr/lib/*/qt5/mkspecs/modules/qt_lib_*_private.pri

override_dh_missing:
	dh_missing --fail-missing

override_dh_link:
	dh_link -pqtwayland5-dev-tools \
		usr/lib/qt5/bin/qtwaylandscanner usr/lib/$(DEB_HOST_MULTIARCH)/qt5/bin/qtwaylandscanner

override_dh_strip:
	dh_strip --dbgsym-migration='qtwayland5-dbg (<< 5.7.0-1~)'
