#!/usr/bin/make -f
include /usr/share/dpkg/buildopts.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export PATH := /opt/plasma-build/rust-1.88.0/bin:/opt/plasma/bin:$(PATH)
export CARGO_HOME = $(CURDIR)/debian/cargo-home
export CARGO_NET_OFFLINE = true
export RUSTC = /opt/plasma-build/rust-1.88.0/bin/rustc
export CARGO = /opt/plasma-build/rust-1.88.0/bin/cargo
export CMAKE_PREFIX_PATH = /opt/plasma
export PKG_CONFIG_PATH = /opt/plasma/lib/pkgconfig:/opt/plasma/share/pkgconfig
export XDG_DATA_DIRS = /opt/plasma/share:/usr/local/share:/usr/share

%:
	dh $@ --buildsystem=qmake --builddirectory=obj-module

override_dh_auto_configure:
	mkdir -p obj-module && cd obj-module && /opt/plasma/bin/qmake -r $(CURDIR)/Accounts/Accounts.pro PREFIX=/opt/plasma LIBDIR=/opt/plasma/lib TOP_SRC_DIR=$(CURDIR) TOP_BUILD_DIR=$(CURDIR)/obj-module CONFIG+=release CONFIG-=debug CONFIG+=c++17 QMAKE_LIBDIR+=/opt/plasma/lib QMAKE_RPATHDIR+=/opt/plasma/lib CMAKE_CONFIG_PATH=/opt/plasma/lib/cmake -after SUBDIRS-=tests SUBDIRS-=test SUBDIRS-=example

override_dh_auto_build:
	$(MAKE) -C obj-module -j$(or $(DEB_BUILD_OPTION_PARALLEL),1)

override_dh_auto_test:
	@echo 'Upstream tests disabled as in the frozen trial; consumer checks omitted.'

override_dh_auto_install:
	$(MAKE) -C obj-module install INSTALL_ROOT=$(CURDIR)/debian/tmp
	python3 debian/normalize-permissions.py
	python3 debian/split.py

override_dh_installdocs:
	dh_installdocs
	python3 debian/install-notices.py

override_dh_missing:
	dh_missing --fail-missing

override_dh_makeshlibs:
	dh_makeshlibs -V --no-scripts

override_dh_shlibdeps:
	dh_shlibdeps -l$(CURDIR)/debian/plasma-next-libaccounts-qt/opt/plasma/lib
