#!/usr/bin/make -f

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

export PYBUILD_NAME = phonopy

%:
	dh $@ --buildsystem cmake

override_dh_auto_configure:
	dh_auto_configure -- -DPHONOPY=ON -DBUILD_SHARED_LIBRARIES=ON
	dh_auto_configure --buildsystem=pybuild

execute_after_dh_auto_build:
	dh_auto_build --buildsystem=pybuild

execute_after_dh_auto_test:
	dh_auto_test --buildsystem=pybuild -- --test-pytest

execute_after_dh_auto_install:
	dh_auto_install --buildsystem=pybuild

execute_after_dh_auto_clean:
	dh_auto_clean --buildsystem=pybuild
	rm -rf phonopy.egg-info

# Manpages should be regenerated after importing, building and installing
# each new upstream release. This has to be done manually, as opposed to
# build time, due to possibly cross-building.

SCRIPTS  = $(wildcard scripts/*)
MANPAGES = ${SCRIPTS:scripts/%=debian/man/%.1}

.PHONY: manpages

manpages: ${MANPAGES}

debian/man/%.1:
	help2man $* --version-string $(DEB_VERSION_UPSTREAM) --no-info > $@
