>>> "Karl" == Karl Berry <[EMAIL PROTECTED]> writes:
> Yeah. I'm not sure I really want to force every maintainer to play with > their admin files. I rather suspect most of them don't need the > advantages and never noticed a problem. Except those would had to insert CLEANFILES by hand because Automake didn't notice something. Most people won't notice if Automake is updated soon enough. ~/src % fgrep CLEANFILES -w */doc/Makefile.am nostromo 16:04 a2ps-4.13/doc/Makefile.am:CLEANFILES = a2ps.tmp a2ps.tps a2ps-4.50/doc/Makefile.am:CLEANFILES = a2ps.tmp a2ps.tps ace/doc/Makefile.am:CLEANFILES = autoconf.ACs autoconf.cvs autoconf.MSs autoconf.prs \ bison/doc/Makefile.am:CLEANFILES = refcard.dvi refcard.log refcard.ps bison.fns All these are no longer needed (some are already superfluous: Automake was educated to notice *some* of them). > So how about if we make the new behavior enabled with an option (or > envvar), instead of making it the default? That will be less intrusive. I was afraid you'd say something like this :( There was another significant advantage: finding the xref files is much easier, and also much safer: you don't have to add bu[0-9] when you discover new obscure naming conventions from plugins. The following is a continuation of my original patch which includes this more robust scheme to handle xref files. Still wanna keep the old scheme? Index: util/texi2dvi =================================================================== RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v retrieving revision 1.52 diff -u -u -r1.52 texi2dvi --- util/texi2dvi 25 May 2005 09:13:24 -0000 1.52 +++ util/texi2dvi 27 May 2005 14:03:24 -0000 @@ -87,8 +87,8 @@ # Don't use `unset' since old bourne shells don't have this command. # Instead, assign them an empty value. batch=false # eval for batch mode -clean= -debug= +clean=false +debug=false escape='\' expand= # t for expansion via makeinfo miincludes= # makeinfo include path @@ -173,6 +173,18 @@ exit $s } +# ensure_dir $DIRECTORY... +# Make sure the directory exists. +ensure_dir () +{ + for dir + do + test -d "$dir" \ + || mkdir "$dir" \ + || fatal 1 "cannot create directory: $dir" + done +} + # Save TEXINPUTS so we can construct a new TEXINPUTS path for each file. # Likewise for bibtex and makeindex. tex_envvars="BIBINPUTS BSTINPUTS INDEXSTYLE TEXINPUTS" @@ -211,8 +223,8 @@ -@ ) escape=@;; # Silently and without documentation accept -b and --b[atch] as synonyms. -b | --b*) batch=true;; - -c | --c*) clean=t;; - -D | --d*) debug=t;; + -c | --c*) clean=true;; + -D | --d*) debug=true;; -e | -E | --e*) expand=t;; -h | --h*) echo "$usage"; exit 0;; -I | --I*) @@ -300,7 +312,7 @@ # Prepare the temporary directory. Remove it at exit, unless debugging. -if test -z "$debug"; then +if $debug; then :; else trap "cd / && rm -rf $tmpdir" 0 1 2 15 fi @@ -350,38 +362,23 @@ EOF -# get_xref_files FILENAME-NOEXT -# ----------------------------- -# Get list of xref files (indexes, tables and lists). -# Takes the filename (without extension) of which we look for xref -# files as argument. The index files must be reported last. +# Compute the list of xref files (indexes, tables and lists). get_xref_files () { - # Find all files having root filename with a two-letter extension, - # saves the ones that are really Texinfo-related files. - # - .?o? - # .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more. - # - bu[0-9]*.aux - # Sub bibliography when using the LaTeX bibunits package. - for this_file in "$1".?o? "$1".aux bu[0-9]*.aux "$1".?? "$1".idx - do - # If file is empty, skip it. - test -s "$this_file" || continue + for this_file in *; do # If the file is not suitable to be an index or xref file, don't # process it. It's suitable if the first character is a # backslash or right quote or at, as long as the first line isn't # \input texinfo. - first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file` - if (test "x$first_character" = "x\\" \ - && sed 1q $this_file | grep -v '^\\input *texinfo' >&6) \ - || test "x$first_character" = "x'" \ - || test "x$first_character" = "x@"; then - xref_files="$xref_files ./$this_file" - fi + case `sed '1q' $this_file` in + "\\input texinfo"*) ;; + [\\''@]*) xref_files="$xref_files ./$this_file";; + esac done echo "$xref_files" } + # Convert relative paths to absolute paths, so we can run in another # directory (e.g., in --clean mode, or during the macro-support detection.) # @@ -442,9 +439,16 @@ cmd="$cmd '$filename_input'" verbose "Running $cmd ..." - if eval "$cmd" >&5; then :; else - test "$clean" = t \ - && cp "$filename_noext.log" "$orig_pwd" + if eval "$cmd" >&5; then + # Update the actual output. + case $oname in + '') dest=$orig_pwd;; + *) dest=$oname;; + esac + verbose "Copying $oformat file from `pwd` to $dest" + cp -p "./$filename_noext.$oformat" "$dest" + else + cp "$filename_noext.log" "$orig_pwd" fatal 1 "$tex exited with bad status, quitting." \ "see $filename_noext.log for errors." fi @@ -476,7 +480,7 @@ # away. But sometimes it is convenient to see that output (e.g., from # a grep) to aid debugging. Especially debugging at distance, via the # user. -if test "$debug" = t; then +if $debug; then exec 6>&1 set -x else @@ -515,26 +519,30 @@ filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'` ext=`echo "$filename_ext" | sed 's/^.*\.//'` + # An auxiliary directory used to compile this document. If --clean, + # then leave it in the global temporary directory. + workdir=`$clean && echo "$tmpdir/"`$filename_noext.t2d + ensure_dir "$workdir" + # We will change directory, better work with an absolute path... + workdir=`cd "$workdir" && pwd` + # Sometimes there are incompatibilities between auxiliary files for + # DVI and PDF. The contents can also change whether we work on PDF + # and/or DVI. So keep separate spaces for each. + workdir=$workdir/$oformat + ensure_dir "$workdir" + # _src. Use same basename since we want to generate aux files with # the same basename as the manual. If --expand, then output the # macro-expanded file to here, else copy the original file. - tmpdir_src=$tmpdir/src - filename_src=$tmpdir_src/$filename_noext.$ext + work_src=$workdir/src + filename_src=$work_src/$filename_noext.$ext - # _xtr. The file with the user's extra commands. - tmpdir_xtr=$tmpdir/xtr - filename_xtr=$tmpdir_xtr/$filename_noext.$ext - - # _rcd. The Texinfo file recoded in 7bit. - tmpdir_rcd=$tmpdir/rcd - filename_rcd=$tmpdir_rcd/$filename_noext.$ext - - # _bak. Copies of the previous xref files (another round is run if - # they differ from the new one). - tmpdir_bak=$tmpdir/bak + # _bak. Copies of the previous auxiliary files (another round is + # run if they differ from the new one). + work_bak=$workdir/bak - # Make all those directories and give up if we can't succeed. - mkdir $tmpdir_src $tmpdir_xtr $tmpdir_rcd $tmpdir_bak || exit 1 + # Make those directories. + ensure_dir $work_src $work_bak # Source file might include additional sources. # We want `.:$orig_pwd' before anything else. (We'll add `.:' later @@ -663,6 +671,10 @@ # Used most commonly for @finalout, @smallbook, etc. if test -n "$textra"; then + # _xtr. The file with the user's extra commands. + work_xtr=$workdir/xtr + filename_xtr=$work_xtr/$filename_noext.$ext + ensure_dir $work_xtr verbose "Inserting extra commands: $textra" sed "$textra_cmd\\ $textra" "$filename_input" >"$filename_xtr" @@ -680,6 +692,10 @@ encoding=`sed -e "$pgm" "$filename_input"` if $recode && test -n "$encoding" && findprog recode; then verbose "Recoding from $encoding to Texinfo." + # _rcd. The Texinfo file recoded in 7bit. + work_rcd=$workdir/rcd + filename_rcd=$work_rcd/$filename_noext.$ext + ensure_dir $work_rcd if recode "$encoding"..texinfo <"$filename_input" >"$filename_rcd" \ && test -s "$filename_rcd"; then filename_input=$filename_rcd @@ -689,20 +705,21 @@ fi fi - # If clean mode was specified, then move to the temporary directory. - if test "$clean" = t; then - verbose "cd $tmpdir_src" - cd "$tmpdir_src" || exit 1 - fi + # Count the number of cycles. + cycle=0 + + # Move to the working directory. + verbose "cd $work_src" + cd "$work_src" || exit 1 while :; do # will break out of loop below - orig_xref_files=`get_xref_files "$filename_noext"` + cycle=`expr $cycle + 1` + verbose "Cycle $cycle for $command_line_filename" - # Save copies of originals for later comparison. - if test -n "$orig_xref_files"; then - verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`" - cp $orig_xref_files $tmpdir_bak - fi + # Save copies of auxiliary files for later comparison. + orig_xref_files=`get_xref_files` + verbose "Backing up xref files: $orig_xref_files" + cp $orig_xref_files $work_bak # Run bibtex on current file. # - If its input (AUX) exists. @@ -744,17 +761,16 @@ done fi - # What we'll run texindex on -- exclude non-index files. - # Since we know index files are last, it is correct to remove everything - # before .aux and .?o?. But don't really do <anything>o<anything> - # -- don't match whitespace as <anything>. - # Otherwise, if orig_xref_files contains something like - # foo.xo foo.whatever - # the space after the o will get matched. - index_files=`echo "$orig_xref_files" \ - | sed "s!.*\.aux!!g; - s!./$filename_noext\.[^ ]o[^ ]!!g; - s/^[ ]*//;s/[ ]*$//"` + # What we'll run texindex on. + index_files=` + for i in $orig_xref_files; + do + case $i in + *.log) ;; + *) echo $i;; + esac + done` + # Run texindex (or makeindex) on current index files. If they # already exist, and after running TeX a first time the index # files don't change, then there's no reason to run TeX again. @@ -769,47 +785,35 @@ # Finally, run TeX. run_tex - # Decide if looping again is needed. - finished=t - # LaTeX (and the package changebar) report in the LOG file if it # should be rerun. This is needed for files included from # subdirs, since texi2dvi does not try to compare xref files in # subdirs. Performing xref files test is still good since LaTeX # does not report changes in xref files. - if grep "Rerun to get" "$filename_noext.log" >&6 2>&1; then - finished= - fi - - # Check if xref files changed. - new_xref_files=`get_xref_files "$filename_noext"` - verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`" - verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`" + grep "Rerun to get" "$filename_noext.log" >&6 2>&1 && + continue # If old and new lists don't at least have the same file list, # then one file or another has definitely changed. - test "x$orig_xref_files" != "x$new_xref_files" && finished= - - # File list is the same. We must compare each file until we find - # a difference. - if test -n "$finished"; then - for this_file in $new_xref_files; do - verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..." - # cmp -s returns nonzero exit status if files differ. - if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else - # We only need to keep comparing until we find one that - # differs, because we'll have to run texindex & tex again no - # matter how many more there might be. - finished= - verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..." - test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file" - break - fi - done - fi + new_xref_files=`get_xref_files` + verbose "Original xref files = $orig_xref_files" + verbose "New xref files = $new_xref_files" + test "x$orig_xref_files" != "x$new_xref_files" && + continue + + # Compare each file until we find a difference. + for this_file in $new_xref_files; do + verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..." + # cmp -s returns nonzero exit status if files differ. + if cmp -s "$this_file" "$work_bak/$this_file"; then :; else + verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..." + $debug && diff -u "$tmpdir_bak/$this_file" "$this_file" + continue 2 + fi + done - # If finished, exit the loop, else rerun the loop. - test -n "$finished" && break + # We're done. + break done # while :; # If we were using thumbpdf and producing PDF, then run thumbpdf @@ -827,23 +831,6 @@ fi fi - # Honor the actual output destination. - case $clean:$oname in - :) dest=;; - - t:) # If we were in clean mode, compilation was in a tmp - # directory. Copy the DVI (or PDF) file into the directory - # where the compilation has been done. (The temp dir is - # about to get removed anyway.) - dest=$orig_pwd;; - - *:*) dest=$oname;; - esac - if test -n "$dest"; then - verbose "Copying $oformat file from `pwd` to $dest" - cp -p "./$filename_noext.$oformat" "$dest" - fi - # Return to the original directory so that # - the next file is processed in correct conditions # - the temporary file can be removed @@ -851,7 +838,7 @@ cd $orig_pwd || exit 1 # Remove temporary files. - if test "x$debug" = "x"; then + if $debug; then :; else verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..." cd / rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak _______________________________________________ Texinfo home page: http://www.gnu.org/software/texinfo/ bug-texinfo@gnu.org http://lists.gnu.org/mailman/listinfo/bug-texinfo