OSDN Git Service

Address unmatch newlines in special ja.po
[linuxjm/LDP_man-pages.git] / Makefile
1 PERKAMON_DIR = perkamon
2 LANGS = ja
3 THRESH = 80
4 THRESH_REL = 80
5 FLAGS ?=
6 PO4AFLAGS ?= -k $(THRESH) $(FLAGS)
7
8 PO4A_SUBDIRS = $(notdir $(wildcard po4a/*))
9
10 .PHONY: all release translate
11
12 all:    translate
13 translate:      translate-pages update-stats
14 release:        release-pages update-tl-finish check-tl-nofinish
15
16 translate-pages:        $(patsubst %, stamp/%, $(PO4A_SUBDIRS))
17 stamp/%:        stamp-jm-setup po4a/%/po/ja.po
18         @echo "*************** translate: $* ***************"
19         mkdir -p stamp
20         LC_ALL=C $(MAKE) process-$* \
21           PO4AFLAGS="$(PO4AFLAGS)" LANGS="$(LANGS)" -C $(PERKAMON_DIR)
22         touch $@
23
24 release-pages:
25         ../../admin/JM-release-all.sh -c
26
27 update-stats:   untrans.html
28
29 untrans.html:   $(patsubst %, stats/%, $(PO4A_SUBDIRS))
30         @echo "*************** Updating translation statistics ***************"
31         ./tools/generate-list.pl $^ > $@
32         if [ -f EXCLUDED_PAGES.txt ]; then \
33           ./tools/generate-list.pl -e EXCLUDED_PAGES.txt $^ > untrans-partial.html; \
34         fi
35
36 stats/%:        stamp-jm-setup po4a/%/po/ja.po
37         @echo "*************** stats: $* ***************"
38         mkdir -p stats
39         mkdir -p _transtmp
40         $(RM) $(PERKAMON_DIR)/build/ja
41         ln -s ../../_transtmp $(PERKAMON_DIR)/build/ja
42         LC_ALL=C $(MAKE) process-$* \
43           PO4AFLAGS="-k 100 $(FLAGS)" LANGS="$(LANGS)" -C $(PERKAMON_DIR) \
44           | tee _log.txt
45         ./tools/extract-untrans.pl < _log.txt > $@
46         $(RM) $(PERKAMON_DIR)/build/ja
47         ln -s ../../draft $(PERKAMON_DIR)/build/ja
48         $(RM) -r _transtmp
49         $(RM) _log.txt
50
51 clean-stats:
52         $(RM) -r stats
53
54 update-tl-finish:
55         @cat stats/* | grep -v '^#' | cut -d , -f 1 | sort > _stats.txt
56         @grep '^[×☆]' translation_list | cut -d : -f 5-6 | sed -e 's/:/./' | sort > _tr_todo.txt
57         @for p in `comm -23 _tr_todo.txt _stats.txt`; do \
58           ../../admin/JM-tl-modify.pl -U translation_list $$p RO; \
59         done
60         @$(RM) _stats.txt _tr_todo.txt
61
62 check-tl-nofinish:
63         @cat stats/* | grep -v '^#' | cut -d , -f 1 | sort > _stats.txt
64         @grep '^○' translation_list | cut -d : -f 5-6 | sed -e 's/:/./' | sort > _tr_finish.txt
65         @comm -12 _tr_finish.txt _stats.txt
66         @$(RM) _stats.txt _tr_finish.txt
67
68 format:
69         set -e; for d in po4a/*; do \
70           echo "----- $$d -----"; cur=`pwd`; cd $$d/po; \
71           f=`/bin/mktemp`; \
72           LC_ALL=C msgmerge --verbose -o $$f ja.po $$(basename $$d) \
73             && mv -f $$f ja.po; \
74           cd $$cur; \
75         done
76
77 format-%:
78         set -e; for d in po4a/$*; do \
79           cd $$d/po; \
80           f=`/bin/mktemp`; \
81           msgmerge --verbose -o $$f ja.po $$(basename $$d) \
82             && mv -f $$f ja.po; \
83           cd $$cur; \
84         done
85
86 postats:        jm-setup
87         @LC_ALL=C $(MAKE) stats \
88           PO4AFLAGS="$(PO4AFLAGS)" LANGS="$(LANGS)" -C $(PERKAMON_DIR)
89
90 untrans-postats:        jm-setup
91         @LC_ALL=C $(MAKE) stats \
92           PO4AFLAGS="$(PO4AFLAGS)" LANGS="$(LANGS)" -C $(PERKAMON_DIR) \
93           2>&1 | grep -vE ' translated messages\.$$'
94
95 jm-setup:       stamp-jm-setup
96 stamp-jm-setup:
97         @# Check perkamon/po4a and JM/po4a
98         ls -1 $(PERKAMON_DIR)/po4a | sort > _po4a_list_perkamon
99         ls -1 po4a | sort > _po4a_list_jm
100         set -e; for d in `comm -13 _po4a_list_perkamon _po4a_list_jm`; do \
101           echo $$d; \
102           rm -vrf po4a/$$d; \
103         done
104         set -e; for d in `comm -23 _po4a_list_perkamon _po4a_list_jm`; do \
105           echo $$d; \
106           mkdir -vp po4a/$$d/po; \
107         done
108         rm _po4a_list_jm _po4a_list_perkamon
109         cd $(PERKAMON_DIR) && make setup
110         @# Create symlink to po4a/*/po in the top dir.
111         set -e; for d in $(PERKAMON_DIR)/po4a/*; do \
112           if [ ! -e $$d/po ]; then \
113             t=$$(echo $$d | sed -e "s|$(PERKAMON_DIR)/||"); \
114             ln -s ../../../$$t/po $$d/po; \
115           fi; \
116         done
117         @set -e; if [ ! -e $(PERKAMON_DIR)/build/ja ]; then \
118           ln -s ../../draft $(PERKAMON_DIR)/build/ja; \
119         fi
120         ln -s ../../add_ja $(PERKAMON_DIR)/po4a
121         touch $@
122
123 clean-setup:
124         $(RM) stamp-jm-setup
125         $(RM) $(PERKAMON_DIR)/man-pages || true
126         $(RM) $(PERKAMON_DIR)/stamp-*
127         $(RM) -rf $(PERKAMON_DIR)/build
128         find $(PERKAMON_DIR) -type l | xargs $(RM)
129
130 upgrade:
131         $(MAKE) clean-setup
132         $(MAKE) jm-setup
133         cd $(PERKAMON_DIR)/man-pages \
134           && ../../../../admin/JM-orig-upd.sh ../../original \
135           && cp README man-pages-* Changes* ../../original
136         cd original \
137           sed -e 's/\^\\\.SH /^\\.S[Hh] /' ../perkamon/man-pages/scripts/remove_COLOPHON.sh \
138           sh ../perkamon/man-pages/scripts/remove_COLOPHON.sh man?/*.[1-8]
139         git add --all original/
140         git status original | ../../admin/git2upd > upd.txt
141         $(eval VERSION = $(shell grep "^V = " $(PERKAMON_DIR)/Makefile | awk '{print $$3}'))
142         ../../admin/upd_tl.perl translation_list upd.txt $(VERSION)
143         mv translation_list.* translation_list
144         $(MAKE) FLAGS="--no-translations -v --force" translate-pages
145         $(MAKE) update-stats
146         git add translation_list
147         git commit -m "LDP: Update original to LDP v$(VERSION)" original/ translation_list
148         git add po4a/ stats/ untrans.html perkamon
149         git commit -m "LDP: Update POT and ja.po to LDP v$(VERSION)" po4a/ stats/ untrans.html
150
151 help:
152         @echo "Available targets:"
153         @echo "   translate       Generate draft from po files"
154         @echo "   translate-<SEC> Generate draft from the specified po file"
155         @echo "   release         Generate release from po files"
156         @echo ""
157         @echo "   update-stats    Update per-page trans stats"
158         @echo "   clean-stats     Remove all caches of per-page trans stats"
159         @echo "   postats         Display per-po trans stats"
160         @echo "   untrans-postats Display per-po trans stats (untrans only)"
161         @echo ""
162         @echo "   jm-setup        Setup perkamon environment"
163         @echo "   clean-setup     Clean perkamon environment"