#!/usr/bin/make -f

%:
	dh $@

override_dh_install:
	dh_install
	convert -geometry 32x32 rtdata/images/logoicon32.png $(CURDIR)/debian/rawtherapee/usr/share/pixmaps/rawtherapee.xpm

SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(.*\)\.*-.*/\1/p')
HG_REV :=  $(shell echo $(SRC_VERSION) | sed 's/.*+hg.*\.\(.*\)~.*/\1/')
.PHONY: get-orig-source
get-orig-source:
	rm -rf get-orig-source rawtherapee-$(SRC_VERSION).orig.tar.gz
	mkdir get-orig-source
	hg clone -r $(HG_REV) https://rawtherapee.googlecode.com/hg/ get-orig-source/rawtherapee-$(SRC_VERSION).orig
	
	# non-GPL compression library
	rm -r get-orig-source/rawtherapee-$(SRC_VERSION).orig/rawzor_*
	# precompiled libaries for windows
	rm -r get-orig-source/rawtherapee-$(SRC_VERSION).orig/lib
	rm get-orig-source/rawtherapee-$(SRC_VERSION).orig/languagePack.nsi
	rm get-orig-source/rawtherapee-$(SRC_VERSION).orig/rtinstaller.nsi
	# binary files in the source tree
	rm get-orig-source/rawtherapee-$(SRC_VERSION).orig/rtgui/myicon.o
	# outdated documentation
	rm -r get-orig-source/rawtherapee-$(SRC_VERSION).orig/doc
	# stuff we don't need
	rm -r get-orig-source/rawtherapee-$(SRC_VERSION).orig/tools
	rm -r get-orig-source/rawtherapee-$(SRC_VERSION).orig/winclude
	rm get-orig-source/rawtherapee-$(SRC_VERSION).orig/rtdata/images/deltags.pp2
	# Mercurial files
	rm -r get-orig-source/rawtherapee-$(SRC_VERSION).orig/.hg
	rm get-orig-source/rawtherapee-$(SRC_VERSION).orig/.hgignore
	rm get-orig-source/rawtherapee-$(SRC_VERSION).orig/.hgtags
	
	GZIP=-9 tar czf rawtherapee_$(SRC_VERSION).orig.tar.gz -C get-orig-source rawtherapee-$(SRC_VERSION).orig
	rm -rf get-orig-source

