OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [readline/] [doc/] [texi2dvi] - Blame information for rev 866

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
#! /bin/sh
2
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
3
# $Id: texi2dvi,v 1.14 2003/02/05 00:42:33 karl Exp $
4
#
5
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
6
# 2002, 2003 Free Software Foundation, Inc.
7
#
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2, or (at your option)
11
# any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, you can either send email to this
20
# program's maintainer or write to: The Free Software Foundation,
21
# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
22
#
23
# Original author: Noah Friedman .
24
#
25
# Please send bug reports, etc. to bug-texinfo@gnu.org.
26
# If possible, please send a copy of the output of the script called with
27
# the `--debug' option when making a bug report.
28
 
29
# This string is expanded by rcs automatically when this file is checked out.
30
rcs_revision='$Revision: 1.14 $'
31
rcs_version=`set - $rcs_revision; echo $2`
32
program=`echo $0 | sed -e 's!.*/!!'`
33
version="texi2dvi (GNU Texinfo 4.5) $rcs_version
34
 
35
Copyright (C) 2003 Free Software Foundation, Inc.
36
There is NO warranty.  You may redistribute this software
37
under the terms of the GNU General Public License.
38
For more information about these matters, see the files named COPYING."
39
 
40
usage="Usage: $program [OPTION]... FILE...
41
 
42
Run each Texinfo or LaTeX FILE through TeX in turn until all
43
cross-references are resolved, building all indices.  The directory
44
containing each FILE is searched for included files.  The suffix of FILE
45
is used to determine its language (LaTeX or Texinfo).
46
 
47
Makeinfo is used to perform Texinfo macro expansion before running TeX
48
when needed.
49
 
50
Operation modes:
51
  -b, --batch         no interaction
52
  -c, --clean         remove all auxiliary files
53
  -D, --debug         turn on shell debugging (set -x)
54
  -h, --help          display this help and exit successfully
55
  -o, --output=OFILE  leave output in OFILE (implies --clean);
56
                      Only one input FILE may be specified in this case
57
  -q, --quiet         no output unless errors (implies --batch)
58
  -s, --silent        same as --quiet
59
  -v, --version       display version information and exit successfully
60
  -V, --verbose       report on what is done
61
 
62
TeX tuning:
63
  -@                   use @input instead of \input; for preloaded Texinfo
64
  -e, -E, --expand     force macro expansion using makeinfo
65
  -I DIR               search DIR for Texinfo files
66
  -l, --language=LANG  specify the LANG of FILE (LaTeX or Texinfo)
67
  -p, --pdf            use pdftex or pdflatex for processing
68
  -t, --texinfo=CMD    insert CMD after @setfilename in copy of input file
69
                       multiple values accumulate
70
 
71
The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
72
TEX (or PDFTEX), and TEXINDEX environment variables are used to run
73
those commands, if they are set.
74
 
75
Email bug reports to ,
76
general questions and discussion to .
77
Texinfo home page: http://www.gnu.org/software/texinfo/"
78
 
79
# Initialize variables for option overriding and otherwise.
80
# Don't use `unset' since old bourne shells don't have this command.
81
# Instead, assign them an empty value.
82
batch=false     # eval for batch mode
83
clean=
84
debug=
85
escape='\'
86
expand=         # t for expansion via makeinfo
87
miincludes=     # makeinfo include path
88
oformat=dvi
89
oname=          # --output
90
quiet=          # by default let the tools' message be displayed
91
set_language=
92
textra=
93
tmpdir=${TMPDIR:-/tmp}/t2d$$  # avoid collisions on 8.3 filesystems.
94
txincludes=     # TEXINPUTS extensions, with trailing colon
95
txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
96
verbose=false   # echo for verbose mode
97
 
98
orig_pwd=`pwd`
99
 
100
# Systems which define $COMSPEC or $ComSpec use semicolons to separate
101
# directories in TEXINPUTS.
102
if test -n "$COMSPEC$ComSpec"; then
103
  path_sep=";"
104
else
105
  path_sep=":"
106
fi
107
 
108
# Pacify verbose cds.
109
CDPATH=${ZSH_VERSION+.}$path_sep
110
 
111
# In case someone crazy insists on using grep -E.
112
: ${EGREP=egrep}
113
 
