#!/usr/bin/make -f

# Uncomment to enable verbose debhelper logging.
#export DH_VERBOSE = 1

# Enable the default hardening flags.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-fortify

# Upstream uses -D_FORTIFY_SOURCE=3.  Debian default to =D_FORTIFY_SOURCE-2.
# We don't want to downgrade the security since upstream has made sure their
# code works with -D_FORTIFY_SOURCE=3.
export DEB_CPPFLAGS_MAINT_APPEND = -D_FORTIFY_SOURCE=3

# Ensure -fstack-clash-protection is used on all architectures.
# Enable -fcf-protection only on amd64, as it's the only architecture
# that supports it.
ifeq ($(shell dpkg --print-architecture),amd64)
  export DEB_CXXFLAGS_MAINT_APPEND = -fcf-protection
  export DEB_CFLAGS_MAINT_APPEND = -fstack-clash-protection -fcf-protection
else
  export DEB_CFLAGS_MAINT_APPEND = -fstack-clash-protection
endif

%:
	dh $@ --builddirectory=build

override_dh_auto_configure:
	# Build with GUI and ZMQ support.
	dh_auto_configure -- -DBUILD_GUI=ON -DWITH_ZMQ=ON

# Write the content of build/test/config.ini to the log, which can be used to
# update debian/tests/config.ini.
#execute_after_dh_auto_build:
#	cat build/test/config.ini
