home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BURKS 2
/
BURKS_AUG97.ISO
/
SLAKWARE
/
AP5
/
TEXINFO.TGZ
/
TEXINFO.tar
/
usr
/
bin
/
texi2dvi
< prev
next >
Wrap
Text File
|
1997-02-01
|
14KB
|
365 lines
#! /bin/sh
# texi2dvi --- smartly produce DVI files from texinfo sources
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
# $Id: texi2dvi,v 1.10 1996/10/04 18:21:55 karl Exp $
# 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, 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; if not, you can either send email to this
# program's maintainer or write to: The Free Software Foundation,
# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
# Commentary:
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Please send bug reports, etc. to bug-texinfo@prep.ai.mit.edu
# If possible, please send a copy of the output of the script called with
# the `--debug' option when making a bug report.
# In the interest of general portability, some common bourne shell
# constructs were avoided because they weren't guaranteed to be available
# in some earlier implementations. I've tried to make this program as
# portable as possible. Welcome to unix, where the lowest common
# denominator is rapidly diminishing.
#
# Among the more interesting lossages I noticed with some bourne shells
# are:
# * No shell functions.
# * No `unset' builtin.
# * `shift' cannot take a numeric argument, and signals an error if
# there are no arguments to shift.
# Code:
# Name by which this script was invoked.
progname=`echo "$0" | sed -e 's/[^\/]*\///g'`
# This string is expanded by rcs automatically when this file is checked out.
rcs_revision='$Revision: 1.10 $'
version=`set - $rcs_revision; echo $2`
# To prevent hairy quoting and escaping later.
bq='`'
eq="'"
usage="Usage: $0 [OPTION]... FILE...
Run a Texinfo document through TeX.
Options:
-D, --debug Turn on shell debugging ($bq${bq}set -x$eq$eq).
-t, --texinfo CMD Insert CMD after @setfilename before running TeX.
--verbose Report on what is done.
-h, --help Display this help and exit.
-v, --version Display version information and exit.
The values of the TEX, TEXINDEX, and MAKEINFO environment variables are
used to run those commands, if they are set.
Email bug reports to bug-texinfo@prep.ai.mit.edu.
"
# Initialize variables.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
# Some of these, like TEX and TEXINDEX, may be inherited from the environment.
backup_extension=.bak # these files get deleted if all goes well.
debug=
orig_pwd="`pwd`"
textra=
verbose=false
makeinfo="${MAKEINFO-makeinfo}"
texindex="${TEXINDEX-texindex}"
tex="${TEX-tex}"
# Save this so we can construct a new TEXINPUTS path for each file.
TEXINPUTS_orig="$TEXINPUTS"
export TEXINPUTS
# Parse command line arguments.
# Make sure that all wildcarded options are long enough to be unambiguous.
# It's a good idea to document the full long option name in each case.
# Long options which take arguments will need a `*' appended to the
# canonical name to match the value appended after the `=' character.
while : ; do
case $# in 0) break ;; esac
case "$1" in
-D | --debug | --d* ) debug=t; shift ;;
-h | --help | --h* ) echo "$usage"; exit 0 ;;
# OK, we should do real option parsing here, but be lazy for now.
-t | --texinfo | --t*) shift; textra="$textra $1"; shift ;;
-v | --vers* )
echo "$progname (Texinfo 3.9) $version"
echo "Copyright (C) 1996 Free Software Foundation, Inc.
There is NO warranty. You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."
exit 0 ;;
--verb* ) verbose=echo; shift ;;
-- ) # Stop option processing
shift
break
;;
-* )
case "$1" in
--*=* ) arg=`echo "$1" | sed -e 's/=.*//'` ;;
* ) arg="$1" ;;
esac
exec 1>&2
echo "$progname: Unknown or ambiguous option $bq$arg$eq."
echo "$progname: Try $bq--help$eq for more information."
exit 1
;;
* )
break
;;
esac
done
# See if there are any command line args left (which will be interpreted as
# filename arguments).
if test $# -eq 0; then
exec 1>&2
echo "$progname: At least one file name is required as an argument."
echo "$progname: Try $bq--help$eq for more information."
exit 2
fi
test "$debug" = t && set -x
# Texify files
for command_line_filename in ${1+"$@"} ; do
$verbose "Processing $command_line_filename ..."
# See if file exists. If it doesn't we're in trouble since, even
# though the user may be able to reenter a valid filename at the tex
# prompt (assuming they're attending the terminal), this script won't
# be able to find the right index files and so forth.
if test ! -r "${command_line_filename}" ; then
echo "$0: Could not read ${command_line_filename}." >&2
continue
fi
# Roughly equivalent to `dirname ...`, but more portable
directory="`echo ${command_line_filename} | sed 's/\/[^\/]*$//'`"
filename_texi="`basename ${command_line_filename}`"
# Strip off the last extension part (probably .texinfo or .texi)
filename_noext="`echo ${filename_texi} | sed 's/\.[^.]*$//'`"
# Use same basename since we want to generate aux files with the same
# basename as the manual. Use extension .texi for the temp file so
# that TeX will ignore it. Thus, we must use a subdirectory.
#
# Output the macro-expanded file to here.
tmp_dir=${TMPDIR-/tmp}/$$
filename_tmp=$tmp_dir/$filename_noext.texi
# Output the file with the user's extra commands to here.
filename_tmp2=$tmp_dir.2/$filename_noext.texi
mkdir $tmp_dir $tmp_dir.2
# If directory and file are the same, then it's probably because there's
# no pathname component. Set dirname to `.', the current directory.
if test "z${directory}" = "z${command_line_filename}" ; then
directory=.
fi
# Source file might @include additional texinfo sources. Put `.' and
# directory where source file(s) reside in TEXINPUTS before anything
# else. `.' goes first to ensure that any old .aux, .cps, etc. files in
# ${directory} don't get used in preference to fresher files in `.'.
TEXINPUTS=".:${directory}:${TEXINPUTS_orig}"
# Expand macro commands in the original source file using Makeinfo;
# the macro syntax bfox implemented is impossible to implement in TeX.
# Always use `end' footnote style, since the `separate' style
# generates different output (arguably this is a bug in -E).
# Discard main info output, the user asked to run TeX, not makeinfo.
# Redirect output to /dev/null to throw away `Making info file...' msg.
$verbose "Macro-expanding $command_line_filename to $filename_tmp ..."
$makeinfo --footnote-style=end -E $filename_tmp -o /dev/null \
$command_line_filename >/dev/null
# But if there were no macros, or makeinfo failed for some reason,
# just use the original file. (It shouldn't make any difference, but
# let's be safe.)
if test $? -ne 0 || cmp -s $filename_tmp $command_line_filename; then
$verbose "Reverting to $command_line_filename ..."
filename_input=$command_line_filename
else
filename_input=$filename_tmp
fi
# Used most commonly for @finalout, @smallbook, etc.
if test -n "$textra"; then
$verbose "Inserting extra commands: $textra."
sed '/^@setfilename/a\
'"$textra" $filename_input >$filename_tmp2
filename_input=$filename_tmp2
fi
while true; do # will break out of loop below
# "Unset" variables that might have values from previous iterations and
# which won't be completely reset later.
definite_index_files=
# Find all files having root filename with a two-letter extension,
# determine whether they're rea