114
# Save this so we can construct a new TEXINPUTS path for each file.
115
TEXINPUTS_orig="$TEXINPUTS"
116
# Unfortunately makeindex does not read TEXINPUTS.
117
INDEXSTYLE_orig="$INDEXSTYLE"
118
export TEXINPUTS INDEXSTYLE
119
 
120
# Push a token among the arguments that will be used to notice when we
121
# ended options/arguments parsing.
122
# Use "set dummy ...; shift" rather than 'set - ..." because on
123
# Solaris set - turns off set -x (but keeps set -e).
124
# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
125
# still expand "$@" to a single argument (the empty string) rather
126
# than nothing at all.
127
arg_sep="$$--$$"
128
set dummy ${1+"$@"} "$arg_sep"; shift
129
 
130
# 
131
# Parse command line arguments.
132
while test x"$1" != x"$arg_sep"; do
133
 
134
  # Handle --option=value by splitting apart and putting back on argv.
135
  case "$1" in
136
    --*=*)
137
      opt=`echo "$1" | sed -e 's/=.*//'`
138
      val=`echo "$1" | sed -e 's/[^=]*=//'`
139
      shift
140
      set dummy "$opt" "$val" ${1+"$@"}; shift
141
      ;;
142
  esac
143
 
144
  # This recognizes --quark as --quiet.  So what.
145
  case "$1" in
146
    -@ ) escape=@;;
147
    # Silently and without documentation accept -b and --b[atch] as synonyms.
148
    -b | --b*) batch=eval;;
149
    -q | -s | --q* | --s*) quiet=t; batch=eval;;
150
    -c | --c*) clean=t;;
151
    -D | --d*) debug=t;;
152
    -e | -E | --e*) expand=t;;
153
    -h | --h*) echo "$usage"; exit 0;;
154
    -I | --I*)
155
      shift
156
      miincludes="$miincludes -I $1"
157
      txincludes="$txincludes$1$path_sep"
158
      ;;
159
    -l | --l*) shift; set_language=$1;;
160
    -o | --o*)
161
      shift
162
      clean=t
163
      case "$1" in
