# Be sure that if tex wants to fail, it is not interactive: # close stdin. $TEX txiversion.tex txiversion.out 2>txiversion.err ); then :; else report "texinfo.tex appears to be broken. This may be due to the environment variable TEX set to something other than (plain) tex, a corrupt texinfo.tex file, or to tex itself simply not working." cat "$version_test_dir/txiversion.out" cat "$version_test_dir/txiversion.err" >&2 error 1 "quitting." fi eval `$SED -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' "$version_test_dir/txiversion.out"` verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..." if test "$txiprereq" -le "$txiversion" >&6 2>&1; then makeinfo= else makeinfo=${MAKEINFO:-makeinfo} fi # If TeX is preloaded, offer the user this convenience: if test "$txiformat" = Texinfo; then escape=@ fi fi if test -n "$makeinfo"; then # in_src: the file with macros expanded. # Use the same basename to generate the same aux file names. work_src=$workdir/src ensure_dir "$work_src" in_src=$work_src/$in_base run_mi_includes=`list_prefix includes -I` verbose "Macro-expanding $command_line_filename to $in_src ..." # eval $makeinfo because it might be defined as something complex # (running missing) and then we end up with things like '"-I"', # and "-I" (including the quotes) is not an option name. This # happens with gettext 0.14.5, at least. eval $makeinfo -c TEXINFO_OUTPUT_FORMAT=plaintexinfo --iftex --no-ifinfo \ --footnote-style=end -I "$in_dir" $run_mi_includes \ "$command_line_filename" >"$in_src" # Continue only if everything succeeded. if test $? -ne 0 \ || test ! -r "$in_src"; then verbose "Expansion failed, ignored..."; else in_input=$in_src fi fi } # insert_commands - Insert $textra commands at the beginning of the file. # Recommended to be used for @finalout, @smallbook, etc. insert_commands () { if test -n "$textra"; then # _xtr. The file with the user's extra commands. work_xtr=$workdir/xtr in_xtr=$work_xtr/$in_base ensure_dir "$work_xtr" verbose "Inserting extra commands: $textra" case $in_lang in latex) textra_cmd=1i;; texinfo) textra_cmd='/^\\input texinfo/a' # insert after @setfilename line if present if head -n 10 $in_input | grep '^@setfilename' ; then textra_cmd='/^@setfilename/a' fi ;; *) error 1 "internal error, unknown language: $in_lang";; esac $SED "$textra_cmd\\ $textra" "$in_input" >"$in_xtr" in_input=$in_xtr fi } # compute_language FILENAME - Return the short string for the language # in which FILENAME is written: `texinfo' or `latex'. compute_language () { # If the user explicitly specified the language, use that. # Otherwise, if the first line is \input texinfo, assume it's texinfo. # Otherwise, guess from the file extension. if test -n "$set_language"; then echo $set_language elif $SED 1q "$1" | grep 'input texinfo' >&6; then echo texinfo else # Get the type of the file (latex or texinfo) from the given language # we just guessed, or from the file extension if not set yet. case $1 in *.ltx | *.tex | *.drv | *.dtx) echo latex;; *) echo texinfo;; esac fi } # compile - Run the full compilation chain, from pre-processing to # installation of the output at its expected location. compile () { # Set include path for tools: # . Include current directory in case there are files there already, so # we don't have more TeX runs than necessary. orig_pwd is used in case # we are in clean build mode, where we have cd'd to a temp directory. # . Include directory containing file, in case there are other # files @include'd. # . Keep a final path_sep to get the default (system) TeX # directories included. # . If we have any includes, put those at the end. common="$orig_pwd$path_sep$in_dir$path_sep" # txincludes=`list_infix includes $path_sep` test -n "$txincludes" && common="$common$txincludes$path_sep" # for var in $tex_envvars; do eval val="\$common\$${var}_orig" # Convert relative paths to absolute paths, so we can run in another # directory (e.g., in clean build mode, or during the macro-support # detection). val=`absolute_filenames "$val"` eval $var="\"$val\"" export $var eval verbose \"$var=\'\$${var}\'\" done # --expand run_makeinfo # --command, --texinfo insert_commands # Run until a fixed point is reached. run_tex_suite } # make_openout_test FLAGS EXTENSION # - Run TeX with an input file that performs an \openout. Pass FLAGS to TeX. # make_openout_test () { recorder_option_maybe="$1" make_tex_cmd ensure_dir "$workdir"/check_recorder cd_dir "$workdir"/check_recorder cat > openout.tex </dev/null 2>&1) } # Check tex supports -recorder option check_recorder_support () { verbose "Checking TeX recorder support..." make_openout_test " -recorder" fls if test -f openout.fls && grep '^OUTPUT dum.dum$' openout.fls > /dev/null then cd_orig verbose "Checking TeX recorder support... yes" return 0 else cd_orig verbose "Checking TeX recorder support... no" return 1 fi } # Check tex supports \openout traces in log check_openout_in_log_support () { verbose "Checking TeX \openout in log support..." make_openout_test "" log if test -f openout.log \ && grep '^\\openout..\? *= *`\?dum\.dum'\''\?' openout.log >/dev/null then cd_orig verbose "Checking TeX \openout in log support... yes" return 0 else cd_orig verbose "Checking TeX \openout in log support... no" return 1 fi } # Set that output auxiliary files are detected with the -recorder option, # which creates a file JOBNAME.fls which is a machine-readable listing of # files read and written during the job. set_aux_files_from_fls () { recorder_option_maybe=" -recorder" generated_files_get_method=generated_files_get_from_fls } # Set that output auxiliary files are detected with searching for \openout # in the log file. set_aux_files_from_log () { recorder_option_maybe='' generated_files_get_method=generated_files_get_from_log } aux_files_error='Your TeX installation appears to be broken - texi2dvi cannot determine auxiliary files output from a TeX run. You may need to install TeX, or change the values of your PATH, TEX or PDFTEX environment variables in order to proceed.' # Decide whether output auxiliary files are detected with the -recorder # option, or by searching for \openout in the log file. decide_aux_files_method () { # Select output file detection method # Valid values of TEXI2DVI_USE_RECORDER are: # yes use the -recorder option, no checks. # no scan for \openout in the log file, no checks. # yesmaybe check whether -recorder option is supported, and if yes # use it, otherwise check for tracing \openout in the # log file is supported, and if yes use it, else it is an # error. # nomaybe same as `yesmaybe', except that the \openout trace in # log file is checked first. # # The default behaviour is `nomaybe'. test -n "$TEXI2DVI_USE_RECORDER" || TEXI2DVI_USE_RECORDER=nomaybe case $TEXI2DVI_USE_RECORDER in yes) set_aux_files_from_fls;; no) set_aux_files_from_log;; yesmaybe) if check_recorder_support; then set_aux_files_from_fls elif check_openout_in_log_support; then set_aux_files_from_log else error 1 "$aux_files_error" fi ;; nomaybe) if check_openout_in_log_support; then set_aux_files_from_log elif check_recorder_support; then set_aux_files_from_fls else error 1 "$aux_files_error" fi ;; *) error 1 "Invalid value of TEXI2DVI_USE_RECORDER environment variable : $TEXI2DVI_USE_RECORDER.";; esac } # remove FILE... remove () { verbose "Removing" "$@" rm -rf "$@" } # all_files - Echo the names of all files generated, including those by # auxiliary tools like texindex. all_files () { echo $in_noext.log echo $in_noext.fls echo $xref_files_new echo `sorted_index_files` } sorted_index_files () { filter_files sorted_index_filter } # Print the name of a generated file based on FILE if there is one. sorted_index_filter () { case $in_lang in texinfo) # texindex: texinfo.cp -> texinfo.cps if test -n "`index_file_p $1`" ; then echo $1s fi ;; esac } # Not currently used - use with filter_files to add secondary files created by # bibtex bibtex_secondary_files () { case $in_lang in latex) if test -n "`aux_file_p $1`"; then # bibtex: *.aux -> *.bbl and *.blg. echo $1 | $SED 's/^\(.*\)\.aux$/\1.bbl/' echo $1 | $SED 's/^\(.*\)\.aux$/\1.blg/' fi ;; esac } # mostly_clean - Remove auxiliary files and directories. Changes back to # the original directory. mostly_clean () { cd_orig set X "$t2ddir" shift $tidy || { set X ${1+"$@"} `all_files` shift } remove ${1+"$@"} } # cleanup - Remove what should be removed according to options. # Called at the end of each compilation cycle, and at the end of # the script. Changes the current directory. cleanup () { case $clean:$tidy in true:true) mostly_clean ;; # build mode is "clean" false:false) cd_orig; remove "$t2ddir";; # build mode is "local" esac } #