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