author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Thu, 12 Jan 2012 22:51:11 +0200 | |
changeset 103 | b5b1dc62bdc0 |
parent 94 | 1b2cf5b2b46c |
child 105 | 35cc545ec03d |
permissions | -rw-r--r-- |
85
0ff3715e6176
To build dictionary you need to install...
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
68
diff
changeset
|
1 |
# To build dictionary you need to install: |
0ff3715e6176
To build dictionary you need to install...
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
68
diff
changeset
|
2 |
# |
0ff3715e6176
To build dictionary you need to install...
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
68
diff
changeset
|
3 |
# $ sudo apt-get install dictfmt |
0ff3715e6176
To build dictionary you need to install...
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
68
diff
changeset
|
4 |
# |
22
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
5 |
# Available target: |
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
6 |
# |
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
7 |
# all build dictionaries |
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
8 |
# install install dictionaries, so they been available in stardict, may require root permission |
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
9 |
# uninstall remove dictionaries, they been unavailable in stardict, may require root permission |
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
10 |
# install-local install dictionaries in user HOME dir, so they been available in stardict for that user |
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
11 |
# uninstall-local remove dictionaries from user HOME directory |
26
6dfc4ac2dc80
Back targets that allow make symlink to dictionaries install dir from user HOME dir.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
23
diff
changeset
|
12 |
# install-local-symlink create symlink from installed dir to user HOME dir, so dictionaries been available in stardict |
6dfc4ac2dc80
Back targets that allow make symlink to dictionaries install dir from user HOME dir.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
23
diff
changeset
|
13 |
# uninstall-local-symlink remove symlink from user HOME directory |
22
0616adf6e983
Describe available build target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
21
diff
changeset
|
14 |
|
36
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
15 |
SHELL = /bin/sh |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
16 |
export PATH := /bin:/usr/bin:${PATH} |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
17 |
|
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
18 |
# Disable built in pattern rules. |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
19 |
MAKEFLAGS += -r |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
20 |
# Disable built in variables. |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
21 |
MAKEFLAGS += -R |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
22 |
# Disable built in suffix rules. |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
23 |
.SUFFIXES: |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
24 |
# Default target. |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
25 |
.DEFAULT_GOAL = all |
6fee90eb2d85
Add default Makefile settings.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
26 |
|
54 | 27 |
################################################################ |
103 | 28 |
# Version extracting/generation. |
29 |
||
30 |
# Prevent from deploying and distributing with wrong version. |
|
31 |
ifneq '' '$(filter deploy%,$(MAKECMDGOALS))' |
|
32 |
ifeq '' '$(MAKE_RESTARTS)' |
|
33 |
$(info $(shell rm VERSION)) |
|
34 |
endif |
|
35 |
endif |
|
36 |
||
37 |
# Here are vmajor and vminor. Look README section "Versioning rules." |
|
38 |
-include VERSION |
|
39 |
||
40 |
VERSION: |
|
41 |
ver=$$(hg log -r . --template '{latesttag}'); \ |
|
42 |
ver=$${ver#t}; \ |
|
43 |
major=$${ver%.*}; \ |
|
44 |
minor=$${ver#*.}; \ |
|
45 |
printf "vmajor=%s\nvminor=%s\n" $$major $$minor >VERSION |
|
46 |
# is_release=`hg log --template '{latesttagdistance}'` |
|
47 |
||
48 |
################################################################ |
|
66 | 49 |
# Platform/environment definition. |
50 |
||
51 |
host_os = unix |
|
52 |
ifneq '' '$(COMSPEC)' |
|
53 |
ifneq '' '$(WINDIR)' |
|
54 |
# Probably under Windows. |
|
55 |
host_os = windows |
|
56 |
endif |
|
57 |
endif |
|
58 |
||
59 |
################################################################ |
|
60 |
# Build tool definition/switches. |
|
61 |
||
62 |
RST2HTML = rst2html |
|
63 |
ifeq '$(host_os)' 'windows' |
|
64 |
RST2HTML = rst2html.py |
|
65 |
endif |
|
66 |
||
67 |
################################################################ |
|
54 | 68 |
# Install paths. |
0 | 69 |
|
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
70 |
ifeq '$(origin prefix)' 'undefined' |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
71 |
ifeq '$(shell id -u)' '0' |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
72 |
prefix = /usr/local |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
73 |
else |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
74 |
prefix = $(HOME)/usr |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
75 |
endif |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
76 |
endif |
0 | 77 |
datarootdir = $(prefix)/share |
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
78 |
datadir = $(datarootdir)/dictd |
0 | 79 |
|
54 | 80 |
################################################################ |
66 | 81 |
# Project dirs/files. |
21
d4b27e5b7a4b
Added per user install target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
20
diff
changeset
|
82 |
|
50
37931fbb857f
Switch from ambiguous extension to unambiguous.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
46
diff
changeset
|
83 |
C5_FILES := $(wildcard *.dict-c5) |
37931fbb857f
Switch from ambiguous extension to unambiguous.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
46
diff
changeset
|
84 |
DICT_FILES := $(C5_FILES:.dict-c5=.dict) |
37931fbb857f
Switch from ambiguous extension to unambiguous.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
46
diff
changeset
|
85 |
DICTDZ_FILES := $(C5_FILES:.dict-c5=.dict.dz) |
37931fbb857f
Switch from ambiguous extension to unambiguous.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
46
diff
changeset
|
86 |
INDEX_FILES := $(C5_FILES:.dict-c5=.index) |
1
b23e948de24a
Make article for all verbs form.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
0
diff
changeset
|
87 |
|
66 | 88 |
RST_FILES := $(wildcard *.rst) |
89 |
HTML_FILES := $(RST_FILES:.rst=.html) |
|
90 |
||
103 | 91 |
name = gadict |
92 |
fullpkgname = $(name)-$(vmajor).$(vminor) |
|
93 |
||
94 |
DIST_DIR = $(fullpkgname) |
|
95 |
DISTSRC_DIR = $(fullpkgname)_src |
|
96 |
||
97 |
DIST_FILES = $(DICTDZ_FILES) $(INDEX_FILES) $(HTML_FILES) $(RST_FILES) VERSION |
|
98 |
||
99 |
DISTSRC_HELPER_FILES = VERSION Makefile rst.css .dir-locals.el |
|
100 |
DISTSRC_FILES = $(HTML_FILES) $(RST_FILES) $(DISTSRC_HELPER_FILES) |
|
101 |
||
102 |
################################################################ |
|
103 |
# Dist targets. |
|
104 |
||
105 |
.PHONY: dist |
|
106 |
dist: dist-dictd dist-src |
|
107 |
||
108 |
.PHONY: dist-dictd |
|
109 |
dist-dictd: $(DIST_DIR).tar.gz $(DIST_DIR).tar.bz2 |
|
110 |
||
111 |
.PHONY: dist-src |
|
112 |
dist-src: $(DISTSRC_DIR).tar.gz $(DISTSRC_DIR).tar.bz2 |
|
113 |
||
114 |
%.tar.gz: % |
|
115 |
tar zcf $*.tar.gz $* |
|
116 |
||
117 |
%.tar.bz2: % |
|
118 |
tar jcf $*.tar.bz2 $* |
|
119 |
||
120 |
$(DIST_DIR): $(DIST_FILES) |
|
121 |
rm -rf $@ |
|
122 |
mkdir $@ |
|
123 |
cp $(DIST_FILES) $@ |
|
124 |
||
125 |
$(DISTSRC_DIR): $(DISTSRC_FILES) |
|
126 |
rm -rf $@ |
|
127 |
mkdir $@ |
|
128 |
cp $(DISTSRC_FILES) $@ |
|
129 |
||
54 | 130 |
################################################################ |
131 |
# Build targets. |
|
0 | 132 |
|
23
946ae4b96419
Phony targets marked.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
133 |
.PHONY: all |
0 | 134 |
all: dist |
135 |
||
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
136 |
.PHONY: dist |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
137 |
dist: $(DICTDZ_FILES) $(INDEX_FILES) |
0 | 138 |
|
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
139 |
# --case-sensitive |
50
37931fbb857f
Switch from ambiguous extension to unambiguous.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
46
diff
changeset
|
140 |
%.dict %.index: %.dict-c5 |
46
86c0184efac7
Comment syntax convention.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
41
diff
changeset
|
141 |
sed '/^#/d' $< | dictfmt -c5 \ |
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
142 |
--headword-separator '; ' --break-headwords \ |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
143 |
--utf8 --allchars \ |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
144 |
-u "`sed -n '\|http://[[:print:]]\+/|{s=^.*\(http://\)=\1=;p;q;}' $<`" \ |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
145 |
-s "`sed -n '/^ABOUT: /{s=ABOUT: ==;p;q;}' $<`" \ |
46
86c0184efac7
Comment syntax convention.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
41
diff
changeset
|
146 |
$* |
0 | 147 |
|
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
148 |
%.dict.dz: %.dict |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
149 |
dictzip -c $< >$@ |
1
b23e948de24a
Make article for all verbs form.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
0
diff
changeset
|
150 |
|
54 | 151 |
################################################################ |
152 |
# Install/uninstall targets. |
|
0 | 153 |
|
23
946ae4b96419
Phony targets marked.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
154 |
.PHONY: install |
0 | 155 |
install: dist |
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
156 |
mkdir -p $(datadir) |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
157 |
for f in $(DICTDZ_FILES) $(INDEX_FILES); do \ |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
158 |
install -m 644 $$f $(datadir); \ |
0 | 159 |
done |
160 |
||
23
946ae4b96419
Phony targets marked.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
161 |
.PHONY: uninstall |
0 | 162 |
uninstall: |
41
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
163 |
for f in $(DICTDZ_FILES) $(INDEX_FILES); do \ |
8f1dc5d77f3d
Switch dictionary to dictd -c5 format.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
28
diff
changeset
|
164 |
rm -f $(datadir)/$$f; \ |
21
d4b27e5b7a4b
Added per user install target.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
20
diff
changeset
|
165 |
done |
13
d0e948499faf
Added targets [un]install-user to proper install dict for current user.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
9
diff
changeset
|
166 |
|
54 | 167 |
################################################################ |
66 | 168 |
# Documentation targets. |
169 |
||
170 |
.PHONY: html |
|
171 |
html: $(HTML_FILES) |
|
172 |
||
173 |
$(HTML_FILES): %.html: %.rst |
|
174 |
$(RST2HTML) --stylesheet=rst.css $*.rst $@ |
|
175 |
||
176 |
################################################################ |
|
94
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
177 |
# Statistics targets. |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
178 |
|
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
179 |
.PHONY: stat |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
180 |
stat: |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
181 |
total=0; \ |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
182 |
for dic in *.dict-c5; do \ |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
183 |
cnt=`grep '^_____' $$dic | wc -l`; \ |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
184 |
echo $$dic 'has ' $$cnt words.; \ |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
185 |
total=$$(($$total + $$cnt)); \ |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
186 |
done; \ |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
187 |
echo Total words count is $$total. |
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
188 |
|
1b2cf5b2b46c
Add target that print statistics about word count.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
85
diff
changeset
|
189 |
################################################################ |
54 | 190 |
# Clean targets. |
191 |
||
23
946ae4b96419
Phony targets marked.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
192 |
.PHONY: distclean |
946ae4b96419
Phony targets marked.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
193 |
distclean: clean |
13
d0e948499faf
Added targets [un]install-user to proper install dict for current user.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
9
diff
changeset
|
194 |
|
23
946ae4b96419
Phony targets marked.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
22
diff
changeset
|
195 |
.PHONY: clean |
0 | 196 |
clean: |
68 | 197 |
rm -f $(DICTDZ_FILES) $(INDEX_FILES) $(HTML_FILES) |
63 | 198 |
|
199 |
################################################################ |
|
200 |
# Helper target. |
|
201 |
||
202 |
.PHONY: help |
|
203 |
help: |
|
204 |
@echo |
|
205 |
@echo Supported targets: |
|
206 |
@sed -n -e '/^[[:alnum:]_-]*:/{s=^\(.*\):.*= \1=;p;}' $(MAKEFILE_LIST) |
|
207 |