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

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

export PYBUILD_NAME = dhros
export PYBUILD_DESTDIR = debian/dh-ros
export PYBUILD_INSTALL_DIR = /usr/share/dh-ros

ifeq ($(shell grep '^version *= *$(DEB_VERSION_UPSTREAM)$$' setup.cfg),)
ifeq ($(shell env | grep SALSA_CI),)
$(error version in setup.py does not match the one in debian/changelog)
endif
endif

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_install:
	find $(PYBUILD_DESTDIR) -name ".pytest_cache" -print0 | xargs -r0 rm -r
	mv $(PYBUILD_DESTDIR)/usr/bin/rosbuilder $(PYBUILD_DESTDIR)$(PYBUILD_INSTALL_DIR)

execute_after_dh_python3:
	# Once debhelper has collected the dependencies, we no longer need this
	rm -r $(PYBUILD_DESTDIR)$(PYBUILD_INSTALL_DIR)/*.dist-info

execute_before_dh_installman: rosbuilder.1

%.1: %.1.in
	sed -e 's/@VERSION@/$(DEB_VERSION_UPSTREAM)/g' $< >$@