#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

export PYBUILD_NAME=ase

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

override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
		PYBUILD_TEST_ARGS="cd ase/test; {interpreter} -m ase.test" \
		PATH=$(CURDIR)/tools:$$PATH \
		LC_ALL=C.UTF-8 \
		dh_auto_test

override_dh_auto_install:
	# Fix some permissions
	chmod -x $(CURDIR)/doc/static/*
	chmod -x $(CURDIR)/doc/ase/calculators/*

	dh_auto_install

	# Move scripts from python3-ase to ase, drop them from python-ase
	mkdir -p $(CURDIR)/debian/ase/usr/bin/
	mv $(CURDIR)/debian/python3-ase/usr/bin/* $(CURDIR)/debian/ase/usr/bin/
	rm -f $(CURDIR)/debian/python-ase/usr/bin/*

generate-manpages:
	help2man --version-string $(DEB_VERSION_UPSTREAM) -N -n "Build simple molecule or bulk structure" \
		ase-build -o $(CURDIR)/debian/man/ase-build.1
	help2man --version-string $(DEB_VERSION_UPSTREAM) -N -n "Put stuff into or query database" \
		ase-db -o $(CURDIR)/debian/man/ase-db.1
	help2man --version-string $(DEB_VERSION_UPSTREAM) -N -n "graphical user interface for ASE" \
		ase-gui -o $(CURDIR)/debian/man/ase-gui.1
	help2man --version-string $(DEB_VERSION_UPSTREAM) -N -n "Write information about files" \
		ase-info -o $(CURDIR)/debian/man/ase-info.1
	help2man --version-string $(DEB_VERSION_UPSTREAM) -N -n "Run calculations with ASE's calculators" \
		ase-run -o $(CURDIR)/debian/man/ase-run.1
