#!/usr/bin/make -f

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

DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^+]+).*,\1,p')

# Fixes some FTBFS, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=730423
# and http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=726989
XDG_CONFIG_DIRS := $(shell echo $(XDG_CONFIG_DIRS)):/usr/lib/$(DEB_HOST_MULTIARCH)
export XDF_CONFIG_DIRS

%:
	dh $@ --parallel

override_dh_clean:
	dh_clean
	rm -rf unix/
	find . -name *.qm -delete
	rm -rf debian/librecad.1 debian/librecad.desktop \
           debian/librecad.sharedmimeinfo debian/librecad.mime \
           debian/librecad.png debian/librecad.xpm debian/librecad.svg \
           librecad/support/doc/LibreCADdoc.qch \
           librecad/support/doc/LibreCADdoc.qhc plugins/intermediate \
           generated/ custom.pro

override_dh_auto_configure:
	if grep -q precise /etc/lsb-release;\
	 then echo "CXX_CPP11_FLAG = -std=c++0x" > custom.pro;\
	fi
	dh_auto_configure -- librecad.pro
	cp desktop/librecad* debian
	cp desktop/graphics_icons_and_splash/Icon\ LibreCAD/Icon_Librecad.svg debian/librecad.svg
	convert -resize 48x48 desktop/graphics_icons_and_splash/Icon\ LibreCAD/Icon_Librecad.svg debian/librecad.png
	convert -resize 32x32 desktop/graphics_icons_and_splash/Icon\ LibreCAD/Icon_Librecad.svg debian/librecad.xpm

override_dh_compress:
	dh_compress -X.qch -X.qhc

copyright_check:
	$(MAKE) -f /usr/share/cdbs/1/rules/utils.mk debian/stamp-copyright-check
	rm debian/stamp-copyright-check

get-orig-source:
	uscan --download-current-version --repack --rename
