#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)

# For hardening (CPPFLAGS is not taken into account by upstream's build system)
CFLAGS += $(CPPFLAGS)
CXXFLAGS += $(CPPFLAGS)

# Prevent useless dependencies
LDFLAGS += -Wl,--as-needed

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- -DPACKAGE_VERSION=$(DEB_VERSION)

override_dh_auto_build:
	dh_auto_build -- VERBOSE=1

# dh_auto_clean doesn't call make distclean automatically from the CMake build
# directory, so we have to remove leftover .qm files manually
override_dh_auto_clean:
	find -name '*.qm' | xargs rm -fv
	dh_auto_clean
