On Thu, 6 Mar 2008, Ralf Wildenhues wrote:

* Peter Breitenlohner wrote on Thu, Mar 06, 2008 at 01:27:05PM CET:
or still something else. If so please indicate what.

Oh sorry, I was in a hurry and not thinking.  What I meant was that
while you can't wrap arbitrary lines ending in backslash-newline in `if
%?NOTRANS_MANS%/else/endif', you can do so at a finer grainage than
whole rules: it's just that it won't work after lines ending in
backslash.

To some extent this is independent of the question you ask about the
rule target names: whether you interleave trans and notrans in the .am
file and whether you give trans and notrans different target names need
not be dealt with at the same time.  So please for now leave you patch
as is, but only change all those NOTR/DOTR prefixes to use if/else/endif
(which includes a few lines of duplication in the .am file).

Clearer now?  If not, then I guess I can also patch that later.

Hi Ralf,

yes, thanks. However, I can only use if/endif if/endif and not if/else/endif
because a section may have trans_ as well as notrans_ man pages.

=========================

Attached are revised versions of the three patches. I hope they take care of
all your earlier comments.

patch-03-notrans_MANS-impl:

The new variables names are more or less self explanatory (I hope).

I had to use
      @unsorted_deps = (keys %notrans_vars, keys %trans_vars,
                        keys %notrans_this_sect, keys %trans_this_sect);
      my @deps = sort @unsorted_deps;
instead of
      my @deps = sort (keys %notrans_vars, keys %trans_vars,
                       keys %notrans_this_sect, keys %trans_this_sect);
because this may give a perl warning [sort (...) used as function],
resulting in three test (instsh.tes, location.test, warnopts.test) to FAIL.

patch-04-notrans_MANS-doc:

I have slightly reworded the text preceding the example, and hope this
clarifies the intent.

patch-05-notrans_MANS-test:

notrans.test now contains all combinations. I have incorporated the checks
that used to be in man4.test into notrans.test, because otherwise there
would have been much repetition.  Hope this is OK.  If so, remember not to
mention man4.test in the ChangLog.  If not, I could make that two separate
tests.

The install-man depedndencies are checked either directly (inspecting
Makefile.in) or indirectly (letting make generate the files).

=========================

regards
Peter Breitenlohner <[EMAIL PROTECTED]>
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti 
automake-1.10.1.orig/automake.in automake-1.10.1/automake.in
--- automake-1.10.1.orig/automake.in    2008-02-19 18:07:41.000000000 +0100
+++ automake-1.10.1/automake.in 2008-03-08 00:10:34.000000000 +0100
@@ -3363,27 +3363,39 @@
   # Find all the sections in use.  We do this by first looking for
   # "standard" sections, and then looking for any additional
   # sections used in man_MANS.
-  my (%sections, %vlist);
+  my (%sections, %notrans_sections, %trans_sections,
+      %notrans_vars, %trans_vars, %notrans_sect_vars, %trans_sect_vars);
   # We handle nodist_ for uniformity.  man pages aren't distributed
   # by default so it isn't actually very important.
+  foreach my $npfx ('', 'notrans_')
+    {
       foreach my $pfx ('', 'dist_', 'nodist_')
        {
          # Add more sections as needed.
          foreach my $section ('0'..'9', 'n', 'l')
            {
-             my $varname = $pfx . 'man' . $section . '_MANS';
+             my $varname = $npfx . $pfx . 'man' . $section . '_MANS';
              if (var ($varname))
                {
                  $sections{$section} = 1;
                  $varname = '$(' . $varname . ')';
-                 $vlist{$varname} = 1;
+                 if ($npfx eq 'notrans_')
+                   {
+                     $notrans_sections{$section} = 1;
+                     $notrans_sect_vars{$varname} = 1;
+                   }
+                 else
+                   {
+                     $trans_sections{$section} = 1;
+                     $trans_sect_vars{$varname} = 1;
+                   }
 
                  &push_dist_common ($varname)
                    if $pfx eq 'dist_';
                }
            }
 
-         my $varname = $pfx . 'man_MANS';
+         my $varname = $npfx . $pfx . 'man_MANS';
          my $var = var ($varname);
          if ($var)
            {
@@ -3393,28 +3405,87 @@
                  if (/\.([0-9a-z])([a-z]*)$/)
                    {
                      $sections{$1} = 1;
+                     if ($npfx eq 'notrans_')
+                       {
+                         $notrans_sections{$1} = 1;
+                       }
+                     else
+                       {
+                         $trans_sections{$1} = 1;
+                       }
                    }
                }
 
              $varname = '$(' . $varname . ')';
-             $vlist{$varname} = 1;
+             if ($npfx eq 'notrans_')
+               {
+                 $notrans_vars{$varname} = 1;
+               }
+             else
+               {
+                 $trans_vars{$varname} = 1;
+               }
              &push_dist_common ($varname)
                if $pfx eq 'dist_';
            }
        }
