#!/usr/bin/make -f

include /usr/share/dpkg/default.mk

#export DH_VERBOSE=1

DEB_HOST_ARCH		?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- -DVERSION=$(DEB_VERSION_UPSTREAM)


override_dh_auto_build: generate-suppport-gpus-510 generate-suppport-gpus-470 \
						generate-suppport-gpus-390 generate-suppport-gpus-340

generate-suppport-gpus-510:
	python3 $(CURDIR)/debian/nvidia_supported \
		$(CURDIR)/debian/supported-gpus-510.json \
		> $(CURDIR)/debian/510-supported-gpus.json

generate-suppport-gpus-470:
	python3 $(CURDIR)/debian/nvidia_supported \
		$(CURDIR)/debian/supported-gpus-470.json \
		> $(CURDIR)/debian/470-supported-gpus.json

generate-suppport-gpus-390:
	$(if $(filter arm64,$(DEB_HOST_ARCH)),,\
	(cp $(CURDIR)/debian/supported-gpus-390.json \
		$(CURDIR)/debian/390-supported-gpus.json))

generate-suppport-gpus-340:
	$(if $(filter arm64,$(DEB_HOST_ARCH)),,\
	(cp $(CURDIR)/debian/supported-gpus-340.json \
		$(CURDIR)/debian/340-supported-gpus.json))
