Trennstellenkategorisierung. Vollstaendig!
[wortliste.git] / Makefile
blob12e1e3f0db0d17f6fc5db0db87ae843f7164d40f
1 # -*- coding: utf-8 -*-
3 # This Makefile creates German hyphenation patterns in subdirectories
4 # $(TRAD) and $(REFO) for traditional and new orthography, respectively.
5 # Hyphenation patterns for traditional Swiss German are generated in
6 # directory $(SWISS).
8 # The input data is in $(SRCDIR); the possible targets are `pattern-trad',
9 # `pattern-refo', and `pattern-swiss'. If no target (or target `all') is
10 # given, all patterns for all three targets are built.
12 # SRCDIR (and the other variables) can be easily modified as parameters
13 # while calling `make', e.g.
15 # make pattern-trad SRCDIR=~/git/wortliste
17 # If you add one of the (phony) targets `major', `fugen', or `suffix',
18 # patterns which only use major hyphenation points (`Haupttrennstellen')
19 # are created. Example:
21 # make major pattern-refo
23 # The used directories names are the same as above but with `-major' (etc.)
24 # appended to the names.
26 # To control the used weights in the major hyphenation patterns, add
27 # variable `W=N', where `N' gives the quality: value 1 specifies the best
28 # hyphenation points only, value 2 both the best and second-best points,
29 # etc. The default is value 0, using all major hyphenation points.
33 # Dieses Makefile erzeugt deutsche Trennmuster in den
34 # Unterverzeichnissen $(TRAD) und $(REFO) für die traditionelle
35 # bzw. reformierte Rechtschreibung. Trennmuster für tradionelles
36 # deutschschweizerisches Deutsch werden Verzeichnis $(SWISS) erzeugt.
38 # Die Eingabedaten werden im Verzeichnis $(SRCDIR) erwartet; die möglichen
39 # Make-Ziele sind `pattern-trad', `pattern-refo' und `pattern-swiss'. Wenn
40 # kein Ziel angegeben ist (oder man das Ziel `all' verwendet), werden alle
41 # drei Trennmuster erzeugt.
43 # SRCDIR (und die anderen Variablen) kann man leicht beim Aufruf von
44 # `make' als Parameter modifizieren, z.B.
46 # make pattern-trad SRCDIR=~/git/wortliste
48 # Wird eines der zusätzlichen (künstliche) Ziele `major', `fugen' oder
49 # `suffix' angegeben, werden Haupttrennstellmuster erzeugt.
51 # Beispiel:
53 # make major pattern-refo
55 # Die verwendeten Verzeichnisnamen sind die gleichen wie oben, allerdings
56 # mit einem angehängten `-major', `-fugen' bzw. `-suffix'.
58 # Diese Spezialmuster spiegeln die Auszeichnung in der Liste direkt wider.
59 # Sie haben nicht das Ziel, "gute" Trennungen in Texten zu erzeugen sondern
60 # sind zum Testen der Konsistenz der Auszeichnung sowie zum "kategorisierten"
61 # Markieren der Trennstellen neuer Wörter gedacht.
63 # Die Wichtung der verwendeten Haupttrennstellen kann mittels der Variable
64 # `W=N' kontrolliert werden, wo `N' die Qualität angibt: Wert 1 selektiert
65 # nur die besten Haupttrennstellen, Wert 2 die besten und zweitbesten
66 # Haupttrennstellen usw. Der Standardwert für `W' ist 0; er gibt an, dass
67 # alle Haupttrennstellen verwendet werden sollen.
70 SRCDIR = .
71 W = 0
73 DATADIR = $(SRCDIR)/daten
74 SCRIPTDIR = $(SRCDIR)/skripte
75 WORDLIST = wortliste
76 # Variables FROM and TO are used by goal `pidiff'. FROM must be a
77 # commit set from shell, like `make pidiff FROM=abcdef', TO is optional
78 # and evaluates to `HEAD' if not given.
80 ifneq ($(findstring major,$(MAKECMDGOALS)),)
81 MAJOR = -major
82 # A single `-' gets removed; all other combinations of `-', `<', `>',
83 # and `=' are converted to a hyphen.
84 SEDMAJOR = $(SED) -e '/[=<>-]/!n' \
85 -e 's/---*/=/g' \
86 -e 's/-//g' \
87 -e 's/[=<>][=<>]*/-/g' \
88 -e '/-/!d'
89 PERLMAJOR = -g $(W)
91 ifeq ($(words $(MAKECMDGOALS)),1)
92 major: all
93 else
94 # This is to suppress the `nothing to be done' warning.
95 major:
97 endif
98 else ifneq ($(findstring fugen,$(MAKECMDGOALS)),)
99 MAJOR = -fugen
100 # All combinations of `-', `<', `>', `<=', `=>' get removed,
101 # runs of `=' are converted to a hyphen.
102 SEDMAJOR = $(SED) -e '/[=<>-]/!n' \
103 -e 's/--*//g' \
104 -e 's/<=*//g' \
105 -e 's/=*>//g' \
106 -e 's/[<>][<>]*//g' \
107 -e 's/[=][=]*/-/g'
108 PERLMAJOR = -g $(W)
110 ifeq ($(words $(MAKECMDGOALS)),1)
111 fugen: all
112 else
113 # This is to suppress the `nothing to be done' warning.
114 fugen:
116 endif
117 else ifneq ($(findstring suffix,$(MAKECMDGOALS)),)
118 MAJOR = -suffix
119 # All combinations of `-', `<', `=' get removed,
120 # runs of `>' are converted to a hyphen.
121 SEDMAJOR = $(SED) -e '/[=<>-]/!n' \
122 -e 's/-//g' \
123 -e 's/[<=][<=]*//g' \
124 -e 's/[>][>]*/-/g'
125 PERLMAJOR = -g $(W)
127 ifeq ($(words $(MAKECMDGOALS)),1)
128 suffix: all
129 else
130 # This is to suppress the `nothing to be done' warning.
131 suffix:
133 endif
134 else
135 MAJOR =
136 SEDMAJOR = cat
137 PERLMAJOR =
138 endif
140 TRAD = dehypht-x$(MAJOR)
141 REFO = dehyphn-x$(MAJOR)
142 SWISS = dehyphts-x$(MAJOR)
144 LC_ENVVARS = LC_COLLATE=de_DE.ISO8859-15 \
145 LC_CTYPE=de_DE.ISO8859-15
147 CAT = cat
148 CHDIR = cd
149 COPY = cp
150 DATE = $(shell date '+%Y-%m-%d')
151 ECHO = echo
152 GIT = git
153 ICONV = iconv -f iso-8859-15 -t utf-8
154 MKDIR = mkdir -p
155 PERL = perl
156 PWD = pwd
157 SED = sed
158 SH = bash
159 SORT = $(LC_ENVVARS) sort -d \
160 | $(LC_ENVVARS) uniq -i
162 GIT_VERSION := `$(CHDIR) $(SRCDIR); \
163 $(GIT) log --format=%H -1 HEAD --`
164 TRADFILES = $(TRAD)/$(TRAD)-$(DATE).pat $(TRAD)/$(TRAD)-$(DATE).tex
165 REFOFILES = $(REFO)/$(REFO)-$(DATE).pat $(REFO)/$(REFO)-$(DATE).tex
166 SWISSFILES = $(SWISS)/$(SWISS)-$(DATE).pat $(SWISS)/$(SWISS)-$(DATE).tex
169 override SRCDIR := $(shell cd $(SRCDIR); $(PWD))
172 all: pattern-trad pattern-refo pattern-swiss
174 .PHONY: pattern-trad pattern-refo pattern-swiss major fugen suffix
175 pattern-trad: $(TRADFILES)
176 pattern-refo: $(REFOFILES)
177 pattern-swiss: $(SWISSFILES)
179 # intermediate targets
181 # auxiliary targets
183 .PHONY: words-trad words-refo
184 words-trad: $(TRAD)/words.hyphenated.trad
185 words-refo: $(REFO)/words.hyphenated.refo
188 .PHONY: pre-trad pre-refo pre-swiss
189 pre-trad:
190 $(MKDIR) $(TRAD)
191 pre-refo:
192 $(MKDIR) $(REFO)
193 pre-swiss:
194 $(MKDIR) $(SWISS)
196 $(TRADFILES) $(TRAD)/words.hyphenated.trad: pre-trad
197 $(REFOFILES) $(REFO)/words.hyphenated.refo: pre-refo
198 $(SWISSFILES) $(SWISS)/words.hyphenated.swiss: pre-swiss
201 # GNU make supports creation of multiple targets by a single
202 # invocation of a recipe only for pattern rules, thus we have
203 # to use a `sentinel file' (using `echo' for the time stamp).
206 $(TRAD)/pattern.8 $(TRAD)/pattern.rules: $(TRAD)/make-full-pattern-trad
208 $(TRAD)/make-full-pattern-trad: $(TRAD)/words.hyphenated.trad
209 $(CHDIR) $(TRAD); \
210 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
211 $(ECHO) done > $@
213 $(TRAD)/$(TRAD)-$(DATE).pat: $(TRAD)/pattern.8 $(TRAD)/pattern.rules
214 $(CAT) $(DATADIR)/$(TRAD).1 \
215 | $(SED) -e "s/@DATE@/$(DATE)/" \
216 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
217 $(CAT) $(TRAD)/pattern.rules >> $@; \
218 $(CAT) $(DATADIR)/$(TRAD).2 >> $@; \
219 $(CAT) $(TRAD)/pattern.8 \
220 | $(ICONV) >> $@; \
221 $(CAT) $(DATADIR)/$(TRAD).3 >> $@
224 $(REFO)/pattern.8 $(REFO)/pattern.rules: $(REFO)/make-full-pattern-refo
226 $(REFO)/make-full-pattern-refo: $(REFO)/words.hyphenated.refo
227 $(CHDIR) $(REFO); \
228 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
229 $(ECHO) done > $@
231 $(REFO)/$(REFO)-$(DATE).pat: $(REFO)/pattern.8 $(REFO)/pattern.rules
232 $(CAT) $(DATADIR)/$(REFO).1 \
233 | $(SED) -e "s/@DATE@/$(DATE)/" \
234 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
235 $(CAT) $(REFO)/pattern.rules >> $@; \
236 $(CAT) $(DATADIR)/$(REFO).2 >> $@; \
237 $(CAT) $(REFO)/pattern.8 \
238 | $(ICONV) >> $@; \
239 $(CAT) $(DATADIR)/$(REFO).3 >> $@
242 $(SWISS)/pattern.8 $(SWISS)/pattern.rules: $(SWISS)/make-full-pattern-swiss
244 $(SWISS)/make-full-pattern-swiss: $(SWISS)/words.hyphenated.swiss
245 $(CHDIR) $(SWISS); \
246 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
247 $(ECHO) done > $@
249 $(SWISS)/$(SWISS)-$(DATE).pat: $(SWISS)/pattern.8 $(SWISS)/pattern.rules
250 $(CAT) $(DATADIR)/$(SWISS).1 \
251 | $(SED) -e "s/@DATE@/$(DATE)/" \
252 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
253 $(CAT) $(SWISS)/pattern.rules >> $@; \
254 $(CAT) $(DATADIR)/$(SWISS).2 >> $@; \
255 $(CAT) $(SWISS)/pattern.8 \
256 | $(ICONV) >> $@; \
257 $(CAT) $(DATADIR)/$(SWISS).3 >> $@
260 $(TRAD)/words.hyphenated.trad: $(SRCDIR)/$(WORDLIST)
261 $(CAT) $< \
262 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -t $(PERLMAJOR) \
263 | $(SEDMAJOR) \
264 | $(SORT) > $@
266 $(REFO)/words.hyphenated.refo: $(SRCDIR)/$(WORDLIST)
267 $(CAT) $< \
268 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l $(PERLMAJOR) \
269 | $(SEDMAJOR) \
270 | $(SORT) > $@
272 $(SWISS)/words.hyphenated.swiss: $(SRCDIR)/$(WORDLIST)
273 $(CAT) $< \
274 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -s $(PERLMAJOR) \
275 | $(SEDMAJOR) \
276 | $(SORT) > $@
279 $(TRAD)/$(TRAD)-$(DATE).tex: $(DATADIR)/$(TRAD).tex.in
280 $(CAT) $< \
281 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
283 $(REFO)/$(REFO)-$(DATE).tex: $(DATADIR)/$(REFO).tex.in
284 $(CAT) $< \
285 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
287 $(SWISS)/$(SWISS)-$(DATE).tex: $(DATADIR)/$(SWISS).tex.in
288 $(CAT) $< \
289 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
291 pidiff:
292 $(SH) skripte/patgen-list-diff.sh $(FROM) $(TO)
294 # EOF