#!/usr/bin/make -f
# -*- makefile -*-

%:
	dh $@ 

override_dh_auto_clean:
	dh_auto_clean
	find PW/examples -name "results" | xargs rm -rf
	find PW/examples/tests -name "*.out" | xargs rm -rf
	rm -f install/make_wannier90.sys
	rm -f install/make_lapack.inc
	rm -f install/make_blas.inc
	rm -f include/fft_defs.h
	# work-around for shipped binary in upstream tarball
	rm -f CPV/src/wfdd.x

override_dh_auto_build:
	$(MAKE) all
	(cd Doc; $(MAKE))

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
export OMPI_MCA_plm_rsh_agent=/bin/false
override_dh_auto_test:
	# Copy in some required pseudo-potentials which are shipped in other 
	# parts of the source tree
	(cd pseudo; for i in \
		TDDFPT/Examples/pseudo/C.pz-rrkjus.UPF \
		TDDFPT/Examples/pseudo/H.pz-vbc.UPF \
		TDDFPT/Examples/pseudo/O.pbe-rrkjus.UPF \
		TDDFPT/Examples/pseudo/O.pz-rrkjus.UPF \
		TDDFPT/Examples/pseudo/Si.pbe-rrkj.UPF \
		atomic/examples/pseudo-LDA-0.5/Si.pz-vbc.UPF \
	; do ln -sf ../$$i .; done)
	-(cd PW/tests; sh ./check-pw.x.j)
	#Remove symliked pseudo-potentials again
	find pseudo -type l | xargs rm -f
endif
