#!/usr/bin/make -f

MAKEFILE = $(firstword $(MAKEFILE_LIST))
DEBIAN_DIR = $(dir $(MAKEFILE))
DEB_VERSION = $(shell dpkg-parsechangelog -l$(DEBIAN_DIR)/changelog | grep ^Vers | cut -d\  -f2)
VERSION = $(shell echo $(DEB_VERSION) | sed 's,-.*,,' | sed 's,+dfsg.*,,')
DEB_CLI_ABI_VERSION = 5.0

override_dh_install:
	# pkg-config
	install -D $(CURDIR)/debian/nrefactory.pc \
	           $(CURDIR)/debian/tmp/usr/lib/pkgconfig/nrefactory.pc
	perl -pe 's/#VERSION#/$(VERSION)/' -i \
	  $(CURDIR)/debian/tmp/usr/lib/pkgconfig/nrefactory.pc
	perl -pe 's/#DEB_CLI_ABI_VERSION#/$(DEB_CLI_ABI_VERSION)/g' -i \
	  $(CURDIR)/debian/tmp/usr/lib/pkgconfig/nrefactory.pc
	dh_install

override_dh_auto_build:
	xbuild $(CURDIR)/NRefactory.sln /p:Configuration=Debug

override_dh_auto_clean:
	xbuild $(CURDIR)/NRefactory.sln /p:Configuration=Debug /t:Clean
	-rm -r $(CURDIR)/bin

override_dh_makeclilibs:
	dh_makeclilibs -V

override_dh_clideps:
	dh_clideps --exclude-moduleref=fusion

%:
	dh $@ --with=cli
