#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export OMPI_MCA_plm_rsh_agent=/bin/false

%:
	dh $@

override_dh_autoreconf:
	echo $(DEB_VERSION_UPSTREAM) > .tarball-version
	echo $(DEB_VERSION_UPSTREAM) > sc/.tarball-version
	dh_autoreconf ./bootstrap

override_dh_auto_configure:
	dh_auto_configure -- \
	--enable-mpi \
	--enable-mpiio

VERSION := 1.1
get-orig-source:
	wget --no-clobber -O p4est-$(VERSION).tar.gz https://github.com/cburstedde/p4est/archive/v${VERSION}.tar.gz
	wget --no-clobber -O libsc-$(VERSION).tar.gz https://github.com/cburstedde/libsc/archive/v${VERSION}.tar.gz
	mkdir p4est-$(VERSION)
	mkdir p4est-$(VERSION)/sc
	tar --strip-components=1 -C p4est-$(VERSION) -xzf p4est-$(VERSION).tar.gz
	tar --strip-components=1 -C p4est-$(VERSION)/sc -xzf libsc-$(VERSION).tar.gz
	set -e; cd p4est-$(VERSION); \
		rm -rf doc/*.pdf sc/doc/*.pdf
	tar -cJf p4est_$(VERSION).orig.tar.xz p4est-$(VERSION)
	rm -rf p4est-$(VERSION)