+    }
 
   return unless %sections;
 
+  my @unsorted_deps;
+
+  # Build section independent variables.
+  my $have_notrans = %notrans_vars;
+  my @notrans_list = sort keys %notrans_vars;
+  my $have_trans = %trans_vars;
+  my @trans_list = sort keys %trans_vars;
+
   # Now for each section, generate an install and uninstall rule.
   # Sort sections so output is deterministic.
   foreach my $section (sort keys %sections)
     {
+      # Build section dependent variables.
+      my $notrans_mans = $have_notrans || exists $notrans_sections{$section};
+      my $trans_mans = $have_trans || exists $trans_sections{$section};
+      my (%notrans_this_sect, %trans_this_sect);
+      my $expr = 'man' . $section . '_MANS';
+      foreach my $varname (keys %notrans_sect_vars)
+       {
+         if ($varname =~ /$expr/)
+           {
+             $notrans_this_sect{$varname} = 1;
+           }
+       }
+      foreach my $varname (keys %trans_sect_vars)
+       {
+         if ($varname =~ /$expr/)
+           {
+             $trans_this_sect{$varname} = 1;
+           }
+       }
+      my @notrans_sect_list = sort keys %notrans_this_sect;
+      my @trans_sect_list = sort keys %trans_this_sect;
+      @unsorted_deps = (keys %notrans_vars, keys %trans_vars,
+                        keys %notrans_this_sect, keys %trans_this_sect);
+      my @deps = sort @unsorted_deps;
       $output_rules .= &file_contents ('mans',
                                       new Automake::Location,
-                                      SECTION => $section);
+                                      SECTION           => $section,
+                                      DEPS              => "@deps",
+                                      NOTRANS_MANS      => $notrans_mans,
+                                      NOTRANS_SECT_LIST => 
"@notrans_sect_list",
+                                      HAVE_NOTRANS      => $have_notrans,
+                                      NOTRANS_LIST      => "@notrans_list",
+                                      TRANS_MANS        => $trans_mans,
+                                      TRANS_SECT_LIST   => "@trans_sect_list",
+                                      HAVE_TRANS        => $have_trans,
+                                      TRANS_LIST        => "@trans_list");
     }
 
-  my @mans = sort keys %vlist;
+  @unsorted_deps  = (keys %notrans_vars, keys %trans_vars,
+                     keys %notrans_sect_vars, keys %trans_sect_vars);
+  my @mans = sort @unsorted_deps;
   $output_vars .= file_contents ('mans-vars',
                                 new Automake::Location,
                                 MANS => "@mans");
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti 
automake-1.10.1.orig/lib/am/mans.am automake-1.10.1/lib/am/mans.am
--- automake-1.10.1.orig/lib/am/mans.am 2008-02-20 09:38:10.000000000 +0100
+++ automake-1.10.1/lib/am/mans.am      2008-03-08 00:10:55.000000000 +0100
@@ -29,19 +29,50 @@
 ?INSTALL-MAN?install-data-am: install-man
 ?INSTALL-MAN?am__installdirs += "$(DESTDIR)$(man%SECTION%dir)"
 .PHONY install-man: install-man%SECTION%
