#  Copyright (c) 2006  Martin Schulze <joey@infodrom.org>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.

prefix = /usr

LOCALE_DIR=$(prefix)/share/locale

basename=gui-apt-key
POFILES=$(shell echo *.po)
MOFILES=$(POFILES:%.po=%.mo)
LANGUAGES=$(POFILES:%.po=%)

ifeq ($(shell whoami),root)
install=install -o root -g root
else
install=install
endif

.SUFFIXES: .po .mo .pot

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

all: $(MOFILES)

pot:
	xgettext --keyword=_ --force-po --language Perl -o $(basename).pot ../gak ../GAK/*.pm

update-po: $(basename).pot
	for lang in $(LANGUAGES); do \
	  msgmerge $$lang.po $(basename).pot -o $$lang.po.new; \
	  cmp $$lang.po.new $$lang.po || cp $$lang.po.new $$lang.po; \
	  rm -f $$lang.po.new; \
	done

install: all
	for lang in $(LANGUAGES); do \
	  test -d $(LOCALE_DIR)/$$lang/LC_MESSAGES || $(install) -d -m 755 $(LOCALE_DIR)/$$lang/LC_MESSAGES; \
	  $(install) -m 644 $$lang.mo $(LOCALE_DIR)/$$lang/LC_MESSAGES/$(basename).mo; \
	  done

clean:
	rm -f $(MOFILES)
