#!/usr/bin/make -f
# -*- makefile -*-
UPSTREAMTAG=upstream/1.2.2

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

export CONFIG_SHELL=/bin/bash

%: 
	dh $@

override_dh_auto_install:
	make install DESTDIR=$(CURDIR)/debian/tmp
	install --mode=0755 --owner=root test/syncevo-http-server.py \
		$(CURDIR)/debian/tmp/usr/bin/syncevo-http-server

override_dh_auto_configure: 
	sh autogen.sh
	/bin/bash ./configure --with-synthesis-src=none --prefix=/usr --sysconfdir=/etc \
			--libexecdir=/usr/lib/syncevolution --enable-gui \
			--with-rst2man --with-rst2html --enable-dav

override_dh_install:
	dh_install -X"*.pl"

override_dh_strip:
	dh_strip --dbg-package=syncevolution-dbg

override_dh_makeshlibs:
	dh_makeshlibs -psyncevolution-libs -n
	dh_makeshlibs -Nsyncevolution-libs

get-orig-source: 
	git archive --format=tar ${UPSTREAMTAG} --prefix=${SOURCEPKG}_${UPSTREAM}/ | gzip -9 > ../${ORIG}

PATCH_EXPORT_SCRIPT=/usr/share/gitpkg/hooks/quilt-patches-deb-export-hook
export-patches:
	[ ! -r debian/patches ] || \
	grep "^\#*$(notdir $(PATCH_EXPORT_SCRIPT))" debian/patches/series
	rm -rf debian/patches
	bash $(PATCH_EXPORT_SCRIPT)
