#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
#export DH_VERBOSE=1

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

export QT_SELECT = qt5

# Define install target dir
INSTALLDIR = $(CURDIR)/debian/tmp

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --with pkgkde_symbolshelper

override_dh_auto_configure:
	qmake

override_dh_auto_install:
	# Install Pascal binding source & fix permissions
	mkdir -p $(INSTALLDIR)/usr/share/pascal/qt5
	install $(CURDIR)/qt5.pas $(INSTALLDIR)/usr/share/pascal/qt5/
	for type in pas p txt ; do find $(INSTALLDIR)/usr/share/ -type f -name "*$$type" -exec chmod -x '{}' \; ; done
	# Now install the lib
	dh_auto_install --destdir=$(INSTALLDIR)
	# If we don't have a multiarch-Qt, copy lib to multiarch path anyway
	$(CURDIR)/debian/fix-multiarch.sh TARGET=$(INSTALLDIR) HOST_MULTIARCH=$(DEB_HOST_MULTIARCH)

override_dh_install:
	dh_install --list-missing