#!/usr/bin/make -f

export OMPI_MCA_plm_rsh_agent=/bin/false                #workaround to start MPI-applications in chroot
export NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))

disable_auto_test_archs_mpi = hurd-i386 mips mipsel s390 s390x

%:
	dh $@ --parallel

override_dh_auto_clean:
	cd src; make clean-all
	dh_clean

override_dh_auto_build:
	cd src; $(MAKE) -j$(NUMJOBS) yes-all; $(MAKE) -j$(NUMJOBS) no-lib; $(MAKE) -j$(NUMJOBS) openmpi
	mv src/lmp_openmpi src/lammps
	chmod 644 examples/USER/sph/shock_tube/shock2d.lmp

override_dh_auto_test:
	mkdir test; cp examples/crack/* test/
	cd test; ./../src/lammps < in.crack
	rm -rf test
ifeq (,$(filter $(DEB_HOST_ARCH),$(disable_auto_test_archs_mpi)))
	mkdir test; cp examples/crack/* test/
	cd test; mpirun -np 2 ./../src/lammps < in.crack
	rm -rf test
endif
