#!/usr/bin/make -f
# -*- makefile -*-

ICONSDIR=debian/retext/usr/share/icons/hicolor

# python3 should be last so that scripts get a correct shebang
PY3REQUESTED=$(shell py3versions -r)
PY3DEFAULT=$(shell py3versions -d)
PYTHON3=$(filter-out $(PY3DEFAULT),$(PY3REQUESTED)) python3

%:
	dh $@ --with python3

override_dh_auto_clean:
	rm -rf build ReText/__pycache__

override_dh_auto_build:
	set -ex; for python in $(PYTHON3); do \
		$$python setup.py build; \
	done
	lrelease-qt4 locale/*.ts

override_dh_auto_install:
	set -ex; for python in $(PYTHON3); do \
		$$python setup.py install --install-layout=deb --install-lib=/usr/share/retext \
		--install-scripts=/usr/share/retext --root=debian/tmp --no-rename; \
	done
	for size in 16 22 24 32 48 128; do \
		mkdir -p $(ICONSDIR)/$$size\x$$size/apps/; \
		convert -resize $$size icons/retext.png $(ICONSDIR)/$$size\x$$size/apps/retext.png; \
	done

override_dh_installchangelogs:
	dh_installchangelogs changelog.md
