Makefile 1.73 KB
Newer Older
1 2
# See LICENSE file for license and copyright information

3 4 5 6 7 8 9
include ../config.mk
include ../common.mk
include ../colors.mk

PROJECT  = zathura
CATALOGS = $(sort $(wildcard *.po))
LINGUAS ?= $(patsubst %.po, %, $(CATALOGS))
Sebastian Ramacher's avatar
Sebastian Ramacher committed
10 11 12 13 14
ifeq ($(LINGUAS),)
ALINGUAS =
else
ALINGUAS = $(shell find $(patsubst %, %.po, $(LINGUAS)) 2>/dev/null)
endif
15
MOS      = $(patsubst %, %/LC_MESSAGES/${GETTEXT_PACKAGE}.mo, $(patsubst %.po, %, $(ALINGUAS)))
16 17 18 19

all: ${MOS}

clean:
Sebastian Ramacher's avatar
Sebastian Ramacher committed
20
	$(QUIET)rm -rf POTFILES.in POTFILES.in.tmp $(patsubst %.po, %, $(CATALOGS)) ${PROJECT}.pot
21

22
POTFILES.in: $(sort $(wildcard ../girara/*.c))
23 24
	$(QUIET) set -e && rm -f $@.tmp && touch $@.tmp && \
	for f in $(^F) ; do \
25
		echo girara/$$f >> $@.tmp ; \
26 27 28
	done && \
	mv $@.tmp $@

29 30 31
${GETTEXT_PACKAGE}.pot: POTFILES.in
	$(ECHO) regenerate $@
	$(QUIET)intltool-update --pot --gettext-package=${GETTEXT_PACKAGE}
32

33 34
update-po: ${GETTEXT_PACKAGE}.pot
	$(call colorecho,PO,"Updating po files ${CATALOGS}")
35
	$(QUIET)set -e && for f in ${CATALOGS} ; do \
36
		intltool-update --dist --gettext-package=${GETTEXT_PACKAGE} `echo $$f | sed 's/\.po//'` ; \
37
		sed -i 's/Report-Msgid-Bugs-To: \\n/Report-Msgid-Bugs-To: http:\/\/bugs.pwmt.org\\n/'  "$$f" ; \
38
	done
39

40
%/LC_MESSAGES/${GETTEXT_PACKAGE}.mo: %.po
41
	@mkdir -p $(@D)
42
	$(call colorecho,MSGFMT,$(shell echo $< | sed 's/\.po//'))
43
	$(QUIET)${MSGFMT} ${MSGFMTFLAGS} -c $< -o $@
44 45

install: ${MOS}
46
	$(call colorecho,INSTALL,"Install translations")
47
	$(QUIET)set -e && for f in $^ ; do \
Sebastian Ramacher's avatar
Sebastian Ramacher committed
48
		mkdir -p -m 755 $(DESTDIR)$(LOCALEDIR)/`dirname $$f`; \
49 50
		install -m 644 $$f $(DESTDIR)$(LOCALEDIR)/`dirname $$f` ; \
	done
51 52

uninstall: ${MOS}
53
	$(call colorecho,UNINSTALL,"Uninstall translations")
54
	$(QUIET)set -e && for f in $^ ; do \
55
		rm -f $(LOCALEDIR)/$$f; \
56
	done
57

58
.PHONY: all clean install uninstall update-po