2 BEGIN { @INC = qw(lib) }
7 if ($Config{userelocatableinc}) {
8 # This might be a considered a hack. Need to get information about the
9 # configuration from Config.pm *before* Config.pm expands any .../
12 # So we set $^X to pretend that we're the already installed perl, so
13 # Config.pm doesits ... expansion off that location.
15 my $location = $Config{initialinstalllocation};
16 die <<'OS' unless defined $location;
17 $Config{initialinstalllocation} is not defined - can't install a relocatable
20 $^X = "$location/perl";
21 # And then remove all trace of ever having loaded Config.pm, so that
22 # it will reload with the revised $^X
24 delete $INC{"Config.pm"};
25 delete $INC{"Config_heavy.pl"};
26 # You never saw us. We weren't here.
34 use File::Path qw(mkpath);
35 use ExtUtils::Packlist;
37 use subs qw(unlink chmod rename link);
38 use vars qw($packlist);
39 use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $Is_Darwin $Is_NetWare);
42 $Is_VMS = $^O eq 'VMS';
43 $Is_W32 = $^O eq 'MSWin32';
44 $Is_OS2 = $^O eq 'os2';
45 $Is_Cygwin = $^O eq 'cygwin';
46 $Is_Darwin = $^O eq 'darwin';
47 if ($Is_VMS) { eval 'use VMS::Filespec;' }
50 if ($Config{d_umask}) {
51 umask(022); # umasks like 077 aren't that useful for installations
54 $ENV{SHELL} = 'sh' if $^O eq 'os2';
56 my $ver = $Config{version}; # Not used presently.
57 my $release = substr($],0,3); # Not used presently.
58 my $patchlevel = substr($],3,2);
59 die "Patchlevel of perl ($patchlevel)",
60 "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n"
61 if $patchlevel != $Config{'PERL_VERSION'};
64 "Usage: installman --man1dir=/usr/wherever --man1ext=1
65 --man3dir=/usr/wherever --man3ext=3
67 --notify --verbose --silent --help
69 man1dir = $Config{'installman1dir'};
70 man1ext = $Config{'man1ext'};
71 man3dir = $Config{'installman3dir'};
72 man3ext = $Config{'man3ext'};
73 --notify (or -n) just lists commands that would be executed.
74 --verbose (or -V) report all progress.
75 --silent (or -S) be silent. Only report errors.\n";
79 qw( man1dir=s man1ext=s man3dir=s man3ext=s batchlimit=i
80 destdir:s notify n help silent S verbose V))
82 die $usage if $opts{help};
83 $opts{destdir} //= '';
85 $opts{man1dir} = "$opts{destdir}$Config{'installman1dir'}"
86 unless defined($opts{man1dir});
87 $opts{man1ext} = $Config{'man1ext'}
88 unless defined($opts{man1ext});
89 $opts{man3dir} = "$opts{destdir}$Config{'installman3dir'}"
90 unless defined($opts{man3dir});
91 $opts{man3ext} = $Config{'man3ext'}
92 unless defined($opts{man3ext});
93 $opts{silent} ||= $opts{S};
94 $opts{notify} ||= $opts{n};
95 $opts{verbose} ||= $opts{V} || $opts{notify};
99 -x "./perl$Config{exe_ext}"
100 or warn "./perl$Config{exe_ext} not found! Have you run make?\n";
101 -d "$opts{destdir}$Config{'installprivlib'}"
102 || warn "Perl library directory $Config{'installprivlib'} not found.
103 Have you run make install?. (Installing anyway.)\n";
104 -x "t/perl$Config{exe_ext}" || warn "WARNING: You've never run 'make test'!!!",
105 " (Installing anyway.)\n";
107 $packlist = ExtUtils::Packlist->new("$opts{destdir}$Config{installarchlib}/.packlist");
110 # Install the main pod pages.
111 pod2man('pod', $opts{man1dir}, $opts{man1ext});
113 # Install the pods for library modules.
114 pod2man('lib', $opts{man3dir}, $opts{man3ext});
116 # Install the pods embedded in the installed scripts
117 my $has_man1dir = $opts{man1dir} ne '' && -d $opts{man1dir};
118 open UTILS, "utils.lst" or die "Can't open 'utils.lst': $!";
122 $_ = $1 if /#.*pod\s*=\s*(\S+)/;
123 my ($where, $what) = m|^(\S*)/(\S+)|;
124 pod2man($where, $opts{man1dir}, $opts{man1ext}, $what);
126 if (my ($where2, $what2) = m|#.*link\s*=\s*(\S+)/(\S+)|) {
127 my $old = "$opts{man1dir}/$what.$opts{man1ext}";
128 my $new = "$opts{man1dir}/$what2.$opts{man1ext}";
132 $xold =~ s/^\Q$opts{'destdir'}\E// if $opts{'destdir'};
134 $xnew =~ s/^\Q$opts{'destdir'}\E// if $opts{'destdir'};
135 $packlist->{$xnew} = { from => $xold, type => 'link' };
141 # @script is scripts names if we are installing manpages embedded
142 # in scripts, () otherwise
143 my($poddir, $mandir, $manext, @script) = @_;
144 if ($mandir eq ' ' or $mandir eq '') {
146 warn "Skipping installation of $poddir/$_ man page.\n"
149 warn "Skipping installation of $poddir man pages.\n";
154 print "installing from $poddir\n" if $opts{verbose};
156 mkpath($mandir, $opts{verbose}, 0777) unless $opts{notify}; # In File::Path
157 # Make a list of all the .pm and .pod files in the directory. We avoid
158 # chdir because we are running with @INC = '../lib', and modules may wish
159 # to dynamically require Carp::Heavy or other diagnostics warnings.
160 # Hash the names of files we find, keys are names relative to perl build
161 # dir ('.'), values are names relative to $poddir.
164 %modpods = (map {+"$poddir/$_", $_} @script);
167 File::Find::find({no_chdir=>1,
169 # $_ is $File::Find::name when using no_chdir
170 if (-f $_ and /\.p(?:m|od)$/) {
173 $modpods{$fullname} = $_;
179 foreach my $mod (sort keys %modpods) {
180 my $manpage = $modpods{$mod};
182 # Skip .pm files that have corresponding .pod files, and Functions.pm.
183 next if (($tmp = $mod) =~ s/\.pm$/.pod/ && -f $tmp);
184 next if $mod =~ m:/t/:; # no pods from test directories
185 next if ($manpage eq 'Pod/Functions.pm'); #### Used only by pod itself
187 # Skip files without pod docs
194 ++$has_pod and last if /^=(?:head\d+|item|pod)\b/;
202 warn "no documentation in $mod\n";
206 # Convert name from File/Basename.pm to File::Basename.3 format,
208 $manpage =~ s#\.p(m|od)$##;
209 if ($^O eq 'os2' || $^O eq 'amigaos' || $^O eq 'uwin' || $^O eq 'cygwin') {
213 $manpage =~ s#/#::#g;
215 $tmp = "${mandir}/${manpage}.tmp";
216 $manpage = "${mandir}/${manpage}.${manext}";
217 push @to_process, [$mod, $tmp, $manpage];
220 foreach my $page (@to_process) {
221 my($pod, $tmp, $manpage) = @$page;
223 my $parser = Pod::Man->new( section => $manext,
225 center => 'Perl Programmers Reference Guide'
227 my $xmanpage = $manpage;
228 $xmanpage =~ s/^\Q$opts{'destdir'}\E// if $opts{'destdir'};
229 print " $xmanpage\n";
230 if (!$opts{notify} && $parser->parse_from_file($pod, $tmp)) {
232 if (rename($tmp, $manpage)) {
233 $packlist->{$xmanpage} = { type => 'file' };
242 $packlist->write() unless $opts{notify};
243 print " Installation complete\n" if $opts{verbose};
247 ###############################################################################
248 # Utility subroutines from installperl
254 return scalar(@names) if $Is_VMS;
256 foreach my $name (@names) {
257 next unless -e $name;
258 chmod 0777, $name if $^O eq 'os2';
259 print " unlink $name\n" if $opts{verbose};
260 ( CORE::unlink($name) and ++$cnt
261 or warn "Couldn't unlink $name: $!\n" ) unless $opts{notify};
270 print " ln $from $to\n" if $opts{verbose};
272 CORE::link($from, $to)
274 : ($from =~ m#^/afs/# || $to =~ m#^/afs/#)
275 ? die "AFS" # okay inside eval {}
276 : die "Couldn't link $from to $to: $!\n"
277 unless $opts{notify};
280 File::Copy::copy($from, $to)
282 : warn "Couldn't copy $from to $to: $!\n"
283 unless $opts{notify};
290 if (-f $to and not unlink($to)) {
292 for ($i = 1; $i < 50; $i++) {
293 last if CORE::rename($to, "$to.$i");
295 warn("Cannot rename to `$to.$i': $!"), return 0
296 if $i >= 50; # Give up!
298 link($from,$to) || return 0;
303 my($mode,$name) = @_;
305 printf " chmod %o %s\n", $mode, $name if $opts{verbose};
306 CORE::chmod($mode,$name) || warn sprintf("Couldn't chmod %o %s: $!\n",$mode,$name)
307 unless $opts{notify};
312 my($dev1, $ino1, $dev2, $ino2);
314 return (lc($p1) eq lc($p2)) if ($Is_W32 || $Is_NetWare);
317 ($dev1, $ino1) = stat($p1);
318 ($dev2, $ino2) = stat($p2);
319 ($dev1 == $dev2 && $ino1 == $ino2);