#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

include /usr/share/cdbs/1/rules/debhelper.mk
include debian/scripts/cdbs/class/ruby-vars.mk

LINGUAS := $(shell cd po; ls *.po| cut -d'.' -f1)
MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po))
VERSION := $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')

update-po:
	xgettext --language=python apt-listbugs -o po/apt-listbugs.pot
	for po in $(LINGUAS); do \
	  msgmerge -U po/$$po.po po/apt-listbugs.pot; \
	done
	for po in $(LINGUAS); do \
	  echo -n $$po ": "; \
	  msgfmt -v po/$$po.po -o /dev/null; \
	done

%.mo: %.po
	msgfmt -o $@ $<


apt-listbugs.1: apt-listbugs
	rd2 -r rd/rd2man-lib.rb -o apt-listbugs apt-listbugs

common-build-indep:: apt-listbugs.1 $(MOFILES)

clean::
	rm -f apt-listbugs.1
	rm -f $(MOFILES)
	-make clean

common-install-indep:: common-build-indep

	dh_installdirs

	# Add here commands to install the package into debian/apt-listbugs.
	sed -e 's/#APT_LISTBUGS_VERSION#/$(VERSION)/' \
		-e 's,#!/usr/bin/ruby -Ilib/,#!/usr/bin/ruby -I/usr/share/apt-listbugs,' \
		< apt-listbugs \
		> $(DEB_DESTDIR)/usr/sbin/apt-listbugs
	chmod 755 $(DEB_DESTDIR)/usr/sbin/apt-listbugs
	install -m 644 10apt-listbugs $(DEB_DESTDIR)/etc/apt/apt.conf.d/
	install -m 644 ignore_bugs $(DEB_DESTDIR)/usr/share/apt-listbugs/
	install -m 755 aptcleanup $(DEB_DESTDIR)/usr/share/apt-listbugs/
	install -m 644 lib/debian/*.rb $(DEB_DESTDIR)/usr/share/apt-listbugs/debian/
	for mo in $(MOFILES); do \
	  install -d $(DEB_DESTDIR)/usr/share/locale/`basename $$mo .mo`/LC_MESSAGES; \
	  install -m644 $$mo $(DEB_DESTDIR)/usr/share/locale/`basename $$mo .mo`/LC_MESSAGES/apt-listbugs.mo; \
	done

