summaryrefslogtreecommitdiff
path: root/Build/source/utils/xindy-new/xindy/make-rules/makeindex.sh
blob: 4891f08f445274febd0ed692e5650f2ed378883e (plain)
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#!/bin/sh
#
# This script is at the same time the documentation for the 
# localization architecture used in Xindy/make-rules.
# (c) 2001 Martin Vermeer
#
# Print out help text:
#
if [ "$1" = "" ] ; then
  echo ""
  echo "Syntax:" 
  echo "  ./makeindex.sh [[-v <var>] [-e <enc>] -m <lang>]* [-d <dp>] [-s <style>] <myindex>"
  echo ""
  echo "  where <myindex> is the index file name *without* extension."
  echo ""
  echo "Multiple -m options allowed; -m always after corresponding -v, -e."
  echo ""
  echo "Languages <lang>:"
  echo "  albanian"
  echo "  belarusian    finnish        swedish"
  echo "  bulgarian     french         hungarian"
  echo "  icelandic     norwegian      latin"
  echo "  croatian      general        polish"
  echo "  portuguese    romanian       slovenian"
  echo "  czech         german         russian"
  echo "  danish        greek          serbian"
  echo "  english       slovak         ukrainian"
  echo "  esperanto     macedonian     spanish"
  echo "  turkish       kurdish        georgian"
  echo "  estonian      latvian        lithuanian"
  echo "  gypsy         hausa          hebrew"
  echo "  gypsy         hausa          hebrew"
  echo "  upper-sorbian lower-sorbian  klingon"
  echo "  mongolian     vietnamese"
  echo ""
  echo "Variants <var>:"
  echo "  german:    duden, din5007"
  echo "  spanish:   traditional, modern"
  echo "  slovak:    large, small"
  echo "  gypsy:     northrussian"
  echo "  kurdish:   turkish-i, bedirxan"
  echo "  mongolian: cyrillic"
  echo ""
  echo "Docprocessors <dp>:"
  echo "  -t :    -d tex"
  echo "  -n :    -d nroff"
  echo ""
  echo "Styles <style>:"
  echo "  -s <style>"
  echo "  -s makeindex (default)"
  exit 0
fi

LOC=""
ENC=""
VAR=""

TEMP=`mktemp /tmp/xindy.XXXXXX` || exit 1

echo "" >$TEMP.xdy

# Default document processor and index style
#
DP="tex"
STYLE="makeindex"

