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))) dicos/radicals.nani |
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) $(addsuffix .sha256, $(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 | modules/nani/serialize.scm |
19 | |
20 | LANGS=fr |
21 | |
22 | all: $(addprefix po/, $(addsuffix /LC_MESSAGES/nani.mo, $(LANGS))) $(WEB_FILES) |
23 | haunt build |
24 | rm -rf public.bak |
25 | mv public public.bak |
26 | mv site public |
27 | touch all |
28 | |
29 | download: |
30 | @rm -f dictionaries/* |
31 | @$(MAKE) dictionaries/JMdict_e.xml dictionaries/JMdict.xml dictionaries/frequency.tsv |
32 | |
33 | # Download JMdict dictionaries from ERDRG |
34 | dictionaries/%.xml: |
35 | dl_filename="$(shell basename "$@" | rev | cut -c5- | rev)"; \ |
36 | wget ftp://ftp.edrdg.org/pub/Nihongo/"$$dl_filename".gz -O "$$dl_filename.gz"; \ |
37 | gunzip "$$dl_filename.gz"; \ |
38 | sed -i -e 's|<|\&\<;|g' -e 's|>|\&\>;|g' "$$dl_filename"; \ |
39 | sed -i -e 's|&\([^;]\+\);|\1|g' "$$dl_filename"; \ |
40 | mv "$$dl_filename" "$@" |
41 | |
42 | # Download frequency analysis run on Wikipedia in 2015 |
43 | # https://en.wiktionary.org/wiki/Wiktionary:Frequency_lists/Japanese2015_10000 |
44 | dictionaries/frequency.tsv: |
45 | wget --no-check-certificate \ |
46 | https://namakajiri.net/data/wikipedia-20150422-lemmas.tsv -O $@.tmp |
47 | sed -i 's| ||g' $@.tmp |
48 | head -n20000 $@.tmp > $@ |
49 | rm $@.tmp |
50 | |
51 | dictionaries/%.sxml: dictionaries/%.xml tools/jmdict.scm |
52 | guile -L modules tools/jmdict.scm convert $< nolang $@ |
53 | |
54 | dicos/JMdict_%.nani: dictionaries/JMdict.sxml tools/jmdict.scm dictionaries/frequency.tsv $(DICO_MODULES) |
55 | guile -L modules tools/jmdict.scm build \ |
56 | $< $(shell echo $@ | sed 's|^.*_\([^.]*\)\..*$$|\1|g') $@ |
57 | |
58 | dicos/JMdict_e.nani: dictionaries/JMdict_e.sxml tools/jmdict.scm dictionaries/frequency.tsv $(DICO_MODULES) |
59 | guile -L modules tools/jmdict.scm build $< e $@ |
60 | |
61 | po/%/LC_MESSAGES/nani.mo: po/%.po |
62 | @mkdir -p $$(dirname $@) |
63 | msgfmt --output-file=$@ $< |
64 | |
65 | po/%.po: po/nani.pot |
66 | if [ -f $@ ]; then \ |
67 | msgmerge --update $@ $< ;\ |
68 | else \ |
69 | msginit --input=$< --locale=$$(printf $$(basename $@) | sed 's|.po$$||') --output=$@ ;\ |
70 | fi |
71 | |
72 | po/nani.pot: $(HAUNT_FILES) |
73 | xgettext --keyword=_ --language=scheme --add-comments --sort-output --from-code UTF-8 -o $@ $^ |
74 | |
75 | %.sha256: % |
76 | sha256sum $< | cut -f1 -d' ' > $@ |
77 | |
78 | include radicals.mk |
79 |