-install-man%SECTION%: $(man%SECTION%_MANS) $(man_MANS)
+install-man%SECTION%: %DEPS%
        @$(NORMAL_INSTALL)
        test -z "$(man%SECTION%dir)" || $(MKDIR_P) 
"$(DESTDIR)$(man%SECTION%dir)"
-       @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) 
$(nodist_man%SECTION%_MANS)'; \
-## Extract all items from man_MANS that should go in this section.
+if %?NOTRANS_MANS%
+## Handle MANS with notrans_ prefix
+       @list='%NOTRANS_SECT_LIST%'; \
+## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
-       l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
-       for i in $$l2; do \
-         case "$$i" in \
+?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; \
+?HAVE_NOTRANS? for i in $$l2; do \
+?HAVE_NOTRANS?   case "$$i" in \
 ## Have to accept files like `foo.1c'.
-           *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?     *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?   esac; \
+?HAVE_NOTRANS? done; \
+       for i in $$list; do \
+## Find the file.
+         if test -f $$i; then file=$$i; \
+         else file=$(srcdir)/$$i; fi; \
+## Change the extension if needed.
+         ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+         case "$$ext" in \
+           %SECTION%*) ;; \
+           *) ext='%SECTION%' ;; \
          esac; \
-       done; \
+## Extract basename of man page and append extension.
+         inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+         inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
+         echo " $(INSTALL_DATA) '$$file' 
'$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+         $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+       done
+endif %?NOTRANS_MANS%
+if %?TRANS_MANS%
+## Handle MANS without notrans_ prefix
+       @list='%TRANS_SECT_LIST%'; \
+## Extract all items from man_MANS that should go in this section.
+## This must be done dynamically to support conditionals.
+?HAVE_TRANS?   l2='%TRANS_LIST%'; \
+?HAVE_TRANS?   for i in $$l2; do \
+?HAVE_TRANS?     case "$$i" in \
+## Have to accept files like `foo.1c'.
+?HAVE_TRANS?       *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_TRANS?     esac; \
+?HAVE_TRANS?   done; \
        for i in $$list; do \
 ## Find the file.
          if test -f $$i; then file=$$i; \
@@ -60,6 +91,7 @@
          echo " $(INSTALL_DATA) '$$file' 
'$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
          $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
        done
+endif %?TRANS_MANS%
 
 
 ## -------------- ##
@@ -72,16 +104,44 @@
 .PHONY uninstall-man: uninstall-man%SECTION%
 uninstall-man%SECTION%:
        @$(NORMAL_UNINSTALL)
-       @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) 
$(nodist_man%SECTION%_MANS)'; \
-## Extract all items from man_MANS that should go in this section.
+if %?NOTRANS_MANS%
+## Handle MANS with notrans_ prefix
+       @list='%NOTRANS_SECT_LIST%'; \
+## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
-       l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
-       for i in $$l2; do \
-         case "$$i" in \
+?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; \
+?HAVE_NOTRANS? for i in $$l2; do \
+?HAVE_NOTRANS?   case "$$i" in \
 ## Have to accept files like `foo.1c'.
-           *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?     *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?   esac; \
+?HAVE_NOTRANS? done; \
+       for i in $$list; do \
+## Change the extension if needed.
+         ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+         case "$$ext" in \
+           %SECTION%*) ;; \
+           *) ext='%SECTION%' ;; \
          esac; \
-       done; \
+## Extract basename of man page and append extension.
+         inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+         inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
+         echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+         rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+       done
+endif %?NOTRANS_MANS%
+if %?TRANS_MANS%
+## Handle MANS without notrans_ prefix
+       @list='%TRANS_SECT_LIST%'; \
+## Extract all items from man_MANS that should go in this section.
+## This must be done dynamically to support conditionals.
+?HAVE_TRANS?   l2='%TRANS_LIST%'; \
+?HAVE_TRANS?   for i in $$l2; do \
+?HAVE_TRANS?     case "$$i" in \
+## Have to accept files like `foo.1c'.
+?HAVE_TRANS?       *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_TRANS?     esac; \
+?HAVE_TRANS?   done; \
        for i in $$list; do \
 ## Change the extension if needed.
          ext=`echo $$i | sed -e 's/^.*\\.//'`; \
