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

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

export DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
# Work around pointer equality problem with -Bsymbolic-functions:
# http://lists.linaro.org/pipermail/linaro-toolchain/2014-January/003944.html
ifneq (,$(findstring powerpc,$(DEB_HOST_GNU_TYPE)))
export DEB_BUILD_MAINT_OPTIONS := hardening=+pie
endif

ifneq (,$(findstring arm,$(DEB_HOST_GNU_TYPE)))
export DEB_BUILD_MAINT_OPTIONS := hardening=+pie
endif


ifneq (,$(findstring aarch64,$(DEB_HOST_GNU_TYPE)))
export DEB_BUILD_MAINT_OPTIONS := hardening=+pie
endif

BUILDHOME=$(CURDIR)/debian/build

override_dh_clean:
	dh_clean
	rm -rf $(BUILDHOME)

override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_test:
	mkdir -p $(BUILDHOME)
	HOME=$(BUILDHOME) dh_auto_test

dh_auto_install:
	rm -f debian/tmp/usr/lib/*.so
	dh_install --fail-missing

%:
	dh  $@ --parallel --with translations

override_dh_installdeb:
	dh_apparmor --profile-name=usr.lib.lomiri-download-manager.ldm-extractor -plomiri-download-manager
	dh_installdeb

override_dh_translations:
	make -C po lomiri-download-manager.pot
