#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,-z,defs
export DPKG_GENSYMBOLS_CHECK_LEVEL = 4

ifneq ($(filter alpha m68k riscv64 s390x sparc64 x32,$(DEB_HOST_ARCH)),)
libunwind=false
else
libunwind=true
endif

dh_options =

ifneq ($(filter i386,$(DEB_HOST_ARCH)),)
dh_options += -Nsysprof
gtk=false
else
gtk=true
endif

%:
	dh $@ $(dh_options)

override_dh_auto_configure:
	dh_auto_configure -- \
		-Dlibunwind=$(libunwind) \
		-Dgtk=$(gtk) \
		-Dsysprofd=bundled \
		-Dsystemdunitdir=/lib/systemd/system

override_dh_makeshlibs:
	# The libraries in libsysprof-6-modules are to be loaded with
	# LD_PRELOAD, not linked
	dh_makeshlibs -Nlibsysprof-6-modules
