#!/usr/bin/make -f

PY2_PACKAGE_NAME=python-xe
PY3_PACKAGE_NAME=python3-xe

# Run setup.py with the default python and python3 last so that the scripts use
# #!/usr/bin/python and #!/usr/bin/python3 and not #!/usr/bin/python2.X and
# #!/usr/bin/python3.X.
PYDEFAULT  := $(shell pyversions -d)
PYVERS     := $(shell pyversions -r)
PYVERS     := $(filter-out $(PYDEFAULT),$(PYVERS)) python
PY3DEFAULT := $(shell py3versions -d)
PY3VERS    := $(shell py3versions -r)
PY3VERS    := $(filter-out $(PY3DEFAULT),$(PY3VERS)) python3

override_dh_auto_build:
	set -xe; \
	for py in $(PYVERS) $(PY3VERS); do \
		$$py setup.py build; \
	done

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

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