#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
export QT_SELECT=qt5
export QT_VERSION=5
include /usr/share/dpkg/buildflags.mk

# Convince the upstream build system to avoid using `(fake)root` by
# overriding its definition of these variables
export INSTALL_DIR=install -d -m 755
export INSTALL_FILE=install -m 644
export INSTALL_PROGRAM=install -m 755

%:
	dh $@

override_dh_auto_configure:
	cp ChangeLog txt/changelog
	lrelease x2goclient.pro
	dh_auto_configure --buildsystem=qmake --builddirectory=client_build -- ../x2goclient.pro

override_dh_auto_build:
	dh_auto_build --buildsystem=qmake --builddirectory=client_build
	make PREFIX=/usr build_man

override_dh_auto_install:
	make install_client DESTDIR=$(CURDIR)/$(PACKAGE) PREFIX=/usr
	make install_man DESTDIR=$(CURDIR)/$(PACKAGE) PREFIX=/usr
	mkdir -p $(CURDIR)/$(PACKAGE)/usr/libexec/
	cp $(CURDIR)/$(PACKAGE)/usr/bin/x2goclient $(CURDIR)/$(PACKAGE)/usr/libexec/

override_dh_auto_clean:
	dh_auto_clean
	# clean stray .qm files that are not handled by clean rule in upstream Makefile
	mkdir -p txt/
	rm -Rf res/i18n/x2goclient_*.qm
	rm -f  txt/changelog

override_dh_missing:
	dh_missing --fail-missing

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