1#!./perl -w 2 3BEGIN { 4 chdir '..' if !-d 'lib' and -d '../lib'; 5 @INC = 'lib'; 6 $ENV{PERL5LIB} = 'lib'; 7 8 # This needs to be at BEGIN time, before any use of Config 9 # install_lib itself loads and imports Config into main:: 10 require './install_lib.pl'; 11} 12 13use strict; 14our ($Is_VMS, $Is_W32, $Is_OS2, $Is_Cygwin, $Is_Darwin, $Is_AmigaOS, 15 %opts, $packlist); 16my $versiononly; 17 18BEGIN { 19 if ($Is_VMS) { eval 'use VMS::Filespec;' } 20} 21 22# HP-UX (at least) needs to maintain execute permissions 23# on dynamically-loadable libraries. So we do it for all. 24# 25# In AmigaOS, the 0777 means 'rwed' (e = execute, d = delete), 26# (not 'rwx') and having the 'd' makes updates more convenient. 27my $SO_MODE = $Is_AmigaOS ? 0777 : 0555; 28my $NON_SO_MODE = $Is_AmigaOS ? 0666 : 0444; 29 30my $scr_ext = ($Is_VMS ? '.Com' : $Is_W32 ? '.bat' : ''); 31 32use File::Find; 33use File::Compare; 34use File::Copy (); 35use ExtUtils::Packlist; 36use Cwd; 37# nogetopt_compat to disable treating +v as meaning -v 38use Getopt::Long qw(:config nogetopt_compat no_auto_abbrev noignorecase); 39 40require './Porting/pod_lib.pl'; 41 42my $mainperldir = "/usr/bin"; 43my $exe_ext = $Config{exe_ext}; 44 45# Allow "make install PERLNAME=something_besides_perl": 46my $perl = defined($ENV{PERLNAME}) ? $ENV{PERLNAME} : 'perl'; 47 48# This is the base used for versioned names, like "perl5.6.0". 49# It's separate because a common use of $PERLNAME is to install 50# perl as "perl5", if that's used as base for versioned files you 51# get "perl55.6.0". 52my $perl_verbase = defined($ENV{PERLNAME_VERBASE}) 53 ? $ENV{PERLNAME_VERBASE} 54 : $perl; 55my $dbg = ''; 56my $ndbg = ''; 57if ( $Is_VMS ) { 58 if ( defined $Config{usevmsdebug} ) { 59 if ( $Config{usevmsdebug} eq 'define' ) { 60 $dbg = 'dbg'; 61 $ndbg = 'ndbg'; 62 } 63 } 64} 65 66# This little hack simplifies making the code after the comment "Fetch some 67# frequently-used items from %Config" warning free. With $opts{destdir} always 68# defined, it's also possible to make the s/\Q$opts{destdir}\E unconditional. 69 70$opts{destdir} = ''; 71{ 72 my $usage = 0; 73 if (!GetOptions(\%opts, 'notify|n', 'strip|s', 'silent|S', 74 'skip-otherperls|o', 'force|f', 'verbose|V', 'archname|A', 75 'nopods|p', 'destdir:s', 'help|h|?', 76 'versiononly|v' => \$versiononly, '<>' => sub { 77 if ($_[0] eq '+v') { 78 $versiononly = 0; 79 } else { 80 # Any other unknown argument is going to be an error 81 $usage = 1; 82 } 83 }, 84 )) { 85 $usage = 1; 86 } 87 $opts{verbose} ||= $opts{notify}; 88 89 if ($usage || $opts{help}) { 90 print <<"EOT"; 91Usage $0: [switches] 92 -n Don't actually run any commands; just print them. 93 -s Run strip on installed binaries. 94 -v Only install perl as a binary with the version number in the name. 95 (Override whatever config.sh says) 96 +v Install perl as "perl" and as a binary with the version number in 97 the name. (Override whatever config.sh says) 98 -S Silent mode. 99 -f Force installation (don't check if same version is there) 100 -o Skip checking for other copies of perl in your PATH. 101 -V Verbose mode. 102 -A Also install perl with the architecture's name in the perl binary's 103 name. 104 -p Don't install the pod files. [This will break use diagnostics;] 105 -destdir Prefix installation directories by this string. 106 -h Display this help message. 107EOT 108 exit $usage; 109 } 110} 111 112$versiononly = 1 if $Config{versiononly} && !defined $versiononly; 113my (@scripts, @tolink); 114open SCRIPTS, "utils.lst" or die "Can't open utils.lst: $!"; 115while (<SCRIPTS>) { 116 next if /^#/; 117 chomp; 118 if (/(\S*)\s*#\s*link\s*=\s*(\S*)/) { 119 push @scripts, $1; 120 push @tolink, [$1, $2]; 121 } else { 122 push @scripts, $_; 123 } 124} 125close SCRIPTS; 126 127if ($scr_ext) { @scripts = map { "$_$scr_ext" } @scripts; } 128 129# Specify here any .pm files that are actually architecture-dependent. 130# (Those included with XS extensions under ext/ are automatically 131# added later.) 132# Now that the default privlib has the full perl version number included, 133# we no longer have to play the trick of sticking version-specific .pm 134# files under the archlib directory. 135my %archpms = ( 136 Config => 1, 137 lib => 1, 138); 139 140if ((-e "testcompile") && (defined($ENV{'COMPILE'}))) { 141 push(@scripts, map("$_.exe", @scripts)); 142} 143 144# Exclude nonxs extensions that are not architecture dependent 145my @nonxs = grep(!/^Errno$/, split(' ', $Config{'nonxs_ext'})); 146 147my @ext_dirs = qw(cpan dist ext); 148foreach my $ext_dir (@ext_dirs) { 149 find(sub { 150 if (($File::Find::name =~ m{^$ext_dir\b(.*)/([^/]+)\.pm$}) && 151 ! grep { (my $dir = $_) =~ s/\//-/g; 152 $File::Find::name =~ /^$ext_dir\/$dir\// } @nonxs) 153 { 154 my($path, $modname) = ($1,$2); 155 156 # Change hyphenated name like Filter-Util-Call to nested 157 # directory name Filter/Util/Call 158 $path =~ s{-}{/}g; 159 160 # strip to optional "/lib", or remove trailing component 161 $path =~ s{.*/lib\b}{} or $path =~ s{/[^/]*$}{}; 162 163 # strip any leading / 164 $path =~ s{^/}{}; 165 166 # reconstitute canonical module name 167 $modname = "$path/$modname" if length $path; 168 169 # remember it 170 $archpms{$modname} = 1; 171 } 172 }, $ext_dir); 173} 174 175# print "[$_]\n" for sort keys %archpms; 176 177my $ver = $Config{version}; 178my $release = substr($],0,3); # Not used currently. 179my $patchlevel = substr($],3,2); 180die "Patchlevel of perl ($patchlevel)", 181 "and patchlevel of config.sh ($Config{'PERL_VERSION'}) don't match\n" 182 if $patchlevel != $Config{'PERL_VERSION'}; 183 184# Fetch some frequently-used items from %Config 185my $installbin = "$opts{destdir}$Config{installbin}"; 186my $installscript = "$opts{destdir}$Config{installscript}"; 187my $installprivlib = "$opts{destdir}$Config{installprivlib}"; 188my $installarchlib = "$opts{destdir}$Config{installarchlib}"; 189my $installsitelib = "$opts{destdir}$Config{installsitelib}"; 190my $installsitearch = "$opts{destdir}$Config{installsitearch}"; 191my $installman1dir = "$opts{destdir}$Config{installman1dir}"; 192my $man1ext = $Config{man1ext}; 193my $libperl = $Config{libperl}; 194# Shared library and dynamic loading suffixes. 195my $so = $Config{so}; 196my $dlext = $Config{dlext}; 197my $dlsrc = $Config{dlsrc}; 198if ($^O eq 'os390') { 199 my $pwd; 200 chomp($pwd=`pwd`); 201 my $archlibexp = $Config{archlibexp}; 202 my $usedl = $Config{usedl}; 203 if ($usedl eq 'define') { 204 `./$^X -pibak -e 's{$pwd\/libperl.x}{$archlibexp/CORE/libperl.x}' lib/Config.pm`; 205 } 206} 207 208my $binexp = $Config{binexp}; 209 210if ($Is_VMS) { # Hang in there until File::Spec hits the big time 211 foreach ( \$installbin, \$installscript, \$installprivlib, 212 \$installarchlib, \$installsitelib, \$installsitearch, 213 \$installman1dir ) { 214 $$_ = unixify($$_); $$_ =~ s:/$::; 215 } 216} 217 218# Do some quick sanity checks. 219 220 $installbin || die "No installbin directory in config.sh\n"; 221-d $installbin || mkpath($installbin); 222-d $installbin || $opts{notify} || die "$installbin is not a directory\n"; 223-w $installbin || $opts{notify} || die "$installbin is not writable by you\n" 224 unless $installbin =~ m#^/afs/# || $opts{notify}; 225 226if (!$Is_VMS) { 227-x 'perl' . $exe_ext || die "perl isn't executable!\n"; 228} 229else { 230-x $ndbg . 'perl' . $exe_ext || die "${ndbg}perl$exe_ext isn't executable!\n"; 231 if ($dbg) { 232 -x $dbg . 'perl' . $exe_ext || die "${dbg}perl$exe_ext isn't executable!\n"; 233 } 234} 235 236-f 't/rantests' || $Is_W32 237 || warn "WARNING: You've never run 'make test' or", 238 " some tests failed! (Installing anyway.)\n"; 239 240# This will be used to store the packlist 241$packlist = ExtUtils::Packlist->new("$installarchlib/.packlist"); 242 243if ($Is_W32 or $Is_Cygwin) { 244 my $perldll; 245 246 if ($Is_Cygwin) { 247 $perldll = $libperl; 248 } else { 249 $perldll = 'perl5'.$Config{patchlevel}.'.'.$so; 250 } 251 252 if ($dlsrc ne "dl_none.xs") { 253 -f $perldll || die "No perl DLL built\n"; 254 } 255 256 # Install the DLL 257 safe_unlink("$installbin/$perldll"); 258 copy("$perldll", "$installbin/$perldll"); 259 chmod(0755, "$installbin/$perldll"); 260 $packlist->{"$Config{installbin}/$perldll"} = { type => 'file' }; 261} # if ($Is_W32 or $Is_Cygwin) 262 263# First we install the version-numbered executables. 264 265if ($Is_VMS) { 266 safe_unlink("$installbin/perl_setup.com"); 267 copy("perl_setup.com", "$installbin/perl_setup.com"); 268 chmod(0755, "$installbin/perl_setup.com"); 269 safe_unlink("$installbin/$dbg$perl$exe_ext"); 270 copy("$dbg$perl$exe_ext", "$installbin/$dbg$perl$exe_ext"); 271 chmod(0755, "$installbin/$dbg$perl$exe_ext"); 272 safe_unlink("$installbin/$dbg${perl}shr$exe_ext"); 273 copy("$dbg${perl}shr$exe_ext", "$installbin/$dbg${perl}shr$exe_ext"); 274 chmod(0755, "$installbin/$dbg${perl}shr$exe_ext"); 275 if ($ndbg) { 276 safe_unlink("$installbin/$ndbg$perl$exe_ext"); 277 copy("$ndbg$perl$exe_ext", "$installbin/$ndbg$perl$exe_ext"); 278 chmod(0755, "$installbin/$ndbg$perl$exe_ext"); 279 } 280} 281else { 282 safe_unlink("$installbin/$perl_verbase$ver$exe_ext"); 283 copy("perl$exe_ext", "$installbin/$perl_verbase$ver$exe_ext"); 284 strip("$installbin/$perl_verbase$ver$exe_ext"); 285 fix_dep_names("$installbin/$perl_verbase$ver$exe_ext"); 286 chmod(0755, "$installbin/$perl_verbase$ver$exe_ext"); 287 `chtag -r "$installbin/$perl_verbase$ver$exe_ext"` if ($^O eq 'os390'); 288} 289 290# Install library files. 291 292my $do_installarchlib = !samepath($installarchlib, 'lib'); 293my $do_installprivlib = !samepath($installprivlib, 'lib'); 294my $vershort = ($Is_Cygwin and !$Config{usedevel}) ? substr($ver,0,-2) : $ver; 295$do_installprivlib = 0 if $versiononly && !($installprivlib =~ m/\Q$vershort/); 296 297mkpath($installprivlib); 298mkpath($installarchlib); 299mkpath($installsitelib, $opts{verbose}, 0777) if ($installsitelib); 300mkpath($installsitearch, $opts{verbose}, 0777) if ($installsitearch); 301 302if (-d 'lib') { 303 find({no_chdir => 1, wanted => \&installlib}, 'lib') 304 if $do_installarchlib || $do_installprivlib; 305} 306else { 307 warn "Can't install lib files - 'lib/' does not exist"; 308} 309 310# Install header files and libraries. 311mkpath("$installarchlib/CORE"); 312my @corefiles; 313if ($Is_VMS) { # We did core file selection during build 314 my $coredir = "lib/$Config{archname}/$ver/CORE"; 315 $coredir =~ tr/./_/; 316 map { s|^$coredir/||i; } @corefiles = <$coredir/*.*>; 317} 318elsif ($Is_Cygwin) { # On Cygwin symlink it to CORE to make Makefile happy 319 @corefiles = <*.h libperl*.* perl*$Config{lib_ext}>; 320 my $coredll = "$installarchlib/CORE/$libperl"; 321 my $instcoredll = "$Config{installarchlib}/CORE/$libperl"; 322 safe_unlink($coredll); 323 ( $Config{'d_link'} eq 'define' && 324 eval { 325 CORE::link("$installbin/$libperl", $coredll); 326 $packlist->{$instcoredll} = { from => "$Config{installbin}/$libperl", 327 type => 'link' }; 328 } 329 ) || 330 eval { 331 symlink("$installbin/$libperl", $coredll); 332 $packlist->{$instcoredll} = { from => "$Config{installbin}/$libperl", 333 type => 'link' }; 334 } || 335 ( copy("$installbin/$libperl", $coredll) && 336 push(@corefiles, $instcoredll) 337 ) 338} elsif ($Is_W32) { 339 @corefiles = <*.h>; 340} else { 341 # [als] hard-coded 'libperl' name... not good! 342 @corefiles = <*.h libperl*.* perl*$Config{lib_ext}>; 343 344 # AIX needs perl.exp installed as well. 345 push(@corefiles,'perl.exp') if $^O eq 'aix'; 346} 347 348 349foreach my $file (@corefiles) { 350 if (copy_if_diff($file,"$installarchlib/CORE/$file")) { 351 if ($file =~ /\.(\Q$so\E|\Q$dlext\E)$/) { 352 strip("-S", "$installarchlib/CORE/$file") if $^O eq 'darwin'; 353 fix_dep_names("$installarchlib/CORE/$file"); 354 chmod($SO_MODE, "$installarchlib/CORE/$file"); 355 } else { 356 chmod($NON_SO_MODE, "$installarchlib/CORE/$file"); 357 } 358 `chtag -r "$installarchlib/CORE/$file"` if ($^O eq 'os390'); 359 } 360} 361 362if ($Is_W32) { #linking lib isn't made in root but in CORE on Win32 363 @corefiles = <lib/CORE/libperl*.* lib/CORE/perl*$Config{lib_ext}>; 364 my $dest; 365 copy_if_diff($_,($dest = $installarchlib.substr($_,3))) && 366 chmod($NON_SO_MODE, $dest) foreach @corefiles; 367} 368 369# Install main perl executables 370# Make links to ordinary names if installbin directory isn't current directory. 371 372if (! $versiononly && ! samepath($installbin, '.') && ! $Is_VMS) { 373 safe_unlink("$installbin/$perl$exe_ext", "$installbin/suid$perl$exe_ext"); 374 if ($^O eq 'vos') { 375 # VOS doesn't support hard links, so use a symlink. 376 symlink("$installbin/$perl_verbase$ver$exe_ext", 377 "$installbin/$perl$exe_ext"); 378 } else { 379 link("$installbin/$perl_verbase$ver$exe_ext", 380 "$installbin/$perl$exe_ext"); 381 } 382} 383 384# For development purposes it can be very useful to have multiple perls 385# build for different "architectures" (eg threading or not) simultaneously. 386if ($opts{archname} && ! samepath($installbin, '.') && ! $Is_VMS) { 387 my $archperl = "$perl_verbase$ver-$Config{archname}$exe_ext"; 388 safe_unlink("$installbin/$archperl"); 389 if ($^O eq 'vos') { 390 # VOS doesn't support hard links, so use a symlink. 391 symlink("$installbin/$perl_verbase$ver$exe_ext", 392 "$installbin/$archperl"); 393 } else { 394 link("$installbin/$perl_verbase$ver$exe_ext", "$installbin/$archperl"); 395 } 396} 397 398# Offer to install perl in a "standard" location 399 400my $mainperl_is_instperl = 0; 401 402if ($Config{installusrbinperl} && $Config{installusrbinperl} eq 'define' && 403 !$versiononly && !$opts{notify} && !$Is_W32 && !$Is_VMS && -t STDIN && -t STDERR 404 && -w $mainperldir && ! samepath($mainperldir, $installbin)) { 405 my($usrbinperl) = "$mainperldir/$perl$exe_ext"; 406 my($instperl) = "$installbin/$perl$exe_ext"; 407 my($expinstperl) = "$binexp/$perl$exe_ext"; 408 409 # First make sure $usrbinperl is not already the same as the perl we 410 # just installed. 411 if (-x $usrbinperl) { 412 # Try to be clever about mainperl being a symbolic link 413 # to binexp/perl if binexp and installbin are different. 414 $mainperl_is_instperl = 415 samepath($usrbinperl, $instperl) || 416 samepath($usrbinperl, $expinstperl) || 417 (($binexp ne $installbin) && 418 (-l $usrbinperl) && 419 ((readlink $usrbinperl) eq $expinstperl)); 420 } 421 if (! $mainperl_is_instperl) { 422 unlink($usrbinperl); 423 ( $Config{'d_link'} eq 'define' && 424 eval { CORE::link $instperl, $usrbinperl } ) || 425 eval { symlink $expinstperl, $usrbinperl } || 426 copy($instperl, $usrbinperl); 427 `chtag -r "$usrbinperl"` if ($^O eq 'os390'); 428 429 $mainperl_is_instperl = 1; 430 } 431} 432 433# cppstdin is just a script, but it is architecture-dependent, so 434# it can't safely be shared. Place it in $installbin. 435# Note that Configure doesn't build cppstin if it isn't needed, so 436# we skip this if cppstdin doesn't exist. 437if (! $versiononly && (-f 'cppstdin') && (! samepath($installbin, '.'))) { 438 safe_unlink("$installbin/cppstdin"); 439 copy("cppstdin", "$installbin/cppstdin"); 440 chmod(0755, "$installbin/cppstdin"); 441} 442 443sub script_alias { 444 my ($installscript, $orig, $alias, $scr_ext) = @_; 445 446 safe_unlink("$installscript/$alias$scr_ext"); 447 if ($Is_VMS or $^O eq 'transit') { 448 copy("$installscript/$orig$scr_ext", 449 "$installscript/$alias$scr_ext"); 450 } elsif ($^O eq 'vos') { 451 symlink("$installscript/$orig$scr_ext", 452 "$installscript/$alias$scr_ext"); 453 } else { 454 link("$installscript/$orig$scr_ext", 455 "$installscript/$alias$scr_ext"); 456 } 457} 458 459# Install scripts. 460mkpath($installscript); 461if ($versiononly) { 462 for (@scripts) { 463 (my $base = $_) =~ s#.*/##; 464 $base .= $ver; 465 copy($_, "$installscript/$base"); 466 chmod(0755, "$installscript/$base"); 467 } 468 469 for (@tolink) { 470 my ($from, $to) = map { "$_$ver" } @$_; 471 (my $frbase = $from) =~ s#.*/##; 472 (my $tobase = $to) =~ s#.*/##; 473 script_alias($installscript, $frbase, $tobase, $scr_ext); 474 } 475} else { 476 for (@scripts) { 477 (my $base = $_) =~ s#.*/##; 478 copy($_, "$installscript/$base"); 479 chmod(0755, "$installscript/$base"); 480 if ($Is_AmigaOS) { 481 my $amigapath = unixtoamiga("$installscript/$base"); 482 amigaprotect($amigapath,"+s"); 483 } 484 } 485 486 for (@tolink) { 487 my ($from, $to) = @$_; 488 (my $frbase = $from) =~ s#.*/##; 489 (my $tobase = $to) =~ s#.*/##; 490 script_alias($installscript, $frbase, $tobase, $scr_ext); 491 } 492} 493 494# Install pod pages. Where? I guess in $installprivlib/pod 495# ($installprivlib/pods for cygwin). 496if (!$opts{nopods} && (!$versiononly || ($installprivlib =~ m/\Q$vershort/))) { 497 my $pod = ($Is_Cygwin || $Is_Darwin || $Is_VMS || $Is_W32) ? 'pods' : 'pod'; 498 mkpath("${installprivlib}/$pod"); 499 500 for (map {$_->[1]} @{get_pod_metadata()->{master}}) { 501 # $_ is a name like pod/perl.pod 502 (my $base = $_) =~ s#.*/##; 503 copy_if_diff($_, "${installprivlib}/$pod/${base}"); 504 chmod(0644, "${installprivlib}/$pod/${base}"); 505 } 506 507} 508 509 510$packlist->write() unless $opts{notify}; 511print " Installation complete\n" if $opts{verbose}; 512 513exit 0; 514 515############################################################################### 516 517# If these are needed elsewhere, move them into install_lib.pl rather than 518# copying them. 519 520sub yn { 521 my($prompt) = @_; 522 my($answer); 523 my($default) = $prompt =~ m/\[([yn])\]\s*$/i; 524 print STDERR $prompt; 525 chop($answer = <STDIN>); 526 $answer = $default if $answer =~ m/^\s*$/; 527 ($answer =~ m/^[yY]/); 528} 529 530sub safe_unlink { 531 return if $opts{notify} or $Is_VMS; 532 my @names = @_; 533 foreach my $name (@names) { 534 next unless -e $name; 535 chmod 0777, $name if ($Is_OS2 || $Is_W32); 536 print " unlink $name\n" if $opts{verbose}; 537 next if CORE::unlink($name); 538 warn "Couldn't unlink $name: $!\n"; 539 if ($! =~ /busy/i) { 540 print " mv $name $name.old\n" if $opts{verbose}; 541 safe_rename($name, "$name.old") 542 or warn "Couldn't rename $name: $!\n"; 543 } 544 } 545} 546 547sub copy { 548 my($from,$to) = @_; 549 550 my $xto = $to; 551 $xto =~ s/^\Q$opts{destdir}\E//; 552 print $opts{verbose} ? " cp $from $xto\n" : " $xto\n" 553 unless $opts{silent}; 554 print " creating new version of $xto\n" 555 if $Is_VMS and -e $to and !$opts{silent}; 556 unless ($opts{notify} or File::Copy::copy($from, $to)) { 557 # Might have been that F::C::c can't overwrite the target 558 warn "Couldn't copy $from to $to: $!\n" 559 unless -f $to and (chmod(0666, $to), unlink $to) 560 and File::Copy::copy($from, $to); 561 } 562 $packlist->{$xto} = { type => 'file' }; 563} 564 565sub installlib { 566 my $dir = $File::Find::dir; 567 $dir =~ s!\Alib/?!!; 568 569 m!([^/]+)\z!; 570 my $name = $1; 571 572 # This remains ugly, and in need of refactoring. 573 574 # $name always starts as the leafname 575 # $dir is the directory *within* lib 576 # $name later has $dir pre-pended, to give the relative path in lib/ 577 # which is used to create the path in the target directory. 578 579 # $_ was always the filename to use on disk. Adding no_chdir doesn't change 580 # this, as $_ becomes a pathname, and so still works. However, it's not 581 # obvious that $_ is needed later, and hence $_ must not be modified. 582 583 # Also, many of the regex exclusion tests below are now superfluous, as the 584 # files in question are either no longer in blead, or now in ext/, dist/ or 585 # cpan/ and not copied into lib/ 586 587 # Ignore version control directories. 588 if ($name =~ /^(?:CVS|RCS|SCCS|\.svn)\z/ and -d $name) { 589 $File::Find::prune = 1; 590 return; 591 } 592 593 # ignore patch backups, RCS files, emacs backup & temp files and the 594 # .exists files, .PL files, and test files. 595 return if $name =~ m{\.orig$|\.rej$|~$|^#.+#$|,v$|^\.exists|\.PL$|\.plc$|\.t$|^test\.pl$|^dbm_filter_util\.pl$|^filter-util\.pl$|^uupacktool\.pl$|^\.gitignore$} || 596 $dir =~ m{/t(?:/|$)}; 597 # ignore the cpan script in lib/CPAN/bin, the instmodsh and xsubpp 598 # scripts in lib/ExtUtils, the prove script in lib/Test/Harness, 599 # the corelist script from lib/Module/CoreList/bin and ptar* in 600 # lib/Archive/Tar/bin and zipdetails in cpan/IO-Compress/bin 601 # (they're installed later with other utils) 602 return if $name =~ /^(?:cpan|instmodsh|prove|corelist|ptar|ptardiff|ptargrep|zipdetails)\z/; 603 # ignore the Makefiles 604 return if $name =~ /^makefile$/i; 605 # ignore the test extensions, dont install PPPort.so/.dll 606 return if $dir =~ m{\b(?:XS/(?:APItest|Typemap)|Devel/PPPort)\b}; 607 return if $name =~ m{\b(?:APItest|Typemap)\.pm$}; 608 # ignore the build support code 609 return if $name =~ /\bbuildcustomize\.pl$/; 610 # ignore the demo files 611 return if $dir =~ /\b(?:demos?|eg)\b/; 612 # ignore unneeded unicore files 613 if ( $dir =~ /^unicore/ ) { 614 if ( $name =~ /\.txt\z/ ) { 615 # We can ignore most, but not all .txt files 616 return unless $name =~ /\A(?:Blocks|SpecialCasing|NamedSequences)\.txt\z/; 617 } 618 else { 619 # TestProp only needed during testing 620 return if $name =~ /\ATestProp.pl\z/; 621 # we need version and *.pl files and can skip the rest 622 return unless $name =~ /\A(?:version|\w+\.p[lm])\z/; 623 } 624 } 625 626 # ignore READMEs, MANIFESTs, INSTALL docs, META.ymls and change logs. 627 # Changes.e2x and README.e2x are needed by enc2xs. 628 return if $name =~ m{^(?:README(?:\.\w+)?)$} && $name ne 'README.e2x'; 629 return if $name =~ m{^(?:MANIFEST|META\.yml)$}; 630 return if $name =~ m{^(?:INSTALL|TODO|BUGS|CREDITS)$}i; 631 return if $name =~ m{^change(?:s|log)(?:\.libnet)?$}i; 632 return if $name =~ m{^(?:SIGNATURE|PAUSE200\d\.pub)$}; # CPAN files 633 return if $name =~ m{^(?:NOTES|PATCHING)$}; # ExtUtils files 634 635 # if using a shared perl library then ignore: 636 # - static library files [of statically linked extensions]; 637 # - import library files and export library files (only present on Win32 638 # anyway?) and empty bootstrap files [of dynamically linked extensions]. 639 return if $Config{useshrplib} eq 'true' and 640 ($name =~ /$Config{_a}$/ or $name =~ /\.exp$/ or ($name =~ /\.bs$/ and -z $name)); 641 642 $name = "$dir/$name" if $dir ne ''; 643 644 # ignore pods that are stand alone documentation from dual life modules. 645 return if /\.pod\z/ && is_duplicate_pod($_); 646 647 return if $name eq 'ExtUtils/XSSymSet.pm' and !$Is_VMS; 648 649 #blead comes with version, blead isn't 5.8/5.6 650 return if $name eq 'ExtUtils/MakeMaker/version/regex.pm'; 651 652 my $installlib = $installprivlib; 653 if ($dir =~ /^auto\// || 654 ($name =~ /^(.*)\.(?:pm|pod)$/ && $archpms{$1}) || 655 ($name =~ /^(.*)\.(?:h|lib)$/i && $Is_W32) || 656 $name=~/^Config_(heavy|git)\.pl\z/ 657 ) { 658 $installlib = $installarchlib; 659 return unless $do_installarchlib; 660 } else { 661 return unless $do_installprivlib; 662 } 663 664 if (-f $_) { 665 my $xname = "$installlib/$name"; 666 $xname =~ s/^\Q$opts{destdir}\E//; 667 $packlist->{$xname} = { type => 'file' }; 668 if ($opts{force} || compare($_, "$installlib/$name") || $opts{notify}) { 669 unlink("$installlib/$name"); 670 mkpath("$installlib/$dir"); 671 # HP-UX (at least) needs to maintain execute permissions 672 # on dynamically-loaded libraries. 673 if (copy_if_diff($_, "$installlib/$name")) { 674 strip("-S", "$installlib/$name") 675 if $^O eq 'darwin' and /\.(?:so|$dlext|a)$/; 676 chmod(/\.(so|$dlext)$/ ? $SO_MODE : $NON_SO_MODE, 677 "$installlib/$name"); 678 } 679 } 680 } 681} 682 683# Copy $from to $to, only if $from is different than $to. 684# Also preserve modification times for .a libraries. 685# On some systems, if you do 686# ranlib libperl.a 687# cp libperl.a /usr/local/lib/perl5/archlib/CORE/libperl.a 688# and then try to link against the installed libperl.a, you might 689# get an error message to the effect that the symbol table is older 690# than the library. 691# Return true if copying occurred. 692 693sub copy_if_diff { 694 my($from,$to)=@_; 695 return 1 if (($^O eq 'VMS') && (-d $from)); 696 my $xto = $to; 697 $xto =~ s/^\Q$opts{destdir}\E//; 698 my $perlpodbadsymlink; 699 if ($from =~ m!^pod/perl[\w-]+\.pod$! && 700 -l $from && 701 ! -e $from) { 702 # Some Linux implementations have problems traversing over 703 # multiple symlinks (when going over NFS?) and fail to read 704 # the symlink target. Combine this with the fact that some 705 # of the pod files (the perl$OS.pod) are symlinks (to ../README.$OS), 706 # and you end up with those pods not getting installed. 707 $perlpodbadsymlink = 1; 708 } 709 -f $from || $perlpodbadsymlink || warn "$0: $from not found"; 710 $packlist->{$xto} = { type => 'file' }; 711 if ($opts{force} || compare($from, $to) || $opts{notify}) { 712 safe_unlink($to); # In case we don't have write permissions. 713 if ($perlpodbadsymlink && $from =~ m!^pod/perl(.+)\.pod$!) { 714 $from = "README.$1"; 715 } 716 copy($from, $to); 717 # Restore timestamps if it's a .a library or for OS/2. 718 if (!$opts{notify} && ($Is_OS2 || $to =~ /\.a$/)) { 719 my ($atime, $mtime) = (stat $from)[8,9]; 720 utime $atime, $mtime, $to; 721 } 722 `chtag -r "$to"` if ($^O eq "os390"); 723 1; 724 } 725} 726 727sub strip 728{ 729 my(@args) = @_; 730 731 return unless $opts{strip}; 732 733 my @opts; 734 while (@args && $args[0] =~ /^(-\w+)$/) { 735 push @opts, shift @args; 736 } 737 738 foreach my $file (@args) { 739 if (-f $file) { 740 if ($opts{verbose}) { 741 print " strip " . join(' ', @opts); 742 print " " if (@opts); 743 print "$file\n"; 744 } 745 system("strip", @opts, $file); 746 } else { 747 print "# file '$file' skipped\n" if $opts{verbose}; 748 } 749 } 750} 751 752sub fix_dep_names { 753 my $file = shift; 754 755 $^O eq "darwin" && $Config{osvers} =~ /^(1[5-9]|[2-9])/ 756 && $Config{useshrplib} 757 or return; 758 759 my @opts; 760 my $so = $Config{so}; 761 my $libperl = "$Config{archlibexp}/CORE/libperl.$Config{so}"; 762 if ($file =~ /\blibperl.\Q$Config{so}\E$/a) { 763 push @opts, -id => $libperl; 764 } 765 else { 766 push @opts, -change => getcwd . "/libperl.$so", $libperl; 767 } 768 push @opts, $file; 769 770 $opts{verbose} and print " install_name_tool @opts\n"; 771 system "install_name_tool", @opts 772 and die "Cannot update $file dependency paths\n"; 773} 774 775# ex: set ts=8 sts=4 sw=4 et: 776