Makefile
1 | .PRECIOUS: po/%.po dictionaries/% |
2 | |
3 | JMDICT_LANGS=dut fre ger hun rus slv spa swe |
4 | |
5 | DICOS=dicos/JMdict_e.nani $(addprefix dicos/JMdict_, $(addsuffix .nani, $(JMDICT_LANGS))) |
6 | |
7 | PAGES=blog.scm data.scm documentation.scm e404.scm feeds.scm index.scm mentions.scm |
8 | |
9 | HAUNT_FILES= haunt.scm $(addprefix pages/, $(PAGES)) \ |
10 | tools/i18n.scm tools/theme.scm |
11 | |
12 | WEB_FILES= $(HAUNT_FILES) \ |
13 | $(shell find css) $(shell find images) $(DICOS) \ |
14 | |
15 | DICO_MODULES=modules/nani/trie.scm modules/nani/result.scm modules/nani/jmdict/trie.scm \ |
16 | modules/nani/jmdict/serialize.scm modules/nani/jmdict/xml.scm \ |
17 | modules/nani/jmdict/entities.scm modules/nani/frequency.scm |
18 | |
19 | LANGS=fr |
20 | |
21 | all: $(addprefix po/, $(addsuffix /LC_MESSAGES/nani.mo, $(LANGS))) $(WEB_FILES) |
22 | haunt build |
23 | rm -rf public.bak |
24 | mv public public.bak |
25 | mv site public |
26 | touch all |
27 | |
28 | download: |
29 | @rm -f dictionaries/* |
30 | @$(MAKE) dictionaries/JMdic_e.xml dictionaries/JMdic.xml dictionaries/frequency.tsv |
31 | |
32 | # Download JMdict dictionaries from ERDRG |
33 | dictionaries/%.xml: |
34 | dl_filename="$(shell echo "$@" | rev | cut -c5- | rev)"; \ |
35 | wget http://ftp.monash.edu/pub/nihongo/"$$dl_filename".gz -O "$$dl_filename.gz"; \ |
36 | gunzip "$$dl_filename.gz"; \ |
37 | sed -i -e 's|<|\&\<;|g' -e 's|>|\&\>;|g' "$$dl_filename"; \ |
38 | sed -i -e 's|&\([^;]\+\);|\1|g' "$$dl_filename"; \ |
39 | cp "$$dl_filename" "$@" |
40 | |
41 | # Download frequency analysis run on Wikipedia in 2015 |
42 | # https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Japanese2015_10000 |
43 | dictionaries/frequency.tsv: |
44 | wget --no-check-certificate \ |
45 | https://namakajiri.net/data/wikipedia-20150422-lemmas.tsv -O $@.tmp |
46 | sed -i 's| ||g' $@.tmp |
47 | mv $@.tmp $@ |
48 | |
49 | dictionaries/%.sxml: dictionaries/%.xml tools/jmdict.scm |
50 | guile -L modules tools/jmdict.scm convert $< nolang $@ |
51 | |
52 | dicos/JMdict_%.nani: dictionaries/JMdict.sxml tools/jmdict.scm dictionaries/frequency.tsv $(DICO_MODULES) |
53 | guile -L modules tools/jmdict.scm build \ |
54 | $< $(shell echo $@ | sed 's|^.*_\([^.]*\)\..*$$|\1|g') $@ |
55 | |
56 | dicos/JMdict_e.nani: dictionaries/JMdict_e.sxml tools/jmdict.scm dictionaries/frequency.tsv $(DICO_MODULES) |
57 | guile -L modules tools/jmdict.scm build $< e $@ |
58 | |
59 | po/%/LC_MESSAGES/nani.mo: po/%.po |
60 | @mkdir -p $$(dirname $@) |
61 | msgfmt --output-file=$@ $< |
62 | |
63 | po/%.po: po/nani.pot |
64 | if [ -f $@ ]; then \ |
65 | msgmerge --update $@ $< ;\ |
66 | else \ |
67 | msginit --input=$< --locale=$$(printf $$(basename $@) | sed 's|.po$$||') --output=$@ ;\ |
68 | fi |
69 | |
70 | po/nani.pot: $(HAUNT_FILES) |
71 | xgettext --keyword=_ --language=scheme --add-comments --sort-output --from-code UTF-8 -o $@ $^ |
72 |