#!/usr/bin/make -f
# -*- makefile -*-

NULL =

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

export DPKG_GENSYMBOLS_CHECK_LEVEL=4

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Workaround linking issue on Ubuntu 26.04, where QArrayData::shared_null gets
# included in the binary instead of being referred from libQt5Core5.so, breaking
# QByteArray::isNull().
export DEB_BUILD_MAINT_OPTIONS += optimize=-lto

# http://ccache.samba.org/manual.html#_precompiled_headers
export CCACHE_SLOPPINESS=time_macros

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure --builddirectory=build-qt6 -- \
	                     -DCMAKE_INSTALL_SYSCONFDIR=/etc \
	                     -DCMAKE_INSTALL_DOCDIR=share/doc/liblomiri-thumbnailer-qt-dev \
	                     -DENABLE_QT6=ON \
	                     -DENABLE_UBUNTU_COMPAT=OFF \
	                     -DENABLE_DOC=OFF \
	                     -DCHECK_WHITESPACE_IGNORE=$(CURDIR)/build-qt6\;$(CURDIR)/build-qt5 \
	                     -DCHECK_COPYRIGHT_IGNORE=$(CURDIR)/build \
	                     $(NULL)
	dh_auto_configure --builddirectory=build-qt5 -- \
	                     -DCMAKE_INSTALL_SYSCONFDIR=/etc \
	                     -DCMAKE_INSTALL_DOCDIR=share/doc/liblomiri-thumbnailer-qt-dev \
	                     -DENABLE_QT6=OFF \
	                     -DENABLE_UBUNTU_COMPAT=OFF \
	                     -DCHECK_WHITESPACE_IGNORE=$(CURDIR)/build-qt6\;$(CURDIR)/build-qt5 \
	                     -DCHECK_COPYRIGHT_IGNORE=$(CURDIR)/build \
	                     $(NULL)

override_dh_auto_build:
	dh_auto_build --builddirectory=build-qt6
	dh_auto_build --builddirectory=build-qt5

# Tests are not written to be run in parallel.
# We ignore failing tests on PPC because the thumbnailer is irrelevant there,
# and gstreamer has bugs in the plugins for PPC.
override_dh_auto_test:
	dh_auto_test --builddirectory=build-qt6 --no-parallel -- ARGS=\"--verbose\"
	dh_auto_test --builddirectory=build-qt5 --no-parallel -- ARGS=\"--verbose\"

override_dh_auto_install:
	dh_auto_install --builddirectory=build-qt6
	dh_auto_install --builddirectory=build-qt5

override_dh_auto_clean:
	dh_auto_clean --builddirectory=build-qt6
	dh_auto_clean --builddirectory=build-qt5

get-orig-source:
	uscan --noconf --force-download --rename --download-current-version --destdir=..
