#!/usr/bin/make -f

PYVERS = $(shell py3versions -vs)

MIN_VER = 3.13.2-1~
NEXT_VER = 3.14

SPACE := $(EMPTY) $(EMPTY)
COMMA := ,
# $(call _pyver,<prefix>,<versions>,<suffix>)
_pyver = $(subst $(SPACE),$(COMMA)$(SPACE),$(strip $(foreach v,$2,$1$(v)$3)))

%:
	dh $@

override_dh_auto_install:
	( \
	  echo 'python3:Depends=python3 (>= $(MIN_VER)), python3 (<< $(NEXT_VER))'; \
	  echo 'python3:Versions=$(call _pyver,,$(PYVERS),)'; \
	  echo 'python3:Provides=$(call _pyver,python,$(PYVERS),-gdbm)'; \
	  echo 'gdbm:Depends=$(call _pyver,python,$(PYVERS),-gdbm)'; \
	) >> debian/python3-gdbm.substvars
	( \
	  echo 'python3:Depends=python3 (>= $(MIN_VER)), python3 (<< $(NEXT_VER))'; \
	  echo 'python3:Versions=$(call _pyver,,$(PYVERS),)'; \
	  echo 'python3:Provides=$(call _pyver,python,$(PYVERS),-tk)'; \
	  echo 'tk:Depends=$(call _pyver,python,$(PYVERS),-tk)'; \
	) >> debian/python3-tk.substvars

override_dh_installdocs:
	dh_installdocs -p python3-gdbm-dbg --link-doc python3-gdbm
	dh_installdocs -p python3-tk-dbg --link-doc python3-tk
	dh_installdocs --remaining-packages
