#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
CFLAGS+=$(CPPFLAGS)
CXXFLAGS+=$(CPPFLAGS)

%:
	dh $@

override_dh_auto_configure:
	ln -s /usr/include/fmt src/3rdparty/fmt
	ln -s /usr/include/rapidjson src/3rdparty/rapidjson

# Work around flaky arch detection in CMake script on armhf
ifeq ($(DEB_HOST_ARCH), armhf)
	dh_auto_configure -- -DWITH_KAWPOW=OFF -DARM_V7=ON
else
	dh_auto_configure -- -DWITH_KAWPOW=OFF
endif

execute_before_dh_auto_build:
	# blhc is triggered by the lack of -D_FORTIFY_SOURCE=2 in the
	# assembler flags. The flag does not affect assembly, so this
	# is a false positive. This line tells blhc to ignore assembly.
	@echo "blhc: ignore-line-regexp: /usr/(bin|lib/ccache)/cc.*\S+\.S"

execute_before_dh_installman:
	help2man -s 1 -n "CPU/GPU cryptocurrency miner" debian/xmrig/usr/bin/xmrig > debian/xmrig.1