#!/usr/bin/make -f

PYVERS   := $(shell pyversions -r)
PY3VERS  := $(shell py3versions -r)

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

override_dh_auto_build:
	set -xe; \
	for py in $(PYVERS) $(PY3VERS); do \
		$$py setup.py build; \
	done
	sphinx-build -aEN -b html -d build/doctrees doc/source build/html

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	set -xe; \
	export PYTHONPATH=.; \
	for py in $(PYVERS); do \
		$$py /usr/bin/nosetests; \
	done
	set -xe; \
	cd build/lib; \
	export PYTHONPATH=.; \
	for py in $(PY3VERS); do \
		$$py -m unittest discover -s bs4; \
	done
endif

override_dh_auto_install:
	set -xe; \
	for py in $(PYVERS); do \
		$$py setup.py install --skip-build --root debian/python-bs4 \
			--install-layout deb; \
	done
	set -xe; \
	for py in $(PY3VERS); do \
		$$py setup.py install --skip-build --root debian/python3-bs4 \
			--install-layout deb; \
	done

override_dh_installchangelogs:
	dh_installchangelogs NEWS.txt

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build
