Zusammenfassen identischer Sprach-Spalten. Etymologische Trennung von Di-stanz.
[wortliste.git] / Makefile
blobd1b166cd3e499040ce4dea384848aa154b6d28c4
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 the (phony) target `major', patterns which only use major
18 # hyphenation points (`Haupttrennstellen') are created. Example:
20 # make major pattern-refo
22 # The used directories names are the same as above but with `-major'
23 # appended to the names.
25 # To control the used weights in the major hyphenation patterns, add
26 # variable `W=N', where `N' gives the quality: value 1 specifies the best
27 # hyphenation points only, value 2 both the best and second-best points,
28 # etc. The default is value 0, using all major hyphenation points.
32 # Dieses Makefile erzeugt deutsche Trennmuster in den
33 # Unterverzeichnissen $(TRAD) und $(REFO) für die traditionelle
34 # bzw. reformierte Rechtschreibung. Trennmuster für tradionelles
35 # deutschschweizerisches Deutsch werden Verzeichnis $(SWISS) erzeugt.
37 # Die Eingabedaten werden im Verzeichnis $(SRCDIR) erwartet; die möglichen
38 # Make-Ziele sind `pattern-trad', `pattern-refo' und `pattern-swiss'. Wenn
39 # kein Ziel angegeben ist (oder man das Ziel `all' verwendet), werden alle
40 # drei Trennmuster erzeugt.
42 # SRCDIR (und die anderen Variablen) kann man leicht beim Aufruf von
43 # `make' als Parameter modifizieren, z.B.
45 # make pattern-trad SRCDIR=~/git/wortliste
47 # Wird zusätzlich das zusätzliche (künstliche) Ziel `major' angegeben,
48 # werden Haupttrennstellmuster erzeugt.
50 # Beispiel:
52 # make major pattern-refo
54 # Die verwendeten Verzeichnisnamen sind die gleichen wie oben, allerdings
55 # mit einem angehängten `-major'.
57 # Die Wichtung der verwendeten Haupttrennstellen kann mittels der Variable
58 # `W=N' kontrolliert werden, wo `N' die Qualität angibt: Wert 1 selektiert
59 # nur die besten Haupttrennstellen, Wert 2 die besten und zweitbesten
60 # Haupttrennstellen usw. Der Standardwert für `W' ist 0; er gibt an, dass
61 # alle Haupttrennstellen verwendet werden sollen.
64 SRCDIR = .
65 W = 0
67 DATADIR = $(SRCDIR)/daten
68 SCRIPTDIR = $(SRCDIR)/skripte
69 WORDLIST = wortliste
70 # Variables FROM and TO are used by goal `pidiff'. FROM must be a
71 # commit set from shell, like `make pidiff FROM=abcdef', TO is optional
72 # and evaluates to `HEAD' if not given.
74 ifneq ($(findstring major,$(MAKECMDGOALS)),)
75 MAJOR = -major
76 # A single `-' gets removed; all other combinations of `-', `<', `>',
77 # `=', and `|' are converted to a hyphen.
78 SEDMAJOR = $(SED) -e '/[=|<>-]/!n' \
79 -e 's/---*/=/g' \
80 -e 's/-//g' \
81 -e 's/[=|<>][=|<>]*/-/g' \
82 -e '/-/!d'
83 PERLMAJOR = -g $(W)
85 ifeq ($(words $(MAKECMDGOALS)),1)
86 major: all
87 else
88 # This is to suppress the `nothing to be done' warning.
89 major:
91 endif
92 else
93 MAJOR =
94 SEDMAJOR = cat
95 PERLMAJOR =
96 endif
98 TRAD = dehypht-x$(MAJOR)
99 REFO = dehyphn-x$(MAJOR)
100 SWISS = dehyphts-x$(MAJOR)
102 LC_ENVVARS = LC_COLLATE=de_DE.ISO8859-15 \
103 LC_CTYPE=de_DE.ISO8859-15
105 CAT = cat
106 CHDIR = cd
107 COPY = cp
108 DATE = $(shell date '+%Y-%m-%d')
109 ECHO = echo
110 GIT = git
111 ICONV = iconv -f iso-8859-15 -t utf-8
112 MKDIR = mkdir -p
113 PERL = perl
114 PWD = pwd
115 SED = sed
116 SH = bash
117 SORT = $(LC_ENVVARS) sort -d \
118 | $(LC_ENVVARS) uniq -i
120 GIT_VERSION := `$(CHDIR) $(SRCDIR); \
121 $(GIT) log --format=%H -1 HEAD --`
122 TRADFILES = $(TRAD)/$(TRAD)-$(DATE).pat $(TRAD)/$(TRAD)-$(DATE).tex
123 REFOFILES = $(REFO)/$(REFO)-$(DATE).pat $(REFO)/$(REFO)-$(DATE).tex
124 SWISSFILES = $(SWISS)/$(SWISS)-$(DATE).pat $(SWISS)/$(SWISS)-$(DATE).tex
127 override SRCDIR := $(shell cd $(SRCDIR); $(PWD))
130 all: pattern-trad pattern-refo pattern-swiss
132 .PHONY: pattern-trad pattern-refo pattern-swiss major
133 pattern-trad: $(TRADFILES)
134 pattern-refo: $(REFOFILES)
135 pattern-swiss: $(SWISSFILES)
137 # auxiliary targets
139 .PHONY: words-trad words-refo
140 words-trad: $(TRAD)/words.hyphenated.trad
141 words-refo: $(REFO)/words.hyphenated.refo
144 .PHONY: pre-trad pre-refo pre-swiss
145 pre-trad:
146 $(MKDIR) $(TRAD)
147 pre-refo:
148 $(MKDIR) $(REFO)
149 pre-swiss:
150 $(MKDIR) $(SWISS)
152 $(TRADFILES) $(TRAD)/words.hyphenated.trad: pre-trad
153 $(REFOFILES) $(REFO)/words.hyphenated.refo: pre-refo
154 $(SWISSFILES) $(SWISS)/words.hyphenated.swiss: pre-swiss
157 # GNU make supports creation of multiple targets by a single
158 # invocation of a recipe only for pattern rules, thus we have
159 # to use a `sentinel file' (using `echo' for the time stamp).
162 $(TRAD)/pattern.8 $(TRAD)/pattern.rules: $(TRAD)/make-full-pattern-trad
164 $(TRAD)/make-full-pattern-trad: $(TRAD)/words.hyphenated.trad
165 $(CHDIR) $(TRAD); \
166 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
167 $(ECHO) done > $@
169 $(TRAD)/$(TRAD)-$(DATE).pat: $(TRAD)/pattern.8 $(TRAD)/pattern.rules
170 $(CAT) $(DATADIR)/$(TRAD).1 \
171 | $(SED) -e "s/@DATE@/$(DATE)/" \
172 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
173 $(CAT) $(TRAD)/pattern.rules >> $@; \
174 $(CAT) $(DATADIR)/$(TRAD).2 >> $@; \
175 $(CAT) $(TRAD)/pattern.8 \
176 | $(ICONV) >> $@; \
177 $(CAT) $(DATADIR)/$(TRAD).3 >> $@
180 $(REFO)/pattern.8 $(REFO)/pattern.rules: $(REFO)/make-full-pattern-refo
182 $(REFO)/make-full-pattern-refo: $(REFO)/words.hyphenated.refo
183 $(CHDIR) $(REFO); \
184 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
185 $(ECHO) done > $@
187 $(REFO)/$(REFO)-$(DATE).pat: $(REFO)/pattern.8 $(REFO)/pattern.rules
188 $(CAT) $(DATADIR)/$(REFO).1 \
189 | $(SED) -e "s/@DATE@/$(DATE)/" \
190 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
191 $(CAT) $(REFO)/pattern.rules >> $@; \
192 $(CAT) $(DATADIR)/$(REFO).2 >> $@; \
193 $(CAT) $(REFO)/pattern.8 \
194 | $(ICONV) >> $@; \
195 $(CAT) $(DATADIR)/$(REFO).3 >> $@
198 $(SWISS)/pattern.8 $(SWISS)/pattern.rules: $(SWISS)/make-full-pattern-swiss
200 $(SWISS)/make-full-pattern-swiss: $(SWISS)/words.hyphenated.swiss
201 $(CHDIR) $(SWISS); \
202 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
203 $(ECHO) done > $@
205 $(SWISS)/$(SWISS)-$(DATE).pat: $(SWISS)/pattern.8 $(SWISS)/pattern.rules
206 $(CAT) $(DATADIR)/$(SWISS).1 \
207 | $(SED) -e "s/@DATE@/$(DATE)/" \
208 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
209 $(CAT) $(SWISS)/pattern.rules >> $@; \
210 $(CAT) $(DATADIR)/$(SWISS).2 >> $@; \
211 $(CAT) $(SWISS)/pattern.8 \
212 | $(ICONV) >> $@; \
213 $(CAT) $(DATADIR)/$(SWISS).3 >> $@
216 $(TRAD)/words.hyphenated.trad: $(SRCDIR)/$(WORDLIST)
217 $(CAT) $< \
218 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -t $(PERLMAJOR) \
219 | $(SEDMAJOR) \
220 | $(SORT) > $@
222 $(REFO)/words.hyphenated.refo: $(SRCDIR)/$(WORDLIST)
223 $(CAT) $< \
224 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l $(PERLMAJOR) \
225 | $(SEDMAJOR) \
226 | $(SORT) > $@
228 $(SWISS)/words.hyphenated.swiss: $(SRCDIR)/$(WORDLIST)
229 $(CAT) $< \
230 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -s $(PERLMAJOR) \
231 | $(SEDMAJOR) \
232 | $(SORT) > $@
235 $(TRAD)/$(TRAD)-$(DATE).tex: $(DATADIR)/$(TRAD).tex.in
236 $(CAT) $< \
237 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
239 $(REFO)/$(REFO)-$(DATE).tex: $(DATADIR)/$(REFO).tex.in
240 $(CAT) $< \
241 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
243 $(SWISS)/$(SWISS)-$(DATE).tex: $(DATADIR)/$(SWISS).tex.in
244 $(CAT) $< \
245 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
247 pidiff:
248 $(SH) skripte/patgen-list-diff.sh $(FROM) $(TO)
250 # EOF