while getopts "m:v:d:e:tnls:" OPT
do
  case "$OPT" in
    "m")
      LOC="$OPTARG"
      # Language two-letter codes following ISO-639-1
      case $LOC in
        "english")
        ENC_="ascii"
        PRE="en"
        ;;
        "finnish")
        ENC_="cp1252"
        PRE="fi"
        ;;
        "german")
        ENC_="latin1"
        PRE="de"
        VAR_="din5007-"
        ;;
        "belarusian")
        ENC_="iso88595"
        PRE="be"
        ;;
        "danish")
        ENC_="latin1"
        PRE="dk"
        ;;
        "french")
        ENC_="latin9"
        PRE="fr"
        ;;
        "bulgarian")
        ENC_="iso88595"
        PRE="bg"
        ;;
        "croatian")
        ENC_="latin2"
        PRE="hr"
        ;;
        "czech")
        ENC_="latin2"
        PRE="cs"
        ;;
        "esperanto")
        ENC_="latin3"
        PRE="eo"
        ;;
        "greek")
        ENC_="iso88597"
        PRE="el"
        ;;
        "macedonian")
        ENC_="latin2"
        PRE="mk"
        ;;
        "norwegian")
        ENC_="latin1"
        PRE="no"
        ;;
        "polish")
        ENC_="latin2"
        PRE="pl"
        ;;
        "russian")
        ENC_="koi8-r"
        PRE="ru"
        ;;
        "serbian")
        ENC_="iso88595"
        PRE="sr"
        ;;
        "slovak")
        ENC_="latin2"
        PRE="sk"
        VAR_="small-"
        ;;
        "spanish")
        ENC_="latin1"
        PRE="es"
        VAR_="traditional-"
        ;;
        "swedish")
        ENC_="latin1"
        PRE="se"
        ;;
        "ukrainian")
        ENC_="koi8-u"
        PRE="uk"
        ;;
        "albanian")
        ENC_="latin1"
        PRE="sq"
        ;;
        "hungarian")
        ENC_="latin2"
        PRE="hu"
        ;;
        "icelandic")
        ENC_="latin1"
        PRE="is"
        ;;
        "lower-sorbian")
        ENC_="latin2"
        PRE="s1"
        ;;
        "upper-sorbian")
        ENC_="latin2"
        PRE="s2"
        ;;
        "portuguese")
        ENC_="latin1"
        PRE="pt"
        ;;
        "romanian")
        ENC_="latin2"
        PRE="ro"
        ;;
        "slovenian")
        ENC_="latin2"
        PRE="sl"
        ;;
        "turkish")
        ENC_="latin5"
        PRE="tr"
        ;;
        "dutch")
        ENC_="latin1"
        PRE="nl"
        ;;
        "estonian")
        ENC_="latin1"
        PRE="et"
        ;;
        "georgian")
        ENC_="georgian"
        PRE="ka"
        ;;
        "gypsy")
        ENC_="utf8"
        PRE="g1"
		VAR="northrussian-"
        ;;
        "hausa")
        ENC_="utf8"
        PRE="ha"
		;;
        "hebrew")
        ENC_="iso88598"
        PRE="iw"
		;;
        "italian")
        ENC_="latin1"
        PRE="it"
		;;
        "klingon")
        ENC_="utf8"
        PRE="kl"
		;;
        "kurdish")
        ENC_="latin5"
        PRE="kl"
		VAR="turkish-i-"
		;;
        "latin")
        ENC_="utf8"
        PRE="la"
		;;
        "latvian")
        ENC_="latin4"
        PRE="lv"
		;;
        "lithuanian")
        ENC_="latin4"
        PRE="lt"
		;;
        "mongolian")
        ENC_="utf8"
        PRE="mn"
		VAR="cyrillic-"
		;;
        "vietnamese")
        ENC_="utf8"
        PRE="vi"
		;;
     esac
      IGNORESPECIAL="$IGNORESPECIAL \"$PRE-ignore-special\"" 
      ALPHABETIZE="$ALPHABETIZE \"$PRE-alphabetize\"" 
      RESOLVEDIACRITICS="$RESOLVEDIACRITICS \"$PRE-resolve-diacritics\"" 
      RESOLVECASE="$RESOLVECASE \"$PRE-resolve-case\"" 
      RESOLVESPECIAL="$RESOLVESPECIAL \"$PRE-resolve-special\"" 
      if [ "$ENC" = "" ] ; then
        ENC=$ENC_  
      fi
      if [ "$VAR" = "" ] ; then
        VAR=$VAR_  
      fi

      #
      # ** Create file(s) containing locale-related req's: **
      #
      # This file contains:
      # - the document processor specific stuff that was not 
      #   generated (correctly) automatically;
      # - a call to inputenc/<encoding>.xdy, which was generated
      #   automatically by make-enc-rules.pl.
      # This file is *created by hand for every language* 
      # (and doc processor, variant and encoding)
      #
      echo "(require \"lang/$LOC/$DP-$VAR$ENC.xdy\")" >>$TEMP.xdy
      #
      # This file will contain the language and encoding and variant 
      # specific stuff. Nothing document specific here. Generated
      # automatically by make-rules.pl.
      #
      echo "(require \"lang/$LOC/$VAR$ENC.xdy\")" >>$TEMP.xdy

      ENC=""
      VAR=""
      ;;
    "v")
      VAR="$OPTARG-"
      ;;
    "d")
      DP="$OPTARG"
      ;;
    "e")
      ENC="$OPTARG"
      ;;
    "t")
      DP="tex"
      ;;
    "n")
      DP="nroff"
      ;;
    "l")
      DP="lout"
      ;;
    "s")
      STYLE="$OPTARG"
      ;;
  esac
done

#
# Default language:
#
if [ "$LOC" = "" ] ; then
  LOC="english"
  ENC="ascii"
  PRE="en"
  IGNORESPECIAL="\"en-ignore-special\""
  ALPHABETIZE="\"en-alphabetize\""
  RESOLVEDIACRITICS="\"en-resolve-diacritics\"" 
  RESOLVECASE="\"en-resolve-case\"" 
  RESOLVESPECIAL="\"en-resolve-special\"" 
  # Do this in the absence of -m options:
  echo "(require \"lang/$LOC/$DP-$VAR$ENC.xdy\")" >>$TEMP.xdy
  echo "(require \"lang/$LOC/$VAR$ENC.xdy\")" >>$TEMP.xdy

fi

shift $[$#-1]
DATA=$1

tex2xindy <$DATA.idx >$DATA.raw

#
# Language/variant sorting rules, possibly multi:
#
echo "(define-sort-rule-orientations (forward backward forward forward))" \
	>>$TEMP.xdy
echo "(use-rule-set :run 0 :rule-set \
	($ALPHABETIZE $IGNORESPECIAL))" >>$TEMP.xdy
echo "(use-rule-set :run 1 :rule-set \
	($RESOLVEDIACRITICS $IGNORESPECIAL))" >>$TEMP.xdy
echo "(use-rule-set :run 2 :rule-set \
	($RESOLVECASE $IGNORESPECIAL))" >>$TEMP.xdy
echo "(use-rule-set :run 3 :rule-set \
	($RESOLVESPECIAL))" >>$TEMP.xdy

#
# The index style chosen:
#
echo "(require \"styles/$STYLE.xdy\")" >>$TEMP.xdy

xindy $TEMP.xdy $DATA.raw