#!/usr/bin/make -f

#DH_VERBOSE=1

export PYBUILD_NAME=odfpy
PYTHON2=$(shell pyversions -vr)

%:
	dh $@ --buildsystem=pybuild --with python2 --with python3

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
test-python%:
	cd tests; \
	PYTHONPATH=../`python$* -c "import sys; print ':'.join(sys.path)"`; \
	for F in `ls test*.py` ; do \
		PYTHONPATH=$$PYTHONPATH python$* $$F; \
	done

override_dh_auto_test: $(PYTHON2:%=test-python%)
endif


override_dh_clean:
	# remove manfiles
	for D in csv2ods mailodf odf2xhtml odf2mht odf2xml odfimgimport odflint odfmeta odfoutline odfuserfield xml2odf; do \
		( cd $$D && \
		rm -f $$D.1) \
	done
	# remove build space
	rm -rf build
	# remove generated symlinks
	find . -name odf -type l | xargs rm -f
	dh_clean

override_dh_auto_build:
	for D in csv2ods mailodf odf2xhtml odf2mht odf2xml odfimgimport odflint odfmeta odfoutline odfuserfield xml2odf; do \
		( cd $$D && \
		$(MAKE) ) \
	done
	dh_auto_build
