On Sun, Jan 28, 2024 at 07:06:10PM +0100, Bruno Haible wrote:
> Hi Patrice,
> 
> > It may be strange to apply it now, before the Texinfo release, however.  I
> > can re-propose it after the Texinfo release, you tell me.
> 
> It's unlikely that the --trace-includes features gets removed again before
> the texinfo 7.2 release, right?

Very unlikely, Gavin revised the manual.  The release number could be
8.0, though, but the patch would still be ok.

> Then it's OK to commit a patch like this into Gnulib now.

Ok.

I have attched an updated version with the changes in indentation.

> But
> 
>   - The 'case' statement is misindented: should indent by 2, not 3 spaces.

Ok.

>   - What's the point of the 'eval'? Can't you get rid of it? And if not,
>     then make it safer by writing
>       cmd="\\$SETLANG \\$MAKEINFO \\$commonarg --trace-includes \"\\$base\""

I am not competent enough to know what to do here, I just mimicked the
other MAKEINFO invokations.  I think that the eval is to get quoting
right, but that is a wild guess.  I could use your code here, but I
didn't as I think that it should not be changed at that occasion, but
rather all the $MAKEINFO invokations should be changed consistently.
However, do not hesitate to make the change if you think that it is
better.

>   - Better indentation: Hiding the command name 'tar' in the middle of a line
>     is not ideal, when this command spans multiple lines. Also, the GNU
>     standards favour listing the operators at the beginning of a line, not
>     at the end. I mean, change
> 
>     eval "$cmd" | tar -czhf "$abs_outdir/$PACKAGE.texi.tar.gz" \
>       --verbatim-files-from -T- -- "$base" $pats \
>       ${source_extra+"$source_extra"} &&
>     ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
> 
>     to
> 
>     eval "$cmd" \
>     | tar -czhf "$abs_outdir/$PACKAGE.texi.tar.gz" \
>         --verbatim-files-from -T- -- "$base" $pats \
>         ${source_extra+"$source_extra"} \
>     && ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"

Ok.

-- 
Pat
diff --git a/ChangeLog b/ChangeLog
index 58fd6e5d4c..6a40954843 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-27  Patrice Dumas  <[email protected]>
+
+	gendocs: get only targetted manual source and includes, when possible
+	* build-aux/gendocs.sh: if makeinfo, based on version, has the
+	--trace-includes option, gather only the targetted manual srcfile and
+	the included files obtained with makeinfo --trace-includes. In that
+	case output include files to tar stdin and use -T-. Bruno Haible for
+	the version comparison and use of tar.
+
 2024-01-27  Paul Eggert  <[email protected]>
 
 	gendocs: allow other chars in source file names
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index bdf105e02b..60447d4f5c 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -422,16 +422,42 @@ d=`dirname $srcfile`
   # file names to be put into the .tar.gz for sources.
   # Omit patterns that do not expand to file names.
   pats=
-  for pat in '*.texinfo' '*.texi' '*.txi' '*.eps'; do
-    for file in $pat; do
-      test "$file" = "$pat" && test ! -e "$file" || pats="$pats $pat"
-      break
+
+  if case `$MAKEINFO --version | sed -e 's/^[^0-9]*//' -e 1q` in \
+       [1-6]* | 7.[01]*) false;; \
+       *) true;; \
+     esac \
+  ; then
+
+    for pat in '*.eps'; do
+      for file in $pat; do
+        test "$file" = "$pat" && test ! -e "$file" || pats="$pats $pat"
+        break
+      done
+    done
+
+    # if $MAKEINFO is recent enough, use --trace-includes on the
+    # $srcfile to get the included files of the targetted manual only
+    base=`basename "$srcfile"`
+
+    cmd="$SETLANG $MAKEINFO $commonarg --trace-includes \"$base\""
+    eval "$cmd" \
+    | tar -czhf "$abs_outdir/$PACKAGE.texi.tar.gz" \
+        --verbatim-files-from -T- -- "$base" $pats \
+        ${source_extra+"$source_extra"} \
+    && ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
+  else
+    for pat in '*.texinfo' '*.texi' '*.txi' '*.eps'; do
+     for file in $pat; do
+       test "$file" = "$pat" && test ! -e "$file" || pats="$pats $pat"
+       break
+      done
     done
-  done
 
-  tar -czhf "$abs_outdir/$PACKAGE.texi.tar.gz" \
-    -- $pats ${source_extra+"$source_extra"} &&
-  ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
+    tar -czhf "$abs_outdir/$PACKAGE.texi.tar.gz" \
+       -- $pats ${source_extra+"$source_extra"} \
+    && ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
+  fi
 ) || exit
 texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"`
 

Reply via email to