#
# This Makefile is for installing, since the code doesn't have to
# be compiled.
#

# some directories to use
PREFIX = /usr
BINDIR = $(PREFIX)/games
MANDIR = $(PREFIX)/share/man/man6
ICONDIR = $(PREFIX)/share/pixmaps
LOCALEDIR = $(PREFIX)/share/locale

# location of helper programs
MSGFMT = /usr/bin/msgfmt
MSGMERGE = /usr/bin/msgmerge
XGETTEXT = /usr/bin/xgettext
INSTALL = /usr/bin/install

# available languages
LANGUAGES = de pl es

# you should not have to change anything below this line.

all:
	@echo Nothing has to be done. Please run "make install" as root.

clean:
	@echo Nothing to clean up. Done.

install:
	$(INSTALL) -d $(BINDIR)
	$(INSTALL) -d $(MANDIR)
	$(INSTALL) -d $(ICONDIR)
	$(INSTALL) -o root -g root -m 0755 animals-game $(BINDIR)
	$(INSTALL) -o root -g root -m 0644 animals-game.6.gz $(MANDIR)
	$(INSTALL) -o root -g root -m 0644 animals-game_16x16.xpm $(ICONDIR)
	$(INSTALL) -o root -g root -m 0644 animals-game_32x32.xpm $(ICONDIR)
	@for lang in $(LANGUAGES); do \
		dir=$(LOCALEDIR)/$$lang/LC_MESSAGES; \
		$(INSTALL) -d $$dir; \
		$(INSTALL) -o root -g root -m 0644 po/$$lang.mo $$dir/animals-game.mo; \
	done;

# This is mainly to use before a new release comes out

update-pot:
	$(XGETTEXT) --language=python --add-comments="Notice for translation:" \
	--output=po/animals-game.pot animals-game

update-po:
	@for lang in $(LANGUAGES); do \
		echo Updating language: $$lang; \
		$(MSGMERGE) --update po/$$lang.po po/animals-game.pot; \
	done

languages:
	@for lang in $(LANGUAGES); do \
		echo Converting language: $$lang; \
		$(MSGFMT) po/$$lang.po --output-file=po/$$lang.mo; \
	done

stats:
	@for lang in $(LANGUAGES); do \
		echo -n "$$lang: "; \
		$(MSGFMT) --statistics --output-file=/dev/null po/$$lang.po; \
	done