164
        /* | ?:/*) oname=$1;;
165
                *) oname="$orig_pwd/$1";;
166
      esac;;
167
    -p | --p*) oformat=pdf;;
168
    -t | --t*) shift; textra="$textra\\
169
$1";;
170
    -v | --vers*) echo "$version"; exit 0;;
171
    -V | --verb*) verbose=echo;;
172
    --) # What remains are not options.
173
      shift
174
      while test x"$1" != x"$arg_sep"; do
175
        set dummy ${1+"$@"} "$1"; shift
176
        shift
177
      done
178
      break;;
179
    -*)
180
      echo "$0: Unknown or ambiguous option \`$1'." >&2
181
      echo "$0: Try \`--help' for more information." >&2
182
      exit 1;;
183
    *) set dummy ${1+"$@"} "$1"; shift;;
184
   esac
185
   shift
186
done
187
# Pop the token
188
shift
189
 
190
# Interpret remaining command line args as filenames.
191
case $# in
192
 0)
193
  echo "$0: Missing file arguments." >&2
194
  echo "$0: Try \`--help' for more information." >&2
195
  exit 2
196
  ;;
197
 1) ;;
198
 *)
199
  if test -n "$oname"; then
200
    echo "$0: Can't use option \`--output' with more than one argument." >&2
201
    exit 2
202
  fi
203
  ;;
204
esac
205
 
206
# Prepare the temporary directory.  Remove it at exit, unless debugging.
207
if test -z "$debug"; then
208
  trap "cd / && rm -rf $tmpdir" 0 1 2 15
209
fi
210
 
211
# Create the temporary directory with strict rights
212
(umask 077 && mkdir $tmpdir) || exit 1
213
 
214
# Prepare the tools we might need.  This may be extra work in some
215
# cases, but improves the readibility of the script.
216
utildir=$tmpdir/utils
217
mkdir $utildir || exit 1
218
 
219
# A sed script that preprocesses Texinfo sources in order to keep the
220
# iftex sections only.  We want to remove non TeX sections, and
221
# comment (with `@c texi2dvi') TeX sections so that makeinfo does not
222
# try to parse them.  Nevertheless, while commenting TeX sections,
223
# don't comment @macro/@end macro so that makeinfo does propagate
224
# them.  Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo
225
# doesn't work well enough (yet) to use that, so work around with sed.
226
comment_iftex_sed=$utildir/comment.sed
227
cat <$comment_iftex_sed
228
/^@tex/,/^@end tex/{
229
  s/^/@c texi2dvi/
230
}
231
/^@iftex/,/^@end iftex/{
232
  s/^/@c texi2dvi/
233
  /^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
234
    s/^@c texi2dvi//
235
  }
236
}
237
/^@html/,/^@end html/{
238
  s/^/@c (texi2dvi)/
239
}
240
/^@ifhtml/,/^@end ifhtml/{
241
  s/^/@c (texi2dvi)/
242
}
243
/^@ifnottex/,/^@end ifnottex/{
244
  s/^/@c (texi2dvi)/
245
}
246
/^@ifinfo/,/^@end ifinfo/{
247
  /^@node/p
248
  /^@menu/,/^@end menu/p
249
  t
250
  s/^/@c (texi2dvi)/
251
}
252
s/^@ifnotinfo/@c texi2dvi@ifnotinfo/
253
s/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/
254
EOF
255
# Uncommenting is simple: Remove any leading `@c texi2dvi'.
256
uncomment_iftex_sed=$utildir/uncomment.sed
257
cat <$uncomment_iftex_sed
258
s/^@c texi2dvi//
259
EOF
260
 
261
# A shell script that computes the list of xref files.
262
# Takes the filename (without extension) of which we look for xref
263
# files as argument.  The index files must be reported last.
264
get_xref_files=$utildir/get_xref.sh
265
cat <<\EOF >$get_xref_files
266
#! /bin/sh
267
 
268
# Get list of xref files (indexes, tables and lists).
269
# Find all files having root filename with a two-letter extension,
270
# saves the ones that are really Texinfo-related files.  .?o? catches
271
# many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
272
for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
273
  # If file is empty, skip it.
274
  test -s "$this_file" || continue
275
  # If the file is not suitable to be an index or xref file, don't
276
  # process it.  The file can't be if its first character is not a
277
  # backslash or single quote.
278
  first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
279
  if test "x$first_character" = "x\\" \
280
     || test "x$first_character" = "x'"; then
281
    xref_files="$xref_files ./$this_file"
282
  fi
283
done
284
echo "$xref_files"
285
EOF
286
chmod 500 $get_xref_files
287
 
288
# File descriptor usage:
289
# 0 standard input
290
# 1 standard output (--verbose messages)
291
# 2 standard error
292
# 3 some systems may open it to /dev/tty
293
# 4 used on the Kubota Titan
294
# 5 tools output (turned off by --quiet)
295
 
296
# Tools' output.  If quiet, discard, else redirect to the message flow.
297
if test "$quiet" = t; then
298
  exec 5>/dev/null
299
else
300
  exec 5>&1
301
fi
302
 
303
# Enable tracing
304
test "$debug" = t && set -x
305
 
306
# 
307
# TeXify files.
308
 
309
for command_line_filename in ${1+"$@"}; do
310
  $verbose "Processing $command_line_filename ..."
311
 
312
  # If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
313
  # prepend `./' in order to avoid that the tools take it as an option.
314
  echo "$command_line_filename" | $EGREP '^(/|[A-z]:/)' >/dev/null \
315
  || command_line_filename="./$command_line_filename"
316
 
317
  # See if the file exists.  If it doesn't we're in trouble since, even
318
  # though the user may be able to reenter a valid filename at the tex
319
  # prompt (assuming they're attending the terminal), this script won't
320
  # be able to find the right xref files and so forth.
321
  if test ! -r "$command_line_filename"; then
322
    echo "$0: Could not read $command_line_filename, skipping." >&2
323
    continue
324
  fi
325
 
326
  # Get the name of the current directory.  We want the full path
327
  # because in clean mode we are in tmp, in which case a relative
328
  # path has no meaning.
329
  filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
330
  filename_dir=`cd "$filename_dir" >/dev/null && pwd`
331
 
332
  # Strip directory part but leave extension.
333
  filename_ext=`basename "$command_line_filename"`
334
  # Strip extension.
335
  filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
336
  ext=`echo "$filename_ext" | sed 's/^.*\.//'`
337
 
338
  # _src.  Use same basename since we want to generate aux files with
339
  # the same basename as the manual.  If --expand, then output the
340
  # macro-expanded file to here, else copy the original file.
341
  tmpdir_src=$tmpdir/src
342
  filename_src=$tmpdir_src/$filename_noext.$ext
343
 
344
  # _xtr.  The file with the user's extra commands.
345
  tmpdir_xtr=$tmpdir/xtr
346
  filename_xtr=$tmpdir_xtr/$filename_noext.$ext
347
 
348
  # _bak.  Copies of the previous xref files (another round is run if
349
  # they differ from the new one).
350
  tmpdir_bak=$tmpdir/bak
351
 
352
  # Make all those directories and give up if we can't succeed.
353
  mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
354
 
355
  # Source file might include additional sources.
356
  # We want `.:$orig_pwd' before anything else.  (We'll add `.:' later
357
  # after all other directories have been turned into absolute paths.)
358
  # `.' goes first to ensure that any old .aux, .cps,
359
  # etc. files in ${directory} don't get used in preference to fresher
360
  # files in `.'.  Include orig_pwd in case we are in clean mode, where
361
  # we've cd'd to a temp directory.
362
  common="$orig_pwd$path_sep$filename_dir$path_sep$txincludes"
363
   TEXINPUTS="$common$TEXINPUTS_orig"
364
  INDEXSTYLE="$common$INDEXSTYLE_orig"
365
 
366
  # Convert relative paths to absolute paths, so we can run in another
367
  # directory (e.g., in --clean mode, or during the macro-support
368
  # detection.)
369
  #
370
  # Empty path components are meaningful to tex.  We rewrite them
371
  # as `EMPTY' so they don't get lost when we split on $path_sep.
372
   TEXINPUTS=`echo $TEXINPUTS  |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
373
  INDEXSTYLE=`echo $INDEXSTYLE |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
374
  save_IFS=$IFS
375
  IFS=$path_sep
376
  set x $TEXINPUTS; shift
377
  TEXINPUTS=.
378
  for dir
379
  do
380
    case $dir in
381
      EMPTY)
382
        TEXINPUTS=$TEXINPUTS$path_sep
383
        ;;
384
      [\\/]* | ?:[\\/]*)        # Absolute paths don't need to be expansed.
385
        TEXINPUTS=$TEXINPUTS$path_sep$dir
386
        ;;
387
      *)
388
        abs=`cd "$dir" && pwd` && TEXINPUTS=$TEXINPUTS$path_sep$abs
389
        ;;
390
    esac
391
  done
392
  set x $INDEXSTYLE; shift
393
  INDEXSTYLE=.
394
  for dir
395
  do
396
    case $dir in
397
      EMPTY)
398
        INDEXSTYLE=$INDEXSTYLE$path_sep
399
        ;;
400
      [\\/]* | ?:[\\/]*)        # Absolute paths don't need to be expansed.
401
        INDEXSTYLE=$INDEXSTYLE$path_sep$dir
402
        ;;
403
      *)
404
        abs=`cd "$dir" && pwd` && INDEXSTYLE=$INDEXSTYLE$path_sep$abs
405
        ;;
406
    esac
407
  done
408
  IFS=$save_IFS
409
 
410
  # If the user explicitly specified the language, use that.
411
  # Otherwise, if the first line is \input texinfo, assume it's texinfo.
412
  # Otherwise, guess from the file extension.
413
  if test -n "$set_language"; then
414
    language=$set_language
415
  elif sed 1q "$command_line_filename" | grep 'input texinfo' >/dev/null; then
416
    language=texinfo
417
  else
418
    language=
419
  fi
420
 
421
  # Get the type of the file (latex or texinfo) from the given language
422
  # we just guessed, or from the file extension if not set yet.
423
  case ${language:-$filename_ext} in
424
    [lL]a[tT]e[xX] | *.ltx | *.tex)
425
      # Assume a LaTeX file.  LaTeX needs bibtex and uses latex for
426
      # compilation.  No makeinfo.
427
      bibtex=${BIBTEX:-bibtex}
428
      makeinfo= # no point in running makeinfo on latex source.
429
      texindex=${MAKEINDEX:-makeindex}
430
      if test $oformat = dvi; then
431
        tex=${LATEX:-latex}
432
      else
433
        tex=${PDFLATEX:-pdflatex}
434
      fi
435
      ;;
436
 
437
    *)
438
      # Assume a Texinfo file.  Texinfo files need makeinfo, texindex and tex.
439
      bibtex=
440
      texindex=${TEXINDEX:-texindex}
441
      if test $oformat = dvi; then
442
        tex=${TEX:-tex}
443
      else
444
        tex=${PDFTEX:-pdftex}
445
      fi
446
      # Unless required by the user, makeinfo expansion is wanted only
447
      # if texinfo.tex is too old.
448
      if test "$expand" = t; then
449
        makeinfo=${MAKEINFO:-makeinfo}
450
      else
451
        # Check if texinfo.tex performs macro expansion by looking for
452
        # its version.  The version is a date of the form YEAR-MO-DA.
453
        # We don't need to use [0-9] to match the digits since anyway
454
        # the comparison with $txiprereq, a number, will fail with non
455
        # digits.
456
        txiversion_tex=txiversion.tex
457
        echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
458
        # Run in the tmpdir to avoid leaving files.
459
        eval `cd $tmpdir >/dev/null &&
460
              $tex $txiversion_tex 2>/dev/null |
461
              sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
462
        $verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
463
        if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
464
          makeinfo=
465
        else
466
          makeinfo=${MAKEINFO:-makeinfo}
467
        fi
468
        # As long as we had to run TeX, offer the user this convenience
469
        if test "$txiformat" = Texinfo; then
470
          escape=@
471
        fi
472
      fi
473
      ;;
474
  esac
475
 
476
  # Expand macro commands in the original source file using Makeinfo.
477
  # Always use `end' footnote style, since the `separate' style
478
  #   generates different output (arguably this is a bug in -E).
479
  # Discard main info output, the user asked to run TeX, not makeinfo.
480
  if test -n "$makeinfo"; then
481
    $verbose "Macro-expanding $command_line_filename to $filename_src ..."
482
    sed -f $comment_iftex_sed "$command_line_filename" \
483
      | $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
484
        -o /dev/null --macro-expand=- \
485
      | sed -f $uncomment_iftex_sed >"$filename_src"
486
    filename_input=$filename_src
487
  fi
488
 
489
  # If makeinfo failed (or was not even run), use the original file as input.
490
  if test $? -ne 0 \
491
     || test ! -r "$filename_src"; then
492
    $verbose "Reverting to $command_line_filename ..."
493
    filename_input=$filename_dir/$filename_ext
494
  fi
495
 
496
  # Used most commonly for @finalout, @smallbook, etc.
497
  if test -n "$textra"; then
498
    $verbose "Inserting extra commands: $textra"
499
    sed '/^@setfilename/a\
500
'"$textra" "$filename_input" >$filename_xtr
501
    filename_input=$filename_xtr
502
  fi
503
 
504
  # If clean mode was specified, then move to the temporary directory.
505
  if test "$clean" = t; then
506
    $verbose "cd $tmpdir_src"
507
    cd "$tmpdir_src" || exit 1
508
  fi
509
 
510
  while :; do # will break out of loop below
511
    orig_xref_files=`$get_xref_files "$filename_noext"`
512
 
513
    # Save copies of originals for later comparison.
514
    if test -n "$orig_xref_files"; then
515
      $verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
516
      cp $orig_xref_files $tmpdir_bak
517
    fi
518
 
519
    # Run bibtex on current file.
520
    # - If its input (AUX) exists.
521
    # - If AUX contains both `\bibdata' and `\bibstyle'.
522
    # - If some citations are missing (LOG contains `Citation').
523
    #   or the LOG complains of a missing .bbl
524
    #
525
    # We run bibtex first, because I can see reasons for the indexes
526
    # to change after bibtex is run, but I see no reason for the
527
    # converse.
528
    #
529
    # Don't try to be too smart.  Running bibtex only if the bbl file
530
    # exists and is older than the LaTeX file is wrong, since the
531
    # document might include files that have changed.  Because there
532
    # can be several AUX (if there are \include's), but a single LOG,
533
    # looking for missing citations in LOG is easier, though we take
534
    # the risk to match false messages.
535
    if test -n "$bibtex" \
536
       && test -r "$filename_noext.aux" \
537
       && test -r "$filename_noext.log" \
538
       && (grep '^\\bibdata[{]'  "$filename_noext.aux" \
539
           && grep '^\\bibstyle[{]' "$filename_noext.aux" \
540
           && (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
541
               || grep 'No file .*\.bbl\.' "$filename_noext.log")) \
542
          >/dev/null 2>&1; \
543
    then
544
      $verbose "Running $bibtex $filename_noext ..."
545
      if $bibtex "$filename_noext" >&5; then :; else
546
        echo "$0: $bibtex exited with bad status, quitting." >&2
547
        exit 1
548
      fi
549
    fi
550
 
551
    # What we'll run texindex on -- exclude non-index files.
552
    # Since we know index files are last, it is correct to remove everything
553
    # before .aux and .?o?.  But don't really do o
554
    # -- don't match whitespace as .
555
    # Otherwise, if orig_xref_files contains something like
556
    #   foo.xo foo.whatever
557
    # the space after the o will get matched.
558
    index_files=`echo "$orig_xref_files" \
559
                 | sed "s!.*\.aux!!g;
560
                        s!./$filename_noext\.[^ ]o[^ ]!!g;
561
                        s/^[ ]*//;s/[ ]*$//"`
