#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DPKG_GENSYMBOLS_CHECK_LEVEL = 4

ifneq (amd64,$(DEB_HOST_ARCH))
CMAKE_EXTRA_FLAGS:=-DIMAGE_SUPPORT=OFF
else
CMAKE_EXTRA_FLAGS:=
endif


CMAKE_EXTRA_FLAGS += \
 -DINCLUDE_PATH_COMPATIBILITY=OFF \
 -DCMAKE_PREFIX_PATH=/usr/lib/rocm \
 -DBUILD_ROCRTST=ON \
 -DROCRTST_BLD_TYPE=Release

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure $@ -- $(CMAKE_EXTRA_FLAGS)

# dh_fixperms doesn't fix platform_config.yaml because its not being installed in
# /usr/share, so we need to manually fix the permissions to remove the executable bit
override_dh_fixperms:
	dh_fixperms
	chmod -x debian/libhsa-runtime64-tests/usr/libexec/rocm/libhsa-runtime64-tests/platform_config.yaml

# Skip stripping GPU kernel binaries (.hsaco) - not valid host ELF files
override_dh_strip:
	dh_strip --exclude=.hsaco

# Skip DWZ for GPU kernel binaries (.hsaco) - do not contain DWARF debug info
override_dh_dwz:
	dh_dwz --exclude=.hsaco
