"DDR-Woerter"; Kategorisierungskorrekturen (nach Test mit "make fugen")
[wortliste.git] / Makefile
blob64850afa06a2cd9635c3d1a537c5be653adabd7c
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 ifneq ($(findstring fugen,$(MAKECMDGOALS)),)
93 MAJOR = -fugen
94 # All combinations of `-', `<', `>' get removed,
95 # runs of `=' are converted to a hyphen.
96 SEDMAJOR = $(SED) -e '/[=<>-]/!n' \
97 -e 's/-//g' \
98 -e 's/[<>][<>]*//g' \
99 -e 's/[=][=]*/-/g'
100 PERLMAJOR = -g $(W)
102 ifeq ($(words $(MAKECMDGOALS)),1)
103 fugen: all
104 else
105 # This is to suppress the `nothing to be done' warning.
106 fugen:
108 endif
109 else
110 MAJOR =
111 SEDMAJOR = cat
112 PERLMAJOR =
113 endif
115 TRAD = dehypht-x$(MAJOR)
116 REFO = dehyphn-x$(MAJOR)
117 SWISS = dehyphts-x$(MAJOR)
119 LC_ENVVARS = LC_COLLATE=de_DE.ISO8859-15 \
120 LC_CTYPE=de_DE.ISO8859-15
122 CAT = cat
123 CHDIR = cd
124 COPY = cp
125 DATE = $(shell date '+%Y-%m-%d')
126 ECHO = echo
127 GIT = git
128 ICONV = iconv -f iso-8859-15 -t utf-8
129 MKDIR = mkdir -p
130 PERL = perl
131 PWD = pwd
132 SED = sed
133 SH = bash
134 SORT = $(LC_ENVVARS) sort -d \
135 | $(LC_ENVVARS) uniq -i
137 GIT_VERSION := `$(CHDIR) $(SRCDIR); \
138 $(GIT) log --format=%H -1 HEAD --`
139 TRADFILES = $(TRAD)/$(TRAD)-$(DATE).pat $(TRAD)/$(TRAD)-$(DATE).tex
140 REFOFILES = $(REFO)/$(REFO)-$(DATE).pat $(REFO)/$(REFO)-$(DATE).tex
141 SWISSFILES = $(SWISS)/$(SWISS)-$(DATE).pat $(SWISS)/$(SWISS)-$(DATE).tex
144 override SRCDIR := $(shell cd $(SRCDIR); $(PWD))
147 all: pattern-trad pattern-refo pattern-swiss
149 .PHONY: pattern-trad pattern-refo pattern-swiss major
150 pattern-trad: $(TRADFILES)
151 pattern-refo: $(REFOFILES)
152 pattern-swiss: $(SWISSFILES)
154 # auxiliary targets
156 .PHONY: words-trad words-refo
157 words-trad: $(TRAD)/words.hyphenated.trad
158 words-refo: $(REFO)/words.hyphenated.refo
161 .PHONY: pre-trad pre-refo pre-swiss
162 pre-trad:
163 $(MKDIR) $(TRAD)
164 pre-refo:
165 $(MKDIR) $(REFO)
166 pre-swiss:
167 $(MKDIR) $(SWISS)
169 $(TRADFILES) $(TRAD)/words.hyphenated.trad: pre-trad
170 $(REFOFILES) $(REFO)/words.hyphenated.refo: pre-refo
171 $(SWISSFILES) $(SWISS)/words.hyphenated.swiss: pre-swiss
174 # GNU make supports creation of multiple targets by a single
175 # invocation of a recipe only for pattern rules, thus we have
176 # to use a `sentinel file' (using `echo' for the time stamp).
179 $(TRAD)/pattern.8 $(TRAD)/pattern.rules: $(TRAD)/make-full-pattern-trad
181 $(TRAD)/make-full-pattern-trad: $(TRAD)/words.hyphenated.trad
182 $(CHDIR) $(TRAD); \
183 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
184 $(ECHO) done > $@
186 $(TRAD)/$(TRAD)-$(DATE).pat: $(TRAD)/pattern.8 $(TRAD)/pattern.rules
187 $(CAT) $(DATADIR)/$(TRAD).1 \
188 | $(SED) -e "s/@DATE@/$(DATE)/" \
189 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
190 $(CAT) $(TRAD)/pattern.rules >> $@; \
191 $(CAT) $(DATADIR)/$(TRAD).2 >> $@; \
192 $(CAT) $(TRAD)/pattern.8 \
193 | $(ICONV) >> $@; \
194 $(CAT) $(DATADIR)/$(TRAD).3 >> $@
197 $(REFO)/pattern.8 $(REFO)/pattern.rules: $(REFO)/make-full-pattern-refo
199 $(REFO)/make-full-pattern-refo: $(REFO)/words.hyphenated.refo
200 $(CHDIR) $(REFO); \
201 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
202 $(ECHO) done > $@
204 $(REFO)/$(REFO)-$(DATE).pat: $(REFO)/pattern.8 $(REFO)/pattern.rules
205 $(CAT) $(DATADIR)/$(REFO).1 \
206 | $(SED) -e "s/@DATE@/$(DATE)/" \
207 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
208 $(CAT) $(REFO)/pattern.rules >> $@; \
209 $(CAT) $(DATADIR)/$(REFO).2 >> $@; \
210 $(CAT) $(REFO)/pattern.8 \
211 | $(ICONV) >> $@; \
212 $(CAT) $(DATADIR)/$(REFO).3 >> $@
215 $(SWISS)/pattern.8 $(SWISS)/pattern.rules: $(SWISS)/make-full-pattern-swiss
217 $(SWISS)/make-full-pattern-swiss: $(SWISS)/words.hyphenated.swiss
218 $(CHDIR) $(SWISS); \
219 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
220 $(ECHO) done > $@
222 $(SWISS)/$(SWISS)-$(DATE).pat: $(SWISS)/pattern.8 $(SWISS)/pattern.rules
223 $(CAT) $(DATADIR)/$(SWISS).1 \
224 | $(SED) -e "s/@DATE@/$(DATE)/" \
225 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
226 $(CAT) $(SWISS)/pattern.rules >> $@; \
227 $(CAT) $(DATADIR)/$(SWISS).2 >> $@; \
228 $(CAT) $(SWISS)/pattern.8 \
229 | $(ICONV) >> $@; \
230 $(CAT) $(DATADIR)/$(SWISS).3 >> $@
233 $(TRAD)/words.hyphenated.trad: $(SRCDIR)/$(WORDLIST)
234 $(CAT) $< \
235 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -t $(PERLMAJOR) \
236 | $(SEDMAJOR) \
237 | $(SORT) > $@
239 $(REFO)/words.hyphenated.refo: $(SRCDIR)/$(WORDLIST)
240 $(CAT) $< \
241 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l $(PERLMAJOR) \
242 | $(SEDMAJOR) \
243 | $(SORT) > $@
245 $(SWISS)/words.hyphenated.swiss: $(SRCDIR)/$(WORDLIST)
246 $(CAT) $< \
247 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -s $(PERLMAJOR) \
248 | $(SEDMAJOR) \
249 | $(SORT) > $@
252 $(TRAD)/$(TRAD)-$(DATE).tex: $(DATADIR)/$(TRAD).tex.in
253 $(CAT) $< \
254 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
256 $(REFO)/$(REFO)-$(DATE).tex: $(DATADIR)/$(REFO).tex.in
257 $(CAT) $< \
258 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
260 $(SWISS)/$(SWISS)-$(DATE).tex: $(DATADIR)/$(SWISS).tex.in
261 $(CAT) $< \
262 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
264 pidiff:
265 $(SH) skripte/patgen-list-diff.sh $(FROM) $(TO)
267 # EOF