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

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

PKG=byobu
VER=`head -n 1 debian/changelog | sed 's/^.*(//' | sed 's/).*//' | sed 's/-.*//'`

release-upstream:
	dh_testdir
	bzr export ../${PKG}_${VER}.orig.tar.gz

install-po: update-pot
	for po in po/*.po ; do \
		lang=$${po#po/}; lang=$${lang%.po}; \
		mkdir -p po/locale/$${lang}/LC_MESSAGES/; \
		msgfmt $${po} -o po/locale/$${lang}/LC_MESSAGES/${PKG}.mo ; \
	done

update-pot:
	rm -f po/${PKG}.pot
	xgettext -f po/POTFILES.Shell -o po/${PKG}.pot -L Shell
	xgettext -f po/POTFILES.Python -o po/${PKG}.pot -L Python -j
	for po in po/*.po ; do \
		msgmerge $${po} po/${PKG}.pot -o $${po} ; \
	done

prebuild:

build:
	# auto-generate the logo'd light/dark profiles
	./profiles_generator/generate

clean:
	dh_clean
	./profiles_generator/generate --clean
	for po in po/*.po ; do \
		lang=$${po#po/}; lang=$${lang%.po}; \
		rm -f po/locale/$${lang}/LC_MESSAGES/${PKG}.mo ; \
	done

install: build install-po
	dh_testdir
	dh_testroot
	dh_clean -k
	# These links must be done in the postinst, as screen-profiles might not
	# be uninstalled yet
	#dh_link usr/bin/byobu-status usr/bin/screen-profiles-status
	#dh_link usr/bin/byobu-launcher usr/bin/screen-launcher
	dh_link usr/share/byobu/keybindings/f-keys usr/share/byobu/keybindings/common
	dh_install -X.bzr

# Everything else is handled by dh_install

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir -i
	dh_testroot -i
	dh_installdocs -X.bzr -i
	dh_installman -i byobu-launcher.1 byobu.1 byobu-config.1 byobu-select-profile.1 motd+shell.1 byobu-export.1 byobu-status.1 byobu-status-detail.1
	dh_installchangelogs -i
	dh_installdebconf -i
	dh_compress -i
	dh_fixperms -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i

binary: binary-indep
.PHONY: build clean binary-indep binary install prebuild get-orig-source

binary-arch:
