#!/usr/bin/make -f

%:
	dh  $@

override_dh_auto_build:
	dh_auto_build
	lrelease -nounfinished $(CURDIR)/translations/xflr5v6_fr.ts -qm $(CURDIR)/translations/xflr5v6_fr.qm
	lrelease -nounfinished $(CURDIR)/translations/xflr5v6_de.ts -qm $(CURDIR)/translations/xflr5v6_de.qm
	lrelease -nounfinished $(CURDIR)/translations/xflr5v6_ja.ts -qm $(CURDIR)/translations/xflr5v6_ja.qm
	docbook-to-man debian/xflr5.sgml > debian/xflr5.1

override_dh_auto_clean:
	dh_auto_clean
	rm -f `find $(CURDIR)/translations -name *.qm` $(CURDIR)/debian/xflr5.1

override_dh_compress:
	dh_compress -X.pdf

# Adapted from http://wiki.debian.org/SandroTosi/Svn_get-orig-source
PACKAGE = xflr5
SRC_VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
SRC_RELEASE := $(shell echo $(SRC_VERSION) | awk -F"+" '{ print $$1 }' )
SVN_REVISION := $(shell echo $(SRC_VERSION) | awk -F"+" '{ print $$2 }' | sed 's/svn//' )
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.bz2
.PHONY: get-orig-source
get-orig-source:
	rm -rf get-orig-source $(TARBALL)
	mkdir get-orig-source
	svn export -r $(SVN_REVISION) "https://xflr5.svn.sourceforge.net/svnroot/xflr5/branches/xflr5-$(SRC_RELEASE)" \
	get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig
	find get-orig-source/$(PACKAGE)-$(SRC_VERSION).orig -type f -exec chmod -x {} +
	tar cjf $(TARBALL) -C get-orig-source $(PACKAGE)-$(SRC_VERSION).orig
	rm -rf get-orig-source
	echo "  "$(TARBALL)" created; move it to the right destination to build the package"
