#! /usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
#
# debian/rules
# Part of Debian ‘bugs-everywhere’ package.
#
# Copyright © 2008–2011 Ben Finney <ben+debian@benfinney.id.au>
# This is free software; you may copy, modify, and/or distribute this work
# under the terms of the GNU General Public License, version 2 or later.
# No warranty expressed or implied.
# See the file ‘/usr/share/common-licenses/GPL-2’ for details.

%:
	dh $@ --with=python2

override_dh_auto_install:
	dh_auto_install -- INSTALL_OPTIONS="--install-layout=deb --root=$(CURDIR)/debian/bugs-everywhere --prefix=/usr" LIBBE_VERSION=

# this mess is to automatically generate the _version.py file that contains git commit metadata
# since we usually build in a clean export of the git repository, the upstream build system fails
# so we disable that build and build it ourselves

# generate metadata that willbe included in the file
version=$(shell parsechangelog --format=rfc822 | grep Version: | cut -d' ' -f2-)
date=$(shell date +%Y-%m-%d)
LIBBE_VERSION:=libbe/_version.py

show-version: $(LIBBE_VERSION)
	cat $(LIBBE_VERSION)

# disable generation of the metadata, hook our generation in there
override_dh_auto_build: $(LIBBE_VERSION)
	dh_auto_build -- LIBBE_VERSION=

# generate version file based on our generated metadata
$(LIBBE_VERSION):
	printf "# -*- coding: utf-8 -*-\n# Autogenerated by debian/rules libbe/_version.py\nversion_info = {\n    'date': '$(date)',\n    'revision': '$(version)',\n    'committer': 'Debian build scripts'}\n" > $@

override_dh_auto_clean:
	dh_auto_clean
	rm -f $(LIBBE_VERSION)

override_dh_auto_test:


override_dh_installchangelogs:
	dh_installchangelogs -k NEWS


# Local Variables:
# mode: makefile
# coding: utf-8
# End:
# vim: filetype=make fileencoding=utf-8 :
