~ubuntu-branches/ubuntu/lucid/dict-ns/lucid

« back to all changes in this revision

Viewing changes to utils/Makefile.language

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-02-06 20:11:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070206201142-vix5rf0kn1h06h94
Tags: upstream-20070206
ImportĀ upstreamĀ versionĀ 20070206

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# this makefile is used to automate building of dictionaries
 
2
# based on affix files etc...
 
3
 
 
4
# if you need to adapt this Makefile for another language,
 
5
# all you should have to do is change these variables.
 
6
# if you need to change anything else, please submit it back
 
7
# to the project so other people can benefit
 
8
 
 
9
# The version will automatically be read in from the VERSION file
 
10
VERSION=$(shell cat VERSION)
 
11
VERSION_ASPELL=$(shell cat ../VERSION.aspell)
 
12
 
 
13
# Only set these if the user has not overridden them in the language Makefile
 
14
LANG_FAKE?=$(LANG)
 
15
REGION_FAKE?=$(REGION)
 
16
 
 
17
.PHONY: all clean clean-myspell clean-ispell clean-aspell clean-autocorr ispell myspell aspell count check wordlist autocorr
 
18
 
 
19
 
 
20
TARGETS_MYSPELL=myspell/wordlist.$(CHARSET) myspell/pack-$(LANG)-$(REGION)-$(VERSION).zip myspell/$(LANG)_$(REGION).zip myspell/$(LANG)_$(REGION).dic myspell/spell.txt myspell/VERSION_$(LANG)_$(REGION).txt myspell/install.js myspell/spell-$(LANG)-$(REGION).xpi myspell/$(LANG)-$(REGION).dic myspell/$(LANG)-$(REGION).aff myspell/README-$(LANG)-$(REGION).txt
 
21
 
 
22
TARGETS_ISPELL=ispell/$(LANGNAMELOW).hash ispell/$(LANGNAMELOW)-ispell-$(VERSION).tar.bz2 ispell/wordlist.$(CHARSET) ispell/wordlist.$(CHARSET).cnt ispell/wordlist.$(CHARSET).stat
 
