Merge branch 'master' of git+ssh://repo.or.cz/srv/git/wortliste
[wortliste.git] / Makefile
blob557ddd8f89b6ae2e4848eae316697c9e54264aac
1 # This Makefile creates German hyphenation patterns in subdirectories
2 # $(TRAD) and $(REFO) for traditional and new orthography, respectively.
3 # Hyphenation patterns for traditional Swiss German are generated in
4 # directory $(SWISS).
6 # The input data is in $(SRCDIR); the possible targets are `pattern-trad',
7 # `pattern-refo', and `pattern-swiss'. If no target (or target `all') is
8 # given, all patterns for all three targets are built.
10 # SRCDIR (and the other variables) can be easily modified as parameters
11 # while calling `make', e.g.
13 # make pattern-trad SRCDIR=~/git/wortliste
15 # If you add the (phony) target `major', patterns which only use major
16 # hyphenation points (`Haupttrennstellen') are created. Example:
18 # make major pattern-refo
20 # The used directories names are the same as above but with `-major'
21 # appended to the names.
25 # Dieses Makefile erzeugt deutsche Trennmuster in den
26 # Unterverzeichnissen $(TRAD) und $(REFO) für die traditionelle
27 # bzw. reformierte Rechtschreibung. Trennmuster für tradionelles
28 # deutschschweizerisches Deutsch werden Verzeichnis $(SWISS) erzeugt.
30 # Die Eingabedaten werden im Verzeichnis $(SRCDIR) erwartet; die möglichen
31 # Make-Ziele sind `pattern-trad', `pattern-refo' und `pattern-swiss'. Wenn
32 # kein Ziel angegeben ist (oder man das Ziel `all' verwendet), werden alle
33 # drei Trennmuster erzeugt.
35 # SRCDIR (und die anderen Variablen) kann man leicht beim Aufruf von
36 # `make' als Parameter modifizieren, z.B.
38 # make pattern-trad SRCDIR=~/git/wortliste
40 # Wird zusätzlich das zusätzliche (künstliche) Ziel `major' angegeben,
41 # werden Haupttrennstellmuster erzeugt.
43 # Beispiel:
45 # make major pattern-refo
47 # Die verwendeten Verzeichnisnamen sind die gleichen wie oben,
48 # allerdings mit einem angehängten `-major'.
51 SRCDIR = .
52 DATADIR = $(SRCDIR)/daten
53 SCRIPTDIR = $(SRCDIR)/skripte
54 WORDLIST = wortliste
56 ifneq ($(findstring major,$(MAKECMDGOALS)),)
57 MAJOR = -major
58 # A single `-' gets removed; all other combinations of `-', `=', and `|'
59 # are converted to a hyphen.
60 SEDMAJOR = $(SED) -e '/[=|-]/!n' \
61 -e 's/---*/=/g' \
62 -e 's/-//g' \
63 -e 's/[=|][=|]*/-/g' \
64 -e '/-/!d'
65 PERLMAJOR = -g
67 ifeq ($(words $(MAKECMDGOALS)),1)
68 major: all
69 else
70 # This is to suppress the `nothing to be done' warning.
71 major:
73 endif
74 else
75 MAJOR =
76 SEDMAJOR = cat
77 PERLMAJOR =
78 endif
80 TRAD = dehypht-x$(MAJOR)
81 REFO = dehyphn-x$(MAJOR)
82 SWISS = dehyphts-x$(MAJOR)
84 LC_ENVVARS = LC_COLLATE=de_DE.ISO8859-1 \
85 LC_CTYPE=de_DE.ISO8859-1
87 CAT = cat
88 CHDIR = cd
89 COPY = cp
90 DATE = $(shell date '+%Y-%m-%d')
91 ECHO = echo
92 GIT = git
93 ICONV = iconv -f latin1 -t utf-8
94 MKDIR = mkdir -p
95 PERL = perl
96 PWD = pwd
97 SED = sed
98 SH = bash
99 SORT = $(LC_ENVVARS) sort -d \
100 | $(LC_ENVVARS) uniq -i
102 GIT_VERSION := `$(CHDIR) $(SRCDIR); \
103 $(GIT) log --format=%H -1 HEAD --`
104 TRADFILES = $(TRAD)/$(TRAD)-$(DATE).pat $(TRAD)/$(TRAD)-$(DATE).tex
105 REFOFILES = $(REFO)/$(REFO)-$(DATE).pat $(REFO)/$(REFO)-$(DATE).tex
106 SWISSFILES = $(SWISS)/$(SWISS)-$(DATE).pat $(SWISS)/$(SWISS)-$(DATE).tex
109 override SRCDIR := $(shell cd $(SRCDIR); $(PWD))
112 all: pattern-trad pattern-refo pattern-swiss
114 .PHONY: pattern-trad pattern-refo pattern-swiss major
115 pattern-trad: $(TRADFILES)
116 pattern-refo: $(REFOFILES)
117 pattern-swiss: $(SWISSFILES)
119 # auxiliary targets
121 .PHONY: words-trad words-refo
122 words-trad: $(TRAD)/words.hyphenated.trad
123 words-refo: $(REFO)/words.hyphenated.refo
126 .PHONY: pre-trad pre-refo pre-swiss
127 pre-trad:
128 $(MKDIR) $(TRAD)
129 pre-refo:
130 $(MKDIR) $(REFO)
131 pre-swiss:
132 $(MKDIR) $(SWISS)
134 $(TRADFILES) $(TRAD)/words.hyphenated.trad: pre-trad
135 $(REFOFILES) $(REFO)/words.hyphenated.refo: pre-refo
136 $(SWISSFILES) $(SWISS)/words.hyphenated.swiss: pre-swiss
139 # GNU make supports creation of multiple targets by a single
140 # invocation of a recipe only for pattern rules, thus we have
141 # to use a `sentinel file' (using `echo' for the time stamp).
144 $(TRAD)/pattern.8 $(TRAD)/pattern.rules: $(TRAD)/make-full-pattern-trad
146 $(TRAD)/make-full-pattern-trad: $(TRAD)/words.hyphenated.trad
147 $(CHDIR) $(TRAD); \
148 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
149 $(ECHO) done > $@
151 $(TRAD)/$(TRAD)-$(DATE).pat: $(TRAD)/pattern.8 $(TRAD)/pattern.rules
152 $(CAT) $(DATADIR)/$(TRAD).1 \
153 | $(SED) -e "s/@DATE@/$(DATE)/" \
154 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
155 $(CAT) $(TRAD)/pattern.rules >> $@; \
156 $(CAT) $(DATADIR)/$(TRAD).2 >> $@; \
157 $(CAT) $(TRAD)/pattern.8 \
158 | $(ICONV) >> $@; \
159 $(CAT) $(DATADIR)/$(TRAD).3 >> $@
162 $(REFO)/pattern.8 $(REFO)/pattern.rules: $(REFO)/make-full-pattern-refo
164 $(REFO)/make-full-pattern-refo: $(REFO)/words.hyphenated.refo
165 $(CHDIR) $(REFO); \
166 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
167 $(ECHO) done > $@
169 $(REFO)/$(REFO)-$(DATE).pat: $(REFO)/pattern.8 $(REFO)/pattern.rules
170 $(CAT) $(DATADIR)/$(REFO).1 \
171 | $(SED) -e "s/@DATE@/$(DATE)/" \
172 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
173 $(CAT) $(REFO)/pattern.rules >> $@; \
174 $(CAT) $(DATADIR)/$(REFO).2 >> $@; \
175 $(CAT) $(REFO)/pattern.8 \
176 | $(ICONV) >> $@; \
177 $(CAT) $(DATADIR)/$(REFO).3 >> $@
180 $(SWISS)/pattern.8 $(SWISS)/pattern.rules: $(SWISS)/make-full-pattern-swiss
182 $(SWISS)/make-full-pattern-swiss: $(SWISS)/words.hyphenated.swiss
183 $(CHDIR) $(SWISS); \
184 $(SH) $(SCRIPTDIR)/make-full-pattern.sh $(<F) $(DATADIR)/german.tr
185 $(ECHO) done > $@
187 $(SWISS)/$(SWISS)-$(DATE).pat: $(SWISS)/pattern.8 $(SWISS)/pattern.rules
188 $(CAT) $(DATADIR)/$(SWISS).1 \
189 | $(SED) -e "s/@DATE@/$(DATE)/" \
190 -e "s/@GIT_VERSION@/$(GIT_VERSION)/" > $@; \
191 $(CAT) $(SWISS)/pattern.rules >> $@; \
192 $(CAT) $(DATADIR)/$(SWISS).2 >> $@; \
193 $(CAT) $(SWISS)/pattern.8 \
194 | $(ICONV) >> $@; \
195 $(CAT) $(DATADIR)/$(SWISS).3 >> $@
198 $(TRAD)/words.hyphenated.trad: $(SRCDIR)/$(WORDLIST)
199 $(CAT) $< \
200 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -t $(PERLMAJOR) \
201 | $(SEDMAJOR) \
202 | $(SORT) > $@
204 $(REFO)/words.hyphenated.refo: $(SRCDIR)/$(WORDLIST)
205 $(CAT) $< \
206 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l $(PERLMAJOR) \
207 | $(SEDMAJOR) \
208 | $(SORT) > $@
210 $(SWISS)/words.hyphenated.swiss: $(SRCDIR)/$(WORDLIST)
211 $(CAT) $< \
212 | $(PERL) $(SCRIPTDIR)/extract-tex.pl -l -s $(PERLMAJOR) \
213 | $(SEDMAJOR) \
214 | $(SORT) > $@
217 $(TRAD)/$(TRAD)-$(DATE).tex: $(DATADIR)/$(TRAD).tex.in
218 $(CAT) $< \
219 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
221 $(REFO)/$(REFO)-$(DATE).tex: $(DATADIR)/$(REFO).tex.in
222 $(CAT) $< \
223 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
225 $(SWISS)/$(SWISS)-$(DATE).tex: $(DATADIR)/$(SWISS).tex.in
226 $(CAT) $< \
227 | $(SED) -e "s/@DATE@/$(DATE)/" > $@
229 # EOF