aboutsummaryrefslogtreecommitdiff
path: root/db/makefile
blob: 3968ae7c76782b6338f21158eecdf6e241a33607 (plain)
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
SQL = sqlite3
DICT_DB = dict.db
USER_DB = user.db

DICT_TEMPLATE = dict/template.sql

# comment any of these lines to disable including in the default DB
DEFAULT_DICTS += dict/test_a.sql
DEFAULT_DICTS += dict/test_b.sql
DEFAULT_DICTS += dict/test_pitch_accent.sql
DEFAULT_DICTS += ../import/jmdict/jmdict.sql

.PHONY: clean test

all: $(DICT_DB) $(USER_DB)

$(DICT_DB): dict/full.sql
	$(SQL) $@ < $<

$(USER_DB): user/full.sql
	$(SQL) $@ < $<

dict/base.sql: dict/reset.sql dict/init.sql dict/deinflections.sql dict/tags.sql
	cat $^ > $@

dict/full.sql: dict/base.sql dict/dict.sql
	cat $^ > $@

dict/dict.sql: $(DEFAULT_DICTS)
	cat $^ > $@

user/base.sql: user/reset.sql user/init.sql
	cat $^ > $@

user/full.sql: user/base.sql # user/root.sql
	cat $^ > $@

%.sql: %.dict.sql $(DICT_TEMPLATE)
	echo "" | cat - $< | m4 -P $(DICT_TEMPLATE) > $@

# delete generated sql files and database
clean:
	$(RM) $(DICT_DB) $(USER_DB) dict/base.sql dict/full.sql dict/dict.sql $(DEFAULT_DICTS) user/base.sql user/full.sql

test: $(DICT_DB) find.sql
	./test/find '浮上しました'
	./test/find 'ならない'
	./test/find '浮上した'
	./test/find 'なって'
	./test/find 'の下にて'