#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

export QT_SELECT = qt5
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Optimize with O3 to make the computationally expensive higher levels faster.
ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
  export DEB_CXXFLAGS_MAINT_APPEND = -O3
endif

# Use an external web browser where Qt5WebView is not available.
WEBVIEW_ARCHS = amd64 arm64 armhf i386 mipsel
ifeq (,$(filter $(WEBVIEW_ARCHS),$(DEB_HOST_ARCH)))
  WEBVIEW_FLAG = -DPENTOBI_OPEN_HELP_EXTERNALLY=ON
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_TESTING=ON \
		-DCMAKE_INSTALL_BINDIR=/usr/games \
		-DCMAKE_INSTALL_DATADIR=/usr/share/games \
		-DKDE_INSTALL_USE_QT_SYS_PATHS=ON \
		-DPENTOBI_BUILD_KDE_THUMBNAILER=ON \
		$(WEBVIEW_FLAG)

# dh_makeshlibs not needed, the KDE thumbnailer .so file is a plugin.
override_dh_makeshlibs:
