#!/usr/bin/make -f
#export DH_VERBOSE=1

DEB_BUILD_MAINT_OPTIONS=hardening=-pie reproducible=-fixfilepath,+fixdebugpath

# Test failures occured with LTO on these architectures
ifneq ($(findstring $(DEB_HOST_ARCH), arm64 ppc64el s390x),)
	DEB_BUILD_MAINT_OPTIONS += optimize=-lto
endif
export DEB_BUILD_MAINT_OPTIONS

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

ifeq ($(DEB_HOST_ARCH),amd64)
	DEBIAN_OPTIMIZE := amd64
endif

ifeq ($(DEB_HOST_ARCH),i386)
	DEBIAN_OPTIMIZE := x86
endif

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- $(DEBIAN_OPTIMIZE)