23
 
 
24
TARGET_ASPELL=aspell/wordlist.$(CHARSET) aspell/$(LANG).rws aspell/aspell-$(LANG)-$(VERSION_ASPELL)-$(VERSION).tar.bz2 aspell/proc aspell/configure aspell/$(LANG).cwl aspell/info aspell/Makefile aspell/Makefile.pre aspell/$(LANG).* aspell/*.alias aspell/COPYING aspell/README aspell/aspell-$(LANG)-$(VERSION_ASPELL)-$(VERSION)
 
25
 
 
26
TARGET_AUTOCORR=acor/acor_$(LANG)-$(REGION).dat*
 
27
 
 
28
TARGET_WORDLISTS=wordlists/wordlist.$(CHARSET) $(WORDLIST.CHARSET)
 
29
 
 
30
all: myspell aspell wordlist acor
 
31
 
 
32
clean: clean-myspell clean-ispell clean-aspell clean-wordlists clean-acor
 
33
 
 
34
# Statistics
 
35
 
 
36
count: wordlists/wordlist.$(CHARSET) $(WORDLIST.IN)
 
37
        @echo "Comments removed"
 
38
        @for f in $^; do \
 
39
                echo -n "$$f    "; \
 
40
        egrep -v "^#" $$f | sort --unique | wc -l; \
 
41
    done
 
42
        @echo
 
43
        @echo "Comments and words with whitespace removed"
 
44
        @for f in $^; do \
 
45
                echo -n "$$f    "; \
 
46
        egrep -v "(^#| )" $$f | sort --unique | wc -l; \
 
47
    done
 
48
        @echo
 
49
        @echo "Comments removed words with whitespace split"
 
50
        @for f in $^; do \
 
51
                echo -n "$$f    "; \
 
52
        egrep -v "^#" $$f | tr " " "\n" | sort --unique | wc -l; \
 
53
    done
 
54
 
 
55
# Checks
 
56
 
 
57
check: wordlists/wordlist.$(CHARSET)
 
58
        @echo First line is existing TRY sequence.  Second line is new TRY sequence.
 
59
        @egrep "^TRY" myspell/$(LANG)_$(REGION).aff | sed "s/TRY //g"
 
60
        @LC_ALL=en_US.utf8 LANG=en_US.utf8 LANGUAGE=en_US.utf8 ../../src/wordlist/letter-frequency.py -i $^ -len_US
 
61
 
 
62
 
 
63
# General
 
64
 
 
65
WORDLIST.CHARSET=$(patsubst %.in, %.$(CHARSET), $(WORDLIST.IN))
 
66
 
 
67
%.$(CHARSET): %.in
 
68
        iconv -f utf-8 -t $(CHARSET) < $< >$@
 
69
 
 
70
wordlists/wordlist.$(CHARSET): $(WORDLIST.CHARSET)
 
71
        cat $^ | egrep -v "^#|^$$" | sort --unique > $@
 
72
 
 
73
wordlists/wordlist-$(LANG)-$(VERSION).zip: $(WORDLIST.IN) wordlists/wordlist.$(CHARSET)
 
74
        zip -j $@ $^
 
75
 
 
76
wordlist: wordlists/wordlist-$(LANG)-$(VERSION).zip
 
77
 
 
78
clean-wordlists:
 
79
        rm -rf $(TARGET_WORDLISTS)
 
80
 
 
81
# MySpell rules
 
82
 
 
83
clean-myspell:
 
84
        rm -f $(TARGETS_MYSPELL)
 
85
 
 
86
# make myspell will make the required zip files
 
87
myspell: myspell/myspell-$(LANG)_$(REGION)-$(VERSION).zip myspell/myspell-pack-$(LANG)-$(REGION)-$(VERSION).zip myspell/spell-$(LANG)-$(REGION)-$(VERSION).xpi
 
88
 
 
89
# this is a package that is usable for offline installation
 
90
myspell/myspell-pack-$(LANG)-$(REGION)-$(VERSION).zip: myspell/myspell-$(LANG)_$(REGION)-$(VERSION).zip myspell/spell.txt
 
91
        zip -j $@ $^
 
92
 
 
93
# we autogenerate the index file...
 
94
myspell/spell.txt:
 
95
        echo '$(LANG_FAKE),$(REGION_FAKE),$(LANG_FAKE)_$(REGION_FAKE),$(LANGNAME) ($(REGIONNAME)),myspell-$(LANG)_$(REGION)-$(VERSION).zip' >$@
 
96
 
 
97
# this is the standard myspell package
 
98
myspell/myspell-$(LANG)_$(REGION)-$(VERSION).zip: myspell/$(LANG)_$(REGION).dic myspell/$(LANG)_$(REGION).aff myspell/README_$(LANG)_$(REGION).txt myspell/VERSION_$(LANG)_$(REGION).txt
 
99
        zip -j $@ $^
 
100
 
 
101
# make sure the VERSION file name doesn't conflict with other packages
 
102
myspell/VERSION_$(LANG)_$(REGION).txt: VERSION
 
103
        cp -p $^ $@
 
104
 
 
105
# myspell/ispell don't like the header, or words with spaces in them
 
106
myspell/wordlist.$(CHARSET): wordlists/wordlist.$(CHARSET)
 
107
        egrep -v '(^#| )' <$< >$@
 
108
 
 
109
 
 
110
# this does the work of converting a wordlist into a myspell dictionary
 
111
# it can take a while
 
112
# the munch utility is located under the dict/utils project
 
113
myspell/$(LANG)_$(REGION).dic: myspell/wordlist.$(CHARSET) myspell/$(LANG)_$(REGION).aff ../utils/munch
 
114
        ../utils/munch myspell/wordlist.$(CHARSET) myspell/$(LANG)_$(REGION).aff >$@
 
115
 
 
116
# The following are for building a Mozilla XPI of the spellchecker
 
117
# Customise the install.js
 
118
myspell/install.js: ../utils/install.js.in
 
119
        sed "s/{LANG}/$(LANG)/; s/{REGION}/$(REGION)/; s/{LANGNAME}/$(LANGNAME)/; s/{REGIONNAME}/$(REGIONNAME)/; s/{VERSION}/$(VERSION)/" < $< > $@
 
120
 
 
121
myspell/README-$(LANG)-$(REGION).txt: myspell/README_$(LANG)_$(REGION).txt
 
122
        cp $^ $@
 
123
 
 
124
myspell/$(LANG)-$(REGION).dic: myspell/$(LANG)_$(REGION).dic
 
125
        cp $^ $@
 
126
 
 
127
myspell/$(LANG)-$(REGION).aff: myspell/$(LANG)_$(REGION).aff
 
128
        cp $^ $@
 
129
 
 
130
myspell/spell-$(LANG)-$(REGION)-$(VERSION).xpi: myspell/$(LANG)-$(REGION).aff myspell/$(LANG)-$(REGION).dic myspell/README-$(LANG)-$(REGION).txt myspell/install.js
 
131
        zip -j $@ $^
 
132
 
 
133
# Ispell Rules
 
134
 
 
135
clean-ispell:
 
136
        rm -f $(TARGETS_ISPELL)
 
137
 
 
138
ispell/$(LANGNAMELOW).hash: ispell/wordlist.$(CHARSET) ispell/$(LANGNAMELOW).aff
 
139
        buildhash $^ $@
 
140
 
 
141
ispell/$(LANGNAMELOW)-ispell-$(VERSION).tar.bz2: ispell/$(LANGNAMELOW).hash ispell/$(LANGNAMELOW).aff ispell/README
 
142
        tar cvjf $@ $^
 
143
 
 
144
ispell: ispell/$(LANGNAMELOW)-ispell-$(VERSION).tar.bz2
 
145
 
 
146
ispell/wordlist.$(CHARSET): wordlists/wordlist.$(CHARSET)
 
147
        egrep -v '(^#| )' <$< >$@
 
148
 
 
149
# Aspell Rules
 
150
 
 
151
aspell: aspell/aspell-$(LANG)-$(VERSION_ASPELL)-$(VERSION).tar.bz2
 
152
 
 
153
clean-aspell:
 
154
        rm -rf $(TARGET_ASPELL)
 
155
 
 
156
aspell/$(LANG).cwl: aspell/wordlist.$(CHARSET)
 
157
        (export LC_COLLATE=C; cat $< | sort -u | word-list-compress compress > $@)
 
158
 
 
159
aspell/proc: ../utils/proc
 
160
        cp -p $< $@
 
161
 
 
162
aspell/configure: ../utils/configure
 
163
        cp -p $< $@
 
164
 
 
165
aspell/wordlist.$(CHARSET): wordlists/wordlist.$(CHARSET)
 
166
        cat $< | egrep -v '(^#| |\.|-$$|[0-9]|/|=$$)' | LC_COLLATE=C sort --unique >$@
 
167
 
 
168
aspell/aspell-$(LANG)-$(VERSION_ASPELL)-$(VERSION).tar.bz2: aspell/$(LANG).cwl aspell/configure aspell/Makefile.pre aspell/Copyright
 
169
        cd aspell; ./configure; make dist && make distcheck && rm -rf aspell-$(LANG)-$(VERSION_ASPELL)-$(VERSION)
 
170
 
 
171
aspell/info: aspell/info.in ../VERSION.aspell VERSION
 
172
        sed "s/{VERSION}/$(VERSION_ASPELL)\-$(VERSION)/" < $< > $@
 
173
 
 
174
aspell/Makefile.pre: aspell/proc aspell/info
 
175
        (cd aspell; export LC_COLLATE=C; ./proc create)
 
176
 
 
177
# Autocorrect rules
 
178
 
 
179
# Naming format for OpenOffice.org 2
 
180
acor/acor_$(LANG)-$(REGION).dat: acor/DocumentList.csv acor/SentenceExceptList.csv acor/WordExceptList.csv
 
181
        (cd acor; ../../utils/csv2acor.py $(@F))
 
182
 
 
183
acor: acor/acor_$(LANG)-$(REGION).dat
 
184
 
 
185
autocorrect: acor
 
186
 
 
187
clean-acor: 
 
188
        rm -rf $(TARGET_AUTOCORR)