#!/usr/bin/make -f

DEB_HOST_ARCH_CPU=$(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
export DEB_CPPFLAGS_MAINT_APPEND = -D_FORCE_INLINES

ifeq ($(DEB_HOST_ARCH_CPU),s390x)
OPENMPI=no
else
OPENMPI=yes
endif

CONFIGURE_ENV=CUPTI_ROOT=/usr
CONFIGURE=--with-cuda=/usr --with-litl=/usr --with-gtg=/usr --with-starpu=/usr

%:
	dh $@ --parallel --with autoreconf

override_dh_auto_configure:
	$(CONFIGURE_ENV) dh_auto_configure -Bbuild-mpich -- $(CONFIGURE) --with-mpi-include=/usr/include/mpich --with-mpi-module-name=mpich --with-mpi-event-id=4

override_dh_auto_build:
	dh_auto_build -Bbuild-mpich -- -C src/modules/cuda

override_dh_auto_clean:
	dh_auto_clean -Bbuild-mpich -- -C src/modules/cuda
	rm -f test/automake/testcommon.h

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp -Bbuild-mpich -- -C src/modules/cuda

override_dh_auto_test:
	-dh_auto_test --no-parallel -Bbuild-mpich -- -C src/modules/cuda -k

override_dh_strip:
	dh_strip -Xlibeztrace-autostart-
