2 BEGIN { @INC = ('lib') }
6 use File::Path qw(mkpath);
12 $release = substr($ver,0,3); # Not used presently.
13 $patchlevel = substr($ver,3,2);
14 die "Patchlevel of perl ($patchlevel)",
15 "and patchlevel of config.sh ($Config{'PATCHLEVEL'}) don't match\n"
16 if $patchlevel != $Config{'PATCHLEVEL'};
19 "Usage: installman --man1dir=/usr/wherever --man1ext=1
20 --man3dir=/usr/wherever --man3ext=3
23 man1dir = $Config{'installman1dir'};
24 man1ext = $Config{'man1ext'};
25 man3dir = $Config{'installman3dir'};
26 man3ext = $Config{'man3ext'};
27 --notify (or -n) just lists commands that would be executed.\n";
29 GetOptions( qw( man1dir=s man1ext=s man3dir=s man3ext=s notify help))
31 die $usage if $opt_help;
33 # These are written funny to avoid -w typo warnings.
34 $man1dir = defined($opt_man1dir) ? $opt_man1dir : $Config{'installman1dir'};
35 $man1ext = defined($opt_man1ext) ? $opt_man1ext : $Config{'man1ext'};
36 $man3dir = defined($opt_man3dir) ? $opt_man3dir : $Config{'installman3dir'};
37 $man3ext = defined($opt_man3ext) ? $opt_man3ext : $Config{'man3ext'};
39 $notify = defined($opt_notify) ? $opt_notify : 0;
43 -x "./perl" || warn "./perl not found! Have you run make?\n";
44 -d $Config{'installprivlib'}
45 || warn "Perl library directory $Config{'installprivlib'} not found.
46 Have you run make install?. (Installing anyway.)\n";
47 -x 't/TEST' || warn "WARNING: You've never run 'make test'!!!",
48 " (Installing anyway.)\n";
50 # Install the main pod pages.
51 runpod2man('pod', $man1dir, $man1ext);
53 # Install the pods for library modules.
54 runpod2man('lib', $man3dir, $man3ext);
57 my($poddir, $mandir, $manext) = @_;
58 my($builddir) = Cwd::getcwd();
60 if ($mandir eq ' ' or $mandir eq '') {
61 print STDERR "Skipping installation of $poddir man pages.\n";
65 chdir $poddir || die "Unable to cd to $poddir directory!\n$!\n";
67 # We insist on using the current version of pod2man in case there
68 # are enhancements or changes from previous installed versions.
69 # The error message doesn't include the '..' because the user
70 # won't be aware that we've chdir to $poddir.
71 -x "../pod/pod2man" || die "Executable pod/pod2man not found.\n";
73 # We want to be sure to use the current perl. We can't rely on
74 # the installed perl because it might not be actually installed
75 # yet. (The user may have set the $install* Configure variables
76 # to point to some temporary home, from which the executable gets
77 # installed by occult means.)
78 $pod2man = "../perl -I ../lib ../pod/pod2man --section=$manext --official";
80 mkpath($mandir, 1, 0777); # In File::Path
81 # Make a list of all the .pm and .pod files in the directory. We will
82 # always run pod2man from the lib directory and feed it the full pathname
83 # of the pod. This might be useful for pod2man someday.
85 find(\&lsmodpods, '.');
86 foreach $mod (@modpods) {
88 # Convert name from File/Basename.pm to File::Basename.3 format,
90 $manpage =~ s#\.p(m|od)$##;
92 $manpage = "${mandir}/${manpage}.${manext}";
93 &cmd("$pod2man $mod > $manpage");
95 print STDERR "unlink $manpage\n";
97 unlink($manpage) || warn "cannot unlink $manpage: $!";
101 chdir "$builddir" || die "Unable to cd back to $builddir directory!\n$!\n";
105 my $dir = $File::Find::dir;
106 my $name = $File::Find::name;
109 push(@modpods, $name) if ($name =~ /\.p(m|od)$/);
113 print STDERR " Installation complete\n";
118 ###############################################################################
119 # Utility subroutines from installperl
123 print STDERR " $cmd\n";
125 if ($Config{d_fork}) {
126 fork ? wait : exec $cmd; # Allow user to ^C out of command.
131 warn "Command failed!!\n" if $?;
137 local($from,$to) = @_;
139 print STDERR " ln $from $to\n";
140 link($from,$to) || warn "Couldn't link $from to $to: $!\n" unless $notify;
144 local($mode,$name) = @_;
146 printf STDERR " chmod %o %s\n", $mode, $name;
147 chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name)
152 local($p1, $p2) = @_;
153 local($dev1, $ino1, $dev2, $ino2);
156 ($dev1, $ino1) = stat($p1);
157 ($dev2, $ino2) = stat($p2);
158 ($dev1 == $dev2 && $ino1 == $ino2);