#!/usr/bin/make -f

PKD  = $(abspath $(dir $(MAKEFILE_LIST)))
PKG  = $(word 2,$(shell dpkg-parsechangelog -l$(PKD)/changelog | grep ^Source))
VER ?= $(shell dpkg-parsechangelog -l$(PKD)/changelog | perl -ne 'print $$1 if m{^Version:\s+(?:\d+:)?(\d.*)(?:\-\d+.*)};')

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

# Workaround gcc 4.9 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61214
export DEB_CXXFLAGS_MAINT_APPEND = -fno-devirtualize

%:
	dh $@ --parallel

override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_INSTALL_LIBDIR=lib

override_dh_shlibdeps:
	dh_shlibdeps -Lcodelite

.PHONY: get-orig-source
## http://wiki.debian.org/onlyjob/get-orig-source
get-orig-source:
	uscan --noconf --verbose --rename --destdir=$(CURDIR) --check-dirname-level=0 --force-download --upstream-version $(VER) $(PKD)