@@ -97,3 +157,4 @@
          echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
          rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
        done
+endif %?TRANS_MANS%
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti 
automake-1.10.1.orig/doc/automake.texi automake-1.10.1/doc/automake.texi
--- automake-1.10.1.orig/doc/automake.texi      2008-01-21 23:41:02.000000000 
+0100
+++ automake-1.10.1/doc/automake.texi   2008-03-08 01:15:41.000000000 +0100
@@ -1034,7 +1034,8 @@
 @cindex Programs, renaming during installation
 
 The GNU Build System provides means to automatically rename
-executables before they are installed.  This is especially convenient
+executables and manpages before they are installed (@pxref{Man pages}).
+This is especially convenient
 when installing a GNU package on a system that already has a
 proprietary implementation you do not want to overwrite.  For instance,
 you may want to install GNU @command{tar} as @command{gtar} so you can
@@ -1962,8 +1963,9 @@
 
 Some primaries also allow additional prefixes that control other
 aspects of @command{automake}'s behavior.  The currently defined prefixes
-are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}.  These prefixes
-are explained later (@pxref{Program and Library Variables}).
+are @samp{dist_}, @samp{nodist_}, @samp{nobase_}, and @samp{notrans_}.
+These prefixes are explained later (@pxref{Program and Library Variables})
+(@pxref{Man pages}).
 
 
 @node Canonicalization
@@ -7633,6 +7635,32 @@
 The @code{nobase_} prefix is meaningless for man pages and is
 disallowed.
 
[EMAIL PROTECTED] notrans_
[EMAIL PROTECTED] @code{notrans_} prefix
[EMAIL PROTECTED] Man page renaming, avoiding
[EMAIL PROTECTED] Avoiding man page renaming
+
+Executables and manpages may be renamed upon installation
+(@pxref{Renaming}).  For manpages this can be avoided by use of the
[EMAIL PROTECTED] prefix.  For instance, suppose an executable @samp{foo}
+allowing to access a library function @samp{foo()} from the command line.
+The way to avoid renaming of the @file{foo.3} manpage is:
+
[EMAIL PROTECTED]
+man_MANS = foo.1
+notrans_man_MANS = foo.3
[EMAIL PROTECTED] example
+
[EMAIL PROTECTED] @code{notrans_} and @code{dist_} or @code{nodist_}
[EMAIL PROTECTED] @code{dist_} and @code{notrans_}
[EMAIL PROTECTED] @code{nodist_} and @code{notrans_}
+
[EMAIL PROTECTED] must be specified first when used in conjunction with
+either @samp{dist_} or @samp{nodist_} (@pxref{Dist}).  For instance:
+
[EMAIL PROTECTED]
+notrans_dist_man3_MANS = bar.3
[EMAIL PROTECTED] example
 
 @node Install
 @chapter What Gets Installed
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti 
automake-1.10.1.orig/tests/Makefile.am automake-1.10.1/tests/Makefile.am
--- automake-1.10.1.orig/tests/Makefile.am      2008-02-20 09:38:10.000000000 
+0100
+++ automake-1.10.1/tests/Makefile.am   2008-03-07 23:12:35.000000000 +0100
@@ -393,6 +393,7 @@
 noinstdir.test \
 nolink.test \
 nostdinc.test \
+notrans.test \
 number.test \
 objc.test \
 objc2.test \
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti 
automake-1.10.1.orig/tests/Makefile.in automake-1.10.1/tests/Makefile.in
--- automake-1.10.1.orig/tests/Makefile.in      2008-02-20 09:38:10.000000000 
+0100
+++ automake-1.10.1/tests/Makefile.in   2008-03-07 23:12:37.000000000 +0100
@@ -525,6 +525,7 @@
 noinstdir.test \
 nolink.test \
 nostdinc.test \
