2 # texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
3 # Id: texi2dvi,v 1.34 2004/12/01 18:35:36 karl Exp
5 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
6 # 2002, 2003, 2004 Free Software Foundation, Inc.
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)
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.
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.
23 # Original author: Noah Friedman.
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.
29 # This string is expanded by rcs automatically when this file is checked out.
30 rcs_revision
='Revision: 1.34'
31 rcs_version
=`set - $rcs_revision; echo $2`
32 program
=`echo $0 | sed -e 's!.*/!!'`
33 version
="texi2dvi (GNU Texinfo 4.8) $rcs_version
35 Copyright (C) 2004 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."
40 usage
="Usage: $program [OPTION]... FILE...
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).
47 Makeinfo is used to perform Texinfo macro expansion before running TeX
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
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 -r, --recode call recode before TeX to translate input characters
69 -t, --command=CMD insert CMD in copy of input file
70 or --texinfo=CMD multiple values accumulate
72 The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
73 TEX (or PDFTEX), TEXINDEX, and THUMBPDF environment variables are used
74 to run those commands, if they are set. Any CMD strings are added
75 after @setfilename for Texinfo input, in the first line for LaTeX input.
77 Email bug reports to <bug-texinfo@gnu.org>,
78 general questions and discussion to <help-texinfo@gnu.org>.
79 Texinfo home page: http://www.gnu.org/software/texinfo/"
81 # Initialize variables for option overriding and otherwise.
82 # Don't use `unset' since old bourne shells don't have this command.
83 # Instead, assign them an empty value.
84 batch=false
# eval for batch mode
88 expand= # t for expansion via makeinfo
89 miincludes= # makeinfo include path
92 quiet= # by default let the tools' message be displayed
95 textra
= # Extra TeX commands to insert in the input file.
96 textra_cmd
= # sed command to insert TEXTRA where appropriate
97 tmpdir
=${TMPDIR:-/tmp}/t2d$$
# avoid collisions on 8.3 filesystems.
98 txincludes
= # TEXINPUTS extensions, with trailing colon
99 txiprereq
=19990129 # minimum texinfo.tex version with macro expansion
100 verbose
=false
# echo for verbose mode
104 # Systems which define $COMSPEC or $ComSpec use semicolons to separate
105 # directories in TEXINPUTS.
106 if test -n "$COMSPEC$ComSpec"; then
112 # Pacify verbose cds.
113 CDPATH
=${ZSH_VERSION+.}$path_sep
115 # In case someone crazy insists on using grep -E.
118 # return true if program $1 is somewhere in PATH, else false.
122 for dir
in `echo $PATH | tr "$path_sep" " "`; do
123 if test -x "$dir/$1"; then # does anyone still need test -f?
131 # Report an error and exit with failure.
137 # Save TEXINPUTS so we can construct a new TEXINPUTS path for each file.
138 # Likewise for bibtex and makeindex.
139 tex_envvars
="BIBINPUTS BSTINPUTS INDEXSTYLE TEXINPUTS"
140 for var
in $tex_envvars; do
141 eval ${var}_orig
=\$
$var
146 # Push a token among the arguments that will be used to notice when we
147 # ended options/arguments parsing.
148 # Use "set dummy ...; shift" rather than 'set - ..." because on
149 # Solaris set - turns off set -x (but keeps set -e).
150 # Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
151 # still expand "$@" to a single argument (the empty string) rather
152 # than nothing at all.
154 set dummy
${1+"$@"} "$arg_sep"; shift
157 # Parse command line arguments.
158 while test x
"$1" != x
"$arg_sep"; do
160 # Handle --option=value by splitting apart and putting back on argv.
163 opt
=`echo "$1" | sed -e 's/=.*//'`
164 val
=`echo "$1" | sed -e 's/[^=]*=//'`
166 set dummy
"$opt" "$val" ${1+"$@"}; shift
170 # This recognizes --quark as --quiet. So what.
173 # Silently and without documentation accept -b and --b[atch] as synonyms.
174 -b |
--b*) batch=true
;;
177 -e |
-E |
--e*) expand=t
;;
178 -h |
--h*) echo "$usage"; exit 0;;
181 miincludes
="$miincludes -I $1"
182 txincludes
="$txincludes$1$path_sep"
184 -l |
--l*) shift; set_language
=$1;;
189 /* | ?
:/*) oname
=$1;;
190 *) oname
="$orig_pwd/$1";;
192 -p |
--p*) oformat
=pdf
;;
193 -q |
-s |
--q* |
--s*) quiet
=t
; batch=true
;;
194 -r |
--r*) recode=true
;;
195 -t |
--tex* |
--com* ) shift; textra
="$textra\\
196 "`echo "$1" | sed 's/\\\\/\\\\\\\\/g'`;;
197 -v |
--vers*) echo "$version"; exit 0;;
198 -V |
--verb*) verbose
=echo;;
199 --) # What remains are not options.
201 while test x
"$1" != x
"$arg_sep"; do
202 set dummy
${1+"$@"} "$1"; shift
207 echo "$0: Unknown or ambiguous option \`$1'." >&2
208 echo "$0: Try \`--help' for more information." >&2
210 *) set dummy
${1+"$@"} "$1"; shift;;
217 # Interpret remaining command line args as filenames.
220 echo "$0: Missing file arguments." >&2
221 echo "$0: Try \`--help' for more information." >&2
226 if test -n "$oname"; then
227 echo "$0: Can't use option \`--output' with more than one argument." >&2
234 # We can't do much without tex.
236 if findprog
${TEX:-tex}; then :; else cat <<EOM
237 You don't have a working TeX binary (${TEX:-tex}) installed anywhere in
238 your PATH, and texi2dvi cannot proceed without one. If you want to use
239 this script, you'll need to install TeX (if you don't have it) or change
240 your PATH or TEX environment variable (if you do). See the --help
241 output for more details.
243 For information about obtaining TeX, please see http://www.tug.org. If
244 you happen to be using Debian, you can get it with this command:
245 apt-get install tetex-bin
251 # We want to use etex (or pdftex) if they are available, and the user
252 # didn't explicitly specify. We don't check for elatex and pdfelatex
253 # because (as of 2003), the LaTeX team has asked that new distributions
254 # use etex by default anyway.
256 # End up with the TEX and PDFTEX variables set to what we are going to use.
257 if test -z "$TEX"; then
258 if findprog etex
; then TEX
=etex
; else TEX
=tex
; fi
261 if test -z "$PDFTEX"; then
262 if findprog pdfetex
; then PDFTEX
=pdfetex
; else PDFTEX
=pdftex
; fi
266 # Prepare the temporary directory. Remove it at exit, unless debugging.
267 if test -z "$debug"; then
268 trap "cd / && rm -rf $tmpdir" 0 1 2 15
271 # Create the temporary directory with strict rights
272 (umask 077 && mkdir
$tmpdir) ||
exit 1
274 # Prepare the tools we might need. This may be extra work in some
275 # cases, but improves the readability of the script.
276 utildir
=$tmpdir/utils
277 mkdir
$utildir ||
exit 1
279 # A sed script that preprocesses Texinfo sources in order to keep the
280 # iftex sections only. We want to remove non TeX sections, and comment
281 # (with `@c texi2dvi') TeX sections so that makeinfo does not try to
282 # parse them. Nevertheless, while commenting TeX sections, don't
283 # comment @macro/@end macro so that makeinfo does propagate them.
284 # Unfortunately makeinfo --iftex --no-ifinfo doesn't work well enough
285 # (yet), makeinfo can't parse the TeX commands, so work around with sed.
287 comment_iftex_sed
=$utildir/comment.
sed
288 cat <<EOF >$comment_iftex_sed
292 /^@iftex/,/^@end iftex/{
294 /^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
298 /^@ifnottex/,/^@end ifnottex/{
301 /^@ifinfo/,/^@end ifinfo/{
303 /^@menu/,/^@end menu/p
307 s/^@ifnotinfo/@c texi2dvi@ifnotinfo/
308 s/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/
310 # Uncommenting is simple: Remove any leading `@c texi2dvi'.
311 uncomment_iftex_sed
=$utildir/uncomment.
sed
312 cat <<EOF >$uncomment_iftex_sed
316 # Compute the list of xref files.
317 # Takes the filename (without extension) of which we look for xref
318 # files as argument. The index files must be reported last.
321 # Get list of xref files (indexes, tables and lists).
322 # Find all files having root filename with a two-letter extension,
323 # saves the ones that are really Texinfo-related files. .?o? catches
324 # many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
325 for this_file
in "$1".?o?
"$1".aux
"$1".??
"$1".idx
; do
326 # If file is empty, skip it.
327 test -s "$this_file" ||
continue
328 # If the file is not suitable to be an index or xref file, don't
329 # process it. It's suitable if the first character is a
330 # backslash or right quote or at, as long as the first line isn't
332 first_character
=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
333 if (test "x$first_character" = "x\\" \
334 && sed 1q
$this_file |
grep -v '^\\input *texinfo' >/dev
/null
) \
335 ||
test "x$first_character" = "x'" \
336 ||
test "x$first_character" = "x@"; then
337 xref_files
="$xref_files ./$this_file"
343 # File descriptor usage:
345 # 1 standard output (--verbose messages)
347 # 3 some systems may open it to /dev/tty
348 # 4 used on the Kubota Titan
349 # 5 tools output (turned off by --quiet)
351 # Tools' output. If quiet, discard, else redirect to the message flow.
352 if test "$quiet" = t
; then
359 if test "$debug" = t
; then
369 for command_line_filename
in ${1+"$@"}; do
370 $verbose "Processing $command_line_filename ..."
372 # If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
373 # prepend `./' in order to avoid that the tools take it as an option.
374 echo "$command_line_filename" |
$EGREP '^(/|[A-z]:/)' >&6 \
375 || command_line_filename
="./$command_line_filename"
377 # See if the file exists. If it doesn't we're in trouble since, even
378 # though the user may be able to reenter a valid filename at the tex
379 # prompt (assuming they're attending the terminal), this script won't
380 # be able to find the right xref files and so forth.
381 if test ! -r "$command_line_filename"; then
382 echo "$0: Could not read $command_line_filename, skipping." >&2
386 # Get the name of the current directory. We want the full path
387 # because in clean mode we are in tmp, in which case a relative
388 # path has no meaning.
389 filename_dir
=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
390 filename_dir
=`cd "$filename_dir" >/dev/null && pwd`
392 # Strip directory part but leave extension.
393 filename_ext
=`basename "$command_line_filename"`
395 filename_noext
=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
396 ext
=`echo "$filename_ext" | sed 's/^.*\.//'`
398 # _src. Use same basename since we want to generate aux files with
399 # the same basename as the manual. If --expand, then output the
400 # macro-expanded file to here, else copy the original file.
401 tmpdir_src
=$tmpdir/src
402 filename_src
=$tmpdir_src/$filename_noext.
$ext
404 # _xtr. The file with the user's extra commands.
405 tmpdir_xtr
=$tmpdir/xtr
406 filename_xtr
=$tmpdir_xtr/$filename_noext.
$ext
408 # _rcd. The Texinfo file recoded in 7bit.
409 tmpdir_rcd
=$tmpdir/rcd
410 filename_rcd
=$tmpdir_rcd/$filename_noext.
$ext
412 # _bak. Copies of the previous xref files (another round is run if
413 # they differ from the new one).
414 tmpdir_bak
=$tmpdir/bak
416 # Make all those directories and give up if we can't succeed.
417 mkdir
$tmpdir_src $tmpdir_xtr $tmpdir_rcd $tmpdir_bak ||
exit 1
419 # Source file might include additional sources.
420 # We want `.:$orig_pwd' before anything else. (We'll add `.:' later
421 # after all other directories have been turned into absolute paths.)
422 # `.' goes first to ensure that any old .aux, .cps,
423 # etc. files in ${directory} don't get used in preference to fresher
424 # files in `.'. Include orig_pwd in case we are in clean mode, where
425 # we've cd'd to a temp directory.
426 common
="$orig_pwd$path_sep$filename_dir$path_sep$txincludes"
427 for var
in $tex_envvars; do
428 eval ${var}="\$common\$${var}_orig"
432 # Convert relative paths to absolute paths, so we can run in another
433 # directory (e.g., in --clean mode, or during the macro-support detection.)
435 # Empty path components are meaningful to tex. We rewrite them
436 # as `EMPTY' so they don't get lost when we split on $path_sep.
437 # Hopefully no one will have an actual directory named EMPTY.
438 replace_empty
="-e 's/^$path_sep/EMPTY$path_sep/g' \
439 -e 's/$path_sep\$/${path_sep}EMPTY/g' \
440 -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
441 TEXINPUTS
=`echo $TEXINPUTS | eval sed $replace_empty`
442 INDEXSTYLE
=`echo $INDEXSTYLE | eval sed $replace_empty`
445 set x
$TEXINPUTS; shift
451 TEXINPUTS
=$TEXINPUTS$path_sep
453 [\\/]* | ?
:[\\/]*) # Absolute paths don't need to be expanded.
454 TEXINPUTS
=$TEXINPUTS$path_sep$dir
457 abs
=`cd "$dir" && pwd` && TEXINPUTS
=$TEXINPUTS$path_sep$abs
461 set x
$INDEXSTYLE; shift
467 INDEXSTYLE
=$INDEXSTYLE$path_sep
469 [\\/]* | ?
:[\\/]*) # Absolute paths don't need to be expansed.
470 INDEXSTYLE
=$INDEXSTYLE$path_sep$dir
473 abs
=`cd "$dir" && pwd` && INDEXSTYLE
=$INDEXSTYLE$path_sep$abs
479 # If the user explicitly specified the language, use that.
480 # Otherwise, if the first line is \input texinfo, assume it's texinfo.
481 # Otherwise, guess from the file extension.
482 if test -n "$set_language"; then
483 language
=$set_language
484 elif sed 1q
"$command_line_filename" |
grep 'input texinfo' >&6; then
490 # Get the type of the file (latex or texinfo) from the given language
491 # we just guessed, or from the file extension if not set yet.
492 case ${language:-$filename_ext} in
493 [lL
]a
[tT
]e
[xX
] |
*.ltx |
*.tex
)
494 # Assume a LaTeX file. LaTeX needs bibtex and uses latex for
495 # compilation. No makeinfo.
497 bibtex
=${BIBTEX:-bibtex}
498 makeinfo
= # no point in running makeinfo on latex source.
499 texindex
=${MAKEINDEX:-makeindex}
501 if test $oformat = dvi
; then
504 tex
=${PDFLATEX:-pdflatex}
506 thumbpdf
=${THUMBPDF:-thumbpdf}
510 # Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
513 texindex
=${TEXINDEX:-texindex}
514 textra_cmd
='/^@setfilename/a'
515 if test $oformat = dvi
; then
516 # MetaPost also uses the TEX environment variable. If the user
517 # has set TEX=latex for that reason, don't bomb out.
518 if echo $TEX |
grep 'latex$' >/dev
/null
; then
519 tex
=tex
# don't bother trying to find etex
526 # Unless required by the user, makeinfo expansion is wanted only
527 # if texinfo.tex is too old.
528 if test "$expand" = t
; then
529 makeinfo
=${MAKEINFO:-makeinfo}
531 # Check if texinfo.tex performs macro expansion by looking for
532 # its version. The version is a date of the form YEAR-MO-DA.
533 # We don't need to use [0-9] to match the digits since anyway
534 # the comparison with $txiprereq, a number, will fail with non
536 # Run in the tmpdir to avoid leaving files.
539 echo '\input texinfo.tex @bye' >txiversion.tex
540 # Be sure that if tex wants to fail, it is not interactive:
542 $tex txiversion.tex
</dev
/null
543 ) >$tmpdir/txiversion.out
2>$tmpdir/txiversion.err
544 if test $?
!= 0; then
545 cat $tmpdir/txiversion.out
546 cat $tmpdir/txiversion.err
>&2
547 fatal
"texinfo.tex appears to be broken, quitting."
549 eval `sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' $tmpdir/txiversion.out`
550 $verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
551 if test "$txiprereq" -le "$txiversion" >/dev
/null
2>&1; then
554 makeinfo
=${MAKEINFO:-makeinfo}
556 # As long as we had to run TeX, offer the user this convenience:
557 test "$txiformat" = Texinfo
&& escape
=@
559 thumbpdf
=${THUMBPDF:-thumbpdf}
563 # Go to $tmpdir to try --help, since old versions that don't accept
564 # --help will generate a texput.log.
565 tex_help
=`cd $tmpdir >/dev/null && $tex --help </dev/null 2>&1`
567 # If possible, make TeX report error locations in GNU format.
570 *file-line-error
*) tex_args
="$tex_args --file-line-error";;
573 # Tell TeX to be batch if requested. (\batchmode does not show
574 # terminal output at all, so we don't want that.)
575 $batch && tex_args
="$tex_args ${escape}nonstopmode ${escape}input"
577 # Expand macro commands in the original source file using Makeinfo.
578 # Always use `end' footnote style, since the `separate' style
579 # generates different output (arguably this is a bug in -E).
580 # Discard main info output, the user asked to run TeX, not makeinfo.
581 if test -n "$makeinfo"; then
582 $verbose "Macro-expanding $command_line_filename to $filename_src ..."
583 sed -f $comment_iftex_sed "$command_line_filename" \
584 |
$makeinfo --footnote-style=end
-I "$filename_dir" $miincludes \
585 -o /dev
/null
--macro-expand=- \
586 |
sed -f $uncomment_iftex_sed >"$filename_src"
587 filename_input
=$filename_src
590 # If makeinfo failed (or was not even run), use the original file as input.
592 ||
test ! -r "$filename_src"; then
593 $verbose "Reverting to $command_line_filename ..."
594 filename_input
=$filename_dir/$filename_ext
597 # Used most commonly for @finalout, @smallbook, etc.
598 if test -n "$textra"; then
599 $verbose "Inserting extra commands: $textra"
601 $textra" "$filename_input" >"$filename_xtr"
602 filename_input
=$filename_xtr
605 # If this is a Texinfo file with a specified input encoding, and
606 # recode is available, then recode to plain 7 bit Texinfo.
607 if test $language = texinfo
; then
608 pgm
='s/\(^\|.* \)@documentencoding *\([^ ][^ ]*\)\( .*\|$\)/\2/
613 encoding
=`sed -e "$pgm" "$filename_input"`
614 if $recode && test -n "$encoding" && findprog
recode; then
615 $verbose "Recoding from $encoding to Texinfo."
616 if recode "$encoding"..texinfo
<"$filename_input" >"$filename_rcd" \
617 && test -s "$filename_rcd"; then
618 filename_input
=$filename_rcd
620 $verbose "Recoding failed, using original input."
625 # If clean mode was specified, then move to the temporary directory.
626 if test "$clean" = t
; then
627 $verbose "cd $tmpdir_src"
628 cd "$tmpdir_src" ||
exit 1
631 while :; do # will break out of loop below
632 orig_xref_files
=`get_xref_files "$filename_noext"`
634 # Save copies of originals for later comparison.
635 if test -n "$orig_xref_files"; then
636 $verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
637 cp $orig_xref_files $tmpdir_bak
640 # Run bibtex on current file.
641 # - If its input (AUX) exists.
642 # - If AUX contains both `\bibdata' and `\bibstyle'.
643 # - If some citations are missing (LOG contains `Citation').
644 # or the LOG complains of a missing .bbl
646 # We run bibtex first, because I can see reasons for the indexes
647 # to change after bibtex is run, but I see no reason for the
650 # Don't try to be too smart. Running bibtex only if the bbl file
651 # exists and is older than the LaTeX file is wrong, since the
652 # document might include files that have changed. Because there
653 # can be several AUX (if there are \include's), but a single LOG,
654 # looking for missing citations in LOG is easier, though we take
655 # the risk to match false messages.
656 if test -n "$bibtex" \
657 && test -r "$filename_noext.aux" \
658 && test -r "$filename_noext.log" \
659 && (grep '^\\bibdata[{]' "$filename_noext.aux" \
660 && grep '^\\bibstyle[{]' "$filename_noext.aux" \
661 && (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
662 ||
grep 'No file .*\.bbl\.' "$filename_noext.log")) \
665 $verbose "Running $bibtex $filename_noext ..."
666 $bibtex "$filename_noext" >&5 ||
667 fatal
"$bibtex exited with bad status, quitting."
670 # What we'll run texindex on -- exclude non-index files.
671 # Since we know index files are last, it is correct to remove everything
672 # before .aux and .?o?. But don't really do <anything>o<anything>
673 # -- don't match whitespace as <anything>.
674 # Otherwise, if orig_xref_files contains something like
675 # foo.xo foo.whatever
676 # the space after the o will get matched.
677 index_files
=`echo "$orig_xref_files" \
679 s!./$filename_noext\.[^ ]o[^ ]!!g;
680 s/^[ ]*//;s/[ ]*$//"`
681 # Run texindex (or makeindex) on current index files. If they
682 # already exist, and after running TeX a first time the index
683 # files don't change, then there's no reason to run TeX again.
684 # But we won't know that if the index files are out of date or
686 if test -n "$texindex" && test -n "$index_files"; then
687 $verbose "Running $texindex $index_files ..."
688 $texindex $index_files 2>&5 1>&2 ||
689 fatal
"$texindex exited with bad status, quitting."
694 $verbose "Running $cmd ..."
695 if $cmd "$filename_input" >&5; then :; else
696 echo "$0: TeX failed. If the above said 'tex: not found', " >&2
697 echo "$0: you may need to install TeX;" >&2
698 echo "$0: it is available from the pkgsrc system in print/teTeX." >&2
699 echo "$0: If TeX is installed, make sure it is in your $PATH, or" >&2
700 echo "$0: set the environment variable $TEX to its location." >&2
701 echo "$0: $tex exited with bad status, quitting." >&2
702 echo "$0: see $filename_noext.log for errors." >&2
704 && cp "$filename_noext.log" "$orig_pwd"
709 # Decide if looping again is needed.
712 # LaTeX (and the package changebar) report in the LOG file if it
713 # should be rerun. This is needed for files included from
714 # subdirs, since texi2dvi does not try to compare xref files in
715 # subdirs. Performing xref files test is still good since LaTeX
716 # does not report changes in xref files.
717 if grep "Rerun to get" "$filename_noext.log" >&6 2>&1; then
721 # Check if xref files changed.
722 new_xref_files
=`get_xref_files "$filename_noext"`
723 $verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
724 $verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
726 # If old and new lists don't at least have the same file list,
727 # then one file or another has definitely changed.
728 test "x$orig_xref_files" != "x$new_xref_files" && finished
=
730 # File list is the same. We must compare each file until we find
732 if test -n "$finished"; then
733 for this_file
in $new_xref_files; do
734 $verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
735 # cmp -s returns nonzero exit status if files differ.
736 if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
737 # We only need to keep comparing until we find one that
738 # differs, because we'll have to run texindex & tex again no
739 # matter how many more there might be.
741 $verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
742 test "$debug" = t
&& diff -c "$tmpdir_bak/$this_file" "$this_file"
748 # If finished, exit the loop, else rerun the loop.
749 test -n "$finished" && break
752 # If we were using thumbpdf and producing PDF, then run thumbpdf
753 # and TeX one last time.
754 if test $oformat = pdf \
755 && test -r "$filename_noext.log" \
756 && grep 'thumbpdf\.sty' "$filename_noext.log" >&6 2>&1; \
758 $verbose "Running $thumbpdf $filename_noext ..."
759 $thumbpdf "$filename_noext" >&5 ||
760 fatal
"$thumbpdf exited with bad status, quitting."
762 $verbose "Running $cmd $filename_input..."
763 if $cmd "$filename_input" >&5; then :; else
764 echo "$0: $tex exited with bad status, quitting." >&2
765 echo "$0: see $filename_noext.log for errors." >&2
767 && cp "$filename_noext.log" "$orig_pwd"
773 # If we were in clean mode, compilation was in a tmp directory.
774 # Copy the DVI (or PDF) file into the directory where the compilation
775 # has been done. (The temp dir is about to get removed anyway.)
776 # We also return to the original directory so that
777 # - the next file is processed in correct conditions
778 # - the temporary file can be removed
779 if test -n "$clean"; then
780 if test -n "$oname"; then
785 $verbose "Copying $oformat file from `pwd` to $dest"
786 cp -p "./$filename_noext.$oformat" "$dest"
787 cd / # in case $orig_pwd is on a different drive (for DOS)
788 cd $orig_pwd ||
exit 1
791 # Remove temporary files.
792 if test "x$debug" = "x"; then
793 $verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
795 rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
800 exit 0 # exit successfully, not however we ended the loop.