#!/usr/bin/make -f
DTMP = $(CURDIR)/debian/tmp
HIP_VERSION = $(shell sed -n '1s/.*(\([0-9.]\+\)-.*).*/\1/p' debian/changelog)

# Environment
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -lpthread
export HIP_CLANG_PATH = /usr/bin
export ROCM_PATH = /usr
export HIP_CLANG_HCC_COMPAT_MODE = 1
# Verbose mode, for help with debuging build problems
#export HIPCC_COMPILE_FLAGS_APPEND += -v
#export HIPCC_LINK_FLAGS_APPEND += -v
#export HIPCC_VERBOSE = 7

# List of supported architecture to proceed to offload.  This is a work around
# failure to build from source on autobuilders
OFFLOAD_ARCHS = gfx803
OFFLOAD_ARCHS+= gfx900
OFFLOAD_ARCHS+= gfx906
OFFLOAD_ARCHS+= gfx1030
OFFLOAD_ARCHS_STR = $(foreach ARCH, $(OFFLOAD_ARCHS), --offload-arch=$(ARCH))

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_SKIP_RPATH=ON \
		-DHIP_COMMON_DIR=$(shell realpath hip) \
		-DCLR_BUILD_HIP=ON \
		-DCLR_BUILD_OCL=ON \
		-DROCM_PATH=/usr \
		-DFILE_REORG_BACKWARD_COMPATIBILITY=OFF \
		-DCMAKE_HIP_ARCHITECTURES=gfx906 \
		-DOFFLOAD_ARCH_STR=" $(OFFLOAD_ARCHS_STR)" \
		-DHIP_PLATFORM=amd \
		-DUSE_PROF_API=OFF \
		-DHIPCC_BIN_DIR="/usr/bin"

# dwz doesn't fully support DWARF-5 yet, see #1016936
override_dh_dwz:
	:

override_dh_auto_test:
	:
