#!/usr/bin/make -f

# Path to the debian directory
DEBIAN_DIR := $(shell echo ${MAKEFILE_LIST} |awk '{print $$1}' |xargs dirname)
VERSION ?=$(shell uscan --dehs | \
sed -n 's/.*<upstream-version>\(.*\)<\/upstream-version>.*/\1/p')
CATALOGS := de it es cs sv

%:
	dh $@

override_dh_auto_configure:
	uudecode -o debian/waf debian/waf.uuencoded
	chmod +x debian/waf
	debian/waf configure --prefix=/usr

override_dh_auto_build:
	debian/waf

override_dh_auto_clean:
	rm -rf build-stamp configure-stamp build .waf* .lock-wscript
	rm -rf po/*.mo
	dh_auto_clean

override_dh_auto_install:
	debian/waf --destdir=$(CURDIR)/debian/gnome-format install 
	for x in $(CATALOGS); \
	do \
		msgfmt po/$$x.po -c -o po/gnome-format.mo; install -D -m 644 po/gnome-format.mo \
		$(CURDIR)/debian/gnome-format/usr/share/locale/$$x/LC_MESSAGES/gnome-format.mo; \
	done

get-orig-source:
	cd $(CURDIR)/.. && wget --user-agent="" -O gnome-format-$(VERSION).tar.bz2 \
	"http://live.gnome.org/gnome-format/Download?action=AttachFile&do=get\
	&target=gnome-format-$(VERSION).tar.bz2"
	bunzip2 ../gnome-format-$(VERSION).tar.bz2
	mv ../gnome-format-$(VERSION).tar \
	../gnome-format_$(VERSION).orig.tar
	gzip -9fn ../gnome-format_$(VERSION).orig.tar
