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

SOURCEPKG=$(shell dpkg-parsechangelog | sed  -n 's/^Source: \(.*\)/\1/p')
UPSTREAM=$(shell dpkg-parsechangelog |  sed -n 's/^Version: \(.*\)-[^-]*/\1/p')
SHA1=$(lastword $(subst ~g, ,$(UPSTREAM)))
ORIG=${SOURCEPKG}_${UPSTREAM}.orig.tar.gz

export CONFIG_SHELL=/bin/bash

%:
	dh $@ --parallel

override_dh_auto_configure: cmake/version.cmake
	dh_auto_configure -- -DDONT_INSTALL_GCONF_SCHEMAS=1 -DINSTALL_IOP_LEGACY=1 -DINSTALL_IOP_EXPERIMENTAL=1 -DBINARY_PACKAGE_BUILD=1

override_dh_auto_build:
	dh_auto_build

override_dh_strip:
	dh_strip --dbg-package=darktable-dbg

describe-current-version:
	git describe --tags upstream | sed 's,^release-,,;s,-,+,;s,-,~,;'

get-orig-source:
	git archive --format=tar $(SHA1) | gzip -9 > ../$(ORIG)

.PHONY: describe-current-version git-orig-source

cmake/version.cmake:
	echo "set(PROJECT_VERSION \"${UPSTREAM}\")" > $@
