#!/usr/bin/make -f
# -*- makefile -*-

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

CURVER := $(shell dpkg-parsechangelog | grep ^Version | cut -d\  -f2 | sed -e "s/\(\+.*\)\|\(\-.*\)//")

override_dh_auto_configure:
	python setup.py configure \
		--no-install-acpi \
		--no-install-docs \
		--lib=/usr/share/wicd \
		--share=/usr/share/wicd \
		--wicdgroup=netdev \
		--loggroup=adm \
		--logperms=0640

override_dh_auto_build:
	dh_auto_build
	python setup.py compile_translations

	# pybabel currently doesn't support Asturian
	msgfmt po/ast.po -o translations/ast/LC_MESSAGES/wicd.mo

override_dh_auto_clean:
	dh_auto_clean
	-find . \( -name "*.pyc" -o -name "*.pyo" \) -delete
	-rm -rf build/ init/ scripts/ translations/

override_dh_auto_install:
	python setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb

	find $(CURDIR)/debian/tmp -name "*.png" -exec chmod 644 {} \;
	find $(CURDIR)/debian/tmp/etc/wicd/ -type f -exec chmod 644 {} \;
	find $(CURDIR)/debian/tmp \( -name "*.glade" -o -name "*.conf" -o -name "*.desktop" \) -exec chmod 644 {} \;

	find $(CURDIR)/debian/tmp/ -name ".empty_on_purpose" -delete

	-rm -rf $(CURDIR)/debian/tmp/var/run

override_dh_installinit:
	dh_python2 -i
	dh_installinit -i --name=wicd --restart-after-upgrade

override_dh_bugfiles:
	dh_bugfiles -A

override_dh_python2:
	dh_python2
	dh_python2 -p wicd-curses /usr/share/wicd/curses
	dh_python2 -p wicd-daemon /usr/share/wicd/daemon
	dh_python2 -p wicd-gtk /usr/share/wicd/gtk

%:
	dh $@ \
		--with python2
