#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with=sphinxdoc

override_dh_auto_configure:
	QT_SELECT=qt5 dh_auto_configure --builddir=build5 -- ..
	mkdir -p build6 && cd build6 && qmake6 "QMAKE_CFLAGS_RELEASE=${CFLAGS} ${CPPFLAGS}" "QMAKE_CFLAGS_DEBUG=${CFLAGS} ${CPPFLAGS}" "QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS} ${CPPFLAGS}" "QMAKE_CXXFLAGS_DEBUG=${CXXFLAGS} ${CPPFLAGS}" "QMAKE_LFLAGS_RELEASE=${LDFLAGS}" "QMAKE_LFLAGS_DEBUG=${LDFLAGS}" QMAKE_STRIP=: PREFIX=/usr .. && cd ..

override_dh_auto_build:
	dh_auto_build --builddir=build6
	dh_auto_build --builddir=build5
	/usr/share/sphinx/scripts/python3/sphinx-build -b html docs build/sphinx/html

override_dh_auto_install:
	dh_auto_install --builddir=build6
	dh_auto_install --builddir=build5

override_dh_auto_clean:
	dh_auto_clean --builddir=build6
	dh_auto_clean --builddir=build5
	rm -rf build build5 build6

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	xvfb-run -a ./build5/tests/tests
	xvfb-run -a ./build6/tests/tests
endif

override_dh_installdocs:
	dh_installdocs -ppyotherside-doc --doc-main-package=qml-module-io-thp-pyotherside
	dh_installdocs --remaining-packages

execute_after_dh_install-arch:
	install --mode=644 $(CURDIR)/qtquicktests/*.qml $(CURDIR)/qtquicktests/*py debian/pyotherside-tests/usr/lib/$(DEB_HOST_MULTIARCH)/pyotherside/tests