5 chdir '..' if !-d 'lib' and -d '../lib';
7 $ENV{PERL5LIB} = 'lib';
9 # This needs to be at BEGIN time, before any use of Config
10 require './install_lib.pl';
14 use vars qw($Is_VMS $Is_W32 $Is_OS2 $Is_Cygwin $Is_Darwin $Is_NetWare
16 my ($dostrip, $versiononly, $force,
17 $otherperls, $archname, $nwinstall, $nopods);
18 # Not sure how easy it would be to refactor to remove the need for local $depth
23 if ($Is_VMS) { eval 'use VMS::Filespec;' }
26 my $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : '');
32 use ExtUtils::Packlist;
40 # override the ones in the rest of the script
42 File::Path::mkpath(@_) unless $opts{notify};
45 my $mainperldir = "/usr/bin";
46 my $exe_ext = $Config{exe_ext};
48 # Allow "make install PERLNAME=something_besides_perl":
49 my $perl = defined($ENV{PERLNAME}) ? $ENV{PERLNAME} : 'perl';
51 # This is the base used for versioned names, like "perl5.6.0".
52 # It's separate because a common use of $PERLNAME is to install
53 # perl as "perl5", if that's used as base for versioned files you
55 my $perl_verbase = defined($ENV{PERLNAME_VERBASE})
56 ? $ENV{PERLNAME_VERBASE}
61 if ( defined $Config{usevmsdebug} ) {
62 if ( $Config{usevmsdebug} eq 'define' ) {
70 # This little hack simplifies making the code after the comment "Fetch some
71 # frequently-used items from %Config" warning free. With $opts{destdir} always
72 # defined, it's also possible to make the s/\Q$opts{destdir}\E unconditional.
75 # Consider refactoring this to use Getopt::Long once Getopt::Long's planned
76 # feature is implemented, to distinguish + and - options.
78 $opts{notify} = 1 if $ARGV[0] eq '-n';
79 $dostrip = 1 if $ARGV[0] eq '-s';
80 $versiononly = 1 if $ARGV[0] eq '-v';
81 $versiononly = 0 if $ARGV[0] eq '+v';
82 $opts{silent} = 1 if $ARGV[0] eq '-S';
83 $otherperls = 0 if $ARGV[0] eq '-o';
84 $force = 1 if $ARGV[0] eq '-f';
85 $opts{verbose} = 1 if $ARGV[0] eq '-V' || $ARGV [0] eq '-n';
86 $archname = 1 if $ARGV[0] eq '-A';
87 $nwinstall = 1 if $ARGV[0] eq '-netware';
88 $nopods = 1 if $ARGV[0] eq '-p';
89 $opts{destdir} = $1 if $ARGV[0] =~ /^-?-destdir=(.*)$/;
90 if ($ARGV[0] eq '-?' or $ARGV[0] =~ /^-?-h/) {
93 -n Don't actually run any commands; just print them.
94 -s Run strip on installed binaries.
95 -v Only install perl as a binary with the version number in the name.
96 (Override whatever config.sh says)
97 +v Install perl as "perl" and as a binary with the version number in
98 the name. (Override whatever config.sh says)
100 -f Force installation (don't check if same version is there)
101 -o Skip checking for other copies of perl in your PATH.
103 -A Also install perl with the architecture's name in the perl binary's
105 -p Don't install the pod files. [This will break use diagnostics;]
106 -netware Install correctly on a Netware server.
107 -destdir Prefix installation directories by this string.
114 $versiononly = 1 if $Config{versiononly} && !defined $versiononly;
115 my (@scripts, @tolink);
116 open SCRIPTS, "utils.lst" or die "Can't open utils.lst: $!";
119 s/\s*#\s*pod\s*=.*//; # install script regardless of pod location
120 next if /a2p/; # a2p is binary, to be installed separately
122 if (/(\S*)\s*#\s*link\s*=\s*(\S*)/) {
124 push @tolink, [$1, $2];
131 if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; }
133 my @pods = $nopods ? () : (<pod/*.pod>, 'x2p/a2p.pod');
135 # Specify here any .pm files that are actually architecture-dependent.
136 # (Those included with XS extensions under ext/ are automatically
138 # Now that the default privlib has the full perl version number included,
139 # we no longer have to play the trick of sticking version-specific .pm
140 # files under the archlib directory.
148 push(@scripts,'djgpp/fixpmain');
149 $archpms{config} = $archpms{filehand} = 1;
152 if ((-e "testcompile") && (defined($ENV{'COMPILE'}))) {
153 push(@scripts, map("$_.exe", @scripts));
156 # Exclude nonxs extensions that are not architecture dependent
157 my @nonxs = grep(!/^Errno$/, split(' ', $Config{'nonxs_ext'}));
160 if (($File::Find::name =~ m{^ext\b(.*)/([^/]+)\.pm$}) &&
161 ! grep { (my $dir = $_) =~ s/\//-/g;
162 $File::Find::name =~ /^ext\/$dir/ } @nonxs)
164 my($path, $modname) = ($1,$2);
166 # strip to optional "/lib", or remove trailing component
167 $path =~ s{.*/lib\b}{} or $path =~ s{/[^/]*$}{};
169 # strip any leading /
172 # reconstitute canonical module name
173 $modname = "$path/$modname" if length $path;
176 $archpms{$modname} = 1;
180 # print "[$_]\n" for sort keys %archpms;
182 my $ver = $Config{version};
183 my $release = substr($],0,3); # Not used currently.
184 my $patchlevel = substr($],3,2);
185 die "Patchlevel of perl ($patchlevel)",
186 "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n"
187 if $patchlevel != $Config{'PERL_VERSION'};
189 # Fetch some frequently-used items from %Config
190 my $installbin = "$opts{destdir}$Config{installbin}";
191 my $installscript = "$opts{destdir}$Config{installscript}";
192 my $installprivlib = "$opts{destdir}$Config{installprivlib}";
193 my $installarchlib = "$opts{destdir}$Config{installarchlib}";
194 my $installsitelib = "$opts{destdir}$Config{installsitelib}";
195 my $installsitearch = "$opts{destdir}$Config{installsitearch}";
196 my $installman1dir = "$opts{destdir}$Config{installman1dir}";
197 my $man1ext = $Config{man1ext};
198 my $libperl = $Config{libperl};
199 # Shared library and dynamic loading suffixes.
200 my $so = $Config{so};
201 my $dlext = $Config{dlext};
202 my $dlsrc = $Config{dlsrc};
203 if ($^O eq 'os390') {
206 my $archlibexp = $Config{archlibexp};
207 my $usedl = $Config{usedl};
208 if ($usedl eq 'define') {
209 `./$^X -pibak -e 's{$pwd\/libperl.x}{$archlibexp/CORE/libperl.x}' lib/Config.pm`;
214 # This is required only if we are installing on a NetWare server
215 $installscript = $Config{installnwscripts};
216 $installprivlib = $Config{installnwlib};
217 $installarchlib = $Config{installnwlib};
218 $installsitelib = $Config{installnwlib};
221 my $binexp = $Config{binexp};
223 if ($Is_VMS) { # Hang in there until File::Spec hits the big time
224 foreach ( \$installbin, \$installscript, \$installprivlib,
225 \$installarchlib, \$installsitelib, \$installsitearch,
227 $$_ = unixify($$_); $$_ =~ s:/$::;
231 # Do some quick sanity checks.
233 $installbin || die "No installbin directory in config.sh\n";
234 -d $installbin || mkpath($installbin, $opts{verbose}, 0777);
235 -d $installbin || $opts{notify} || die "$installbin is not a directory\n";
236 -w $installbin || $opts{notify} || die "$installbin is not writable by you\n"
237 unless $installbin =~ m#^/afs/# || $opts{notify};
241 -x 'perl' . $exe_ext || die "perl isn't executable!\n";
244 -x $ndbg . 'perl' . $exe_ext || die "${ndbg}perl$exe_ext isn't executable!\n";
246 -x $dbg . 'perl' . $exe_ext || die "${dbg}perl$exe_ext isn't executable!\n";
250 -f 't/rantests' || $Is_W32
251 || warn "WARNING: You've never run 'make test' or",
252 " some tests failed! (Installing anyway.)\n";
255 # This will be used to store the packlist
256 $packlist = ExtUtils::Packlist->new("$installarchlib/.packlist");
258 if (($Is_W32 and ! $Is_NetWare) or $Is_Cygwin) {
264 $perldll = 'perl5'.$Config{patchlevel}.'.'.$dlext;
267 if ($dlsrc ne "dl_none.xs") {
268 -f $perldll || die "No perl DLL built\n";
272 safe_unlink("$installbin/$perldll");
273 copy("$perldll", "$installbin/$perldll");
274 chmod(0755, "$installbin/$perldll");
275 $packlist->{"$installbin/$perldll"} = { type => 'file' };
276 } # if (($Is_W32 and ! $Is_NetWare) or $Is_Cygwin)
278 # First we install the version-numbered executables.
281 safe_unlink("$installbin/perl_setup.com");
282 copy("perl_setup.com", "$installbin/perl_setup.com");
283 chmod(0755, "$installbin/perl_setup.com");
284 safe_unlink("$installbin/$dbg$perl$exe_ext");
285 copy("$dbg$perl$exe_ext", "$installbin/$dbg$perl$exe_ext");
286 chmod(0755, "$installbin/$dbg$perl$exe_ext");
287 safe_unlink("$installbin/$dbg${perl}shr$exe_ext");
288 copy("$dbg${perl}shr$exe_ext", "$installbin/$dbg${perl}shr$exe_ext");
289 chmod(0755, "$installbin/$dbg${perl}shr$exe_ext");
291 safe_unlink("$installbin/$ndbg$perl$exe_ext");
292 copy("$ndbg$perl$exe_ext", "$installbin/$ndbg$perl$exe_ext");
293 chmod(0755, "$installbin/$ndbg$perl$exe_ext");
294 safe_unlink("$installbin/${dbg}a2p$exe_ext");
295 copy("x2p/${dbg}a2p$exe_ext", "$installbin/${dbg}a2p$exe_ext");
296 chmod(0755, "$installbin/${dbg}a2p$exe_ext");
299 elsif ($^O eq 'mpeix') {
300 # MPE lacks hard links and requires that executables with special
301 # capabilities reside in the MPE namespace.
302 safe_unlink("$installbin/perl$ver$exe_ext", $Config{perlpath});
303 # Install the primary executable into the MPE namespace as perlpath.
304 copy("perl$exe_ext", $Config{perlpath});
305 chmod(0755, $Config{perlpath});
306 # Create a backup copy with the version number.
307 link($Config{perlpath}, "$installbin/perl$ver$exe_ext");
309 elsif ($^O ne 'dos') {
311 safe_unlink("$installbin/$perl_verbase$ver$exe_ext");
312 copy("perl$exe_ext", "$installbin/$perl_verbase$ver$exe_ext");
313 strip("$installbin/$perl_verbase$ver$exe_ext");
314 chmod(0755, "$installbin/$perl_verbase$ver$exe_ext");
317 # If installing onto a NetWare server
319 # Copy perl.nlm, echo.nlm, type.nlm, a2p.nlm & cgi2perl.nlm
320 mkpath($Config{installnwsystem}, 1, 0777);
321 copy("netware\\".$ENV{'MAKE_TYPE'}."\\perl.nlm", $Config{installnwsystem});
322 copy("netware\\testnlm\\echo\\echo.nlm", $Config{installnwsystem});
323 copy("netware\\testnlm\\type\\type.nlm", $Config{installnwsystem});
324 copy("x2p\\a2p.nlm", $Config{installnwsystem});
325 chmod(0755, "$Config{installnwsystem}\\perl.nlm");
326 mkpath($Config{installnwlcgi}, 1, 0777);
327 copy("lib\\auto\\cgi2perl\\cgi2perl.nlm", $Config{installnwlcgi});
332 safe_unlink("$installbin/$perl.exe");
333 copy("perl.exe", "$installbin/$perl.exe");
336 # Install library files.
338 my ($do_installarchlib, $do_installprivlib) = (0, 0);
339 my $vershort = ($Is_Cygwin and !$Config{usedevel}) ? substr($ver,0,-2) : $ver;
341 mkpath($installprivlib, $opts{verbose}, 0777);
342 mkpath($installarchlib, $opts{verbose}, 0777);
343 mkpath($installsitelib, $opts{verbose}, 0777) if ($installsitelib);
344 mkpath($installsitearch, $opts{verbose}, 0777) if ($installsitearch);
347 $do_installarchlib = ! samepath($installarchlib, '.');
348 $do_installprivlib = ! samepath($installprivlib, '.');
349 $do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$vershort/);
351 if ($do_installarchlib || $do_installprivlib) {
352 find(\&installlib, '.');
354 chdir ".." || die "Can't cd back to source directory: $!\n";
357 warn "Can't cd to lib to install lib files: $!\n";
360 # Install header files and libraries.
361 mkpath("$installarchlib/CORE", $opts{verbose}, 0777);
363 if ($Is_VMS) { # We did core file selection during build
364 my $coredir = "lib/$Config{archname}/$ver/CORE";
366 map { s|^$coredir/||i; } @corefiles = <$coredir/*.*>;
368 elsif ($Is_Cygwin) { # On Cygwin symlink it to CORE to make Makefile happy
369 @corefiles = <*.h libperl*.* perl*$Config{lib_ext}>;
370 my $coredll = "$installarchlib/CORE/$libperl";
371 safe_unlink($coredll);
372 ( $Config{'d_link'} eq 'define' &&
374 CORE::link("$installbin/$libperl", $coredll);
375 $packlist->{$coredll} = { from => "$installbin/$libperl",
380 symlink("$installbin/$libperl", $coredll);
381 $packlist->{$coredll} = { from => "$installbin/$libperl",
384 ( copy("$installbin/$libperl", $coredll) &&
385 push(@corefiles, $coredll)
388 # [als] hard-coded 'libperl' name... not good!
389 @corefiles = <*.h libperl*.* perl*$Config{lib_ext}>;
391 # AIX needs perl.exp installed as well.
392 push(@corefiles,'perl.exp') if $^O eq 'aix';
393 if ($^O eq 'mpeix') {
394 # MPE needs mpeixish.h installed as well.
395 mkpath("$installarchlib/CORE/mpeix", $opts{verbose}, 0777);
396 push(@corefiles,'mpeix/mpeixish.h');
398 # If they have built sperl.o...
399 push(@corefiles,'sperl.o') if -f 'sperl.o';
401 foreach my $file (@corefiles) {
402 # HP-UX (at least) needs to maintain execute permissions
403 # on dynamically-loadable libraries. So we do it for all.
404 if (copy_if_diff($file,"$installarchlib/CORE/$file")) {
405 if ($file =~ /\.(\Q$so\E|\Q$dlext\E)$/) {
406 strip("-S", "$installarchlib/CORE/$file") if $^O =~ /^(rhapsody|darwin)$/;
407 chmod(0555, "$installarchlib/CORE/$file");
409 chmod(0444, "$installarchlib/CORE/$file");
414 # Install main perl executables
415 # Make links to ordinary names if installbin directory isn't current directory.
417 if (! $versiononly && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS && ! $Is_NetWare) {
418 safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext");
419 if ($^O eq 'mpeix') {
420 # MPE doesn't support hard links, so use a symlink.
421 # We don't want another cloned copy.
422 symlink($Config{perlpath}, "$installbin/perl$exe_ext");
423 } elsif ($^O eq 'vos') {
424 # VOS doesn't support hard links, so use a symlink.
425 symlink("$installbin/$perl_verbase$ver$exe_ext",
426 "$installbin/$perl$exe_ext");
428 link("$installbin/$perl_verbase$ver$exe_ext",
429 "$installbin/$perl$exe_ext");
433 # For development purposes it can be very useful to have multiple perls
434 # build for different "architectures" (eg threading or not) simultaneously.
435 if ($archname && ! samepath($installbin, '.') && ($^O ne 'dos') && ! $Is_VMS) {
436 my $archperl = "$perl_verbase$ver-$Config{archname}$exe_ext";
437 safe_unlink("$installbin/$archperl");
438 if ($^O eq 'mpeix') {
439 # MPE doesn't support hard links, so use a symlink.
440 # We don't want another cloned copy.
441 symlink($Config{perlpath}, "$installbin/$archperl");
442 } elsif ($^O eq 'vos') {
443 # VOS doesn't support hard links, so use a symlink.
444 symlink("$installbin/$perl_verbase$ver$exe_ext",
445 "$installbin/$archperl");
447 link("$installbin/$perl_verbase$ver$exe_ext", "$installbin/$archperl");
451 # Offer to install perl in a "standard" location
453 my $mainperl_is_instperl = 0;
455 if ($Config{installusrbinperl} && $Config{installusrbinperl} eq 'define' &&
456 !$versiononly && !$opts{notify} && !$Is_W32 && !$Is_NetWare && !$Is_VMS && -t STDIN && -t STDERR
457 && -w $mainperldir && ! samepath($mainperldir, $installbin)) {
458 my($usrbinperl) = "$mainperldir/$perl$exe_ext";
459 my($instperl) = "$installbin/$perl$exe_ext";
460 my($expinstperl) = "$binexp/$perl$exe_ext";
462 # First make sure $usrbinperl is not already the same as the perl we
464 if (-x $usrbinperl) {
465 # Try to be clever about mainperl being a symbolic link
466 # to binexp/perl if binexp and installbin are different.
467 $mainperl_is_instperl =
468 samepath($usrbinperl, $instperl) ||
469 samepath($usrbinperl, $expinstperl) ||
470 (($binexp ne $installbin) &&
472 ((readlink $usrbinperl) eq $expinstperl));
474 if (! $mainperl_is_instperl) {
476 ( $Config{'d_link'} eq 'define' &&
477 eval { CORE::link $instperl, $usrbinperl } ) ||
478 eval { symlink $expinstperl, $usrbinperl } ||
479 copy($instperl, $usrbinperl);
481 $mainperl_is_instperl = 1;
485 # Make links to ordinary names if installbin directory isn't current directory.
486 if (!$Is_NetWare && $dbg eq '') {
487 if (! samepath($installbin, 'x2p')) {
489 $base .= $ver if $versiononly;
490 safe_unlink("$installbin/$base$exe_ext");
491 copy("x2p/a2p$exe_ext", "$installbin/$base$exe_ext");
492 strip("$installbin/$base$exe_ext");
493 chmod(0755, "$installbin/$base$exe_ext");
497 # cppstdin is just a script, but it is architecture-dependent, so
498 # it can't safely be shared. Place it in $installbin.
499 # Note that Configure doesn't build cppstin if it isn't needed, so
500 # we skip this if cppstdin doesn't exist.
501 if (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) {
502 safe_unlink("$installbin/cppstdin");
503 copy("cppstdin", "$installbin/cppstdin");
504 chmod(0755, "$installbin/cppstdin");
508 my ($installscript, $orig, $alias, $scr_ext) = @_;
510 safe_unlink("$installscript/$alias$scr_ext");
511 if ($^O eq 'dos' or $Is_VMS or $^O eq 'transit') {
512 copy("$installscript/$orig$scr_ext",
513 "$installscript/$alias$scr_ext");
514 } elsif ($^O eq 'vos') {
515 symlink("$installscript/$orig$scr_ext",
516 "$installscript/$alias$scr_ext");
518 link("$installscript/$orig$scr_ext",
519 "$installscript/$alias$scr_ext");
524 mkpath($installscript, $opts{verbose}, 0777);
527 (my $base = $_) =~ s#.*/##;
529 copy($_, "$installscript/$base");
530 chmod(0755, "$installscript/$base");
534 my ($from, $to) = map { "$_$ver" } @$_;
535 (my $frbase = $from) =~ s#.*/##;
536 (my $tobase = $to) =~ s#.*/##;
537 script_alias($installscript, $frbase, $tobase, $scr_ext);
541 (my $base = $_) =~ s#.*/##;
542 copy($_, "$installscript/$base");
543 chmod(0755, "$installscript/$base");
547 my ($from, $to) = @$_;
548 (my $frbase = $from) =~ s#.*/##;
549 (my $tobase = $to) =~ s#.*/##;
550 script_alias($installscript, $frbase, $tobase, $scr_ext);
554 # Install pod pages. Where? I guess in $installprivlib/pod
555 # ($installprivlib/pods for cygwin).
557 my $pod = ($Is_Cygwin || $Is_Darwin || $Is_VMS || $Is_W32) ? 'pods' : 'pod';
558 if ( !$versiononly || ($installprivlib =~ m/\Q$vershort/)) {
559 mkpath("${installprivlib}/$pod", $opts{verbose}, 0777);
561 # If Perl 5.003's perldiag.pod is there, rename it.
562 if (open POD, "${installprivlib}/$pod/perldiag.pod") {
565 # Some of Perl 5.003's diagnostic messages ended with periods.
567 my ($from, $to) = ("${installprivlib}/$pod/perldiag.pod",
568 "${installprivlib}/$pod/perldiag-5.003.pod");
569 print " rename $from $to";
571 or warn "Couldn't rename $from to $to: $!\n"
572 unless $opts{notify};
577 # $_ is a name like pod/perl.pod
578 (my $base = $_) =~ s#.*/##;
579 copy_if_diff($_, "${installprivlib}/$pod/${base}");
584 # Check to make sure there aren't other perls around in installer's
585 # path. This is probably UNIX-specific. Check all absolute directories
586 # in the path except for where public executables are supposed to live.
587 # Also skip $mainperl if the user opted to have it be a link to the
590 if (!$versiononly && $otherperls) {
592 my $dirsep = ($Is_OS2 || $Is_W32 || $Is_NetWare) ? ';' : ':' ;
593 ($path = $ENV{"PATH"}) =~ s:\\:/:g ;
594 @path = split(/$dirsep/, $path);
597 while (exists $ENV{'DCL$PATH' . $i}) {
598 my $dir = unixpath($ENV{'DCL$PATH' . $i}); $dir =~ s-/$--;
606 # Use &samepath here because some systems have other dirs linked
607 # to $mainperldir (like SunOS)
609 next if samepath($_, $binexp);
610 next if samepath($_, cwd());
611 next if ($mainperl_is_instperl && samepath($_, $mainperldir));
612 my $otherperl = "$_/$perl$exe_ext";
613 next if $otherperls{$otherperl}++;
614 push(@otherperls, $otherperl)
615 if (-x $otherperl && ! -d $otherperl);
618 warn "\nWarning: $perl appears in your path in the following " .
619 "locations beyond where\nwe just installed it:\n";
628 $packlist->write() unless $opts{notify};
629 print " Installation complete\n" if $opts{verbose};
633 ###############################################################################
635 # If these are needed elsewhere, move them into install_lib.pl rather than
641 my($default) = $prompt =~ m/\[([yn])\]\s*$/i;
642 print STDERR $prompt;
643 chop($answer = <STDIN>);
644 $answer = $default if $answer =~ m/^\s*$/;
645 ($answer =~ m/^[yY]/);
649 return if $opts{notify} or $Is_VMS;
651 foreach my $name (@names) {
652 next unless -e $name;
653 chmod 0777, $name if ($Is_OS2 || $Is_W32 || $Is_NetWare);
654 print " unlink $name\n" if $opts{verbose};
655 next if CORE::unlink($name);
656 warn "Couldn't unlink $name: $!\n";
658 print " mv $name $name.old\n" if $opts{verbose};
659 safe_rename($name, "$name.old")
660 or warn "Couldn't rename $name: $!\n";
667 if (-f $to and not unlink($to)) {
669 for ($i = 1; $i < 50; $i++) {
670 last if rename($to, "$to.$i");
672 warn("Cannot rename to `$to.$i': $!"), return 0
673 if $i >= 50; # Give up!
675 link($from,$to) || return 0;
683 $xto =~ s/^\Q$opts{destdir}\E//;
684 print $opts{verbose} ? " cp $from $xto\n" : " $xto\n"
685 unless $opts{silent};
686 print " creating new version of $xto\n"
687 if $Is_VMS and -e $to and !$opts{silent};
688 unless ($opts{notify} or File::Copy::copy($from, $to)) {
689 # Might have been that F::C::c can't overwrite the target
690 warn "Couldn't copy $from to $to: $!\n"
691 unless -f $to and (chmod(0666, $to), unlink $to)
692 and File::Copy::copy($from, $to);
694 $packlist->{$xto} = { type => 'file' };
698 my $dir = $File::Find::dir;
699 $dir =~ s#^\.(?![^/])/?##;
700 local($depth) = $dir ? "lib/$dir" : "lib";
704 # Ignore version control directories.
705 if ($name =~ /^(?:CVS|RCS|SCCS|\.svn)\z/ and -d $name) {
706 $File::Find::prune = 1;
710 # ignore patch backups, RCS files, emacs backup & temp files and the
711 # .exists files, .PL files, and test files.
712 return if $name =~ m{\.orig$|\.rej$|~$|^#.+#$|,v$|^\.exists|\.PL$|\.plc$|\.t$|^test\.pl$|^dbm_filter_util.pl$} ||
713 $dir =~ m{/t(?:/|$)};
714 # ignore the cpan script in lib/CPAN/bin, the instmodsh and xsubpp
715 # scripts in lib/ExtUtils, the prove script in lib/Test/Harness,
716 # the corelist script from lib/Module/CoreList/bin and ptar* in
717 # lib/Archive/Tar/bin, the config_data script in lib/Module/Build/scripts
718 # (they're installed later with other utils)
719 return if $name =~ /^(?:cpan|instmodsh|prove|corelist|ptar|cpan2dist|cpanp|cpanp-run-perl|ptardiff|config_data)\z/;
720 # ignore the Makefiles
721 return if $name =~ /^makefile$/i;
722 # ignore the test extensions
723 return if $dir =~ m{\bXS/(?:APItest|Typemap)\b};
724 return if $name =~ m{\b(?:APItest|Typemap)\.pm$};
725 # ignore the demo files
726 return if $dir =~ /\b(?:demos?|eg)\b/;
728 # ignore READMEs, MANIFESTs, INSTALL docs, META.ymls and change logs.
729 # Changes.e2x and README.e2x are needed by enc2xs.
730 return if $name =~ m{^(?:README(?:\.\w+)?)$} && $name ne 'README.e2x';
731 return if $name =~ m{^(?:MANIFEST|META\.yml)$};
732 return if $name =~ m{^(?:INSTALL|TODO|BUGS|CREDITS)$}i;
733 return if $name =~ m{^change(?:s|log)(?:\.libnet)?$}i;
734 return if $name =~ m{^(?:SIGNATURE|PAUSE200\d\.pub)$}; # CPAN files
735 return if $name =~ m{^(?:NOTES|PATCHING)$}; # ExtUtils files
737 # if using a shared perl library then ignore:
738 # - static library files [of statically linked extensions];
739 # - import library files and export library files (only present on Win32
740 # anyway?) and empty bootstrap files [of dynamically linked extensions].
741 return if $Config{useshrplib} eq 'true' and
742 ($name =~ /$Config{_a}$/ or $name =~ /\.exp$/ or ($name =~ /\.bs$/ and -z $name));
744 $name = "$dir/$name" if $dir ne '';
746 return if $name eq 'ExtUtils/XSSymSet.pm' and !$Is_VMS;
748 my $installlib = $installprivlib;
749 if ($dir =~ /^auto\// ||
750 ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) ||
751 ($name =~ /^(.*)\.(?:h|lib)$/i && ($Is_W32 || $Is_NetWare)) ||
752 $name=~/^Config_(heavy\|git)\.pl\z/
754 $installlib = $installarchlib;
755 return unless $do_installarchlib;
757 return unless $do_installprivlib;
761 if (/\.(?:al|ix)$/ && !($dir =~ m[^auto/(.*)$])) {
762 $installlib = $installprivlib;
763 #We're installing *.al and *.ix files into $installprivlib,
764 #but we have to delete old *.al and *.ix files from the 5.000
766 #This might not work because $archname might have changed.
767 unlink("$installarchlib/$name");
769 my $xname = "$installlib/$name";
770 $xname =~ s/^\Q$opts{destdir}\E//;
771 $packlist->{$xname} = { type => 'file' };
772 if ($force || compare($_, "$installlib/$name") || $opts{notify}) {
773 unlink("$installlib/$name");
774 mkpath("$installlib/$dir", $opts{verbose}, 0777);
775 # HP-UX (at least) needs to maintain execute permissions
776 # on dynamically-loaded libraries.
777 if ($Is_NetWare && !$nwinstall) {
778 # Don't copy .nlp,.nlm files, doesn't make sense on Windows and also
779 # if copied will give problems when building new extensions.
780 # Has to be copied if we are installing on a NetWare server and hence
781 # the check !$nwinstall
782 if (!(/\.(?:nlp|nlm|bs)$/)) {
783 copy_if_diff($_, "$installlib/$name")
784 and chmod($name =~ /\.(so|$dlext)$/o ? 0555 : 0444,
785 "$installlib/$name");
788 if (copy_if_diff($_, "$installlib/$name")) {
789 if ($name =~ /\.(so|$dlext)$/o) {
790 strip("-S", "$installlib/$name") if $^O =~ /^(rhapsody|darwin)$/;
791 chmod(0555, "$installlib/$name");
793 strip("-S", "$installlib/$name")
794 if ($name =~ /\.a$/o and $^O =~ /^(rhapsody|darwin)$/);
795 chmod(0444, "$installlib/$name");
803 # Copy $from to $to, only if $from is different than $to.
804 # Also preserve modification times for .a libraries.
805 # On some systems, if you do
807 # cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a
808 # and then try to link against the installed libperl.a, you might
809 # get an error message to the effect that the symbol table is older
811 # Return true if copying occurred.
815 return 1 if (($^O eq 'VMS') && (-d $from));
817 $xto =~ s/^\Q$opts{destdir}\E//;
818 my $perlpodbadsymlink;
819 if ($from =~ m!^pod/perl[\w-]+\.pod$! &&
822 # Some Linux implementations have problems traversing over
823 # multiple symlinks (when going over NFS?) and fail to read
824 # the symlink target. Combine this with the fact that some
825 # of the pod files (the perl$OS.pod) are symlinks (to ../README.$OS),
826 # and you end up with those pods not getting installed.
827 $perlpodbadsymlink = 1;
829 -f $from || $perlpodbadsymlink || warn "$0: $from not found";
830 $packlist->{$xto} = { type => 'file' };
831 if ($force || compare($from, $to) || $opts{notify}) {
832 safe_unlink($to); # In case we don't have write permissions.
834 $from = $depth . "/" . $from if $depth;
836 if ($perlpodbadsymlink && $from =~ m!^pod/perl(.+)\.pod$!) {
840 # Restore timestamps if it's a .a library or for OS/2.
841 if (!$opts{notify} && ($Is_OS2 || $to =~ /\.a$/)) {
842 my ($atime, $mtime) = (stat $from)[8,9];
843 utime $atime, $mtime, $to;
853 return unless $dostrip;
856 while (@args && $args[0] =~ /^(-\w+)$/) {
857 push @opts, shift @args;
860 foreach my $file (@args) {
862 if ($opts{verbose}) {
863 print " strip " . join(' ', @opts);
864 print " " if (@opts);
867 system("strip", @opts, $file);
869 print "# file '$file' skipped\n" if $opts{verbose};