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