This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add comments explaining why win32.h/embed.h are included where they are
[perl5.git] / installman
index c1f3837..6e00774 100755 (executable)
@@ -11,6 +11,10 @@ use subs qw(unlink chmod rename link);
 use vars qw($packlist @modpods);
 require Cwd;
 
+if ($Config{d_umask}) {
+    umask(022); # umasks like 077 aren't that useful for installations
+}
+
 $ENV{SHELL} = 'sh' if $^O eq 'os2';
 
 my $ver = $Config{version};     # Not used presently.
@@ -23,19 +27,21 @@ die "Patchlevel of perl ($patchlevel)",
 my $usage =
 "Usage:  installman --man1dir=/usr/wherever --man1ext=1
                    --man3dir=/usr/wherever --man3ext=3
+                  --batchlimit=40
                   --notify --verbose --silent --help
        Defaults are:
        man1dir = $Config{'installman1dir'};
        man1ext = $Config{'man1ext'};
        man3dir = $Config{'installman3dir'};
        man3ext = $Config{'man3ext'};
+        batchlimit is maximum number of pod files per invocation of pod2man
        --notify  (or -n) just lists commands that would be executed.
         --verbose (or -V) report all progress.
         --silent  (or -S) be silent. Only report errors.\n";
 
 my %opts;
 GetOptions( \%opts,
-            qw( man1dir=s man1ext=s man3dir=s man3ext=s
+            qw( man1dir=s man1ext=s man3dir=s man3ext=s batchlimit=i
                 notify n help silent S verbose V)) 
        || die $usage;
 die $usage if $opts{help};
@@ -48,6 +54,7 @@ $opts{man3dir} = $Config{'installman3dir'}
     unless defined($opts{man3dir}); 
 $opts{man3ext} = $Config{'man3ext'}
     unless defined($opts{man3ext}); 
+$opts{batchlimit} ||= 40;
 $opts{silent} ||= $opts{S};
 $opts{notify} ||= $opts{n};
 $opts{verbose} ||= $opts{V} || $opts{notify};
@@ -64,6 +71,7 @@ $opts{verbose} ||= $opts{V} || $opts{notify};
 
 $packlist = ExtUtils::Packlist->new("$Config{installarchlib}/.packlist");
 
+
 # Install the main pod pages.
 runpod2man('pod', $opts{man1dir}, $opts{man1ext});
 
@@ -71,36 +79,22 @@ runpod2man('pod', $opts{man1dir}, $opts{man1ext});
 runpod2man('lib', $opts{man3dir}, $opts{man3ext});
 
 # Install the pods embedded in the installed scripts
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'c2ph');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'h2ph');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'h2xs');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'perlcc');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'perldoc');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'perlbug');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'pl2pm');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'splain');
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'dprofpp');
-runpod2man('x2p', $opts{man1dir}, $opts{man1ext}, 's2p');
-runpod2man('x2p', $opts{man1dir}, $opts{man1ext}, 'a2p.pod');
-runpod2man('x2p', $opts{man1dir}, $opts{man1ext}, 'find2perl');
-runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2man');
-runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2html');
-runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2text');
-runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'pod2usage');
-runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'podchecker');
-runpod2man('pod', $opts{man1dir}, $opts{man1ext}, 'podselect');
-
-# It would probably be better to have this page linked
-# to the c2ph man page.  Or, this one could say ".so man1/c2ph.1",
-# but then it would have to pay attention to $opts{man1dir} and $opts{man1ext}.
-runpod2man('utils', $opts{man1dir}, $opts{man1ext}, 'pstruct'); 
-
-runpod2man('lib/ExtUtils', $opts{man1dir}, $opts{man1ext}, 'xsubpp');
+open UTILS, "utils.lst" or die "Can't open 'utils.lst': $!";
+while (<UTILS>) {
+    next if /^#/;
+    chomp;
+    $_ = $1 if /#.*pod\s*=\s*(\S+)/;
+    my ($where, $what) = m|^(.*?)/(\S+)|;
+    runpod2man($where, $opts{man1dir}, $opts{man1ext}, $what);
+    if (($where, $what) = m|#.*link\s*=\s*(\S+)/(\S+)|) {
+        runpod2man($where, $opts{man1dir}, $opts{man1ext}, $what);
+    }
+}
 
 sub runpod2man {
-    # $script is script name if we are installing a manpage embedded 
-    # in a script, undef otherwise
-    my($poddir, $mandir, $manext, $script) = @_;
+    # @script is scripts names if we are installing manpages embedded 
+    # in scripts, () otherwise
+    my($poddir, $mandir, $manext, @script) = @_;
 
     my($downdir); # can't just use .. when installing xsubpp manpage
 
@@ -109,8 +103,12 @@ sub runpod2man {
     my($builddir) = Cwd::getcwd();
 
     if ($mandir eq ' ' or $mandir eq '') {
-       warn "Skipping installation of ",
-           ($script ? "$poddir/$script man page" : "$poddir man pages"), ".\n";
+       if (@script) {
+           warn "Skipping installation of $poddir/$_ man page.\n"
+               foreach @script;
+       } else {
+           warn "Skipping installation of $poddir man pages.\n";
+       }
        return;
     }
 
@@ -130,17 +128,18 @@ sub runpod2man {
     # installed by occult means.)
     my $pod2man = "$downdir/perl -I $downdir/lib $downdir/pod/pod2man --section=$manext --official";
 
-    mkpath($mandir, $verbose, 0777) unless $notify;  # In File::Path
+    mkpath($mandir, $opts{verbose}, 0777) unless $opts{notify};  # In File::Path
     # Make a list of all the .pm and .pod files in the directory.  We will
     # always run pod2man from the lib directory and feed it the full pathname
     # of the pod.  This might be useful for pod2man someday.
-    if ($script) {
-       @modpods = ($script);
+    if (@script) {
+       @modpods = @script;
     }
     else {
        @modpods = ();
        File::Find::find(\&lsmodpods, '.');
     }
+    my @to_process;
     foreach my $mod (@modpods) {
        my $manpage = $mod;
        my $tmp;
@@ -159,15 +158,25 @@ sub runpod2man {
        }
        $tmp = "${mandir}/${manpage}.tmp";
        $manpage = "${mandir}/${manpage}.${manext}";
-       if (&cmd("$pod2man $mod > $tmp") == 0 && !$opts{notify} && -s $tmp) {
-           if (rename($tmp, $manpage)) {
-               $packlist->{$manpage} = { type => 'file' };
-               next;
+       push @to_process, [$mod, $tmp, $manpage];
+    }
+    # Don't do all pods in same command to avoid busting command line limits
+    while (my @this_batch = splice @to_process, 0, $opts{batchlimit}) {
+       my $cmd = join " ", $pod2man, map "$$_[0] $$_[1]", @this_batch;
+       if (&cmd($cmd) == 0 && !$opts{notify}) {
+           foreach (@this_batch) {
+               my (undef, $tmp, $manpage) = @$_;
+               if (-s $tmp) {
+                   if (rename($tmp, $manpage)) {
+                       $packlist->{$manpage} = { type => 'file' };
+                       next;
+                   }
+               }
+               unless ($opts{notify}) {
+                   unlink($tmp);
+               }
            }
        }
-       unless ($opts{notify}) {
-           unlink($tmp);
-       }
     }
     chdir "$builddir" || die "Unable to cd back to $builddir directory!\n$!\n";
     print "  chdir $builddir\n" if $opts{verbose};