forked from petdance/bobby-tables
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (50 loc) · 1.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.PHONY: \
crank \
clean \
prereq
BUILD=build
SOURCE=s
LOCALE=share/locale
TEXTDOMAIN=com.bobby-tables
POTEMPLATE=$(LOCALE)/$(TEXTDOMAIN).pot
default: crank
prereq:
perl ./modules.pl
clean:
rm -fr $(BUILD)
rm -fr $(SOURCE)/*.tt2
rm -fr $(POTEMPLATE)
rm -fr $(LOCALE)/*/LC_MESSAGES/$(TEXTDOMAIN).mo
crank: prereq clean messages
mkdir -p $(BUILD)/ || true > /dev/null 2>&1
# force English for top directory
LANG=C perl crank.pl --sourcepath=$(SOURCE) --buildpath=$(BUILD)
# other languages in subdirectories
# that substr is ugly, but nested evals of basename/dirname are worse
for pofile in $(LOCALE)/*/LC_MESSAGES/$(TEXTDOMAIN).po ; do \
language=`perl -e'print substr(shift,13,5)' $$pofile` ; \
mkdir -p $(BUILD)/$$language || true > /dev/null 2>&1 ; \
LANG=$$language perl crank.pl --sourcepath=$(SOURCE) --buildpath=$(BUILD)/$$language ; \
done
cp -R static/* $(BUILD)/
test: crank
prove t/*.t
messages:
# wrap markdown paragraphs into TT loc fragments
for markdownfile in $(SOURCE)/*.md; do \
perl -lne'BEGIN {$$/ = "\n\n";}; print "[% |loc %]$${_}[% END %]\n" if $${_}' \
< $$markdownfile > $$markdownfile.tt2 ; done
# extract string literals to po template
xgettext.pl -u -g -P tt2 -P perl -o $(POTEMPLATE) tt/* $(SOURCE)/*.tt2 crank.pl
# update po/mo files
for pofile in $(LOCALE)/*/LC_MESSAGES/$(TEXTDOMAIN).po ; do \
msgmerge -U -F -q $$pofile $(POTEMPLATE) ; \
msgfmt $$pofile -o `dirname $$pofile`/$(TEXTDOMAIN).mo ; done
l10n-stats: messages
for pofile in $(LOCALE)/*/LC_MESSAGES/$(TEXTDOMAIN).po ; do \
echo -n "`perl -e'print substr(shift,13,5)' $$pofile`: " ; \
LANG=C msgfmt --statistics $$pofile -o /dev/null ; done
# This is only useful for Andy
rsync:
rsync -azu -e ssh --delete --verbose \
$(BUILD)/ [email protected]:/srv/bobby