#!/usr/bin/make -f
#export DH_VERBOSE=1
export DH_OPTIONS
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

SVGS = debian/svgs
ICONS = debian/icons
DESTDIR = $(CURDIR)/debian/tmp

%:
	dh $@

override_dh_auto_build:
	$(MAKE) all

override_dh_auto_install:
	for i in 16 22 48; do \
		[ $$i -eq 16 ] && SVG=$(SVGS)/skype16.svg || SVG=$(SVGS)/skype.svg; \
		SVGOUT=$(SVGS)/skypeout.svg; \
		mkdir -p $(ICONS)/$${i}; \
		rsvg-convert -w $${i} -h $${i} $${SVG} \
			-o $(ICONS)/$${i}/skype.png; \
		rsvg-convert -w $${i} -h $${i} $${SVGOUT} \
			-o $(ICONS)/$${i}/skypeout.png; \
	done

override_dh_auto_clean:
	-rm -rf $(ICONS)
	dh_auto_clean

override_dh_strip:
	dh_strip --dbg-package=pidgin-skype-dbg

override_dh_builddeb:
	dh_builddeb -- -Zxz

TMPDIR=tmp-pidgin-skype
get-orig-source:
	@echo date=$(date) svnrev=$(svnrev)
	@if [ "$(date)" = "" ] || [ "$(svnrev)" = "" ];then echo \
		"Usage: debian/rules date=YYYYMMDD svnrev=nnnn get-orig-source";exit 1;fi
	svn export -r $(svnrev) http://skype4pidgin.googlecode.com/svn/trunk/ $(TMPDIR)
	find $(TMPDIR) -type f -name '*.png' -print -delete
	cd $(TMPDIR) && tar --exclude-vcs -Jcf ../../pidgin-skype_$(date)+svn$(svnrev)+dfsg.orig.tar.xz *
	rm -rf $(TMPDIR)