#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk
export PYBUILD_NAME=alembic
export PYBUILD_BEFORE_TEST=cp {dir}/setup.cfg {build_dir}
export PYBUILD_AFTER_TEST=rm {build_dir}/setup.cfg ; rm -rf {build_dir}/scratch ; rm -f {build_dir}/test_schema.db

%:
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild

override_dh_sphinxdoc:
ifeq (,$(findstring nodocs, $(DEB_BUILD_OPTIONS)))
	python3 -m sphinx -b html docs/build $(CURDIR)/debian/alembic/usr/share/doc/alembic/html
	dh_sphinxdoc
	rm $(CURDIR)/debian/alembic/usr/share/doc/alembic/html/_static/site_custom_css.css
endif

override_dh_auto_install:
	dh_auto_install

	mkdir -p debian/alembic/usr
	mv $(CURDIR)/debian/python3-alembic/usr/bin $(CURDIR)/debian/alembic/usr/

help2man:
	help2man --version-string=$(DEB_VERSION_UPSTREAM) -n "lightweight database migration tool for usage with the SQLAlchemy" -N alembic > debian/alembic.1
	sed -i "s/,\(\w\)/, \1/g" debian/alembic.1
