#!/usr/bin/make -f

DEB_HOST_ARCH_CPU=$(shell dpkg-architecture -qDEB_HOST_ARCH_CPU)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie

OPENMPI=yes

CONFIGURE_ENV=
CONFIGURE=--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
ifeq ($(OPENMPI),yes)
	$(CONFIGURE_ENV) dh_auto_configure -Bbuild-openmpi -- $(CONFIGURE) --with-mpi-include=/usr/lib/openmpi/include --with-mpi-module-name=openmpi --with-mpi-event-id=10
endif

override_dh_auto_build:
	dh_auto_build -Bbuild-mpich
ifeq ($(OPENMPI),yes)
	dh_auto_build -Bbuild-openmpi -- -C src/modules/mpi
endif

override_dh_auto_clean:
	dh_auto_clean -Bbuild-mpich
ifeq ($(OPENMPI),yes)
	dh_auto_clean -Bbuild-openmpi
endif
	rm -f test/automake/testcommon.h

override_dh_auto_install:
	dh_auto_install -Bbuild-mpich
ifeq ($(OPENMPI),yes)
	dh_auto_install -Bbuild-openmpi -- -C src/modules/mpi
endif

override_dh_auto_test:
	-dh_auto_test --no-parallel -Bbuild-mpich -- -k
ifeq ($(OPENMPI),yes)
	-dh_auto_test --no-parallel -Bbuild-openmpi -- -C src/modules/mpi -k
endif
