#!/usr/bin/make -f

python3_all = py3versions -s | xargs -n1 | xargs -t -I {} env {}

ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH),arm64)
	NOTMUCH_SKIP_TESTS=T460-emacs-tree
	export NOTMUCH_SKIP_TESTS
endif

%:
	dh $@ --with python2,python3,elpa

override_dh_auto_configure:
	./configure --prefix=/usr \
		--libdir=/usr/lib/$$(dpkg-architecture -q DEB_TARGET_MULTIARCH) \
		--includedir=/usr/include \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--sysconfdir=/etc \
		--localstatedir=/var

override_dh_auto_build:
	dh_auto_build -- V=1
	dh_auto_build --sourcedirectory bindings/python
	cd bindings/python && $(python3_all) setup.py build
	$(MAKE) -C contrib/notmuch-mutt

override_dh_auto_clean:
	dh_auto_clean
	dh_auto_clean --sourcedirectory bindings/python
	cd bindings/python && $(python3_all) setup.py clean -a
	dh_auto_clean --sourcedirectory bindings/ruby
	$(MAKE) -C contrib/notmuch-mutt clean

override_dh_auto_install:
	dh_auto_install
	dh_auto_install --sourcedirectory bindings/python
	cd bindings/python && $(python3_all) setup.py install --install-layout=deb --root=$(CURDIR)/debian/tmp
	dh_auto_install --sourcedirectory bindings/ruby
