fixes for Danish integration
[ikiwiki] / po / Makefile
1 # List here all source files with translatable strings.
2 POTFILES=$(sort $(shell find ../IkiWiki -type f -name \*.pm)) \
3         ../ikiwiki.in ../IkiWiki.pm ../auto.setup
4
5 POFILES=$(wildcard *.po)
6 MOFILES=$(POFILES:.po=.mo)
7
8 all: ikiwiki.pot mo ../underlays/locale
9
10 mo: $(MOFILES)
11
12 install: all
13         for file in $(MOFILES); do \
14                 lang=`echo $$file | sed 's/\.mo//'`; \
15                 install -d $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/; \
16                 install -m 0644 $$file $(DESTDIR)$(PREFIX)/share/locale/$$lang/LC_MESSAGES/ikiwiki.mo; \
17         done
18
19 ikiwiki.pot: $(POTFILES)
20         @if perl -e '($$ver)=`xgettext -V | head -n 1`=~/.*\s+([0-9]+\.[0-9]+)/; die "gettext $$ver too old, not updating the pot file\n" if $$ver < 0.16'; then \
21                 echo "Rebuilding the pot file"; \
22                 xgettext --from-code=UTF-8 $(POTFILES) -o ikiwiki.pot -Lperl --add-comments=translators; \
23         fi
24
25 clean:
26         rm -f $(MOFILES) messages messages.mo *_stamp
27         rm -rf html underlays/.ikiwiki ../underlays/locale
28         find underlays -name \*.mdwn | xargs rm -f
29
30 %.mo: %.po
31         msgfmt -o $@ $<
32
33 %.po: ikiwiki.pot
34         @echo -n "Merging ikiwiki.pot and $@"
35         @msgmerge $@ ikiwiki.pot -o $@.new 2>&1
36 # Typically all that changes was a date or line number. I'd prefer not to
37 # commit such changes, so detect and ignore them.
38         @if [ "`diff $@ $@.new | grep '[<>]' | grep -v '[<>] #:' | wc -l`" -ne 2 ]; then \
39                 mv -f $@.new $@; \
40         else \
41                 rm -f $@.new; \
42         fi
43         @msgfmt --statistics $@ 2>&1
44
45 check:
46         @for file in $(POFILES); do \
47                 lang=`echo $$file | sed 's/\.po//'`; \
48                 printf "$$lang: "; \
49                 msgfmt -o /dev/null -c -v --statistics $$lang.po;\
50         done
51
52 underlays_copy_stamp:
53         # copy all the files we want to translate into a srcdir
54         for file in `cd ..; find underlays -follow -name \*.mdwn`; do \
55                 install -d $$(dirname $$file); \
56                 cp -aL ../$$file $$file 2>/dev/null || \
57                 install -m 644 ../$$file $$file; \
58         done
59         install -d underlays/directives/ikiwiki/directive
60         for file in `cd ..; find doc/ikiwiki/directive/ -maxdepth 1 -type f`; do \
61                 cp -a ../$$file underlays/directives/ikiwiki/directive ||  \
62                 install -m 644 ../$$file underlays/directives/ikiwiki/directive; \
63         done
64         install -d underlays/empty
65         touch $@
66
67 underlays: underlays_copy_stamp
68         ../ikiwiki.out -libdir .. -setup underlay.setup -refresh
69
70 ../underlays/locale: po2wiki_stamp
71 po2wiki_stamp: po2wiki underlays_copy_stamp
72         PERL5LIB=.. ./po2wiki underlay.setup
73         touch $@
74
75 .PHONY: underlays