Neues Ziel "suffix". Konsistenzkorrekturen Suffixauszeichnung.
[wortliste.git] / Makefile
blob23728a38ab3277ba4b748ae4f3a1e33fe1cfca19
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 PERLMAJOR = -g $(W)
108 ifeq ($(words $(MAKECMDGOALS)),1)
109 fugen: all
110 else
111 # This is to suppress the `nothing to be done' warning.
112 fugen:
114 endif
115 else ifneq ($(findstring suffix,$(MAKECMDGOALS)),)
116 MAJOR = -suffix
117 # All combinations of `-', `<', `=' get removed,
118 # runs of `>' are converted to a hyphen.
119 SEDMAJOR = $(SED) -e '/[=<>-]/!n' \
120 -e 's/-//g' \
121 -e 's/[<=][<=]*//g' \
122 -e 's/[>][>]*/-/g'
123 PERLMAJOR = -g $(W)
125 ifeq ($(words $(MAKECMDGOALS)),1)
126 suffix: all
127 else
128 # This is to suppress the `nothing to be done' warning.
129 suffix:
131 endif
132 else
133 MAJOR =
134 SEDMAJOR = cat
135 PERLMAJOR =
136 endif
138 TRAD = dehypht-x$(MAJOR)
139 REFO = dehyphn-x$(MAJOR)
140 SWISS = dehyphts-x$(MAJOR)
142 LC_ENVVARS = LC_COLLATE=de_DE.ISO8859-15 \
143 LC_CTYPE=de_DE.ISO8859-15
145 CAT = cat
146 CHDIR = cd
147 COPY = cp
148 DATE = $(shell date '+%Y-%m-%d')
149 ECHO = echo
150 GIT = git
151 ICONV = iconv -f iso-8859-15 -t utf-8
152 MKDIR = mkdir -p
153 PERL = perl
154 PWD = pwd
155 SED = sed
156 SH = bash
157 SORT = $(LC_ENVVARS) sort -d \
158 | $(LC_ENVVARS) uniq -i
160 GIT_VERSION := `$(CHDIR) $(SRCDIR); \
161 $(GIT) log --format=%H -1 HEAD --`
162 TRADFILES = $(TRAD)/$(TRAD)-$(DATE).pat $(TRAD)/$(TRAD)-$(DATE).tex
163 REFOFILES = $(REFO)/$(REFO)-$(DATE).pat $(REFO)/$(REFO)-$(DATE).tex
164 SWISSFILES = $(SWISS)/$(SWISS)-$(DATE).pat $(SWISS)/$(SWISS)-$(DATE).tex
167 override SRCDIR := $(shell cd $(SRCDIR); $(PWD))
170 all: pattern-trad pattern-refo pattern-swiss
172 .PHONY: pattern-trad pattern-refo pattern-swiss major fugen suffix
173 pattern-trad: $(TRADFILES)
174 pattern-refo: $(REFOFILES)
175 pattern-swiss: $(SWISSFILES)
177 # intermediate targets
179 # auxiliary targets
181 .PHONY: words-trad words-refo
182 words-trad: $(TRAD)/words.hyphenated.trad
183 words-refo: $(REFO)/words.hyphenated.refo
186 .PHONY: pre-trad pre-refo pre-swiss
187 pre-trad:
188 $(MKDIR) $(TRAD)
189 pre-refo:
190 $(MKDIR) $(REFO)
191 pre-swiss:
192 $(MKDIR) $(SWISS)
194 $(TRADFILES) $(TRAD)/words.hyphenated.trad: pre-trad
195 $(REFOFILES) $(REFO)/words.hyphenated.refo: pre-refo
196 $(SWISSFILES) $(SWISS)/words.hyphenated.swiss: pre-swiss
199 # GNU make supports creation of multiple targets by a single
200 # invocation of a recipe only for pattern rules, thus we have
201 # to use a `sentinel file' (using `echo' for the time stamp).
204 $(TRAD)/pattern.8 $(TRAD)/pattern.rules: $(TRAD)/make-full-pattern-trad
206 $(TRAD)/make-full-pattern-trad: $(TRAD)/words.hyphenated.trad
207 $(CHDIR) $(TRAD); \
208 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
209 $(ECHO) done > $@
211 $(TRAD)/$(TRAD)-$(DATE).pat: $(TRAD)/pattern.8 $(TRAD)/pattern.rules
212 $(CAT) $(DATADIR)/$(TRAD).1 \
213 | $(SED) -e "s/@DATE@/$(DATE)/" \
214 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
215 $(CAT) $(TRAD)/pattern.rules >> $@; \
216 $(CAT) $(DATADIR)/$(TRAD).2 >> $@; \
217 $(CAT) $(TRAD)/pattern.8 \
218 | $(ICONV) >> $@; \
219 $(CAT) $(DATADIR)/$(TRAD).3 >> $@
222 $(REFO)/pattern.8 $(REFO)/pattern.rules: $(REFO)/make-full-pattern-refo
224 $(REFO)/make-full-pattern-refo: $(REFO)/words.hyphenated.refo
225 $(CHDIR) $(REFO); \
226 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
227 $(ECHO) done > $@
229 $(REFO)/$(REFO)-$(DATE).pat: $(REFO)/pattern.8 $(REFO)/pattern.rules
230 $(CAT) $(DATADIR)/$(REFO).1 \
231 | $(SED) -e "s/@DATE@/$(DATE)/" \
232 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
233 $(CAT) $(REFO)/pattern.rules >> $@; \
234 $(CAT) $(DATADIR)/$(REFO).2 >> $@; \
235 $(CAT) $(REFO)/pattern.8 \
236 | $(ICONV) >> $@; \
237 $(CAT) $(DATADIR)/$(REFO).3 >> $@
240 $(SWISS)/pattern.8 $(SWISS)/pattern.rules: $(SWISS)/make-full-pattern-swiss
242 $(SWISS)/make-full-pattern-swiss: $(SWISS)/words.hyphenated.swiss
243 $(CHDIR) $(SWISS); \
244 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
245 $(ECHO) done > $@
247 $(SWISS)/$(SWISS)-$(DATE).pat: $(SWISS)/pattern.8 $(SWISS)/pattern.rules
248 $(CAT) $(DATADIR)/$(SWISS).1 \
249 | $(SED) -e "s/@DATE@/$(DATE)/" \
250 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
251 $(CAT) $(SWISS)/pattern.rules >> $@; \
252 $(CAT) $(DATADIR)/$(SWISS).2 >> $@; \
253 $(CAT) $(SWISS)/pattern.8 \
254 | $(ICONV) >> $@; \
255 $(CAT) $(DATADIR)/$(SWISS).3 >> $@
258 $(TRAD)/words.hyphenated.trad: $(SRCDIR)/$(WORDLIST)
259 $(CAT) $< \
260 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -t $(PERLMAJOR) \
261 | $(SEDMAJOR) \
262 | $(SORT) > $@
264 $(REFO)/words.hyphenated.refo: $(SRCDIR)/$(WORDLIST)
265 $(CAT) $< \
266 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l $(PERLMAJOR) \
267 | $(SEDMAJOR) \
268 | $(SORT) > $@
270 $(SWISS)/words.hyphenated.swiss: $(SRCDIR)/$(WORDLIST)
271 $(CAT) $< \
272 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -s $(PERLMAJOR) \
273 | $(SEDMAJOR) \
274 | $(SORT) > $@
277 $(TRAD)/$(TRAD)-$(DATE).tex: $(DATADIR)/$(TRAD).tex.in
278 $(CAT) $< \
279 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
281 $(REFO)/$(REFO)-$(DATE).tex: $(DATADIR)/$(REFO).tex.in
282 $(CAT) $< \
283 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
285 $(SWISS)/$(SWISS)-$(DATE).tex: $(DATADIR)/$(SWISS).tex.in
286 $(CAT) $< \
287 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
289 pidiff:
290 $(SH) skripte/patgen-list-diff.sh $(FROM) $(TO)
292 # EOF