1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
#! /bin/sh
# Copyright (C) 2010 Peter Breitenlohner <tex-live@tug.org>.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program in the file COPYING; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301 USA.
# Generate the Makefile fragments lang/Makefile.am from language
# definitions in lang.defs containing lines:
# lang [[prefix] UTF8_DOC [DOC]...]...
# where
# prefix is an optional filename prefix, without final '-'
# UTF8_DOC is a DOCS_UTF8_* variable, without leading 'DOCS_'
# DOC is an other DOCS_* variable, without leading 'DOCS_'
CP_DOCS='CP1250 CP1252 CP850'
LATIN_DOCS='LATIN1 LATIN2 LATIN3 LATIN4 LATIN5 LATIN9'
CYR_DOCS='CYR_1251 CYR_ISO88595 CYR_ISOIR111 CYR_KOI8_R CYR_KOI8_U'
ISO_DOCS='ISO88597 ISO88598'
UTF_DOCS='UTF8_LAT UTF8_CYR UTF8_OTHER'
ALL_DOCS="$CP_DOCS $LATIN_DOCS $CYR_DOCS $ISO_DOCS $UTF_DOCS"
err_exit () {
echo "bad argument \"$arg\""
exit 1
}
do_XDY () {
XDY="$XDY $name"
eval DOCS_$arg="\"\$DOCS_$arg $name\""
}
do_UTF8 () {
PLIN="$PLIN $name"
do_XDY
}
do_CODE () {
PL="$PL $name"
do_XDY
}
parse_lang () {
for DOC in $ALL_DOCS; do
eval DOCS_$DOC=
done
PLIN= PL= XDY=
lang=$1
shift
pref=
for arg
do
case $arg in
[a-z]*) pref="$arg-";;
UTF8_*) name=${pref}utf8; do_UTF8;;
[A-Z]*) case $arg in
CP*) val="cp${arg:2}";;
ISO*) val="iso${arg:3}";;
LATIN*) val="latin${arg:5}";;
CYR_1251) val=cp1251;;
CYR_ISO88595) val=iso88595;;
CYR_ISOIR111) val=isoir111;;
CYR_KOI8_R) val=koi8-r;;
CYR_KOI8_U) val=koi8-u;;
*) err_exit;;
esac
name="$pref$val"
do_CODE
;;
*) err_exit;;
esac
done
}
print_header () {
cat <<-_EOF
## Makefile fragment for $lang.
## Copyright (C) 2009, 2010 by Peter Breitenlohner.
## Copyright (C) 2004-2005 by Gour.
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program in the file COPYING; if not, write to the
## Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
## Boston, MA 02110-1301 USA.
subdirs += $lang
_EOF
}
print_xdy () {
test $# -eq 0 && return
printf '\nnobase_nodist_lang_DATA +='
for xdy
do
printf ' \\\n\t'$lang'/%s-lang.xdy' $xdy
printf ' \\\n\t'$lang'/%s-test.xdy' $xdy
printf ' \\\n\t'$lang'/%s.xdy' $xdy
done
printf "\n"
}
print_docs () {
test $# -eq 0 && return
printf '\nDOCS_%s +=' $DOC
printf ' \\\n\t'$lang'/%s-doc.tex' "$@"
printf "\n"
}
print_extra_hdr () {
test -n "$print_extra_hdr_done" && return
printf '\nEXTRA_DIST +='
print_extra_hdr_done=yes
}
print_extra () {
test $# -eq 0 && return
print_extra_hdr
printf ' \\\n\t%s' "$@"
}
print_extra_plin () {
test $# -eq 0 && return
print_extra_hdr
printf ' \\\n\t'$lang'/%s.pl.in' "$@"
}
print_pl () {
test $# -eq 0 && return
printf '\ndist_noinst_DATA +='
printf ' \\\n\t'$lang'/%s.pl' "$@"
printf "\n"
}
print_clean () {
test $# -eq 0 && return
printf '\nCLEANFILES +='
for clean
do
case $clean in
*utf8) printf ' \\\n\t'$lang'/%s.pl' $clean;;
esac
printf ' \\\n\t'$lang'/%s.raw' $clean
done
printf "\n"
}
make_lang () {
print_header
print_xdy $XDY
for DOC in $ALL_DOCS; do
eval print_docs \$DOCS_$DOC
done
print_extra_hdr_done=
case $lang in
general) PL="$PL template";;
klingon) PL="$PL translit-ascii";;
test1) PL="$PL test1";;
romanian)
cat <<\_EOF
romanian/latin2.pl : romanian/utf8.pl.in
sed -e 's/@u{\([^}]*\)}//g;' -f $(srcdir)/rom-comma-kludge.sed <$< | \
$(CONVERT_FROM_UTF8)ISO8859-2 >$@
_EOF
print_extra rom-comma-kludge.sed
;;
esac
print_extra_plin $PLIN
test -n "$print_extra_hdr_done" && printf '\n'
print_pl $PL
print_clean $XDY
echo
}
all_langs () {
while read line
do
parse_lang $line
mkdir -p $lang
make_lang >$lang/Makefile.tmp
if diff $lang/Makefile.tmp $lang/Makefile.am >/dev/null 2>&1; then
rm -f $lang/Makefile.tmp
else
mv -f $lang/Makefile.tmp $lang/Makefile.am
fi
done
}
all_langs < lang.defs
|