562
    # Run texindex (or makeindex) on current index files.  If they
563
    # already exist, and after running TeX a first time the index
564
    # files don't change, then there's no reason to run TeX again.
565
    # But we won't know that if the index files are out of date or
566
    # nonexistent.
567
    if test -n "$texindex" && test -n "$index_files"; then
568
      $verbose "Running $texindex $index_files ..."
569
      if $texindex $index_files 2>&5 1>&2; then :; else
570
         echo "$0: $texindex exited with bad status, quitting." >&2
571
         exit 1
572
      fi
573
    fi
574
 
575
    # Finally, run TeX.
576
    # Prevent $ESCAPE from being interpreted by the shell if it happens
577
    # to be `/'.
578
    $batch tex_args="\\${escape}nonstopmode\ \\${escape}input"
579
    cmd="$tex $tex_args $filename_input"
580
    $verbose "Running $cmd ..."
581
    if $cmd >&5; then :; else
582
      echo "$0: $tex exited with bad status, quitting." >&2
583
      echo "$0: see $filename_noext.log for errors." >&2
584
      test "$clean" = t \
585
        && cp "$filename_noext.log" "$orig_pwd"
586
      exit 1
587
    fi
588
 
589
 
590
    # Decide if looping again is needed.
591
    finished=t
592
 
