add Pod-Parser-1.08 (verbatim module =include tests elided owing
[p5sagit/p5-mst-13.2.git] / installperl
CommitLineData
c623bd54 1#!./perl
68dc0745 2
3BEGIN {
c90c0ff4 4 require 5.004;
d07c2202 5 chdir '..' if !-d 'lib' and -d '..\lib';
68dc0745 6 @INC = 'lib';
7 $ENV{PERL5LIB} = 'lib';
a29d2910 8}
9
10use strict;
11use vars qw($Is_VMS $Is_W32 $Is_OS2 $nonono $versiononly $depth);
12
13BEGIN {
17f28c40 14 $Is_VMS = $^O eq 'VMS';
4a71ed0c 15 $Is_W32 = $^O eq 'MSWin32';
16 $Is_OS2 = $^O eq 'os2';
17f28c40 17 if ($Is_VMS) { eval 'use VMS::Filespec;' }
68dc0745 18}
19
c2cd2081 20my $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : '');
4a71ed0c 21
a0d0e21e 22use File::Find;
5f05dabc 23use File::Compare;
68dc0745 24use File::Copy ();
0ecb046b 25use File::Path ();
354f3b56 26use ExtUtils::Packlist;
4633a7c4 27use Config;
91a06757 28use subs qw(unlink link chmod);
354f3b56 29use vars qw($packlist);
c623bd54 30
0ecb046b 31# override the ones in the rest of the script
68dc0745 32sub mkpath {
33 File::Path::mkpath(@_) unless $nonono;
0ecb046b 34}
35
c2cd2081 36my $mainperldir = "/usr/bin";
37my $exe_ext = $Config{exe_ext};
bee1dbe2 38
6ee623d5 39# Allow ``make install PERLNAME=something_besides_perl'':
c2cd2081 40my $perl = defined($ENV{PERLNAME}) ? $ENV{PERLNAME} : 'perl';
6ee623d5 41
c623bd54 42while (@ARGV) {
43 $nonono = 1 if $ARGV[0] eq '-n';
44 $versiononly = 1 if $ARGV[0] eq '-v';
45 shift;
46}
47
17f28c40 48umask 022 unless $Is_VMS;
45d8adaa 49
c2cd2081 50my @scripts = qw(utils/c2ph utils/h2ph utils/h2xs utils/perlbug utils/perldoc
4a71ed0c 51 utils/pl2pm utils/splain utils/perlcc
6ee623d5 52 x2p/s2p x2p/find2perl
360aca43 53 pod/pod2man pod/pod2html pod/pod2latex pod/pod2text
54 pod/pod2usage pod/podchecker pod/podselect);
16d20bd9 55
4a71ed0c 56if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; }
17f28c40 57
c2cd2081 58my @pods = (<pod/*.pod>);
c623bd54 59
e8ea6127 60# Specify here any .pm files that are actually architecture-dependent.
61# (Those included with XS extensions under ext/ are automatically
62# added later.)
63# Now that the default privlib has the full perl version number included,
64# we no longer have to play the trick of sticking version-specific .pm
65# files under the archlib directory.
c2cd2081 66my %archpms = (
e8ea6127 67 Config => 1,
38b8243a 68);
39e571d4 69
70if ($^O eq 'dos') {
71 push(@scripts,'djgpp/fixpmain');
72 $archpms{config} = $archpms{filehand} = 1;
73}
74
6ee623d5 75if ((-e "testcompile") && (defined($ENV{'COMPILE'})))
76{
77 push(@scripts, map("$_.exe", @scripts));
78}
79
1dd15ed4 80find(sub {
81 if ("$File::Find::dir/$_" =~ m{^ext/[^/]+/(.*)\.pm$}) {
82 (my $pm = $1) =~ s{^lib/}{};
83 $archpms{$pm} = 1;
84 }
85 }, 'ext');
86
c2cd2081 87my $ver = $];
88my $release = substr($ver,0,3); # Not used presently.
89my $patchlevel = substr($ver,3,2);
748a9306 90die "Patchlevel of perl ($patchlevel)",
cceca5ed 91 "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n"
92 if $patchlevel != $Config{'PERL_VERSION'};
4633a7c4 93
94# Fetch some frequently-used items from %Config
c2cd2081 95my $installbin = $Config{installbin};
96my $installscript = $Config{installscript};
97my $installprivlib = $Config{installprivlib};
98my $installarchlib = $Config{installarchlib};
99my $installsitelib = $Config{installsitelib};
100my $installsitearch = $Config{installsitearch};
101my $installman1dir = $Config{installman1dir};
102my $man1ext = $Config{man1ext};
103my $libperl = $Config{libperl};
4633a7c4 104# Shared library and dynamic loading suffixes.
c2cd2081 105my $so = $Config{so};
106my $dlext = $Config{dlext};
4633a7c4 107
c2cd2081 108my $d_dosuid = $Config{d_dosuid};
109my $binexp = $Config{binexp};
c623bd54 110
17f28c40 111if ($Is_VMS) { # Hang in there until File::Spec hits the big time
112 foreach ( \$installbin, \$installscript, \$installprivlib,
113 \$installarchlib, \$installsitelib, \$installsitearch,
114 \$installman1dir ) {
115 $$_ = unixify($$_); $$_ =~ s:/$::;
116 }
117}
118
c623bd54 119# Do some quick sanity checks.
120
121if ($d_dosuid && $>) { die "You must run as root to install suidperl\n"; }
122
fe14fcc3 123 $installbin || die "No installbin directory in config.sh\n";
fcbdbaa8 124-d $installbin || mkpath($installbin, 1, 0777);
0ecb046b 125-d $installbin || $nonono || die "$installbin is not a directory\n";
126-w $installbin || $nonono || die "$installbin is not writable by you\n"
3edbfbe5 127 unless $installbin =~ m#^/afs/# || $nonono;
c623bd54 128
39add537 129-x 'perl' . $exe_ext || die "perl isn't executable!\n";
130-x 'suidperl' . $exe_ext|| die "suidperl isn't executable!\n" if $d_dosuid;
c623bd54 131
4a71ed0c 132-x 't/TEST' || $Is_W32
d07c2202 133 || warn "WARNING: You've never run 'make test'!!!",
134 " (Installing anyway.)\n";
c623bd54 135
4a71ed0c 136if ($Is_W32) {
eef1cf2a 137
c2cd2081 138my $perldll = 'perl.' . $dlext;
f7a92b15 139$perldll = 'perlcore.' . $dlext if $Config{'ccflags'} =~ /PERL_OBJECT/i;
140
141-f $perldll || die "No perl DLL built\n";
eef1cf2a 142
143# Install the DLL
144
f7a92b15 145safe_unlink("$installbin/$perldll");
146copy("$perldll", "$installbin/$perldll");
147chmod(0755, "$installbin/$perldll");
eef1cf2a 148}
149
354f3b56 150# This will be used to store the packlist
c2cd2081 151my $packlist = ExtUtils::Packlist->new("$installarchlib/.packlist");
354f3b56 152
c623bd54 153# First we install the version-numbered executables.
154
17f28c40 155if ($Is_VMS) {
6ee623d5 156 safe_unlink("$installbin/$perl$exe_ext");
157 copy("perl$exe_ext", "$installbin/$perl$exe_ext");
158 chmod(0755, "$installbin/$perl$exe_ext");
159 safe_unlink("$installbin/${perl}shr$exe_ext");
160 copy("perlshr$exe_ext", "$installbin/${perl}shr$exe_ext");
161 chmod(0755, "$installbin/${perl}shr$exe_ext");
17f28c40 162}
1d84e8df 163elsif ($^O eq 'mpeix') {
164 # MPE lacks hard links and requires that executables with special
165 # capabilities reside in the MPE namespace.
166 safe_unlink("$installbin/perl$ver$exe_ext", $Config{perlpath});
167 # Install the primary executable into the MPE namespace as perlpath.
168 copy("perl$exe_ext", $Config{perlpath});
169 chmod(0755, $Config{perlpath});
170 # Create a backup copy with the version number.
171 link($Config{perlpath}, "$installbin/perl$ver$exe_ext");
172}
3f5ee302 173elsif ($^O ne 'dos') {
174 safe_unlink("$installbin/$perl$ver$exe_ext");
175 copy("perl$exe_ext", "$installbin/$perl$ver$exe_ext");
176 chmod(0755, "$installbin/$perl$ver$exe_ext");
177}
1d84e8df 178else {
6ee623d5 179 safe_unlink("$installbin/$perl.exe");
180 copy("perl.exe", "$installbin/$perl.exe");
39e571d4 181}
c623bd54 182
6ee623d5 183safe_unlink("$installbin/s$perl$ver$exe_ext");
c623bd54 184if ($d_dosuid) {
6ee623d5 185 copy("suidperl$exe_ext", "$installbin/s$perl$ver$exe_ext");
186 chmod(04711, "$installbin/s$perl$ver$exe_ext");
c623bd54 187}
188
45d8adaa 189# Install library files.
190
c2cd2081 191my ($do_installarchlib, $do_installprivlib) = (0, 0);
a0d0e21e 192
fcbdbaa8 193mkpath($installprivlib, 1, 0777);
194mkpath($installarchlib, 1, 0777);
195mkpath($installsitelib, 1, 0777) if ($installsitelib);
196mkpath($installsitearch, 1, 0777) if ($installsitearch);
4633a7c4 197
45d8adaa 198if (chdir "lib") {
68dc0745 199 $do_installarchlib = ! samepath($installarchlib, '.');
200 $do_installprivlib = ! samepath($installprivlib, '.');
b971f6e4 201 $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$]/);
45d8adaa 202
a0d0e21e 203 if ($do_installarchlib || $do_installprivlib) {
204 find(\&installlib, '.');
45d8adaa 205 }
206 chdir ".." || die "Can't cd back to source directory: $!\n";
207}
208else {
209 warn "Can't cd to lib to install lib files: $!\n";
210}
211
1aef975c 212# Install header files and libraries.
fcbdbaa8 213mkpath("$installarchlib/CORE", 1, 0777);
c2cd2081 214my @corefiles;
17f28c40 215if ($Is_VMS) { # We did core file selection during build
216 my $coredir = "lib/$Config{'arch'}/$]";
217 $coredir =~ tr/./_/;
218 @corefiles = <$coredir/*.*>;
219}
220else {
221 @corefiles = <*.h libperl*.*>;
222 # AIX needs perl.exp installed as well.
223 push(@corefiles,'perl.exp') if $^O eq 'aix';
9d7f10f2 224 if ($^O eq 'mpeix') {
225 # MPE needs mpeixish.h installed as well.
226 mkpath("$installarchlib/CORE/mpeix", 1, 0777);
227 push(@corefiles,'mpeix/mpeixish.h');
228 }
17f28c40 229 # If they have built sperl.o...
230 push(@corefiles,'sperl.o') if -f 'sperl.o';
231}
c2cd2081 232foreach my $file (@corefiles) {
aa3cf465 233 # HP-UX (at least) needs to maintain execute permissions
efc5ad56 234 # on dynamically-loadable libraries. So we do it for all.
68dc0745 235 copy_if_diff($file,"$installarchlib/CORE/$file")
efc5ad56 236 and chmod($file =~ /\.(so|\Q$dlext\E)$/ ? 0555 : 0444,
aa3cf465 237 "$installarchlib/CORE/$file");
340f689c 238}
3edbfbe5 239
156620fa 240# Install main perl executables
241# Make links to ordinary names if installbin directory isn't current directory.
242
17f28c40 243if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) {
6ee623d5 244 safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext");
1d84e8df 245 if ($^O eq 'mpeix') {
246 # MPE doesn't support hard links, so use a symlink.
247 # We don't want another cloned copy.
248 symlink($Config{perlpath}, "$installbin/perl$exe_ext");
249 } else {
250 link("$installbin/$perl$ver$exe_ext", "$installbin/$perl$exe_ext");
251 }
6ee623d5 252 link("$installbin/s$perl$ver$exe_ext", "$installbin/suid$perl$exe_ext")
156620fa 253 if $d_dosuid;
254}
255
a0d0e21e 256# Offer to install perl in a "standard" location
257
c2cd2081 258my $mainperl_is_instperl = 0;
a0d0e21e 259
472a4973 260if ($Config{installusrbinperl} eq 'define' &&
261 !$versiononly && !$nonono && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR
68dc0745 262 && -w $mainperldir && ! samepath($mainperldir, $installbin)) {
c2cd2081 263 my($usrbinperl) = "$mainperldir/$perl$exe_ext";
264 my($instperl) = "$installbin/$perl$exe_ext";
265 my($expinstperl) = "$binexp/$perl$exe_ext";
55497cff 266
267 # First make sure $usrbinperl is not already the same as the perl we
268 # just installed.
269 if (-x $usrbinperl) {
a0d0e21e 270 # Try to be clever about mainperl being a symbolic link
271 # to binexp/perl if binexp and installbin are different.
272 $mainperl_is_instperl =
68dc0745 273 samepath($usrbinperl, $instperl) ||
274 samepath($usrbinperl, $expinstperl) ||
a0d0e21e 275 (($binexp ne $installbin) &&
55497cff 276 (-l $usrbinperl) &&
277 ((readlink $usrbinperl) eq $expinstperl));
a0d0e21e 278 }
279 if ((! $mainperl_is_instperl) &&
68dc0745 280 (yn("Many scripts expect perl to be installed as $usrbinperl.\n" .
55497cff 281 "Do you wish to have $usrbinperl be the same as\n" .
282 "$expinstperl? [y] ")))
1d84e8df 283 {
55497cff 284 unlink($usrbinperl);
1d84e8df 285 ( $Config{'d_link'} eq 'define' &&
286 eval { CORE::link $instperl, $usrbinperl } ) ||
287 eval { symlink $expinstperl, $usrbinperl } ||
288 copy($instperl, $usrbinperl);
289
a0d0e21e 290 $mainperl_is_instperl = 1;
291 }
292}
293
b971f6e4 294# Make links to ordinary names if installbin directory isn't current directory.
295
68dc0745 296if (!$versiononly && ! samepath($installbin, 'x2p')) {
297 safe_unlink("$installbin/a2p$exe_ext");
298 copy("x2p/a2p$exe_ext", "$installbin/a2p$exe_ext");
299 chmod(0755, "$installbin/a2p$exe_ext");
b971f6e4 300}
301
302# cppstdin is just a script, but it is architecture-dependent, so
303# it can't safely be shared. Place it in $installbin.
304# Note that Configure doesn't build cppstin if it isn't needed, so
305# we skip this if cppstdin doesn't exist.
68dc0745 306if (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) {
307 safe_unlink("$installbin/cppstdin");
308 copy("cppstdin", "$installbin/cppstdin");
309 chmod(0755, "$installbin/cppstdin");
b971f6e4 310}
311
312# Install scripts.
313
314mkpath($installscript, 1, 0777);
315
316if (! $versiononly) {
317 for (@scripts) {
68dc0745 318 (my $base = $_) =~ s#.*/##;
319 copy($_, "$installscript/$base");
320 chmod(0755, "$installscript/$base");
b971f6e4 321 }
322}
323
324# pstruct should be a link to c2ph
325
326if (! $versiononly) {
4a71ed0c 327 safe_unlink("$installscript/pstruct$scr_ext");
17f28c40 328 if ($^O eq 'dos' or $Is_VMS) {
4a71ed0c 329 copy("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext");
39e571d4 330 } else {
4a71ed0c 331 link("$installscript/c2ph$scr_ext", "$installscript/pstruct$scr_ext");
39e571d4 332 }
b971f6e4 333}
334
335# Install pod pages. Where? I guess in $installprivlib/pod.
336
7dda0d2d 337unless ( $versiononly && !($installprivlib =~ m/\Q$]/)) {
b971f6e4 338 mkpath("${installprivlib}/pod", 1, 0777);
91a06757 339
340 # If Perl 5.003's perldiag.pod is there, rename it.
341 if (open POD, "${installprivlib}/pod/perldiag.pod") {
342 read POD, $_, 4000;
343 close POD;
344 # Some of Perl 5.003's diagnostic messages ended with periods.
345 if (/^=.*\.$/m) {
346 my ($from, $to) = ("${installprivlib}/pod/perldiag.pod",
347 "${installprivlib}/pod/perldiag-5.003.pod");
348 print STDERR " rename $from $to";
349 rename($from, $to)
350 or warn "Couldn't rename $from to $to: $!\n"
351 unless $nonono;
352 }
353 }
354
c2cd2081 355 foreach my $file (@pods) {
b971f6e4 356 # $file is a name like pod/perl.pod
68dc0745 357 copy_if_diff($file, "${installprivlib}/${file}");
b971f6e4 358 }
91a06757 359
b971f6e4 360}
361
a0d0e21e 362# Check to make sure there aren't other perls around in installer's
363# path. This is probably UNIX-specific. Check all absolute directories
364# in the path except for where public executables are supposed to live.
365# Also skip $mainperl if the user opted to have it be a link to the
366# installed perl.
367
b971f6e4 368if (!$versiononly) {
c2cd2081 369 my ($path, @path);
370 my $dirsep = ($Is_OS2 || $Is_W32) ? ';' : ':' ;
b971f6e4 371 ($path = $ENV{"PATH"}) =~ s:\\:/:g ;
372 @path = split(/$dirsep/, $path);
17f28c40 373 if ($Is_VMS) {
374 my $i = 0;
375 while (exists $ENV{'DCL$PATH' . $i}) {
c2cd2081 376 my $dir = unixpath($ENV{'DCL$PATH' . $i}); $dir =~ s-/$--;
17f28c40 377 push(@path,$dir);
378 }
379 }
c2cd2081 380 my @otherperls;
b971f6e4 381 for (@path) {
382 next unless m,^/,;
383 # Use &samepath here because some systems have other dirs linked
384 # to $mainperldir (like SunOS)
68dc0745 385 next if samepath($_, $binexp);
386 next if ($mainperl_is_instperl && samepath($_, $mainperldir));
6ee623d5 387 push(@otherperls, "$_/$perl$exe_ext")
388 if (-x "$_/$perl$exe_ext" && ! -d "$_/$perl$exe_ext");
b971f6e4 389 }
390 if (@otherperls) {
6ee623d5 391 print STDERR "\nWarning: $perl appears in your path in the following " .
b971f6e4 392 "locations beyond where\nwe just installed it:\n";
393 for (@otherperls) {
394 print STDERR " ", $_, "\n";
395 }
396 print STDERR "\n";
a0d0e21e 397 }
b971f6e4 398
a0d0e21e 399}
400
3f9aafa0 401$packlist->write() unless $nonono;
c623bd54 402print STDERR " Installation complete\n";
403
404exit 0;
405
406###############################################################################
407
a0d0e21e 408sub yn {
c2cd2081 409 my($prompt) = @_;
410 my($answer);
411 my($default) = $prompt =~ m/\[([yn])\]\s*$/i;
a0d0e21e 412 print STDERR $prompt;
413 chop($answer = <STDIN>);
414 $answer = $default if $answer =~ m/^\s*$/;
415 ($answer =~ m/^[yY]/);
416}
417
c623bd54 418sub unlink {
c2cd2081 419 my(@names) = @_;
39add537 420 my($cnt) = 0;
c623bd54 421
17f28c40 422 return scalar(@names) if $Is_VMS;
423
c2cd2081 424 foreach my $name (@names) {
c623bd54 425 next unless -e $name;
4a71ed0c 426 chmod 0777, $name if ($Is_OS2 || $Is_W32);
c623bd54 427 print STDERR " unlink $name\n";
39add537 428 ( CORE::unlink($name) and ++$cnt
429 or warn "Couldn't unlink $name: $!\n" ) unless $nonono;
c623bd54 430 }
39add537 431 return $cnt;
c623bd54 432}
433
e50aee73 434sub safe_unlink {
17f28c40 435 return if $nonono or $Is_VMS;
c2cd2081 436 my @names = @_;
437 foreach my $name (@names) {
e50aee73 438 next unless -e $name;
4a71ed0c 439 chmod 0777, $name if ($Is_OS2 || $Is_W32);
39add537 440 print STDERR " unlink $name\n";
441 next if CORE::unlink($name);
e50aee73 442 warn "Couldn't unlink $name: $!\n";
443 if ($! =~ /busy/i) {
444 print STDERR " mv $name $name.old\n";
68dc0745 445 safe_rename($name, "$name.old")
446 or warn "Couldn't rename $name: $!\n";
e50aee73 447 }
448 }
449}
450
68dc0745 451sub safe_rename {
c2cd2081 452 my($from,$to) = @_;
39add537 453 if (-f $to and not unlink($to)) {
e50aee73 454 my($i);
455 for ($i = 1; $i < 50; $i++) {
91a06757 456 last if rename($to, "$to.$i");
e50aee73 457 }
39add537 458 warn("Cannot rename to `$to.$i': $!"), return 0
459 if $i >= 50; # Give up!
e50aee73 460 }
461 link($from,$to) || return 0;
462 unlink($from);
463}
464
c623bd54 465sub link {
15792f64 466 my($from,$to) = @_;
467 my($success) = 0;
c623bd54 468
469 print STDERR " ln $from $to\n";
39add537 470 eval {
68dc0745 471 CORE::link($from, $to)
472 ? $success++
7bac28a0 473 : ($from =~ m#^/afs/# || $to =~ m#^/afs/#)
474 ? die "AFS" # okay inside eval {}
475 : warn "Couldn't link $from to $to: $!\n"
68dc0745 476 unless $nonono;
354f3b56 477 $packlist->{$to} = { from => $from, type => 'link' };
39add537 478 };
479 if ($@) {
17f28c40 480 print STDERR " creating new version of $to\n" if $Is_VMS and -e $to;
68dc0745 481 File::Copy::copy($from, $to)
482 ? $success++
483 : warn "Couldn't copy $from to $to: $!\n"
484 unless $nonono;
354f3b56 485 $packlist->{$to} = { type => 'file' };
39add537 486 }
15792f64 487 $success;
c623bd54 488}
489
490sub chmod {
c2cd2081 491 my($mode,$name) = @_;
c623bd54 492
39e571d4 493 return if ($^O eq 'dos');
c623bd54 494 printf STDERR " chmod %o %s\n", $mode, $name;
68dc0745 495 CORE::chmod($mode,$name)
496 || warn sprintf("Couldn't chmod %o %s: $!\n", $mode, $name)
497 unless $nonono;
498}
499
500sub copy {
501 my($from,$to) = @_;
502
503 print STDERR " cp $from $to\n";
17f28c40 504 print STDERR " creating new version of $to\n" if $Is_VMS and -e $to;
68dc0745 505 File::Copy::copy($from, $to)
506 || warn "Couldn't copy $from to $to: $!\n"
507 unless $nonono;
354f3b56 508 $packlist->{$to} = { type => 'file' };
c623bd54 509}
510
a0d0e21e 511sub samepath {
c2cd2081 512 my($p1, $p2) = @_;
eef1cf2a 513
4a71ed0c 514 return (lc($p1) eq lc($p2)) if $Is_W32;
a0d0e21e 515
75f92628 516 if ($p1 ne $p2) {
c2cd2081 517 my($dev1, $ino1, $dev2, $ino2);
a0d0e21e 518 ($dev1, $ino1) = stat($p1);
519 ($dev2, $ino2) = stat($p2);
520 ($dev1 == $dev2 && $ino1 == $ino2);
521 }
522 else {
523 1;
524 }
525}
526
527sub installlib {
528 my $dir = $File::Find::dir;
529 $dir =~ s#^\.(?![^/])/?##;
0ecb046b 530 local($depth) = $dir ? "lib/$dir" : "lib";
a0d0e21e 531
532 my $name = $_;
efc5ad56 533
534 if ($name eq 'CVS' && -d $name) {
535 $File::Find::prune = 1;
536 return;
537 }
e50aee73 538
539 # ignore patch backups and the .exists files.
540 return if $name =~ m{\.orig$|~$|^\.exists};
541
a0d0e21e 542 $name = "$dir/$name" if $dir ne '';
543
544 my $installlib = $installprivlib;
1dd15ed4 545 if ($dir =~ /^auto/ ||
eef1cf2a 546 ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) ||
4a71ed0c 547 ($name =~ /^(.*)\.(?:h|lib)$/i && $Is_W32)
eef1cf2a 548 ) {
a0d0e21e 549 $installlib = $installarchlib;
550 return unless $do_installarchlib;
551 } else {
552 return unless $do_installprivlib;
553 }
554
a0d0e21e 555 if (-f $_) {
5cc330c8 556 if (/\.(?:al|ix)$/ && !($dir =~ m[^auto/(.*)$] && $archpms{$1})) {
3edbfbe5 557 $installlib = $installprivlib;
558 #We're installing *.al and *.ix files into $installprivlib,
559 #but we have to delete old *.al and *.ix files from the 5.000
560 #distribution:
75f92628 561 #This might not work because $archname might have changed.
68dc0745 562 unlink("$installarchlib/$name");
3edbfbe5 563 }
354f3b56 564 $packlist->{"$installlib/$name"} = { type => 'file' };
5f05dabc 565 if (compare($_, "$installlib/$name") || $nonono) {
68dc0745 566 unlink("$installlib/$name");
fcbdbaa8 567 mkpath("$installlib/$dir", 1, 0777);
75f92628 568 # HP-UX (at least) needs to maintain execute permissions
569 # on dynamically-loaded libraries.
68dc0745 570 copy_if_diff($_, "$installlib/$name")
571 and chmod($name =~ /\.(so|$dlext)$/o ? 0555 : 0444,
aa3cf465 572 "$installlib/$name");
a0d0e21e 573 }
a0d0e21e 574 }
575}
3edbfbe5 576
16d20bd9 577# Copy $from to $to, only if $from is different than $to.
578# Also preserve modification times for .a libraries.
579# On some systems, if you do
580# ranlib libperl.a
581# cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a
582# and then try to link against the installed libperl.a, you might
583# get an error message to the effect that the symbol table is older
584# than the library.
aa3cf465 585# Return true if copying occurred.
68dc0745 586
587sub copy_if_diff {
3edbfbe5 588 my($from,$to)=@_;
8530e788 589 return 1 if (($^O eq 'VMS') && (-d $from));
3edbfbe5 590 -f $from || die "$0: $from not found";
354f3b56 591 $packlist->{$to} = { type => 'file' };
5f05dabc 592 if (compare($from, $to) || $nonono) {
68dc0745 593 safe_unlink($to); # In case we don't have write permissions.
0ecb046b 594 if ($nonono) {
595 $from = $depth . "/" . $from if $depth;
596 }
68dc0745 597 copy($from, $to);
598 # Restore timestamps if it's a .a library or for OS/2.
4a71ed0c 599 if (!$nonono && ($Is_OS2 || $to =~ /\.a$/)) {
68dc0745 600 my ($atime, $mtime) = (stat $from)[8,9];
16d20bd9 601 utime $atime, $mtime, $to;
602 }
aa3cf465 603 1;
3edbfbe5 604 }
605}