-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
54 lines (42 loc) · 1.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
joyopdf_url = http://kokugo.bunka.go.jp/kokugo_nihongo/joho/kijun/naikaku/pdf/joyokanjihyo_20101130.pdf
pdfbox_url = http://www-us.apache.org/dist/pdfbox/2.0.2/pdfbox-app-2.0.2.jar
cachedir = cache
moduledir = joyodb
joyopdf = $(cachedir)/joyokanjihyo_20101130.pdf
joyotxt = $(cachedir)/joyokanjihyo_20101130.txt
pdfbox = $(cachedir)/pdfbox-app-2.0.2.jar
all: $(cachedir) $(joyotxt) $(moduledir)/__init__.py
$(cachedir):
mkdir -p $(cachedir)
$(joyotxt): $(joyopdf) $(pdfbox)
java -jar $(pdfbox) ExtractText $(joyopdf) -console > $(joyotxt)
@# pdfbox generates ASCII bells (\x07) for some reason.
sed -e "s/\x07//g" -i $(joyotxt)
$(joyopdf):
wget $(joyopdf_url) -O $(joyopdf)
$(pdfbox):
wget $(pdfbox_url) -O $(pdfbox)
$(moduledir)/__init__.py: $(moduledir)/__init__.py.in
@echo "Building $@."
@echo "# Autogenerated from $(moduledir)/__init__.py.in; do not edit." \
> $(moduledir)/__init__.py
sed -e "s,\$$JOYOHYO_TXT,'`readlink -f $(joyotxt)`',"\
$(moduledir)/__init__.py.in \
>> $(moduledir)/__init__.py
wikipedia_url = 'https://en.wikipedia.org/w/index.php?title=List_of_jōyō_kanji&oldid=727326828'
wikipedia_html = $(cachedir)/List_of_joyo_kanji.html
kanjidic_url = ftp.monash.edu.au::nihongo/kanjidic_comb_utf8
kanjidic = $(cachedir)/kanjidic_comb_utf8
jmdict_url = ftp.monash.edu.au::nihongo/JMdict
jmdict = $(cachedir)/JMdict
test: all $(wikipedia_html) $(kanjidic) $(jmdict)
python3 test/test.py
$(wikipedia_html):
wget $(wikipedia_url) -O $(wikipedia_html)
$(kanjidic):
rsync -z -q $(kanjidic_url) $(kanjidic)
$(jmdict):
rsync -z -q $(jmdict_url) $(jmdict)
clean:
rm $(cachedir)/* $(moduledir)/__init__.py
.PHONY: all clean test