593
    # LaTeX (and the package changebar) report in the LOG file if it
594
    # should be rerun.  This is needed for files included from
595
    # subdirs, since texi2dvi does not try to compare xref files in
596
    # subdirs.  Performing xref files test is still good since LaTeX
597
    # does not report changes in xref files.
598
    if grep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
599
      finished=
600
    fi
601
 
602
    # Check if xref files changed.
603
    new_xref_files=`$get_xref_files "$filename_noext"`
604
    $verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
605
    $verbose "New xref files      = `echo $new_xref_files | sed 's|\./||g'`"
606
 
607
    # If old and new lists don't at least have the same file list,
608
    # then one file or another has definitely changed.
609
    test "x$orig_xref_files" != "x$new_xref_files" && finished=
610
 
611
    # File list is the same.  We must compare each file until we find
612
    # a difference.
613
    if test -n "$finished"; then
614
      for this_file in $new_xref_files; do
615
        $verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
616
        # cmp -s returns nonzero exit status if files differ.
617
        if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
618
          # We only need to keep comparing until we find one that
619
          # differs, because we'll have to run texindex & tex again no
620
          # matter how many more there might be.
621
          finished=
622
          $verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
623
          test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
624
          break
625
        fi
626
      done
627
    fi
628
 
629
    # If finished, exit the loop, else rerun the loop.
630
    test -n "$finished" && break
631
  done
632
 
633
  # If we were in clean mode, compilation was in a tmp directory.
634
  # Copy the DVI (or PDF) file into the directory where the compilation
635
  # has been done.  (The temp dir is about to get removed anyway.)
636
  # We also return to the original directory so that
637
  # - the next file is processed in correct conditions
638
  # - the temporary file can be removed
639
  if test -n "$clean"; then
640
    if test -n "$oname"; then
641
       dest=$oname
642
    else
643
       dest=$orig_pwd
644
    fi
645
    $verbose "Copying $oformat file from `pwd` to $dest"
646
    cp -p "./$filename_noext.$oformat" "$dest"
647
    cd / # in case $orig_pwd is on a different drive (for DOS)
648
    cd $orig_pwd || exit 1
649
  fi
650
 
651
  # Remove temporary files.
652
  if test "x$debug" = "x"; then
653
    $verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
654
    cd /
655
    rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
656
  fi
657
done
658
 
659
$verbose "$0 done."
660
exit 0 # exit successfully, not however we ended the loop.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.