#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

package_version:=$(shell dpkg-parsechangelog | grep "^Version:" | cut  -d" " -f2 | cut -d- -f1 | cut -d+ -f1)
actual_version:=$(shell PYTHONPATH=src python -c "from catkin_lint import __version__; print __version__")
debianized_version:=$(subst a,~a,$(subst b,~b,$(actual_version)))

ifneq ($(package_version),$(debianized_version))
$(error Package version $(package_version) does not match actual version $(debianized_version))
endif

export PYBUILD_NAME=catkin-lint
export PYBUILD_DISABLE=test

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

make-orig-tar:
	git config tar.tar.xz.command "xz -c"
	git archive --prefix=catkin-lint-$(debianized_version)/ -o ../catkin-lint_$(debianized_version).orig.tar.xz $(shell git merge-base debian $(actual_version) )

make-patches:
	rm -rf debian/patches
	mkdir debian/patches
	git format-patch -o debian/patches $(shell git merge-base debian $(actual_version) )..master
	ls debian/patches/[0-9]* | sed -e 's/^debian\/patches\///' > debian/patches/series

clean-patches:
	rm -rf debian/patches

