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

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

DH_OPTIONS=--parallel

DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
libdir := /usr/lib/$(DEB_HOST_MULTIARCH)

# get DEB_VERSION from dpkg itself
include /usr/share/dpkg/pkg-info.mk

%:
	dh $@ $(DH_OPTIONS)

.PHONE: override_dh_auto_install
override_dh_auto_install:
	dh_auto_install
	chrpath -d debian/tmp/usr/bin/pj_dump
	chrpath -d debian/tmp/usr/bin/pj_equals
	mkdir -p debian/tmp$(libdir)
	mv debian/tmp/usr/lib/libpaje* debian/tmp$(libdir)
	mv debian/tmp/usr/lib/pkgconfig debian/tmp$(libdir)
	sed -e 's,/lib$$,/lib/$(DEB_HOST_MULTIARCH),' -i debian/tmp$(libdir)/pkgconfig/libpaje.pc

.PHONY: override_dh_shlibdeps
override_dh_shlibdeps:
	dh_shlibdeps -a -- --warnings=7

.PHONY: override_dh_strip
override_dh_strip:
	dh_strip --dbg-package=paje-dbg

.PHONY: override_dh_install
override_dh_install:
	dh_install --fail-missing

clean:
	dh clean $(DH_OPTIONS)
	$(RM) -r build
	$(RM) -r stamp-*
	# if this is a git repository, restore removed files that would have
	# been ignored by dpkg-source
	-test -d .git && git checkout -- $$(git status | \
		sed -e '/^#[[:space:]]*deleted:[[:space:]]*/s/^#[[:space:]]*deleted:[[:space:]]*//p;d' | \
		grep -v '^debian/')

DEB_UPSTREAM_VERSION := $(shell echo $(DEB_VERSION) | sed -e 's/-[^-]*$$//')
GIT_URL = https://github.com/schnorr/pajeng.git

get-orig-source::
	uscan --verbose --force-download