+notrans.test \
 number.test \
 objc.test \
 objc2.test \
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti 
automake-1.10.1.orig/tests/notrans.test automake-1.10.1/tests/notrans.test
--- automake-1.10.1.orig/tests/notrans.test     1970-01-01 01:00:00.000000000 
+0100
+++ automake-1.10.1/tests/notrans.test  2008-03-07 23:08:42.000000000 +0100
@@ -0,0 +1,115 @@
+#! /bin/sh
+# Copyright (C) 2008  Free Software Foundation, Inc.
+#
+# 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 3, 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, see <http://www.gnu.org/licenses/>.
+
+# Check all notrans_, dist_, nodist_ prefix combinations for MANS
+# primary and install-man dependencies.
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'EOF'
+man_MANS = foo.1
+dist_man_MANS = bar.2
+nodist_man_MANS = baz.3
+notrans_man_MANS = x-foo.4
+notrans_dist_man_MANS = x-bar.5
+notrans_nodist_man_MANS = x-baz.6
+man7_MANS = y-foo.man
+dist_man5_MANS = y-bar.man
+nodist_man4_MANS = y-baz.man
+notrans_man3_MANS = z-foo.man
+notrans_dist_man2_MANS = z-bar.man
+notrans_nodist_man1_MANS = z-baz.man
+
+# These two are ignored
+dist_notrans_man_MANS = nosuch.8
+nodist_notrans_man9_MANS = nosuch.man
+
+y-foo.man:
+       : >$@
+y-bar.man:
+       : >$@
+y-baz.man:
+       : >$@
+z-foo.man:
+       : >$@
+z-bar.man:
+       : >$@
+z-baz.man:
+       : >$@
+
+test-install: install
+       test -f inst/man/man1/gnu-foo.1
+       test -f inst/man/man2/gnu-bar.2
+       test -f inst/man/man3/gnu-baz.3
+       test -f inst/man/man4/x-foo.4
+       test -f inst/man/man5/x-bar.5
+       test -f inst/man/man6/x-baz.6
+       test -f inst/man/man7/gnu-y-foo.7
+       test -f inst/man/man5/gnu-y-bar.5
+       test -f inst/man/man4/gnu-y-baz.4
+       test -f inst/man/man3/z-foo.3
+       test -f inst/man/man2/z-bar.2
+       test -f inst/man/man1/z-baz.1
+       if test -d inst/man/man8; then (exit 1); else :; fi
+       if test -d inst/man/man9; then (exit 1); else :; fi
+EOF
+
+: > foo.1
+: > bar.2
+: > baz.3
+: > x-foo.4
+: > x-bar.5
+: > x-baz.6
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+grep '^install-man1:' Makefile.in | grep '\$(man_MANS)'
+grep '^install-man2:' Makefile.in | grep '\$(dist_man_MANS)'
+grep '^install-man3:' Makefile.in | grep '\$(nodist_man_MANS)'
+grep '^install-man4:' Makefile.in | grep '\$(notrans_man_MANS)'
+grep '^install-man5:' Makefile.in | grep '\$(notrans_dist_man_MANS)'
+grep '^install-man6:' Makefile.in | grep '\$(notrans_nodist_man_MANS)'
+
+if grep '^install-man8:' Makefile.in; then exit 1; else :; fi
+if grep '^install-man9:' Makefile.in; then exit 1; else :; fi
+
+./configure --program-prefix=gnu- --prefix "`pwd`"/inst --mandir 
"`pwd`"/inst/man
+$MAKE
+$MAKE test-install
+test `find inst/man -type f -print | wc -l` = 12
+$MAKE uninstall
+test `find inst/man -type f -print | wc -l` = 0
+
+# Opportunistically test for installdirs.
+rm -rf inst
+$MAKE installdirs
+test -d inst/man/man1
+test -d inst/man/man2
+test -d inst/man/man3
+test -d inst/man/man4
+test -d inst/man/man5
+test -d inst/man/man6
+test -d inst/man/man7
+if test -d inst/man/man8; then exit 1; else :; fi
+if test -d inst/man/man9; then exit 1; else :; fi

Reply via email to