#!/usr/bin/make -f

export DEB_CFLAGS_MAINT_APPEND = -Wno-error=maybe-uninitialized

%:
	dh $@ --with autoreconf

override_dh_auto_build:
	dh_auto_build
	cd python && python3 setup.py build

override_dh_auto_test:
ifneq (,$(filter $(DEB_HOST_ARCH), armhf))
	-dh_auto_test
	-cd python && python3 setup.py test
else
	dh_auto_test
	cd python && python3 setup.py test
endif

override_dh_auto_install:
	dh_auto_install
	cd python && PYTHONPATH=$(CURDIR)/debian/python3-libi8x/usr/lib/python3/dist-packages \
	    python3 setup.py install \
		--root=$(CURDIR)/debian/python3-libi8x \
		--install-layout=deb
	dh_python3 -ppython3-libi8x

override_dh_auto_clean:
	cd python && python3 setup.py clean
	rm -rf python/*.so python/build python/libi8x.c
	find python -type d -name __pycache__ | xargs -r rm -rf
	dh_auto_clean
